|
|
Subscribe / Log in / New account

checkbashisms

checkbashisms

Posted Dec 17, 2010 22:10 UTC (Fri) by cmccabe (guest, #60281)
In reply to: checkbashisms by alecs1
Parent article: Introducing the "Debian's Automated Code Analysis" (DACA) project

I think it's good that they're moving away from using bash for things that it doesn't belong in-- like init scripts. /bin/sh should just be a POSIX shell, not bash. If you want bash, ask for it by making your package depend on bash and invoke it explicitly.

> I sure didn't notice the difference, whatever that might be; but I did
> waste time with dpkg-reconfigure to test this.

You probably didn't notice the difference in thousands of other small optimizations people made, either. But added together, they make a difference.

> I'm pretty sure Bash is not unfixable, it is a damn console, not the
> entire kernel.

I'm pretty sure you've never seen the source code to bash.


to post comments

checkbashisms

Posted Dec 18, 2010 21:07 UTC (Sat) by epa (subscriber, #39769) [Link] (8 responses)

Why 'should' /bin/sh be a plain POSIX shell and not bash?
(Hoping for some answer other than 'because it has always been that way')

checkbashisms

Posted Dec 19, 2010 0:18 UTC (Sun) by foom (subscriber, #14868) [Link] (6 responses)

Because if you meant bash, you can just say "/bin/bash"?

checkbashisms

Posted Dec 19, 2010 0:48 UTC (Sun) by dlang (guest, #313) [Link] (2 responses)

so why not just go through every init script and sed #/bin/sh#/bin/bash# and not have to worry about it any longer?

checkbashisms

Posted Dec 19, 2010 1:08 UTC (Sun) by foom (subscriber, #14868) [Link]

Yup. That sounds like a good plan to me :) (that's what I did with all my shell scripts when Ubuntu first started making a fuss about this.)

checkbashisms

Posted Dec 19, 2010 13:22 UTC (Sun) by pkern (subscriber, #32883) [Link]

That's a valid option of course. However, if it's only a small bit of work you can save a bit of time on every invocation of the script, by using a faster shell than bash as `/bin/sh'. As long as you intentionally expect bash with its feature set for a script, it's fine to just write `/bin/bash' as your interpreter. This work is supposed to check for the accidental expectation that the POSIX `/bin/sh' has the bash feature set.

checkbashisms

Posted Dec 22, 2010 12:31 UTC (Wed) by epa (subscriber, #39769) [Link] (2 responses)

Or, just as well, declare /bin/sh to be bash and have
a separate /bin/minimal_bare_bones_sh for the tiny
number of cases where it is truly needed.

Fifteen years ago bash might have been seen as bloated.
That really isn't an issue any more.

checkbashisms

Posted Dec 25, 2010 5:07 UTC (Sat) by foom (subscriber, #14868) [Link] (1 responses)

POSIX sh is standardized. Regardless of what /bin/sh actually points to, or how bloated bash is or is not, if you write a script that depends on nonstandard extensions in bash, you should put #!/bin/bash at the top.

checkbashisms

Posted Dec 31, 2010 11:52 UTC (Fri) by epa (subscriber, #39769) [Link]

A little ironic that you use POSIX standardization as a reason for a particular shebang line, since the #! syntax is not part of POSIX at all.

I think you are probably right though - to keep everybody happy, if you want bash it's best to say what you mean.

checkbashisms

Posted Dec 19, 2010 2:58 UTC (Sun) by MisterIO (guest, #36192) [Link]

Because if you're invoking the shell as /bin/sh, it should be a POSIX shell. If you want bash, invoke it as /bin/bash. Anyway, I guess the main point of this was that dash has a smaller memory footprint than bash.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds