heman96
1
Hi Ppl,
Need help
$ cat trap.sh
#!/bin/bash
trap cleanup 1 2 3 15
cleanup()
{
echo �I was running \�$BASH_COMMAND\� when you interrupted me.�
echo �Quitting.�
exit 1
}
while :
do
echo -en �hello. �
sleep 1
echo -en �my �
sleep 1
echo -en �name �
sleep 1
echo -en �is �
sleep 1
echo �$0�
done
Any reason you ppl see why "1 2 3 15" was used as arument to cleanup
Thanks
1 2 3 15 are not arguments to cleanup they are signals to trap
1 - hangup
2 - interrupt
3 - quit
15 - software termination (kill)
Check man bash
for details of the trap internal command.
1 Like
Editing your script in Microsoft Word has filled it with nasty smart quotes which the shell will not understand as being quote characters.
Be sure to change all your � � back into " " if you want it to work.
1 Like