This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Group Permissions on root folders problem (Windows 10 TP build 10061)


Greetings, Eric Blake!

>>>>> [ ... -a ... ] is not portable; there are some inherently ambiguous
>>>>> situations that it cannot handle. POSIX recommends that you spell it [
>>>>> ... ] && [ ... ] instead.
>>>>

>> 
>> If a script author did not quote the indirect references, it is their fault,

> No, even with proper quoting, the use of -a and -o creates ambiguous
> situations.  For example, a naive read would claim that

> test "$var1" -a "$var2"

> sets $? to 0 only if both "$var1" and "$var2" are non-empty.  But
> according to the POSIX rules, if $var1 is '!' and $var2 is '', then this
> MUST be treated as the negation of the unary operator '-a "$var2"', if
> the shell has a unary -a (bash does, dash does not).  And in bash's
> case, '-a ""' is false (the empty string never exists as a file), so the
> negation is true, and you have a case where the -a version returned 0 in
> spite of one of the inputs being empty.

That's... great.
At the very least, we have a standard we can rely... refer... to... >.< sigh.

Thanks for your thorough explanation, much appreciated!

(And I have a set of scripts to rewrite...)


-- 
With best regards,
Andrey Repin
Friday, September 11, 2015 04:58:51

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]