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

Re: /bin/sh diversions

>>   unset foo
>>   [ -n $foo ] && echo foo is non-empty
>>   [[ -n $foo ]] && echo foo is non-empty
>> As you can see, only the second one works.
> BTW, i've provided patch in the BTS for dash's test built-in to have
> arithmetic checking of an empty argument and zero right. This was nearly
> a month ago, yet nothing happened.

Also, let me share a hint for speed-optimized scripting.

`-n' and `-z' test cases are completely bogus w.r.t. speed and bugs
mentioned. I would suggest to use ${#foo} and compare size
arithmetically. Because if $foo is big, you are passing it to another
program, built-in or not, doesn't matter. And ${#foo} is always
non-empty expansion, thus one may omit quoiting.

That's why i have patches for arithmetics and asked this list about
using long (as it stated in POSIX) for better usage on 64bit platforms.

The dash's upstream is on vocation or something similar, because same
question aren't answered also. I would like to contribute more, but
lack of feedback is a bad thing. I wonder how all that SoC actually
goes in this period :-/

Reply to: