Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
97 user(s) are online (59 user(s) are browsing Forums)

Members: 0
Guests: 97

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
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.

Go to top

  Register To Post

 




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



Polls
Running AmigaOS 4 on?
AmigaOne SE/XE or microA1
Pegasos2
X5000
X1000
A1222
Sam 440/460
Classic PowerPC Amiga
WinUAE emulation
Qemu emulation
Total Votes: 158
The poll will close at 2025/12/1 12:00
3 Comments


Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project