All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH OSSTEST] standalone: Log things we are running via with_logging
Date: Fri, 4 Dec 2015 09:50:48 +0000	[thread overview]
Message-ID: <1449222648.4424.159.camel@citrix.com> (raw)
In-Reply-To: <22112.28831.606518.686465@mariner.uk.xensource.com>

On Thu, 2015-12-03 at 16:41 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[PATCH OSSTEST] standalone: Log things we are
> running via with_logging"):
> > Turning on set -x is too verbose, so just echo the command ourselves.
> 
> It's not clear to me from the context whether $@ might contain things
> which would require quoting.

It's stuff which is able to be run on the next line with:
    "$@" 2>&1 | tee "$log"
But I'm not sure that answers your question.

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).

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).

>   set -x would quote them.
> 
> 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.

Invoking as sh instead produces unquoted results:

$ sh -xc ': standalone-runs "$@"' x "foo" "bar bar"
+ : standalone-runs foo bar bar

(this must be difference between bash and POSIX?)

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'

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 

This is a tricky thing to search for (you mostly just get stuff about
regular variable quoting).

Closest thing I found to a solution was:
http://stackoverflow.com/questions/12985178/bash-quoted-array-expansion


Ian.

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

  reply	other threads:[~2015-12-04  9:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03 15:40 [PATCH OSSTEST] standalone: Log things we are running via with_logging Ian Campbell
2015-12-03 16:41 ` Ian Jackson
2015-12-04  9:50   ` Ian Campbell [this message]
2015-12-04 15:07     ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449222648.4424.159.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.