1. 32
  1.  

  2. 5
    1. 3

      I love that 6 out of 11 items have received a post-hoc “update” because that’s just the way POSIX shell is. (No offense intended to the author — it really is just that arcane that no-one could get it right first try, even when setting out to write an article about portable shell.)

      1. 2

        Author suggests using minimalist shells such as dash or busybox for everyday use. Anyone here doing this?

        1. 6

          I’m not sure s/he does - it suggests using a basic shell for scripts.

          1. 1

            good point

          2. 3

            I use mksh, which is like “modern ksh” (actually, a MirBSD Korn Shell) for me.

            1. 2

              For scripts? Of course! If you use a big, fancy shell to run your scripts you can more easily accidentally use a non-standard feature. Also, the big, fancy shells are noticeably slower.

              1. 2

                /bin/sh on FreeBSD, ash-derivative.

                1. 1

                  god no. unless your shell use cases are exceedingly simplistic, writing pure POSIX shell scripts is tedious.

                  bash out of the box has useful things like:

                  • parameter transformations like @Q which makes it easy to safely eval values.
                  • pattern substitution
                  • an ERE regexp engine
                  • hash maps and arrays
                  • mapfile
                  • compgen

                  and a lot more.

                  1. 2

                    My ‘usual’ response to this type of thing is:

                    Bash is not universal, and has ‘interesting’ behaviour in various versions.

                    If you find POSIX shell is too simplistic (or the program is too complex), it’s likely that you just need to use a more complex language, not rely on Bash and call it a shell script.

                2. 1

                  Neat, I updated my old headers that got the script name and directory to use this. I fixed it to give the full path.

                  SRC="$0"
                  BASE=${SRC##*/}
                  DIR=$(cd ${SRC%"$BASE"}; pwd)
                  

                  This way $DIR can give the directory of the script depending on where it was started.

                  1. 1

                    Also lots of other interesting reads on that domain.

                    1. 0

                      In all honesty, just man bash or whatever shell you have. most of these articles generally just publish what is very easy to find in bash’s manpage.