* Re: [PR PATCH] [Updated] contrib/mmailto: Fix using longer arguments
2024-04-24 17:05 [PR PATCH] contrib/mmailto: Fix using longer arguments rakoo
@ 2024-06-06 11:12 ` rakoo
2024-06-06 11:25 ` rakoo
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rakoo @ 2024-06-06 11:12 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 569 bytes --]
There is an updated pull request by rakoo against master on the mblaze repository
https://github.com/rakoo/mblaze master
https://github.com/leahneukirchen/mblaze/pull/258
contrib/mmailto: Fix using longer arguments
We put the args to $TERMINAL inside single quotes for terminals that want a single command, and we put arguments extracted from the adress between double quotes to protect from spaces.
This is necessary for `xfce4-terminal` for example, and doesn't break `xterm`
A patch file from https://github.com/leahneukirchen/mblaze/pull/258.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-master-258.patch --]
[-- Type: text/x-diff, Size: 1020 bytes --]
From 76e5985c0c0c8c76cd7418b56c86158870265e8a Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Wed, 24 Apr 2024 18:47:46 +0200
Subject: [PATCH] contrib/mmailto: Fix using longer arguments
We put the args to $TERMINAL inside single quotes for terminals that want a single command,
and we put arguments extracted from the adress between double quotes to protect from spaces
---
contrib/mmailto | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/contrib/mmailto b/contrib/mmailto
index 7feabb4..2b38def 100755
--- a/contrib/mmailto
+++ b/contrib/mmailto
@@ -19,7 +19,7 @@ fi
IFS='
'
-exec $TERMINAL -e mcom $(
+args=$(
awk -v url="$1" '
function decode(s) {
@@ -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) {
@@ -56,3 +56,5 @@ BEGIN {
}
'
)
+
+exec $TERMINAL -e "mcom $args"
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR PATCH] [Updated] contrib/mmailto: Fix using longer arguments
2024-04-24 17:05 [PR PATCH] contrib/mmailto: Fix using longer arguments rakoo
2024-06-06 11:12 ` [PR PATCH] [Updated] " rakoo
@ 2024-06-06 11:25 ` rakoo
2024-09-05 12:13 ` rakoo
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rakoo @ 2024-06-06 11:25 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 569 bytes --]
There is an updated pull request by rakoo against master on the mblaze repository
https://github.com/rakoo/mblaze master
https://github.com/leahneukirchen/mblaze/pull/258
contrib/mmailto: Fix using longer arguments
We put the args to $TERMINAL inside single quotes for terminals that want a single command, and we put arguments extracted from the adress between double quotes to protect from spaces.
This is necessary for `xfce4-terminal` for example, and doesn't break `xterm`
A patch file from https://github.com/leahneukirchen/mblaze/pull/258.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-master-258.patch --]
[-- Type: text/x-diff, Size: 3258 bytes --]
From e109c7b03bd8fcbfd744741f7a53c642e5f31beb Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Wed, 24 Apr 2024 18:47:46 +0200
Subject: [PATCH 1/4] contrib/mmailto: Fix using longer arguments
We put the args to $TERMINAL inside single quotes for terminals that want a single command,
and we put arguments extracted from the adress between double quotes to protect from spaces
---
contrib/mmailto | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/contrib/mmailto b/contrib/mmailto
index 7feabb4..2b38def 100755
--- a/contrib/mmailto
+++ b/contrib/mmailto
@@ -19,7 +19,7 @@ fi
IFS='
'
-exec $TERMINAL -e mcom $(
+args=$(
awk -v url="$1" '
function decode(s) {
@@ -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) {
@@ -56,3 +56,5 @@ BEGIN {
}
'
)
+
+exec $TERMINAL -e "mcom $args"
From 76ae3562037a98198c70db2a674ca405581a1bcf Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Sat, 11 Nov 2023 02:01:19 +0100
Subject: [PATCH 2/4] Attach all files when forwarding in raw mode
---
mcom | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mcom b/mcom
index 4e834c6..4d0362a 100755
--- a/mcom
+++ b/mcom
@@ -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:$:>:'
From f6bebed8b4a7fa358a06270dfaa7ea1a8f1d49e2 Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Mon, 27 Feb 2023 15:33:13 +0100
Subject: [PATCH 3/4] mcom: Document how attachments work
---
man/mcom.1 | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/man/mcom.1 b/man/mcom.1
index 957c322..08592c7 100644
--- a/man/mcom.1
+++ b/man/mcom.1
@@ -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
From bd20ea3c7966478866712ea5eced858e8bedc218 Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Thu, 6 Jun 2024 13:18:02 +0200
Subject: [PATCH 4/4] Don't ask for confirmation of draft deletion
---
mcom | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mcom b/mcom
index 4e834c6..bb819a3 100755
--- a/mcom
+++ b/mcom
@@ -531,7 +531,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"
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PR PATCH] [Updated] contrib/mmailto: Fix using longer arguments
2024-04-24 17:05 [PR PATCH] contrib/mmailto: Fix using longer arguments rakoo
2024-06-06 11:12 ` [PR PATCH] [Updated] " rakoo
2024-06-06 11:25 ` rakoo
@ 2024-09-05 12:13 ` rakoo
2024-09-11 19:48 ` leahneukirchen
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rakoo @ 2024-09-05 12:13 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 569 bytes --]
There is an updated pull request by rakoo against master on the mblaze repository
https://github.com/rakoo/mblaze master
https://github.com/leahneukirchen/mblaze/pull/258
contrib/mmailto: Fix using longer arguments
We put the args to $TERMINAL inside single quotes for terminals that want a single command, and we put arguments extracted from the adress between double quotes to protect from spaces.
This is necessary for `xfce4-terminal` for example, and doesn't break `xterm`
A patch file from https://github.com/leahneukirchen/mblaze/pull/258.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-master-258.patch --]
[-- Type: text/x-diff, Size: 4986 bytes --]
From e109c7b03bd8fcbfd744741f7a53c642e5f31beb Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Wed, 24 Apr 2024 18:47:46 +0200
Subject: [PATCH 1/6] contrib/mmailto: Fix using longer arguments
We put the args to $TERMINAL inside single quotes for terminals that want a single command,
and we put arguments extracted from the adress between double quotes to protect from spaces
---
contrib/mmailto | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/contrib/mmailto b/contrib/mmailto
index 7feabb4..2b38def 100755
--- a/contrib/mmailto
+++ b/contrib/mmailto
@@ -19,7 +19,7 @@ fi
IFS='
'
-exec $TERMINAL -e mcom $(
+args=$(
awk -v url="$1" '
function decode(s) {
@@ -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) {
@@ -56,3 +56,5 @@ BEGIN {
}
'
)
+
+exec $TERMINAL -e "mcom $args"
From 76ae3562037a98198c70db2a674ca405581a1bcf Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Sat, 11 Nov 2023 02:01:19 +0100
Subject: [PATCH 2/6] Attach all files when forwarding in raw mode
---
mcom | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mcom b/mcom
index 4e834c6..4d0362a 100755
--- a/mcom
+++ b/mcom
@@ -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:$:>:'
From f6bebed8b4a7fa358a06270dfaa7ea1a8f1d49e2 Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Mon, 27 Feb 2023 15:33:13 +0100
Subject: [PATCH 3/6] mcom: Document how attachments work
---
man/mcom.1 | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/man/mcom.1 b/man/mcom.1
index 957c322..08592c7 100644
--- a/man/mcom.1
+++ b/man/mcom.1
@@ -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
From bd20ea3c7966478866712ea5eced858e8bedc218 Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Thu, 6 Jun 2024 13:18:02 +0200
Subject: [PATCH 4/6] Don't ask for confirmation of draft deletion
---
mcom | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mcom b/mcom
index 4e834c6..bb819a3 100755
--- a/mcom
+++ b/mcom
@@ -531,7 +531,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"
From 98f76924d81b025596e881cfe5b87fd5c1b6bd45 Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Mon, 17 Jun 2024 23:42:16 +0200
Subject: [PATCH 5/6] mcom: fix reading from body given in arg
---
mcom | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mcom b/mcom
index 4e834c6..28f1ddf 100755
--- a/mcom
+++ b/mcom
@@ -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'
;;
From 435c2f1c6dc3506cabffcee5f796b03dc31191f3 Mon Sep 17 00:00:00 2001
From: Matthieu Rakotojaona <m@rako.space>
Date: Thu, 5 Sep 2024 00:45:38 +0200
Subject: [PATCH 6/6] Add script to deliver mails without duplicates
---
contrib/mdeliver_once.rc | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100755 contrib/mdeliver_once.rc
diff --git a/contrib/mdeliver_once.rc b/contrib/mdeliver_once.rc
new file mode 100755
index 0000000..d248b8d
--- /dev/null
+++ b/contrib/mdeliver_once.rc
@@ -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
+ }
+}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: contrib/mmailto: Fix using longer arguments
2024-04-24 17:05 [PR PATCH] contrib/mmailto: Fix using longer arguments rakoo
` (2 preceding siblings ...)
2024-09-05 12:13 ` rakoo
@ 2024-09-11 19:48 ` leahneukirchen
2024-09-11 23:13 ` rakoo
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2024-09-11 19:48 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 217 bytes --]
New comment by leahneukirchen on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/258#issuecomment-2344574086
Comment:
Regarding the original patch: since we set IFS, I don't think this is necessary?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: contrib/mmailto: Fix using longer arguments
2024-04-24 17:05 [PR PATCH] contrib/mmailto: Fix using longer arguments rakoo
` (3 preceding siblings ...)
2024-09-11 19:48 ` leahneukirchen
@ 2024-09-11 23:13 ` rakoo
2024-09-12 11:39 ` leahneukirchen
2024-09-12 12:10 ` rakoo
6 siblings, 0 replies; 8+ messages in thread
From: rakoo @ 2024-09-11 23:13 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 503 bytes --]
New comment by rakoo on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/258#issuecomment-2344892370
Comment:
Ah, sorry about the unrelated stuff I added by mistake.
After further testing, if I understand correctly, it seems that xfce4-terminal must have arguments after `-e` inside quotes, and when adding quotes the newlines don't seem to work anymore. Going back to args within quotes make it work, but it might not be the prettiest solution, I'll admit.
--
Matthieu Rakotojaona
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: contrib/mmailto: Fix using longer arguments
2024-04-24 17:05 [PR PATCH] contrib/mmailto: Fix using longer arguments rakoo
` (4 preceding siblings ...)
2024-09-11 23:13 ` rakoo
@ 2024-09-12 11:39 ` leahneukirchen
2024-09-12 12:10 ` rakoo
6 siblings, 0 replies; 8+ messages in thread
From: leahneukirchen @ 2024-09-12 11:39 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 380 bytes --]
New comment by leahneukirchen on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/258#issuecomment-2346055578
Comment:
Try `xfce4-terminal -x ...` instead. IMO this is an upstream bug, I don't know why they don't implement `-e` like other terminal emulators.
gnome-terminal just uses `--` these days, so perhaps we should make the flag configurable/detect it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: contrib/mmailto: Fix using longer arguments
2024-04-24 17:05 [PR PATCH] contrib/mmailto: Fix using longer arguments rakoo
` (5 preceding siblings ...)
2024-09-12 11:39 ` leahneukirchen
@ 2024-09-12 12:10 ` rakoo
6 siblings, 0 replies; 8+ messages in thread
From: rakoo @ 2024-09-12 12:10 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
New comment by rakoo on mblaze repository
https://github.com/leahneukirchen/mblaze/pull/258#issuecomment-2346115263
Comment:
I don't think upstream will change the way it works, so I'll just keep a personal diff locally. The idea of configuring the flag is worth a try for the future.
Closing this PR now.
--
Matthieu Rakotojaona
^ permalink raw reply [flat|nested] 8+ messages in thread