On Wednesday 19 Jan 2011 10:42:21 ali hagigat wrote:

> I have two script files and I execute them as follows:
> -------------------------------------
> #script1
> echo ppp
> exit 0
> echo qqq
> /root> ./script1
> ppp
> -------------------------------------
> #script2
> if (exit 0) then
>     echo ppp
> fi
> /root> ./script2
> ppp
> -------------------------------------
> In script1, when exit executes, it returns and immediately
> shell(/bin/bash) returns too. Why in the second script shell completes
> if command and does not return immediately? In script 2, what will be
> the return value of shell? The option of exit or the return value of
> echo?

In your second script, the "exit 0" part runs in a subshell, so "exit" exits 
that subshell (and I'm somewhat surprised that no semicolon is required after 
the closing bracket, but I may have missed something in the grammar). Try 
this:

if exit 0; then
  echo ppp
fi

-- 
D.

Reply via email to