I have a question regarding unix shell script.Say if you do exit 1 in inner if: will it exit or will it still execute the outer if? The following is a dummy example.if [ $PASSWORD == $VALID_PASSWORD ]; then    if [ $PASSWORD -gt 10]; then        echo password is too large!        exit 1    fi    echo You have access!    exit 1fi
What does exit do in an if block in a shell script?
shell;shell script;ksh;exit
exit is usually a shell built-in, so in theory it does depend on which shell you're using.  However, I'm not aware of any shell where it operates other than exiting the current process.  From the bash man page,   exit [n]          Cause the shell to exit with a status of n.  If  n  is  omitted,          the exit status is that of the last command executed.  A trap on          EXIT is executed before the shell terminates.So it doesn't simply end the current if clause, it exits the whole shell (or process, in essence, since the script is being run within a shell process).From man sh, exit [exitstatus]        Terminate the shell process.  If exitstatus is given it is used as        the exit status of the shell; otherwise the exit status of the        preceding command is used.And lastly, from man ksh,    exit [ n ]          Causes  the  shell  to exit with the exit status specified by n.          The value will be the least significant 8 bits of the  specified          status.   If  n  is omitted, then the exit status is that of the          last command executed.  An end-of-file will also cause the shell          to  exit  except for a shell which has the ignoreeof option (see          set below) turned on.