bug-bash
[Top][All Lists]
Advanced

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

Re: RFE: make [[ compatible with [ 'Option'?


From: Linda Walsh
Subject: Re: RFE: make [[ compatible with [ 'Option'?
Date: Mon, 28 Mar 2011 12:09:54 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Thunderbird/2.0.0.24 Mnenhy/0.7.6.666



Greg Wooledge wrote:
On Mon, Mar 28, 2011 at 10:53:21AM -0700, Linda Walsh wrote:
if [ ! -e $d/S??sshd ]; then echo "sshd not enabled"; fi

That will fail quite colorfully if the glob matches multiple files.
(Also, "$d" should be quoted.)
---

If, in 30 years of unix experience, I'd ever seen multiple matches for
the above pattern, I would be concerned...

As I wrote the above, I was aware of that potential problem, as it went against my normal practice to not put such things in double quotes
or take preventive steps.  But given the specific situation, and the
application of the the script, I was willing to risk it.

But then, that's why I used [[ ]], to begin with -- on the presumption of
compatible behavior with spaces within a variable, within [[ ]], not
needing to be quoted.  My hope would be that if expanded, it would act
like the variable expansion case, i.e.:

   d='hi there'
   if [[ 'hi there' == $d ]]; then echo equal; fi

whereas the same with single brackets would not work.



In any case, I see no benefit to changing how [[ works.  A change would
just cause more confusion.

Who said anything about changing how [[ works?



Mike Frysinger wrote:
On Mon, Mar 28, 2011 at 2:25 PM, Greg Wooledge wrote:
In any case, I see no benefit to changing how [[ works. �A change would
just cause more confusion.

and probably break many existing scripts
-mike
---

I guess I really wasn't clear, but I was trying to say that I would like
an "option", -- not a change in the default.
Could you suggest how I should have made this more clear in my email?

Presumably, existing scripts,  wouldn't enable such an option and wouldn't
be affected.

A second point, we are talking 'bash scripts', as for portability, most generic scripts avoid 'bash'isms like "[[ ]]", so it would be a non-issue.

So if a script is 'bash', it's more than likely a "local" script, so I'm
not sure how one would generalize about "many existing scripts".  For example,
I don't know of any scripts on my system that would break with such a change.

But regardless, in the context of my original email asking that it be
an option, do you see it causing compatibility problems with your existing
local scripts if you don't use that option?

-L





reply via email to

[Prev in Thread] Current Thread [Next in Thread]