On 3/1/22 3:46 PM, Gordon Messmer wrote:> On 3/1/22 10:29, Gordon Messmer wrote:
>>
>> Chris Schanzle mentioned off-list that a tab character had been
replaced with spaces (I *knew* that should have been an attached file, shame on
me).? He also suggested an improvement that removes the tab character, so
here's a second try.
>
>
> Or not?? Last try.
>
>
> #!/bin/sh
>
> declare -a cmdline
> tab=$'\t'
> eol=$'\n'
>
> for arg in "$@"
> do
> ? arg="${arg//\\011/$tab}"
> ? arg="${arg//\\012/$eol}"
> ? arg="${arg//\\040/ }"
> ? arg="${arg//\\134/\\}"
> ? arg="${arg//\\\\/\\}"
> ? cmdline+=("$arg")
> done
>
> "${cmdline[@]}"
The problem there is that the last line is going to get interpreted by a shell
before anything is executed, so you now have to escape characters that are
special to the shell within a quoted string. This is unlike the compiled
fstab-decode program that invokes the execvp() library call and avoids further
shell parsing.
--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.