Looks a lot like homework to me....
I got this to work:-
Code:
#!/bin/bash
trap "cd .." 1
trap "pwd >&2; ls -l >&2" 2
trap "ps >&2; sleep 5" 15
typeset -i i
i=0
while true
do
i=`expr $i + 1`
if [ $i -eq 500 ]; then
echo "Hey $USER, I am still runnning"
THIS LINE WILL GENERATE AN ERROR
i=o
fi
done > /dev/null
I don't understand why you redirected stderr to /dev/null at the end of the while loop, or why you're redirecting stdout for that matter either.
My changes send output from the trap statements to stderr, which I have removed from your redirect syntax at the end of the while loop.