help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Bash is setting disposition of a signal, ignored upon en


From: Anoop Sharma
Subject: Re: [Help-bash] Bash is setting disposition of a signal, ignored upon entry to shell, to default
Date: Sat, 12 Jan 2013 23:00:28 +0530


On Sat, Jan 12, 2013 at 1:01 AM, Bob Proulx <address@hidden> wrote:
Anoop Sharma wrote:
> I am testing on Ubuntu 12.04.1 LTS.

Which by default will have /bin/sh symlinked to dash.

  lrwxrwxrwx 1 root root 4 Mar 29  2012 /bin/sh -> dash

Unless you have taken action to modify the default configuration.  If
you have symlinked that to bash (sh -> bash) then it will use bash to
implement the POSIX shell in bash's POSIX mode.

I have not made any modifications to default ubuntu configuration. This is what I see on my machine:

$ ls -l /bin/bash /bin/sh /bin/dash
-rwxr-xr-x 1 root root 920788 Apr  3  2012 /bin/bash*
-rwxr-xr-x 1 root root 100284 Mar 29  2012 /bin/dash*
lrwxrwxrwx 1 root root      4 Mar 29  2012 /bin/sh -> dash*
$
 

> I have narrowed down this issue a bit more. The problem is not seen when I
> include a "#! /bin/bash" in the script or if I use the command "bash -c
> test_1.sh".

Right.  Because then you will be running bash in native mode.  When
using bash features that is "The Right Thing To Do".


I know that doing that is the perfect way. But not including #! should also succeed. What makes executing without #! fail when I start this script from bash? In fact I have not needed to include any #! at all for any of my other scripting needs (which are mostly simple). I use only bash and portability to other shells is not my requirement.
 
> It is only seen when I rely on bash as ubuntu default command interpreter
> to work. I have verified that ubuntu does invoke the same bash as the
> command interpreter by including BASH_VERSION in the script.

If bash is running from /bin/sh it will be running in POSIX mode.  It
will set BASH_VERSION but will disable bash specific features that
conflict with the POSIX /bin/sh mode.  The presence of BASH_VERSION
does not indicate whether bash is running in native mode or not.

  $ set -o | grep posix
  posix           on

  $ set -o | grep posix
  posix           off

> Any idea what could be going wrong?

I think you are calling your script with "#!/bin/sh" instead of
"#!/bin/bash" and therefore are only getting /bin/sh features.


I am not including an #! line in the script at all! In fact, the script fails with #!/bin/sh as well as #!/bin/dash with the following error.

$ ./test_1.sh 
./test_1.sh: 6: kill: invalid signal number or name: SIGXFSZ
sleep survived the signal
 
Instead call your bash script with "#!/bin/bash" if you are going to
use bash features.  (I tend to do the opposite and only use portable
shell features.  But this is the help-bash list after all and so most
people here would recommend use bash features not avoid them.)

Bob

With Thanks,
Anoop


reply via email to

[Prev in Thread] Current Thread [Next in Thread]