> Then why don't you post that? Please take a look and see if you have a better solution than the following code without using quotearg.sh.
/tmp/tmp$ ll * c d: total 0 -rw-r--r-- 1 pengy wheel 0 2011-11-15 20:18:11 xx a b: total 0 -rw-r--r-- 1 pengy wheel 0 2011-11-15 20:18:15 yy /tmp/tmp$ ../convert_args_to_string.sh 'a b' 'c d' -O "-type f -name '*'" TEMP= -O '-type f -name '\''*'\''' -- 'a b' 'c d' a b/yy c d/xx find 'a b' 'c d' -type f -name '*' /tmp/tmp$ cat ../convert_args_to_string.sh #!/bin/bash TEMP=`getopt -o O: --long options: -n "${script_name}.sh" -- "$@"` echo TEMP=$TEMP if [ $? != 0 ] ; then printf "Terminating...\n" >&2 ; exit 1 ; fi eval set -- "$TEMP" abspath_script=`readlink -f -e "$0"` script_absdir=`dirname "$abspath_script"` while true ; do case "$1" in -O|--options) options="$2" shift 2 ;; --) shift break ;; *) echo "Internal error!" exit 1 ;; esac done arg_string=`quotearg.sh "$@"` cmd="find $arg_string $options" eval "$cmd" echo $cmd -- Regards, Peng