2 ms·
What is @Q notation?
by joombaga 6y ago
What is @Q notation?
- cb321 6y agoI belive zimbatm refers to the bash-specific ${var@Q} to expand to a form suitable as re-input into the shell. There are a few other bash-specific syntaxes like that (under "parameter transformation" in the manual page).
- zimbatm 6y agoWhat cb321 said. Sometimes programs take a single argument that contains the whole command. @Q allows to safely escape the list of arguments. This is a synthetic example: args=("my" "arg" "with space") bash -c "rm ${args[*]@Q}" This makes sure that the script will `rm` "my" "arg" and "with space", and not "with" and "space" :)
- graton 6y agoI found this info: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html https://www.gnu.org/software/bash/manual/html_node/Shell-Par... ${parameter@operator} The expansion is either a transformation of the value of parameter or information about parameter itself, depending on the value of operator. Each operator is a single letter: Q The expansion is a string that is the value of parameter quoted in a format that can be reused as input.