Re: [PATCH 3/5] Replace $((...)) with expr invocations.

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

 



Ralf Wildenhues <Ralf.Wildenhues@xxxxxx> writes:

> * Ralf Wildenhues wrote on Tue, Nov 06, 2007 at 09:18:09PM CET:
>> ---
>>  git-filter-branch.sh       |    4 ++--
>>  git-rebase--interactive.sh |    8 ++++----
>>  git-rebase.sh              |    8 ++++----
>>  3 files changed, 10 insertions(+), 10 deletions(-)
>
> Hmm, maybe this one is overkill.  $((...)) is POSIX, I temporarily
> forgot (thanks Benoît!).
>
> I'm unsure whether git targets non-POSIX Bourne shells like Solaris
> /bin/sh.  That would however mean replacing stuff like $(cmd) with
> `cmd` as well, and from grepping the source it looks like you'd rather
> avoid that.

For git, two rough rules are:

 - Most importantly, we never say "It's in POSIX; we'll happily
   screw your system that does not conform."  We live in the
   real world.

 - However, we often say "Let's stay away from that construct,
   it's not even in POSIX".

For shell scripts specifically (not exhaustive):

 - We prefer $( ... ) for command substitution; unlike ``, it
   properly nests.  It should have been the way Bourne spelled
   it from day one, but unfortunately isn't.

 - We use ${parameter-word} and its [-=?+] siblings, and their
   colon'ed "unset or null" form.

 - We use ${parameter#word} and its [#%] siblings, and their
   doubled "longest matching" form.

 - We use Arithmetic Expansion $(( ... )).

 - No "Substring Expansion" ${parameter:offset:length}.

 - No shell arrays.

 - No strlen ${#parameter}.

 - No regexp ${parameter/pattern/string}.

 - We do not use Process Substitution <(list) or >(list).

 - We prefer "test" over "[ ... ]".

 - We do not write noiseword "function" in front of shell
   functions.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux