[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: rsync --delete



On Mon, Oct 19, 2020 at 01:51:04PM -0500, Mike McClain wrote:
> I spent a while searching your wiki trying to find your objections
> without luck, so would you plaese tell this poor heathen what your
> objection to 'set -e' is?

https://mywiki.wooledge.org/BashFAQ/105

> On a different subject, my guess is that your insistence on quoting
> variables and using arrays for multi-part parameters is that doing so
> as a habit covers the times when a string variable will not expand as
> expected while an array will.
> Please correct me if I'm mis-reading things.

https://mywiki.wooledge.org/Quotes

If a string variable contains whitespace (more technically, any
character in IFS), or if it contains globbing characters (* ? [ ]),
the results of an unquoted expansion can be surprising, in a bad way.

Failing to quote the special [@] array expansion is exactly the same
as failing to quote "$@" when using the positional parameters.  Without
the quotews, it will fail to expand each element to a separate word,
which is the entire point of using an array.

unicorn:~$ array=("this array" has four elements)
unicorn:~$ printf '[%s] ' "${array[@]}"  ; echo    # right
[this array] [has] [four] [elements] 
unicorn:~$ printf '[%s] ' ${array[@]}    ; echo    # wrong
[this] [array] [has] [four] [elements] 


Reply to: