I'd like to do this in bash
#!/bin/bash
func(){
    return 1;
}
e=func
echo some text
exit e
but I'm getting
exit: func: numeric argument required
AFAIK variables in bash are without a type, how to "convert" it to int to satisfy requirement?
You need to add a $ in front of a variable to "dereference" it. Also, you must do this:
func
e=$?
# some commands
exit $e
$? contains the return code of the last executed "command"
Doing e=func sets string func to variable e.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With