David, David C. Rankin schreef:
On Thursday 22 October 2009 04:41:46 pm Guy wrote:
David,
The arguments are globbed alright, a simple test shows that (I named the script guy.sh) :
Sorry Guy,
The snippet implied setting the internal field separator to only break on end of line. That's how you handle spaces in file names, etc. Just add:
IFS=$'\n'
immediately before the loops and it will do what you want :-)
The script is exactly as you supplied it. Can you : 1) give us your output of "set|grep SHELLOPTS". 2) run this script with the arguments of your choice : #!/bin/bash --norc OLDIFS=$IFS IFS=$'\n' echo "No of params : "$# ## Fill an Array with all CLI input declare -a CLIARRAY CLIARRAY=( "$@" ) ## Step through CLIARRAY with ls to expand wildcards and process ## files specified on the command line sequentially. Rely on ## rsync to throw error if bad filename ## Simple echo is used for this example echo "Number of array elements:" ${#CLIARRAY[@]} for ((a=0;a<${#CLIARRAY[@]};a++)); do echo "Element $a : ${CLIARRAY[${a}]}" ## if the argument is a directory rsync in 1 shot, else rsync each file if [[ -d ${CLIARRAY[${a}]} ]]; then echo "directory: ${CLIARRAY[${a}]}" else for b in $(ls ${CLIARRAY[${a}]}); do echo "file: $b" done fi done IFS=$OLDIFS exit This will show us what your script is realy doing. Gtz, Guy. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org