Why should I bother with POSIX compliant scripting?



bash already does those things by default. I have noticed some distro do have an auto-complete plugin for bash.
I knew that one existed but none like these:
Code:
zsh-history-substring-search
zsh-syntax-highlighting
I have looked for them in the past for bash and because I couldn't find anything like them I switched to zsh at some point.
 
zsh-history-substring-search zsh-syntax-highlightingI have looked for them in the past for bash and because I couldn't find anything like them I switched to zsh at some point.
Fish shell has these out of the box but doesn't play well with bash.
 
Some clarifying information which may be of interest:

This is from debian's wiki:
The default non-interactive shell on POSIX environments is an executable located on the filesystem at /bin/sh, which is a symbolic link to the default shell. Most system scripts use this, via the #!/bin/sh shebang. Changing a system's default non-interactive shell is simply a matter of changing that symbolic link to target a different executable.

In all releases up to and including DebianLenny, Bash was the default non-interactive shell. Beginning with DebianSqueeze, Debian uses Dash (the Debian Almquist shell) as the target of the /bin/sh symlink. Dash lacks many of the features one would expect in an interactive shell, which allows it to be faster and more memory efficient than Bash.
See: https://wiki.debian.org/Shell

According to wikipedia here: https://en.wikipedia.org/wiki/Almquist_shell, dash is almost compliant with POSIX but doesn't include these features required by POSIX:
internationalization and localization, and multi-byte character encoding.

Zsh appears not to be POSIX compliant. From the zsh docs about zsh on page 1:
It does not provide compatibility with POSIX or other shells in its default operating mode.
See: https://zsh.sourceforge.io/Doc/zsh_a4.pdf

Zsh can be made to be POSIX compliant according to arch by use of the "emulate sh" option. See: https://wiki.archlinux.org/title/Zsh

It may also be possible by use of the environment variable: POSIX_BUILTINS. See: https://zsh.sourceforge.io/Guide/zshguide02.html#l10

Bash has the --posix option about which the man page informs:
Change the behavior of bash where the default operation differs from the POSIX standard to match the standard (posix mode)
 
Last edited:
You are making something for yourself, you can use whatever you want to, you don't have to use something that is POSIX-compliant if you don't want to
 


Follow Linux.org

Members online


Top