Date: Tue, 10 Oct 2017 17:11:14 +1100 From: Cameron Simpson <cs@cskk.id.au> To: Polytropon <freebsd@edvax.de> Cc: Paul Schmehl <pschmehl_lists@tx.rr.com>, FreeBSD Questions <freebsd-questions@freebsd.org>, mutt-users@mutt.org Subject: Re: Scripting problem Message-ID: <20171010061114.GA58401@cskk.homeip.net> In-Reply-To: <20171008095413.b0700f43.freebsd@edvax.de> References: <20171008095413.b0700f43.freebsd@edvax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On 08Oct2017 09:54, Polytropon <freebsd@edvax.de> wrote:
>On Sun, 08 Oct 2017 00:59:39 -0500, Paul Schmehl wrote:
>> I'm having a problem with this line:
>> /usr/local/bin/mutt -s $SUBJECT -i $MESSAGE -a $FILENAME --
>> pschmehl@tx.rr.com < /dev/null
Your variable substitutions are not quoted, as mentioned. That is critical. The
shell is a tool for assembling command string arrays, and quoting is used to
demark single strings.
[...]
>This proves you have a quoting problem. Enclose the parameters
>in the mutt call in "...", like this:
>
> /usr/local/bin/mutt -s "$SUBJECT" -i "$MESSAGE" -a "$FILENAME" -- pschmehl@tx.rr.com < /dev/null
>
>When the variables are being evaluated by the shell, the quotes
>during assignment are removed, and you you get is
>
> /usr/local/bin/mutt -s Today's db backup -i path/to/message.txt -a /whatever/filename/there.is -- pschmehl@tx.rr.com < /dev/null
>
>The unterminated ' is handled more or less gracefully, but it
>probably interferes with mutt's address detection. You can
>now easily recognize the problem.
No, mutt noever considers it for addresses, because it is the subject string.
There's no "more or less gracefully", it is just a string.
The mutt command is invoked as an array of strings, thus (one per line):
/usr/local/bin/mutt
-s
Today's db backup
-i
path/to/message.txt
-a
/whatever/filename/there.is
--
pschmehl@tx.rr.com
There is no subsequent parsing or weird interpretation.
>> I'm running FreeBSD 10.3-RELEASE and the script is written in bash.
Just say "/bin/sh". It may be implemented by bash on your system, but it is
generally the Bourne shell. Nothing you're doing requires bash itself, but all
UNIX systems have /bin/sh.
>Do you have any reasons not to stick to default sh? Do you use
>any features specific to bash?
Ah, I see this has also been maddresses.
Cheers,
Cameron Simpson <cs@cskk.id.au> (formerly cs@zip.com.au)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20171010061114.GA58401>
