How to use printf "%q " in bash? : <p>I would like to print out augments of a function to a file.
I was told a command printf "%q ", whose instruction is following,</p>

<pre><code># man printf
%q     ARGUMENT is printed in a format that can be reused as shell input, escaping non-print‐
          able characters with the proposed POSIX $'' syntax.
</code></pre>

<p>On the basis of instruction above, I tried following code.</p>

<pre><code>#!/bin/bash
# file name : print_out_function_augs.sh

output_file='output.txt'

function print_augs() {
  printf "%q " "$@" &gt;&gt; "${output_file}"
  echo &gt;&gt; "${output_file}"
}

print_augs a 'b c'

cat "${output_file}"
rm "${output_file}"
</code></pre>

<p>and run</p>

<pre><code>bash print_out_function_augs.sh
</code></pre>

<p>The results are following,</p>

<pre><code>a b\ c
</code></pre>

<p>I expected the results as</p>

<pre><code>a 'b c'
</code></pre>

<p>which is the original augments to print_augs function.</p>

<p>Why does the output and the original augments are different?
Or can I print out the original augments as they are?</p>

<p>Thank you very much.</p>
