bug-bash
[Top][All Lists]
Advanced

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

Re: Document m=1 m=2; echo $m result


From: Lawrence Velázquez
Subject: Re: Document m=1 m=2; echo $m result
Date: Sun, 02 Jul 2023 20:56:08 -0400
User-agent: Cyrus-JMAP/3.9.0-alpha0-499-gf27bbf33e2-fm-20230619.001-gf27bbf33

On Sun, Jul 2, 2023, at 8:30 PM, Dan Jacobson wrote:
> man page says:
>
>        A variable may be assigned to by a statement of the form
>
>               name=[value]
>
>        If value is not given, the variable is assigned the null  string.   All
>        values  undergo tilde expansion, parameter and variable
>        expansion...
>
> OK, but do please mention somewhere that "if the variable is set more
> than once within the same statement, the final value is used."
>
> $ m=1 m=2;  echo $m
> #(Yes, acts the same as:)
> $ m=1; m=2; echo $m

This is stated under "Simple Command Expansion".

        When a simple command is executed, the shell performs the
        following expansions, assignments, and redirections, from
        left to right, in the following order.

        [...]

        4.  The text after the = in each variable assignment undergoes
            tilde expansion, parameter expansion, command substitution,
            arithmetic expansion, and quote removal before being
            assigned to the variable.

https://www.gnu.org/software/bash/manual/html_node/Simple-Command-Expansion.html

-- 
vq



reply via email to

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