On 07Apr2016 10:37, derek martin <inva...@pizzashack.org> wrote:
I've yet to notice any of the so-called benefits of getting older,
that people sometimes extoll...
My father once asserted that it was better than the alternative.
Probably fixed in modern interactive shells. Note your test is
testing your interactive shell, not /bin/sh (if they're different).
On the system I ran the test on, they happen to be the same. On other
systems I use /bin/sh is dash, but I believe it behaves the same.
My sysadmin background has led me to think that you should always just
use the system default shell, because it's pretty much always going to
be available unless the system is completely unusable, and because
perhaps there's a good reason it's the default. ;-)
Ah. I like zsh for my interactive shell. But we always leave root's shell
alone. However, I am a _very_ strong advocate for writing scripts for /bin/sh,
and avoiding bashisms for exactly your reasons above. Am I alone in wincing
everytime I hear the term "bash scripting" these days?
Though, the
switch in many Linux distros to dash as the system shell has somewhat
thwarted me--dash isn't (IMO) usable as an interactive shell, has some
issues as a scripting shell, and has slightly different semantics (BSD
vs. SysV echo, for instance) than bash on some oft-used builtins,
etc.. I find this extremely annoying. I get why they did it, but I
think it would have been a much better idea to produce a
bash-workalike shell for the subset of features they wanted to
support. Or patch dash to behave the same where its supported
features differ. Anyway, I digress.
Oh, please digress!
I tend to use printf over echo for when I want well controlled output; the
BSD/SysV echo stuff has been a pain point for decades so I try to just avoid it
when I'm outputting an "unknown" string. So I use echo for all the fixed stuff:
echo "message here, with no leading dashes or backslashes in the text"
but printf for parameterised output:
printf '%s\n' "$arbitrary_value"
and I have my own script "necho" for "echo with no newline" for the appropriat
platform (or I make a shell function necho() calling printf for the same
purpose, depending on context). Then one can go:
necho "prompt> "
in one's script without worrying too much or making the script harder to read.
What other scripting shortcomings have you encountered with dash? I haven't
used it much myself, but would hope to have my scripts portable enough to work
with it.
Cheers,
Cameron Simpson <c...@zip.com.au>