| Paul Jungwirth via plug on 3 Feb 2022 13:50:03 -0800 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: [PLUG] Returning a status without leaving an environment variable hanging around |
I was wondering if there is any way to return a status without using an environment variable, e.g., if there were some way to return $xyz and unset xyz in one fell swoop.
Can't you just not export xyz? Envvars are part of the kernel, but non-exported variables are just part of bash.
Even if you've made xyz an envvar, you could do something like this:
export FOO1=5
export FOO2=8
echo $FOO1
echo $FOO2
ret="${FOO1}"
unset FOO1
# Don't unset FOO2 just to show the difference
return $ret
Then you can say:
$ . test.sh; echo result=$?; env | grep FOO
5
8
result=5
FOO2=8
--
Paul ~{:-)
pj@illuminatedcomputing.com
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug