Randall R Schulz wrote:
On Wednesday March 25 2009, David C. Rankin wrote:
Listmates,
I set up a simple trap to gzip any open files on scripts interrupt or exit:
cleanup () { echo -e "\n\tExecuting cleanup from trap\n" [[ -e $NEWFILE ]] && gzip --force --quiet $NEWFILE [[ -e $XMLFILE ]] && gzip --force --quiet $XMLFILE
}
trap cleanup SIGINT SIGTERM EXIT
rest of script....
trap works correctly, but when it is called, it seems to be inserting 45 blank-lines after the original command line causing the terminal to scroll-up. Looks odd:
It's certainly not trap or you echo command that's doing that. I'd look to the behavior of whatever command is being interrupted.
Also, you might want to capture the output and see if it's really just 45 newlines or possibly something else.
...
-- David C. Rankin
Randall Schulz
Randall, You are on to something. While I counted 45 lines in konsole, evidently "They're not lines." Here is what I see on konsole: 14:23 alchemy:~/linux/scripts/parse> sh xmlparse test.xml.gz | nl 1 Executing cleanup from trap 14:26 alchemy:~/linux/scripts/parse> So we have a 45 line representation of something on konsole. Taking Aaron's advise I 'set -x' at the top of the script and it has generated a great many hieroglyphs on konsole. Looking at the trap stuff, I see: 14:32 alchemy:~/linux/scripts/parse> sh xmlparse test.xml.gz + trap cleanup SIGINT SIGTERM EXIT <big snip> + exit 0 + cleanup + echo -e '\n\tExecuting cleanup from trap\n' Executing cleanup from trap + [[ -e out-1238009586.xml ]] + gzip --force --quiet out-1238009586.xml + [[ -e test.xml ]] + gzip --force --quiet test.xml Here trap was called on exit and it doesn't give me any indication of where all the space is coming from. I did try removing the 'echo' statement from cleanup(), but you were right, it made no difference. What is really strange, is I modified the trap to remove the 'EXIT' signal and just added cleanup at the end to cover the normal exit. Still it makes no difference. As long as trap is in the script, I get the big blank... Any other thoughts?? -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org