On Tue, 15 Nov 2011, Peng Yu wrote:

  Why not use the array instead of making it into a single string?

$cmd "${args[@]}"

  Why are you using eval or quotearg.sh? It sounds as if you are
  making the process more complicated than it need be.

For the examples that I gave, probably it is not necessary.

I'm yet to make a concrete complex example to demonstrate its
usefulness in practice. But I think that it is easy to imagine that
there will be some complex commands that are composed by concatenating
multiple strings to be evaled, in which case this may be useful.

    It may be possible to come up with something, but I doubt that
    there are many cases where the direct use of an array is not more
    appropriate (unless you need portability, in which case you
    wouldn't be using arrays in the first place).

    In any case, combining a command and its arguments in a single
    string is almost always the wrong way to go about it.

--
   Chris F.A. Johnson, <http://cfajohnson.com/>
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Reply via email to