git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Shell script cleanups/style changes?

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 3, 2007, 00:48 UTC
Message-ID
<7vabt9sasl.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<85wswdwjll.fsf@lola.goethe.zz>
David Kastrup <dak@gnu.org> writes:
Show 8 quoted lines
>> 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.

Previous: David KastrupNext: David Kastrup
Message 24 of 42 in “Shell script cleanups/style changes?”
  1. David KastrupAug 2, 2007
  2. Robert SchieleAug 2, 2007
  3. David KastrupAug 2, 2007
  4. Robert SchieleAug 2, 2007
  5. Johannes SchindelinAug 2, 2007
  6. Robert SchieleAug 2, 2007
  7. Uwe Kleine-KönigAug 3, 2007
  8. Bradford SmithAug 2, 2007
  9. Sam RavnborgAug 2, 2007
  10. Junio C HamanoAug 2, 2007
  11. Nguyen Thai Ngoc DuyAug 2, 2007
  12. David KastrupAug 2, 2007
  13. Junio C HamanoAug 2, 2007
  14. David KastrupAug 2, 2007
  15. Junio C HamanoAug 2, 2007
  16. Junio C HamanoAug 2, 2007
  17. David KastrupAug 2, 2007
  18. Robert SchieleAug 2, 2007
  19. David KastrupAug 2, 2007
  20. Junio C HamanoAug 2, 2007
  21. David KastrupAug 2, 2007
  22. Junio C HamanoAug 3, 2007
  23. David KastrupAug 3, 2007
  24. Junio C HamanoAug 3, 2007
  25. David KastrupAug 3, 2007
  26. Junio C HamanoAug 3, 2007
  27. David KastrupAug 3, 2007
  28. David KastrupAug 3, 2007
  29. Robert SchieleAug 3, 2007
  30. David KastrupAug 3, 2007
  31. Robert SchieleAug 2, 2007
  32. David KastrupAug 2, 2007
  33. Robert SchieleAug 2, 2007
  34. David KastrupAug 2, 2007
  35. Robert SchieleAug 3, 2007
  36. David KastrupAug 3, 2007
  37. Junio C HamanoAug 3, 2007
  38. Robert SchieleAug 2, 2007
  39. Florian WeimerAug 4, 2007
  40. Robert SchieleAug 4, 2007
  41. Junio C HamanoAug 4, 2007
  42. David KastrupAug 2, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.