Fixing bash script bogosity - help?

Martin Langhoff martin.langhoff at
Tue Apr 28 07:07:12 EDT 2009

On Tue, Apr 28, 2009 at 1:01 PM, Ignacio Vazquez-Abrams
<ivazqueznet at> wrote:
> Which part of the following doesn't work?

Just test your minimal 3 line script with the example input I've given
you. It breaks:

# cat >
#! /bin/bash

CMD=(touch "$@")
bash -c "${CMD[@]}"
# ./ "this is file one" "this is file two" "file
# bash -x ./ "this is file one" "this is file two" "file \" f"
+ CMD=(touch "$@")
+ bash -c touch 'this is file one' 'this is file two' 'file " f'
touch: missing file operand
Try `touch --help' for more information.

Bash (line runuser) expects a line of shell, quoted/escaped
appropriately, as a single string param -c

*that* is the challenge.

 martin.langhoff at
 martin at -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first

More information about the Devel mailing list