I want an example of "the initial non-assignment word on the line"
CodePudding user response:
Shell commands consist of a series of words (where "word" has a formal meaning). An assignment word is one that contains a =
:
foo=5
That's a single word, though in other languages you might consider that the word foo
, an =
, and a 5
, just not separated by whitespace.
Commands can begin with 0 or more assignment words. An assignment word is not treated as the name of the command to execute, but as a variable assignment that is "local" to that command. For example,
x=5 foo
is a command that runs a program named foo
with a variable x
in its environment with the value 5
, not a command named x=5
with an argument foo
.
For completion purposes, you don't really want to do completion on assignments, because the whole point of the assignment is to define something that might not already exist, and how would the shell know how to complete something you haven't defined yet? So the complete
command ignores the assignment words at the beginning of a command line, and focuses on the first word that could be the name of the command to execute.
CodePudding user response:
example:
The “B” is “non-assignment”. Thanks @chepner’s answer.