xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: John Haxby <john.haxby@oracle.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Matthew Daley <mattjd@gmail.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: xl command autocompletion: domain names
Date: Wed, 20 Nov 2013 14:06:31 +0000	[thread overview]
Message-ID: <528CC1E7.1080803@oracle.com> (raw)
In-Reply-To: <21116.65326.325072.491233@mariner.uk.xensource.com>

On 08/11/13 15:11, Ian Jackson wrote:
> John Haxby writes ("Re: [Xen-devel] xl command autocompletion: domain names"):
>> > On 06/11/13 17:13, Ian Jackson wrote:
>>> > >  bash_completion_sudo () {
>>> > >     if [ x"`whoami`" = xroot ]; then "$@"
>>> > >     else ${BASH_COMPLETION_SUDO-sudo} "$@"; fi
>>> > >  }
>>> > >  bash_completion_sudo xl list
>> > 
>> > It's amazing how old constructs make it into new shell scripts for all
>> > the wrong reasons.
> ...
>> > For some reason there has been a resurgence in the belief that you need
>> > the x's _and_ the quotes.  You don't.  Ideally you'd eschew the archaic
>> > construct altogether.
> The x's are there in case the string looks like an operator for
> test(1).  Depending on the exact syntax of the expression inside [ ],
> it can be ambiguous.  In this case it's OK (I think) but IMO it's a
> good habit to always include the x whenever passing string data values
> to test(1).
> 

I hadn't thought of that ...

Except that test doesn't seem so easily fooled:

test -f == root && echo oops
if [ -f == root ]; then echo oops; fi
if [ -f /etc/passwd ]; then echo phew; fi

At least that's the case for bash; dash doesn't like it.

Still, that's today's new Linux/Unix thing so I'm happy!

jch

  reply	other threads:[~2013-11-20 14:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-27 22:55 xl command autocompletion: domain names Matthew Daley
2013-10-28 15:57 ` Ian Jackson
2013-10-28 22:29   ` Matthew Daley
2013-10-31 15:03     ` Ian Campbell
2013-10-31 15:22       ` Ian Jackson
2013-11-05  8:11         ` Matthew Daley
2013-11-05  8:10       ` Matthew Daley
2013-11-05 10:09         ` Ian Campbell
2013-11-05 15:37         ` Ian Jackson
2013-11-06  0:18           ` Matthew Daley
2013-11-06 10:03             ` Ian Campbell
2013-11-06 11:14               ` Matthew Daley
2013-11-06 11:16                 ` Ian Campbell
2013-11-06 11:40                   ` Matthew Daley
2013-11-06 17:13                     ` Ian Jackson
2013-11-07  1:10                       ` Tim Deegan
2013-11-07 10:02                       ` John Haxby
2013-11-08 15:11                         ` Ian Jackson
2013-11-20 14:06                           ` John Haxby [this message]
2013-11-21 18:56                             ` 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=528CC1E7.1080803@oracle.com \
    --to=john.haxby@oracle.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=mattjd@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).