News for hackers. Stuff that matters.
Re:Test, [, and [[ (2020) by kqr on Thursday November 23, 2023 @06:11AM (#38391565)
I'm going to assume that if one is using [ rather than [[ then one will also want to use expr rather than $(()).
Re:Test, [, and [[ (2020) by ykonstant on Thursday November 23, 2023 @06:29AM (#38391668)
Arithmetic expansion is a feature of all POSIX compliant shells, which furthermore advises against using `expr`. The latter is only needed for non-compliant shells like some legacy implementations of the Bourne shell.
Re:Test, [, and [[ (2020) by kqr on Friday November 24, 2023 @03:05AM (#38401618)
Oh, I did not know that! Thanks.
Re:Test, [, and [[ (2020) by darrenf on Thursday November 23, 2023 @06:52AM (#38391780)
What's the basis for that assumption? I'm struggling to see a reason to not use the shell for arithmetic, regardless of `/usr/bin/[`, builtin `[` or `[[`.