Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
102 user(s) are online (67 user(s) are browsing Forums)

Members: 1
Guests: 101

Paul, more...

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
Just popping in
Just popping in


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-2023 The XOOPS Project