[Scottish] Trapping SIGINTR in shell scripts

Colin McKinnon colin.mckinnon at ntlworld.com
Wed Aug 25 20:28:40 BST 2004


On Wednesday 25 August 2004 11:08, Martin McCarthy wrote:
>
> You'll probably want to untrap the ^C for the child script.  Something
> like:
>
> trap '' 2
> for i in "$1"/* ; do
>         [ -d "$i" ] && continue
>         if [ -x "$i" ]; then
>                 ( trap 2; "$i" )
>         fi
> done
>

I'm a bit hazy on the whole trap thing - I'd have tried running the child in 
in the background and using wait to ensure jobs run sequentially.

for i in "$1"/* ; do
         [ -d "$i" ] && continue
         if [ -x "$i" ]; then
                $i &
		wait
         fi
done

Doesn't mean that Martin's suggestion is wrong (or that mine is right ;-)

C. 



More information about the Scottish mailing list