[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] 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. A long time ago, maybe around Unix Edition 7, maybe before, it was common to see [ x$foo = x ] to test for an empty "$foo". Note the lack of quotes. If $foo is indeed empty then this expanded to [ x = x ] (obviously). Without the x's you would get [ = "" ] which is equally obviously a syntax error. At some stage, decades ago, [ "$foo" = "" ] became possible and the old syntax which had a naked $foo became obsolete. 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. If this particular case, however, you actually want something quite different: if [ $(id -u) -eq 0 ] ... :) jch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |