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 2, 2007, 20:37 UTC
Message-ID
<7vlkctvfk9.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<86bqdqkygp.fsf@lola.quinscape.zz>
David Kastrup <dak@gnu.org> writes:
Show 7 quoted lines
> Hi, I wanted to ask what the general stance towards shell script
> cleanups and simplifications would be.  For example, I find the expr
> usage quite inscrutable in commit, and there is no necessity of
> putting "shift" in every case branch instead of once behind it, and a
> lot of conditionals and other manipulations can be made much easier on
> the eye by using parameter expansion patterns that are, as far as I
> can see, available with every reasonable Bourne Shell and clones.

The shift in parameter parsing case arms were originally generated by an automated tool. If it bothers you, feel free to move them at the end, I would not mind. In fact, handcrafted parameter parser in other scripts do use shift-at-the-end.

As to Bourne-ness of the shell script, please realize that your maintainer is very old fashioned ;-), but is willing to be taught new tricks within reason.

We try to limit ourselves to -, =, ?, + (and their colon "if empty" variants when it really make sense) in parameter expansion of shell variables. We also use % and # (and their "match largest" variants).

Non POSIX substitions such as ${parameter/pattern/string} and ${parameter:offset} are not to be used. We do not want to depend on bash.

We try to avoid [ ] and instead spell "test" explicitly; this is just a personal taste, and not about portability but more about readability.

After 1.5.3 git-commit.sh will hopefully become built-in, so I would rather not touch the script. Certainly, the kind of change that is "intended to be style-only but somebody needs to make sure it does not introduce regression to everybody's shell" is very unwelcome at this point.

Previous: Sam RavnborgNext: Nguyen Thai Ngoc Duy
Message 10 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.