Exit Status Not Returned?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > Exit Status Not Returned?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Exit Status Not Returned?  
absinth


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-29-05 01:09 PM

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






[ Post a follow-up to this message ]



    Re: Exit Status Not Returned?  
absinth


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-29-05 01:09 PM

Follow up 'sdfafa' doesn't exist I used it as an example of a garbage
program.






[ Post a follow-up to this message ]



    Re: Exit Status Not Returned?  
Chris F.A. Johnson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-29-05 01:09 PM

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>





[ Post a follow-up to this message ]



    Re: Exit Status Not Returned?  
absinth


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-29-05 01:09 PM

Is there a way to make the variable local in KSH and also have the exit
status of the command substitution returned?






[ Post a follow-up to this message ]



    Re: Exit Status Not Returned?  
Chris F.A. Johnson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-29-05 01:09 PM

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>





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:39 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register