On 5/12/07, Craig Skinner <[EMAIL PROTECTED]> wrote:
...
OK, thanks for the help. These are my results. Basically I could not get
it to work with single quoting when assembling the cmd line:

1) 1st attempt:

dmp_cmd='"${dump}" "-${level}${dump_flags}" "${device}" | gzip -9'
[[ ! -z ${encryption} ]] && dmp_cmd="${dmp_cmd}"' | "${encryption}" -pass 
"file:${conf}.passwd"'
[ ${debug} ] && echo "${dmp_cmd} > ${file}\n\n"
eval "${dmp_cmd}"' > "${file}"'

+ dump=dump
+ dump_flags=anu -f - -h 0
+ encryption=openssl enc -bf -salt

Argh, that what I get for not stating my assumptions clearly.  I
assumed dump_flags would just be a single argument of options and not
something in need to word splitting.  Ditto for encryption.  Since you
actually _want_ those to be split into multiple arguments, they can't
be double-quoted when eval sees them.  (And my alternative version
using "IFS=" won't work at all, as that disables word splitting
completely.)

      cmd='"${dump}" -${level}${dump_flags} "${device}" | gzip -9'
      if [[ ! -z ${encryption} ]]; then
              cmd="${cmd}"' | ${encryption} -pass "file:${conf}.passwd"
              -out'
      else
              cmd="${cmd} -o"
      fi
      eval "${cmd}"' "${file}"'


Philip Guenther

Reply via email to