.. I had previously _incorrectly_ said: Note that in our case there is only one path/filename, *so this could be further simplified as follows*:
ATTACH=$(/bin/echo -e $(echo "$MAILTO" | grep '^attach=' | sed 's/^attach=//;s|^|file://|g' )) #could also be *This simplification only works if there is only 1 attachment.* I now realize that xdg-email is set up for multiple attachments, even though the man page I'm seeing doesn't mention this. So my first suggestions for a fix still works. In other words, this works for one or multiple attachments: ATTACH=$(/bin/echo -e $(echo "$MAILTO" | grep '^attach=' | sed 's/^attach=//;s|^|file://|g' | awk '{ printf "%s,",$0 }' | sed 's/,$//' )) I've tested this with one and two attachments, as follows: $ xdg-email --attach /usr/share/nemo/actions/foo,bar/x # one attachment file and $ xdg-email --attach /usr/share/nemo/actions/foo,bar/x --attach /usr/share/nemo/actions/foo,bar/y # two attachment files