bug-bash
[Top][All Lists]
Advanced

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

trap builtin ignores function named 'stop' as arg


From: msz
Subject: trap builtin ignores function named 'stop' as arg
Date: Thu, 6 May 2004 16:22:39 +0200

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: i386-redhat-linux-gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' 
-DCONF_VENDOR='redhat' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib 
-D_FILE_OFFSET_BITS=64 -O2 -g -pipe -march=i386 -mcpu=i686
uname output: Linux red04 2.4.22-1.2188.nptlsmp #1 SMP Wed Apr 21 20:12:56 EDT 
2004 i686 i686 i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:

Given "function stop() { ... }" in a bash script and "trap stop SIGINT"
command later in the script, no "trap" is set. Also, the status returned
by 'trap' command is 0.


Repeat-By:

#!/bin/bash
#
# start this script and press Ctrl-C or kill it with SIGTERM
# function stop() will NOT be executed.
#
function stop() {
  echo stopping
  exit 0
}
trap stop SIGINT SIGTERM && echo trap set
while true
do
  sleep 1
done

Fix:

I have no fix. I just guess that this can be caused by the fact that
'stop' is a builtin command in 'sh' but missing from 'bash'

Michal Szymanski




reply via email to

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