[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH OSSTEST] standalone: Log things we are running via with_logging



Ian Campbell writes ("Re: [PATCH OSSTEST] standalone: Log things we are running 
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
> >    bash -xc ': standalone-runs "$@"' x "$@" >&2
> > ?  (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 

The output from -x is nicer, indeed.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.