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

Re: Shell script cleanups/style changes?

From
David Kastrup <dak@gnu.org>
Date
Aug 2, 2007, 22:14 UTC
Message-ID
<85vebxy47e.fsf@lola.goethe.zz>
In-Reply-To
<20070802214103.GT29424@schiele.dyndns.org>
Robert Schiele <rschiele@gmail.com> writes:
> No, you should read the mails you are refering to.  I said that the
> most important stuff does work.  Apparently this did not yet hurt me
> on the platform.
A non-working rebase would seem rather tough.
> Thus we have to decide whether we want some textbook example code
> and thus break this platform completely or whether we want to fix
> the issues you have listed and thus have a more portable
> application.

The "issues" are with Solaris, apparently. There is always a price for portability. If Solaris users can fix their problems with a global search and replace of the first line in *.sh, the question is whether it is worth the hassle of having unreadable but "portable" code. After all, it has to be read also by humans.

Show 11 quoted lines
>> Sure.  What about the git-rebase line using $(($end - $msgnum)) ?
>
> Bad on Solaris:
>
> $ uname -a
> SunOS solaris10-x64 5.10 Generic i86pc i386 i86pc
> $ end=1
> $ msgnum=5
> $ echo $(($end - $msgnum))
> syntax error: `(' unexpected
> $

You are missing the line $ echo $0 which is probably the most interesting one... we don't need to be compatible with everything having a "$ " prompt, just with everything called "/bin/sh".

>> Too bad: this should mean that $EDITOR can get called from C...  I've
>> been glad to see that so far this could be avoided.
>
> Why is it bad to call the editor from C?

See the rationale in my recently posted patch for implementing EDITOR/VISUAL support. One needs to shell-quote stuff properly, and the shell is better at shell-quote magic than C is.

Show 12 quoted lines
>> I do not think we have trouble with ${parameter#word}.  Much
>
> $ uname -a
> SunOS solaris10-x64 5.10 Generic i86pc i386 i86pc
> $ parameter=bla
> $ echo ${parameter#word}
> bad substitution
> $ 
>
>> less with ${parameter+word}; it has been in /bin/sh forever.
>
> That one is ok for Solaris.

If you prepare a patch replacing all existing ${parameter#word} uses and get it accepted, I will not push for inclusion of my cleanup.

But you _really_ should go for it _now_.
-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Previous: Robert SchieleNext: Junio C Hamano
Message 19 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.