mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:38:27 +08:00
docs: Some more $() changes
This commit is contained in:
parent
405a03bfae
commit
a6699576ce
|
@ -12,7 +12,7 @@ Many things are similar - they both fundamentally expand commandlines to execute
|
|||
Command substitutions
|
||||
---------------------
|
||||
|
||||
Fish spells command substitutions as ``(command)`` instead of ``$(command)`` (or ```command```).
|
||||
Fish spells command substitutions as ``$(command)`` or ``(command)``, but not ```command```.
|
||||
|
||||
In addition, it only splits them on newlines instead of $IFS. If you want to split on something else, use :ref:`string split <cmd-string-split>`, :ref:`string split0 <cmd-string-split>` or :ref:`string collect <cmd-string-collect>`. If those are used as the last command in a command substitution the splits they create are carried over. So::
|
||||
|
||||
|
|
|
@ -372,9 +372,9 @@ For more, see :ref:`Lists <variables-lists>`.
|
|||
Command Substitutions
|
||||
---------------------
|
||||
|
||||
Command substitutions use the output of one command as an argument to another. Unlike other shells, fish does not use backticks `` for command substitutions. Instead, it uses parentheses::
|
||||
Command substitutions use the output of one command as an argument to another. Unlike other shells, fish does not use backticks `` for command substitutions. Instead, it uses parentheses with or without a dollar::
|
||||
|
||||
> echo In (pwd), running (uname)
|
||||
> echo In (pwd), running $(uname)
|
||||
In /home/tutorial, running FreeBSD
|
||||
|
||||
A common idiom is to capture the output of a command in a variable::
|
||||
|
@ -383,9 +383,9 @@ A common idiom is to capture the output of a command in a variable::
|
|||
> echo $os
|
||||
Linux
|
||||
|
||||
Command substitutions are not expanded within quotes. Instead, you can temporarily close the quotes, add the command substitution, and reopen them, all in the same argument::
|
||||
Command substitutions without a dollar are not expanded within quotes, so the version with a dollar is simpler::
|
||||
|
||||
> touch "testing_"(date +%s)".txt"
|
||||
> touch "testing_$(date +%s).txt"
|
||||
> ls *.txt
|
||||
testing_1360099791.txt
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user