| Author |
Exit Status Not Returned?
|
|
| absinth 2005-04-29, 8:09 am |
| Can someone help me with this in KSH and tell me why the exit status is
not returned?
Why is "haha" printed?
#!/bin/ksh
getNoGlobalProc()
{
local a=`ls sdfafa`
if [[ $? -ne 0 ]]; then
echo "$SCRIPTNAME : $LINENO : Could not obtain global number of
processes running"
return 1
fi
echo "haha"
return 0
}
getNoGlobalProc
| |
| absinth 2005-04-29, 8:09 am |
| Follow up 'sdfafa' doesn't exist I used it as an example of a garbage
program.
| |
| Chris F.A. Johnson 2005-04-29, 8:09 am |
| On Fri, 29 Apr 2005 at 05:55 GMT, absinth wrote:
> Can someone help me with this in KSH and tell me why the exit status is
> not returned?
>
> Why is "haha" printed?
Because the command (local) succeeded.
> #!/bin/ksh
>
> getNoGlobalProc()
> {
> local a=`ls sdfafa`
>
> if [[ $? -ne 0 ]]; then
> echo "$SCRIPTNAME : $LINENO : Could not obtain global number of
> processes running"
> return 1
> fi
>
> echo "haha"
>
> return 0
> }
>
> getNoGlobalProc
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========================================
==========================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/ssr.html>
| |
| absinth 2005-04-29, 8:09 am |
| Is there a way to make the variable local in KSH and also have the exit
status of the command substitution returned?
| |
| Chris F.A. Johnson 2005-04-29, 8:09 am |
| On Fri, 29 Apr 2005 at 06:41 GMT, absinth wrote:
> Is there a way to make the variable local in KSH and also have the exit
> status of the command substitution returned?
[Please quote enough of the article you are replying to to give the
context.]
local a
a=`ls sdfafa`
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========================================
==========================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/ssr.html>
|
|
|
|