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

Re: rsync --delete



On Sat, Oct 17, 2020 at 03:01:13PM -0700, David Christensen wrote:
> I try to use all lower case letters for variable names and all upper case
> letters for constants.

ALL_UPPER_CASE is reserved for internal shell variables, and environment
variables.

If you abuse it for "constants" as well, on your head be it.  You must
take care to ensure that your ALL_CAPS variable does not collide with
any internal shell variables, or environment variables.

> I use braces whenever evaluating a variable -- '${Params}'.  I forget the
> details why, but I do recall that this practice is important.

It isn't.  It's entirely stylistic.

> I don't use Bourne arrays, and I barely understand how the shell

Bourne shell does not have arrays.  Neither does POSIX shell.

> interpolates lists and preserves items containing whitespace.  When I can't
> figure it out, I switch to Perl.

OK.

> -e ${SSH} -- where:

The stylistic curly braces are NOT a substitute for proper quoting.

>     SSH=/usr/bin/ssh
> 
> 
> (To be pendantic, I should put single parentheses around the RHS?)

No.  foo=(...) creates an array variable, and you are not using this
variable in an array manner.

> > cd /home/mike
> 
> I prefer scripts that I can run from anywhere.

... hence, the cd inside the script.  Doesn't matter where you call it
from, as long as the script cd's to the right location to do its work,
**AND VERIFIES THAT THE cd ACTUALLY WORKED**.

> If the script must change the working directory, I would display that --
> 'set -x', 'cd ...', and 'set +x'.

For god's sake, why?

> I use 'set -e'

NOOOOOOOOOOO!!!!


Reply to: