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

Re: [PATCH] Avoid using non-portable `echo-n` in tests.

From
SFSteve Folly <steve@spfweb.co.uk>
Date
Oct 31, 2008, 09:36 UTC
Message-ID
<loom.20081031T093317-846@post.gmane.org>
In-Reply-To
<7vtzat89br.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster <at> pobox.com> writes:
Show 11 quoted lines
> 
> Brian Gernhardt <benji <at> silverinsanity.com> writes:
> 
> > Not all /bin/sh have a builtin echo that recognizes -n.  Using printf
> > is far more portable.
> >
> > Discovered on OS X 10.5.5 in t4030-diff-textconv.sh and changed in all
> > the test scripts.
> 
> I had an impression that OS X was BSDish.  Wasn't "echo -n" a BSDism?
> 
FYI, "man echo" on OS X 10.5.5 has this to say...
     The following option is available:
     -n    Do not print the trailing newline character.  This may also be
           achieved by appending `\c' to the end of the string, as is done by
           iBCS2 compatible systems.  Note that this option as well as the
           effect of `\c' are implementation-defined in IEEE Std 1003.1-2001
           (``POSIX.1'') as amended by Cor. 1-2002.  Applications aiming for
           maximum portability are strongly encouraged to use printf(1) to
           suppress the newline character.
     Some shells may provide a builtin echo command which is similar or iden-
     tical to this utility.  Most notably, the builtin echo in sh(1) does not
     accept the -n option.  Consult the builtin(1) manual page.

Regards, Steve.

Previous: Junio C HamanoNext: Shawn O. Pearce
Message 8 of 15 in “t4030: Don't use echo -n”
  1. t4030: Don't use echo -nBrian Gernhardt, Oct 30, 2008
  2. Ian HiltOct 30, 2008
  3. Brian GernhardtOct 31, 2008
  4. Avoid using non-portable `echo -n` in tests.Brian Gernhardt, Oct 31, 2008
  5. Junio C HamanoOct 31, 2008
  6. Brian GernhardtOct 31, 2008
  7. Junio C HamanoOct 31, 2008
  8. Steve FollyOct 31, 2008
  9. Shawn O. PearceOct 31, 2008
  10. Jeff KingOct 31, 2008
  11. Pierre HabouzitOct 31, 2008
  12. Jeff KingOct 31, 2008
  13. Francis GaliegueOct 31, 2008
  14. Johannes SchindelinOct 31, 2008
  15. Mike RalphsonNov 3, 2008

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.