RE: Simple bash problem.

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

 



> Anyone know why the following simple bash script fails
> on RHEL3 (fully patched)?  It seems the "trap" command
> is being silently ignored.
> 
> 
> --------------------------------------------
> #!/bin/sh
> 
> sigtrap () {
>     echo "Caught signal!"
>     exit 0
> }
> 
> trap sigtrap 1 2 3 15
> 
> while read X; do
>     echo $X
> done
> --------------------------------------------

I'm not 100% sure, but I think it might be because of the #! Line.  Bash
might be seeing that you've invoked with "/bin/sh", and is deciding to
operate in limited POSIX shell mode (sorry, the exact terminology for
that escapes me).  Try #!/bin/bash and see how that goes,

Craig
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux