help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Where is the usage of `var=xxx cmd` documented?


From: Assaf Gordon
Subject: Re: [Help-bash] Where is the usage of `var=xxx cmd` documented?
Date: Sun, 1 May 2016 01:08:35 -0400

Hello,

> On May 1, 2016, at 00:10, Peng Yu <address@hidden> wrote:
> 
> Hi, I can't find in the man page the document of `var=xxx cmd`. Could
> anybody show me where is it in the man page? Thanks.

If you refer to the grammar of variable-assignment before commands, then the 
man page contains this:
===
SHELL GRAMMAR
  Simple Commands
    A  simple  command  is  a sequence of optional variable assignments
    followed by blank-separated words and redirections, and
    terminated by a control operator.
===

The BASH manual expands on the parsing steps, here:
https://www.gnu.org/software/bash/manual/bashref.html#Simple-Command-Expansion
===
3.7.1 Simple Command Expansion

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

        • The words that the parser has marked as variable assignments (those 
preceding the command name) and redirections are saved for later processing.
        • The words that are not variable assignments or redirections are 
expanded (see Shell Expansions). If any words remain after expansion, the first 
word is taken to be the name of the command and the remaining words are the 
arguments.
        • Redirections are performed as described above (see Redirections).
        • 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.
===

This follows the POSIX "Shell Command Language" definition:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01

regards,
 - assaf




reply via email to

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