3 ms·
Using [ is a mistake. Use [[ and relax!
by yrro 4y ago
Using [ is a mistake. Use [[ and relax!
- rurban 4y agoUnportable
- orra 4y agoPortability isn't binary. The question is, is it portable to the systems you want to support?
- digitalsushi 4y agoIt's portable until it pages out on an incident report. Then, we know it wasn't portable.
- sgbeal 4y ago> The question is, is it portable to the systems you want to support? "Want" isn't always the whole equation. Sysadmins are often called to support ancient OSes, in particular in environments which keep systems in operation long after their "best before" dates (e.g. internal IT in banking systems). There's literally no disadvantage, beyond aesthetics, to _not_ using the x-hack. For many of us older folks, using it is built into our muscle memory.
- rurban 4y agoWe need to support the most common OS in the world, debian. default shell: dash bashisms are forbidden in every corner of the world, sorry https://askubuntu.com/questions/1277922/what-are-syntax-differences-between-bash-and-dash https://askubuntu.com/questions/1277922/what-are-syntax-diff...
- orra 4y agoBy default, dash provides /bin/sh on Debian. But that doesn't prevent people targeting /bin/bash instead. I'll also note that BusyBox supports [[.
- zokier 4y agoWho is this "we"
- rurban 4y agoDevelopers
- yrro 4y agobash is Essential: yes in Debian. /bin/bash is available on every Debian system.
- rurban 4y agoBut not in POSIX, and not in FreeBSD. There it is at /usr/local/bin/bash if you install it.
- Arch-TK 4y agoOnly as unportable as bash. Which is probably the most portable shell.