On Feb 16 2022, Viktor Korsun wrote:
> runme.sh
> #!/bin/bash
> echo $0
> echo $1
> echo $2
> echo $3
> echo $4
> echo $5
> echo $6
Don't use echo to print unknown text. Use printf instead, which can
handle this correctly. Also, don't forget to quote properly.
printf "%s\n" "$4"
>
> command:
> ./runme.sh -q -w -e -r -t -y
>
> produced output:
> ./get_env.sh
> -q
> -w
>
$ help echo
echo: echo [-neE] [arg ...]
Write arguments to the standard output.
Display the ARGs, separated by a single space character and followed by a
newline, on the standard output.
Options:
-n do not append a newline
-e enable interpretation of the following backslash escapes
-E explicitly suppress interpretation of backslash escapes
--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."