Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/mmailto: Fix using longer arguments #258

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions contrib/mdeliver_once.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env rc

# Deliver a stream of mboxrd emails into a given maildir making sure
# there are no duplicates.
# Duplicates are checked through the Message-ID only.
# This script expects a feed of emails, as in `mdeliver -M`

if (~ $1 "") {
echo "missing maildir"
exit 1
}
mmkdir $1

tmpdir=`{mktemp -d '/tmp/sfeed_deliver.XXXX'}
fn sigexit {
rm -r $tmpdir
}

mmkdir $tmpdir/work

mdeliver -M $tmpdir/work

mlist $1 | mhdr -h 'Message-ID' > $tmpdir/ids
for (file in `{mlist $tmpdir/work}) {
myid=`{mhdr -h 'Message-ID' $file}
if (! grep -s $myid $tmpdir/ids) {
mdeliver $1 < $file
}
}
6 changes: 4 additions & 2 deletions contrib/mmailto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
IFS='
'

exec $TERMINAL -e mcom $(
args=$(
awk -v url="$1" '

function decode(s) {
Expand Down Expand Up @@ -47,7 +47,7 @@ BEGIN {
split(fields[i], kv, "=")
if (kv[1] != "r") {
args[length(args)+1] = "-" kv[1]
args[length(args)+1] = kv[2]
args[length(args)+1] = "\"" kv[2] "\""
}
}
for (i in args) {
Expand All @@ -56,3 +56,5 @@ BEGIN {
}
'
)

exec $TERMINAL -e "mcom $args"
7 changes: 7 additions & 0 deletions man/mcom.1
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ Delete the draft and quit.
Preview the draft, using
.Xr mshow 1 .
.El
.Sh ATTACHMENTS
From within the editor, attachments are added by setting an Attach: header with the path to the desired files. Multiple Attach: headers can be added.

To add from the commandline, use
.Sq mcom Fl attach No path/to/file
and the header will be added automatically.
It is possible to use tilde (~) in the file path.
.Sh ENVIRONMENT
.Bl -tag -width Ds
.It Ev EDITOR , Ev VISUAL
Expand Down
17 changes: 15 additions & 2 deletions mcom
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ fi
printf '\n'
(
IFS=$NL
cat -- /dev/null $(printf '%s' "$hdrs" | mhdr -M -h body -)
cat -- /dev/null <(printf '%s' "$hdrs" | mhdr -M -h body -)
)
printf '\n'
;;
Expand All @@ -306,6 +306,19 @@ fi
msgid
museragent
cat "$MBLAZE/headers" 2>/dev/null
if [ -n "$raw" ]; then
prev=$(pwd)
attachdir=$(mktemp -d)
cd $attachdir
trap 'rm -r "$attachdir"' EXIT

mseq -r "$@" \
| xargs -I {} mshow -Bx {} \
| xargs -I {} realpath {} \
| sed '/^$/d; s/^/Attach: /'
cd $prev
fi

printf '\n\n'
if [ -z "$raw" ]; then
mseq -r "$@" | sed 's:^:#message/rfc822#inline :; s:$:>:'
Expand Down Expand Up @@ -531,7 +544,7 @@ while :; do
c=send
;;
d|delete)
rm -i "$draft"
rm "$draft"
if ! [ -f "$draft" ]; then
rm -f "$draftmime"
printf '%s\n' "mcom: deleted draft $draft"
Expand Down