How to warn for the use of unset variables in a korn shell script
Posted
by Lepu
on Stack Overflow
See other posts from Stack Overflow
or by Lepu
Published on 2008-11-28T10:11:31Z
Indexed on
2010/04/25
6:03 UTC
Read the original article
Hit count: 214
Is there any way to throw errors or warnings in a korn shell script to prevent the use of unset variables ? Let's assume I have a temporary folder that I want to remove.
TEMP_FILES_DIR='/app/myapp/tmp'
rm -Rf $TEMP_FILE_DIR #notice the misspelling
How to prevent this kind of mistakes before they actually happen?
I know the script should check for file existence and empty string before attempting to remove, this is just a silly example to illustrate a mistake that could have been avoided with some warnings. I don't know if this feature exists in ksh. If it does exist, how do you turn it on?
© Stack Overflow or respective owner