From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Haxby Subject: Re: xl command autocompletion: domain names Date: Wed, 20 Nov 2013 14:06:31 +0000 Message-ID: <528CC1E7.1080803@oracle.com> References: <21102.35201.728312.130566@mariner.uk.xensource.com> <1383231830.25018.100.camel@dagon.hellion.org.uk> <21113.4284.248761.181909@mariner.uk.xensource.com> <1383732230.26213.34.camel@kazak.uk.xensource.com> <1383736560.26213.69.camel@kazak.uk.xensource.com> <21114.30900.637020.288865@mariner.uk.xensource.com> <527B6527.4010204@oracle.com> <21116.65326.325072.491233@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21116.65326.325072.491233@mariner.uk.xensource.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 Jackson Cc: Matthew Daley , Ian Campbell , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org 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