Skip to content

Commit

Permalink
docs: Mention cartesian product in variable-expansion section
Browse files Browse the repository at this point in the history
See #3002.

(cherry picked from commit 1d101ef)
  • Loading branch information
faho committed May 8, 2016
1 parent 4d1e77f commit 46b819a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doc_src/index.hdr.in
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ echo The plural of $WORD is {$WORD}s

Note that without the quotes or braces, fish will try to expand a variable called `$WORDs`, which may not exist.

The latter syntax `{$WORD}` works by exploiting <a href="#expand-brace">brace expansion</a>; care should be taken with array variables and undefined variables, as these behave very differently to POSIX shells.
The latter syntax `{$WORD}` works by exploiting <a href="#expand-brace">brace expansion</a>; care should be taken with array variables and undefined variables, as these expand as a <a href="#cartesian-product">cartesian product</a>, so undefined variables eliminate the string.

Variable expansion is the only type of expansion performed on double quoted strings. There is, however, an important difference in how variables are expanded when quoted and when unquoted. An unquoted variable expansion will result in a variable number of arguments. For example, if the variable `$foo` has zero elements or is undefined, the argument `$foo` will expand to zero elements. If the variable $foo is an array of five elements, the argument `$foo` will expand to five elements. When quoted, like `"$foo"`, a variable expansion will always result in exactly one argument. Undefined variables will expand to the empty string, and array variables will be concatenated using the space character.

Expand Down

0 comments on commit 46b819a

Please sign in to comment.