help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: name of a global variable to store the result of a function


From: Peng Yu
Subject: Re: name of a global variable to store the result of a function
Date: Tue, 26 May 2020 09:51:12 -0500

> That said, my personal preference is still to use an agreed-upon variable
> name to "return" the function's output value, such as "r" or "_r".  This
> avoids all of the need to validate variable names, to triple-check an eval
> usage, etc.  As long as you're not dealing with recursive functions, this
> works quite well, in my experience.


That’s what I think too. Use eval and perform a sanity check is an overkill
for this purpose. But it is surprising that there is no well accepted
convention given bash already have similar variables like BASH_REMATCH to
hold results of a previous command.
-- 
Regards,
Peng


reply via email to

[Prev in Thread] Current Thread [Next in Thread]