From: Ian Jackson Subject: Re: [PATCH OSSTEST] standalone: Log things we are running via with_logging Date: Fri, 4 Dec 2015 15:07:18 +0000 Message-ID: <22113.44070.126624.327360@mariner.uk.xensource.com> References: <1449157254-30830-1-git-send-email-ian.campbell@citrix.com> <22112.28831.606518.686465@mariner.uk.xensource.com> <1449222648.4424.159.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1449222648.4424.159.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [PATCH OSSTEST] standalone: Log things we are run= ning via with_logging"): > On Thu, 2015-12-03 at 16:41 +0000, Ian Jackson wrote: > > It's not clear to me from the context whether $@ might contain things > > which would require quoting. ... > Are you worried about things being incorrectly expanded in the evaluation > of the echo, or just about being able to cut and paste a command directly > from this output into a shell? (or something else). The latter, but also ambiguity in the debug output which might confuse a human reader. > FWIW $@ is unlikely any $vars at this point or to contain spaces, quotes = or > other special characters, although it's not totally impossible (it would > require job names, or idents, or ts-script arguments etc with such in > them). I would prefer to do this properly if it's in a generic logging subfunction. > > You can perhaps do something like this > > =A0=A0=A0bash -xc ': standalone-runs "$@"' x "$@" >&2 > > ?=A0=A0(Sadly -n suppresses output from -x too.) > = > Sadly it also spews the contents of my .bashrc too. Weirdly (?) adding -- > norc _and_ --noprofile to the mix doesn't change that, which seems rather > contrary to the manpage. Urgh. > This seems to work: > = > $ bash -c 'set -x ; : standalone-runs: "$@"' x "foo" "bar bar" > + : standalone-runs: foo 'bar bar' > = > And this: (set -x ; : "$@") also looks to DTRT: > = > $ foo() { (set -x ; : "$@") } > $ foo "foo" "bar bar" > + : foo 'bar bar' Either of these would suit me. The latter seems tidier. > coreutils' printf(1) also has %q, but it's a bit ugly to use and is > backslashy rather than quoting : > $ printf "%q " "foo bar" "baz" ; echo > foo\ bar baz=A0 The output from -x is nicer, indeed. Ian.