3 ms·
I usually target BASHv3 in my scripts, but then I know the environment that will be using those scripts. My biggest issue with POSIX is the use of the backtick
by ndsipa_pomu 3y ago
I usually target BASHv3 in my scripts, but then I know the environment that will be using those scripts. My biggest issue with POSIX is the use of the backtick which is difficult to read and parse.
ShellCheck is absolutely the most important thing to use when writing scripts. Each time that you get a warning that you don't recognise is a learning opportunity - just follow the link provided in the warning. Also, take the time to add the "# shellcheck disable=" comments so that scripts don't issue any warnings from shellcheck.
I also recommend visiting https://mywiki.wooledge.org/BashFAQ https://mywiki.wooledge.org/BashFAQ for avoiding the many footguns, especially with filename parsing.
- rascul 3y ago> My biggest issue with POSIX is the use of the backtick which is difficult to read and parse. POSIX also has $(command) for command substitution. It can certainly be annoying when it's not used, though. I think shellcheck will recommend it over backticks.
- ndsipa_pomu 3y agoThanks, I didn't know that, but then I almost never target POSIX. My next complaint would be the use of '[' as a test rather than my preferred '[['. Edit: After looking for a problem with POSIX, I found this obscure issue that may well catch out people as under POSIX, IFS is a terminator rather than a separator: https://mywiki.wooledge.org/BashPitfalls#IFS.3D.2C_read_-ra_fields_.3C.3C.3C_.22.24csv_line.22 https://mywiki.wooledge.org/BashPitfalls#IFS.3D.2C_read_-ra_...
- augustk 3y ago> My biggest issue with POSIX is the use of the backtick which is difficult to read and parse. I always use $(...) or rather "$(...)" instead of backticks. Command substitution shall occur when the command is enclosed as follows: $(command) or (backquoted version): `command` https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...