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

Re: [PATCH] status&commit: Teach them to show submodule commit summary

From
RWRalf Wildenhues <ralf.wildenhues@gmx.de>
Date
Nov 12, 2007, 14:46 UTC
Message-ID
<20071112144605.GA16791@ins.uni-bonn.de>
In-Reply-To
<1194877277-31777-1-git-send-email-pkufranky@gmail.com>
Hello,
A couple of portability nits:
* Ping Yin wrote on Mon, Nov 12, 2007 at 03:21:17PM CET:
[...]
> +
> +	# TODO: quote module names containing space or tab
> +	test -n "$modules" && echo -e "# Submodules modifiled: "$modules"\n#"
Typo: s/modifiled/modified/
Then, "echo -e" is not portable (and not used elsewhere in git), but you
can just use this instead:
  test ... && { echo "# ..."; echo "#"; }
Also, it so happens you leave $modules outside quotes which will drop
multiple adjacent white spaces.  Did you mean to use
  echo "# Submodules modified: \"$modules\""
?
> +	OLDIFS=$IFS
> +	IFS=$'\n\r'	# '\r' for mac os

$' is not portable (and not POSIX either). For example pdksh, OpenBSD /bin/sh (which are both similar) will add "$" to the list of sepators here, compare this:

  $ foo=$'\n'; echo ".$foo."
  .$
  .
And at least some ash/dash versions will not interpret this as a newline
at all:
  .$\n.
You can instead just use a literal newline:
  IFS='
  '

(minus the indentation). And add a literal carriage return if need be (is that really needed on Mac OS?), though you may want to enclose that in another pair of quotes to avoid it being "optimized" away by some editor.

Cheers, Ralf

Previous: Ping YinNext: Ping Yin
Message 2 of 16 in “status&commit: Teach them to show submodule commit summary”
  1. status&commit: Teach them to show submodule commit summaryPing Yin, Nov 12, 2007
  2. Ralf WildenhuesNov 12, 2007
  3. Ping YinNov 12, 2007
  4. Brian GernhardtNov 12, 2007
  5. Jakub NarebskiNov 12, 2007
  6. Ping YinNov 12, 2007
  7. Johannes SixtNov 12, 2007
  8. Jakub NarebskiNov 12, 2007
  9. Ping YinNov 12, 2007
  10. Johannes SchindelinNov 12, 2007
  11. Ping YinNov 12, 2007
  12. Johannes SixtNov 12, 2007
  13. Ping YinNov 12, 2007
  14. Johannes SixtNov 12, 2007
  15. Lars HjemliNov 12, 2007
  16. Ping YinNov 15, 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.