Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
157 user(s) are online (148 user(s) are browsing Forums)

Members: 1
Guests: 156

Cap, more...

Support us!

Headlines

 
  Register To Post  

Assign the last Return Code to a variable (SOLVED)
Quite a regular
Quite a regular


See User information
delete BLAH
get RC


You will get the RC of 5.

delete BLAH
set RET 
`get RC`
echo ${
RET}


You will get the value 0. This is not desirable. I expected the value 5.


Edited by rjd324 on 2022/12/23 13:36:07
If liberty means anything at all, it means the right to tell people what they do not want to hear.
George Orwell.
Go to top
Re: Assign the last Return Code to a variable
Home away from home
Home away from home


See User information
Not at my amiga but try something more like

[code]
delete foo
set RET $RC
echo $RET

Go to top
Re: Assign the last Return Code to a variable
Not too shy to talk
Not too shy to talk


See User information
@rjd324

I agree with broadblues solution which is simpler. You've somehow managed to used a shell feature to complicate a simple operation. I've not seen this done before that way.

If I hazard a guess I think what is happening is the 'get RC' in the backticks is running in its own subshell so the RC gets lost.

Do you need to save the RC? That should be fine to do so. Otherwise you can use an 'If WARN/If NOW WARN' type construct.

Go to top
Re: Assign the last Return Code to a variable
Quite a regular
Quite a regular


See User information
Broadblues suggestion works.

Not sure why I was doing it using Get anymore.

Thanks all.

If liberty means anything at all, it means the right to tell people what they do not want to hear.
George Orwell.
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project