How to preserve trailing whitespace in bash function arguments? [duplicate] How to preserve trailing whitespace in bash function arguments? [duplicate] bash bash

How to preserve trailing whitespace in bash function arguments? [duplicate]


  1. What happened to the trailing whitespace in the first argument?

    The whitespace was included on the echo command line, but was discarded by the shell, the same as if you had typed:

    echo -n Testing...                   ^                  |----- there is a space here
  2. How can preserve it?

    Quote your variables:

    function foo {  echo -n "$1"  echo "$2"}