From a6699576cea5ed42b5485965e766347757f99bf5 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 16 Jul 2021 18:08:36 +0200 Subject: [PATCH] docs: Some more $() changes --- doc_src/fish_for_bash_users.rst | 2 +- doc_src/tutorial.rst | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc_src/fish_for_bash_users.rst b/doc_src/fish_for_bash_users.rst index c8bb795b1..406bf8ce6 100644 --- a/doc_src/fish_for_bash_users.rst +++ b/doc_src/fish_for_bash_users.rst @@ -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 `, :ref:`string split0 ` or :ref:`string collect `. If those are used as the last command in a command substitution the splits they create are carried over. So:: diff --git a/doc_src/tutorial.rst b/doc_src/tutorial.rst index 9ec75290e..06ae2970a 100644 --- a/doc_src/tutorial.rst +++ b/doc_src/tutorial.rst @@ -372,9 +372,9 @@ For more, see :ref:`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