Soare Catalin <[email protected]> writes:

>The script will take files or dirs as parameters and will back them up in a
>presefined location, using tar. Problems arise when it will encounter files
>or directories which contain spaces in their names.

>then #is it an existing directory?
>BK_LIST="$BK_LIST ${PARAM}"

here...

>else
>if [ -f "$PARAM" ]; then #is it an existing file?
>BK_LIST="$BK_LIST ${PARAM}"

.... and here.

As you build up BK_LIST, you lose the ability to tell which spaces are
the ones you added, or were already in $PARAM. You end up treating all
spaces as word separators.

To fix this, you want to make BK_LIST an array:

BK_LIST=()
# or declare -a BK_LIST, but I prefer the former

Append to the array with +=

  BK_LIST+="${PARAM}"

Expand the array, preserving spaces:

  tar -cjf $BK_FULLPATH "${BK_LIST[@]}"



-- 
To UNSUBSCRIBE, email to [email protected] 
with a subject of "unsubscribe". Trouble? Contact [email protected]
Archive: http://lists.debian.org/[email protected]

Reply via email to