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

Re: [PATCH 0/5] some shell portability fixes

From
RWRalf Wildenhues <ralf.wildenhues@gmx.de>
Date
Nov 6, 2007, 21:09 UTC
Message-ID
<20071106210925.GJ6361@ins.uni-bonn.de>
In-Reply-To
<7v8x5bgl04.fsf@gitster.siamese.dyndns.org>
Hello Junio,
* Junio C Hamano wrote on Tue, Nov 06, 2007 at 09:46:35PM CET:
> All missing Signed-off-by: lines.
Oops.  Sorry.
> [1/5] In addition to take advantage of the fact that the RHS of
>       assignment is not split, I'd prefer replacing `` with $()
>       with these cases.	 Much easier to read if your shell
>       supports it (and all the modern ones do).
OK.
Show 5 quoted lines
> [2/5] Gaah, AIX sed X-<.  I am not opposed to this patch but
>       would want to get Yays from people with non GNU sed.  Is
>       busybox sed good enough to grok our scripts these days?
>       Please ask help and collect Acks at least from folks on
>       Solaris, MacOS, FBSD, and OBSD.

FWIW, I have little experience with busybox sed, but for the others here you go: With

echo axbyc | sed 's,x,\n,; s,y,\ ,'

I get on OpenBSD, FreeBSD, Solaris, and Darwin (minus indentation):
  anb
  c
GNU sed gives
  a
  b
  c
> [3/5] Arithmetic expansion.  Have you caught _all_ of them, or
>       is this patch about only the ones you noticed?
I have grepped *.sh.  But let's drop that, I see that it goes backwards.
Show 8 quoted lines
> [4/5] I wonder if use of fgrep would be easier to read and more
>       portable with this one:
> 
> 	name=$( GIT_CONFIG=.gitmodules \
> 		git config --get-regexp '^submodule\..*\.path$' |
> 		fgrep "submodule.$1.path" |
> 		sed -e 's/^submodule\.\(.*\)\.path$/\1/'
> 	)

Certainly easier to read. But fgrep itself is not portable (it could be grep -F). Also, isn't the $1 to be matched at the end, after a "=" here? FWIW the pattern I posted has survived a few years in Automake, so there is some hope that it works.

> [5/5] Again, have you covered all of them?

No, oops again. As I searched for `test.*-[oa]' I have missed line wraps and [ ... -o ... ].

>       I am not opposed to
>       this one, although I am a bit curious who lacks -a/-o in
>       practice.

Hmm, good question. I actually don't know whether there is a shell that isn't ruled out by $() anyway. Let's drop that one, too, then.

Cheers, Ralf

Previous: Johannes SchindelinNext: Nguyen Thai Ngoc Duy
Message 32 of 38 in “some shell portability fixes”
  1. 0/5 some shell portability fixesRalf Wildenhues, Nov 6, 2007
  2. 1/5 Avoid a few unportable, needlessly nested "...`...".Ralf Wildenhues, Nov 6, 2007
  3. 2/5 Fix sed script to work with AIX sed.Ralf Wildenhues, Nov 6, 2007
  4. Ralf WildenhuesNov 6, 2007
  5. Ralf WildenhuesNov 6, 2007
  6. Junio C HamanoNov 6, 2007
  7. Add Documentation/CodingStyleJohannes Schindelin, Nov 6, 2007
  8. Andreas EricssonNov 7, 2007
  9. Junio C HamanoNov 7, 2007
  10. Andreas EricssonNov 7, 2007
  11. Add Documentation/CodingStyleJohannes Schindelin, Nov 7, 2007
  12. Robin RosenbergNov 7, 2007
  13. Add Documentation/CodingGuidelinesJohannes Schindelin, Nov 7, 2007
  14. Junio C HamanoNov 7, 2007
  15. Add Documentation/CodingGuidelinesJohannes Schindelin, Nov 8, 2007
  16. Junio C HamanoNov 8, 2007
  17. Johannes SchindelinNov 7, 2007
  18. Wincent ColaiutaNov 7, 2007
  19. Andreas EricssonNov 7, 2007
  20. Jon LoeligerNov 7, 2007
  21. Johannes SchindelinNov 7, 2007
  22. Mike RalphsonNov 8, 2007
  23. 4/5 Fix sed string regex escaping in module_name.Ralf Wildenhues, Nov 6, 2007
  24. 5/5 Avoid "test -o" and "test -a" which are not POSIX, only XSI.Ralf Wildenhues, Nov 6, 2007
  25. Junio C HamanoNov 6, 2007
  26. Mike HommeyNov 6, 2007
  27. Johannes SchindelinNov 6, 2007
  28. Mike RalphsonNov 7, 2007
  29. Johannes SchindelinNov 7, 2007
  30. Mike RalphsonNov 7, 2007
  31. Johannes SchindelinNov 7, 2007
  32. Ralf WildenhuesNov 6, 2007
  33. Nguyen Thai Ngoc DuyNov 7, 2007
  34. Nguyen Thai Ngoc DuyNov 7, 2007
  35. Junio C HamanoNov 7, 2007
  36. Ralf WildenhuesNov 8, 2007
  37. Nguyen Thai Ngoc DuyNov 12, 2007
  38. Miles BaderNov 10, 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.