brent timothy saner on 23 Apr 2010 12:27:01 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Bash script problems - no "function" support?

Hash: SHA1

On 04/23/10 14:15, Mike Leone wrote:
> Thanks so much!

no problem! there are a couple caveats with this, however:

1.) it's very possible that an aptitude upgrade will break this symlink
and revert it back to dash

2.) init scripts may not behave as expected, and your boot time may
increase in time by several seconds. the move to dash was based on
dash's efficiency over bash- it's a little stripped down and doesn't
have a very good, if at all, interactive shell ability, but you don't
need an interactive shell, really, for init scripts so they decided to
try to shave a couple seconds off by having init (and therefore sh) use

the reason you were having such odd behaviour, i guess, is because when
you call it with sh it was using dash (as it should- inits use sh).
however, in your /etc/passwd your user's interactive shell was bash.
(stay with me).

if you had run the script with ./ (or . ./, i suspect it
would have worked, because it then would have used your user's
interactive shell instead of using whatever is linked to sh.

this is also why ubuntu shell scripts should use #!/bin/bash if they're
being run non-interactively- because if #!/bin/sh is used, it will use
dash instead. :) so if you have a shell script cron'd, for instance,
make sure it uses the full bash header and not sh.
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla -

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --