From owner-freebsd-questions@freebsd.org Tue Oct 10 11:19:13 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C5E0E2D654 for ; Tue, 10 Oct 2017 11:19:13 +0000 (UTC) (envelope-from cameron@cskk.homeip.net) Received: from nsstlmta06p.bpe.bigpond.com (nsstlmta06p.bpe.bigpond.com [203.38.21.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "", Issuer "Openwave Messaging Inc." (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 259BF7C293 for ; Tue, 10 Oct 2017 11:19:09 +0000 (UTC) (envelope-from cameron@cskk.homeip.net) Received: from smtp.telstra.com ([10.10.24.4]) by nsstlfep13p-svc.bpe.nexus.telstra.com.au with ESMTP id <20171010061117.YKHL8742.nsstlfep13p-svc.bpe.nexus.telstra.com.au@smtp.telstra.com>; Tue, 10 Oct 2017 17:11:17 +1100 X-RG-Spam: Unknown X-Junkmail-Premium-Raw: score=9/83, refid=2.7.2:2017.10.10.55415:17:9.112, ip=, rules=__HAS_FROM, __TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __CC_NAME, __CC_NAME_DIFF_FROM_ACC, LEO_OBFU_SUBJ_RE, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __HAS_MSGID, __SANE_MSGID, __HAS_REPLYTO, __MIME_VERSION, __CT, __CT_TEXT_PLAIN, __CD, __IN_REP_TO, __USER_AGENT, __REFERENCES, __ANY_URI, __URI_NO_WWW, __FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE, __FORWARDED_MSG, __NO_HTML_TAG_RAW, BODY_SIZE_1900_1999, BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD, __TO_REAL_NAMES, __CC_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, MULTIPLE_RCPTS, BODY_SIZE_2000_LESS, __MIME_TEXT_P, REPLYTO_FROM_DIFF_ADDY, REFERENCES, NO_URI_HTTPS, BODY_SIZE_7000_LESS X-Authentication-Info: Submitted using ID cskk@bigpond.com Received: from buttercup (1.144.52.22) by smtp.telstra.com (9.0.019.16-1) (authenticated as cskk) id 59D67F01017E0D81; Tue, 10 Oct 2017 17:11:16 +1100 Received: from fleet-wk-wifi.l (fleet-wk-wifi [172.16.3.7]) by buttercup (Postfix) with ESMTP id 802447FCAA; Tue, 10 Oct 2017 17:11:14 +1100 (AEDT) Received: by fleet-wk-wifi.l (Postfix, from userid 501) id 5E9BE8F94B06; Tue, 10 Oct 2017 17:11:14 +1100 (AEDT) Date: Tue, 10 Oct 2017 17:11:14 +1100 From: Cameron Simpson To: Polytropon Cc: Paul Schmehl , FreeBSD Questions , mutt-users@mutt.org Subject: Re: Scripting problem Message-ID: <20171010061114.GA58401@cskk.homeip.net> Reply-To: mutt-users@mutt.org, freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20171008095413.b0700f43.freebsd@edvax.de> User-Agent: Mutt/1.5.24 (2015-08-30) References: <20171008095413.b0700f43.freebsd@edvax.de> X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Oct 2017 11:19:13 -0000 On 08Oct2017 09:54, Polytropon 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 (formerly cs@zip.com.au)