On Tue, 15 Nov 2011, Peng Yu wrote:
On Tue, Nov 15, 2011 at 6:43 PM, Chris F.A. Johnson
<ch...@cfajohnson.com> wrote:
On Tue, 15 Nov 2011, Peng Yu wrote:
In any case, combining a command and its arguments in a single
string is almost always the wrong way to go about it.
Please compare the two scripts and see if the second one makes more sense.
/tmp$ cat not_convert_args_to_string.sh
#!/bin/bash
options="$2"
find $1 $options
echo find $1 $options
More sensible would be to have each option a separate argument and
do:
location=$1
shift
find "$location" "$@"
No. My real example use getopt.
Then why don't you post that?
If I have each option in a separate argument, I need to know all the
possible arguments to find, which is not a viable route.
Are you trying to parse arguments that you should let find take care
of?
--
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)