help-bash
[Top][All Lists]
Advanced

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

Re: All bash variables that can be used as temp variables?


From: Peng Yu
Subject: Re: All bash variables that can be used as temp variables?
Date: Fri, 27 Jan 2023 09:33:13 -0600

If you know a variable can be used (under what condition), then you
can just list it.

I only find REPLY is appropriate to be used (when 'read' is not used).
But there may be other variables that can also be used. For example,
probably BASH_VERSION, as I seldom need to check the bash version
because I just use the version that works. If it has any problem with
the version that I use, I will use another version. But there is no
description of whether it will be changed back to its original value
in the manual. So I don't know if I can assume so.

$ echo $BASH_VERSION
5.1.8(1)-release
$ BASH_VERSION=x
$ echo $BASH_VERSION
x

Thus, just reading the manual is not sufficient. Hence, the question
is legitimate, not as you think illegitimate.

On 1/26/23, Koichi Murase <myoga.murase@gmail.com> wrote:
> 2023年1月26日(木) 23:12 Peng Yu <pengyu.ut@gmail.com>:
>> Yes. I have full control of the scripts that I use. I am not trying to
>> use some other people's scripts for this purpose. So the restriction
>> that you mentioned does not apply to me. I want to understand in this
>> situation what variables can be used as temp variables (and under what
>> conditions, if there are restricted conditions like in REPLY).
>
> There are no special Bash variables that can be used for unintended
> purposes unconditionally. Then the condition that a variable can be
> used as a temporary variable is theoretically that you do not use the
> variable for the original purpose, as I have written in the previous
> reply. The usage of each variable is described in Bash Reference
> Manual Sec. 5.2, so you can check the description of each variable
> there and will immediately know what would be the condition for each
> variable. I know that you do not expect us to just copy and paste the
> contents of Sec. 5.2 here, but then what are you expecting us for
> replies?
>


-- 
Regards,
Peng



reply via email to

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