[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exit application with two function calls

From: abi
Subject: Exit application with two function calls
Date: Sun, 27 Jan 2008 08:03:07 -0600 (CST)
User-agent: SquirrelMail/1.4.9a


I am working on a script and ran into an unusual program. Consider the
following script which I called how.sh.



error () {

   echo -e "\n\terror: ${*}\n"

   # kill $$


check_file () {


   if [ -e $input ]; then
      echo "$input"
      error "invalid directory: $input"


chkFile="`check_file $1`"
echo $chkFile
echo "don't print"


When I run the command above I get this output:

# ./how.sh /asdf
error: invalid directory: /asdf
don't print

The intention of the script is not to print the second echo statement.
I've tried changing the first echo with exec and eval and also adding
these commands before the call to check_file in the variable assignment,
but to no avail.

The error() function is suppose to print the error, and completely exit
the script. One alternative is to use the kill statement, however this
route does not print the error message and prints the "termination"

How can the problem I'm having exiting the application be solved? I'd like
to resulting code to be as clean as possible, and make all error messages
go through the error() function.

Thanks in advance.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]