Re: Shell script cleanups/style changes?

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

 



David Kastrup <dak@xxxxxxx> writes:

>> I happen to feel ${parameter#word} is more esoteric than $(cmd).
>> If a system does not even do the latter, then avoiding the
>> former to help such a system is a futile effort.
>
> The situation is that we currently don't avoid the former.  Robert
> said that he had prepared a patch that would do so.
> ...
> But "only a little bit of ${parameter#word}, please" seems pointless.

Absolutely.  And we started to adopt #/% substititions some time
ago.  Undoing them just feels going backwards, and we need to
judge what the merits of going backwards are.

For that discussion, /bin/sh on Solaris does not count.  There
are huge downside of rewriting scripts to work with stock
Solaris /bin/sh:

 (1) that shell does not even grok $(cmd) substitution.

     I won't accept a half-baked patch that replaces "$(" with a
     backtick and matching ")" with another backtick.  You need
     to at least make sure your interpolated variables within
     the backtick pair work sensibly, and you haven't broken
     existing nesting of command interpolations, if any.  I do
     not even want to inspect, comment on and reject that kind
     of changes.  Quite frankly, it's not worth my time.

 (2) Rewriting $(cmd) to `cmd`, and ${parameter#word} with sed
     or expr would reduce readability, at least to other people.

     Remember, I was the one who originally avoided modern
     ${parameter#word} substitutions, and older scripts had many
     more invocations of expr than we currently have.  Reading
     such a backward rewrite would not be too much of a problem
     for *me*, but other people also need to read and understand
     scripts, if only to be able to rewrite them in C.

     There may still be many old parts of the scripts that could
     be made more readable and efficient using ${parameter#word}
     substitutions. If we were to rewrite scripts, more use of
     them could be a good thing, not the other way around.

Besides, on that platform there are more reasonable shells
available via SHELL_PATH, and it is not limited to going to
bash.

-
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