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

[PATCH 1/2] [TopGit] Portability: Use tr instead of sed for translating spaces to newlines

From
Brian Campbell <brian.p.campbell@dartmouth.edu>
Date
Mar 12, 2009, 05:56 UTC
Message-ID
<1236837389-35687-1-git-send-email-brian.p.campbell@dartmouth.edu>

It is not portable to use \n in the replacement of a sed substitute command. On Mac OS X (and presumably FreeBSD, as Mac OS X uses sed from FreeBSD), \n in the replacement of a substitution gives a literal "n" instead of a newline.

This patch replaces the sed command with tr, which should be more portable.

Signed-off-by: Brian Campbell <brian.p.campbell@dartmouth.edu>
---
 tg-create.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tg-create.sh b/tg-create.sh
index 2edd537..ef9a955 100644
--- a/tg-create.sh
+++ b/tg-create.sh
@@ -116,7 +116,7 @@ done
 git update-ref "refs/top-bases/$name" "HEAD" ""
 git checkout -b "$name"
 
-echo "$deps" | sed 's/ /\n/g' >"$root_dir/.topdeps"
+echo "$deps" | tr ' ' '\n' >"$root_dir/.topdeps"
 git add -f "$root_dir/.topdeps"
 
 author="$(git var GIT_AUTHOR_IDENT)"
-- 
1.6.2.185.g8b635.dirty
Next: Brian Campbell
Message 1 of 12 in “[TopGit] Portability: Use tr instead of sed for translating spaces to newlines”
  1. 1/2 [TopGit] Portability: Use tr instead of sed for translating spaces to newlinesBrian Campbell, Mar 12, 2009
  2. 2/2 [TopGit] Portability: Don't use alternation ("|") in sed regular expressionsBrian Campbell, Mar 12, 2009
  3. Junio C HamanoMar 12, 2009
  4. Uwe Kleine-KönigMar 12, 2009
  5. Brian CampbellMar 12, 2009
  6. Uwe Kleine-KönigMar 12, 2009
  7. martin f krafftMar 12, 2009
  8. Junio C HamanoMar 14, 2009
  9. Uwe Kleine-KönigMar 14, 2009
  10. Brian CampbellMar 12, 2009
  11. Uwe Kleine-KönigMar 12, 2009
  12. Uwe Kleine-KönigMar 12, 2009

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.