Bashisms in shell scripts

Discussion in 'Developers' Forum' started by jwarnier, Aug 5, 2010.

  1. jwarnier

    jwarnier ISPConfig Developer ISPConfig Developer

    Historically, bash has been the default /bin/sh on most GNU/Linux distributions.

    Many GNU/Linux distributions nowadays though try to avoid using it whenever not really needed (example: initscripts), as bash is known to load many dynamic libraries and be memory-hungry, making it less than appropriate to run simple scripts, especially those expected to run-and-die quickly.

    So, Debian, Ubuntu, and more, I'm sure, have or are planning to replace /bin/sh with some alternative (dash, as a light POSIX Bourne Shell, being the best one). And boot time is already favorably impacted.

    Purely POSIX shell compatible scripts (i.e. those not relying on features specific to some other shell) are expected to use a /bin/sh shebang.
    Others are advised to remove bashisms whenever possible, or specify /bin/bash in the shebang line.

    A tool to detect bashisms in shell scripts, "checkbashisms", is shipped in package devscripts on Debian and Ubuntu.

    ISPconfig 3 is currently not too bad in this respect, as it says /bin/bash in shebang. But it does so even for trivial scripts, as the ones starting from root's crontab, which might have a negative impact on server's performances.
    Think about server.sh which is executed every single minute...

    So, has anybody here a good objection to me fixing this?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    I see no general problem with changing it. My main concern is that someone has to test such a change with all supported and even historic linux distributions (only were perfect setup guides exist for) to ensure that such a update does not break any existing install.
     
  3. jwarnier

    jwarnier ISPConfig Developer ISPConfig Developer

    As a sysadmin, I'm conservative by nature, so don't be afraid those changes won't break anything.
    Technically, on old systems, /bin/sh certainly point to /bin/bash, so this cannot be a problem. On newer systems, it could, but in this case, many others things also would besides those.

    Note that I'm going soon to submit other changes that might break things, but I'll warn your then. ;-)
     

Share This Page