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

shell scripting woes, was Re: [PATCH 2/2] sh-setup: explicitly mark CR as a field separator

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 25, 2015, 13:56 UTC
Message-ID
<alpine.DEB.1.00.1510251453420.31610@s15462909.onlinehome-server.info>
In-Reply-To
<alpine.DEB.1.00.1510251422310.31610@s15462909.onlinehome-server.info>
Hi Brian,
On Sun, 25 Oct 2015, Johannes Schindelin wrote:
Show 37 quoted lines
> On Sun, 25 Oct 2015, brian m. carlson wrote:
> 
> > On Sun, Oct 25, 2015 at 01:50:32PM +0100, Johannes Schindelin wrote:
> > > This is the correct thing to do, really: we already specify LF as
> > > field separator.
> > > 
> > > Incidentally, this fixes the problem interactive rebase has when the
> > > editor wants to save text with CR/LF line endings, as WordPad does
> > > in Windows 10.
> > > 
> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > > ---
> > >  git-sh-setup.sh               | 2 +-
> > >  t/t3404-rebase-interactive.sh | 2 +-
> > >  2 files changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/git-sh-setup.sh b/git-sh-setup.sh
> > > index 4691fbc..94dfe04 100644
> > > --- a/git-sh-setup.sh
> > > +++ b/git-sh-setup.sh
> > > @@ -13,7 +13,7 @@ unset CDPATH
> > >  # do not equate an unset IFS with IFS with the default, so here is
> > >  # an explicit SP HT LF.
> > >  IFS=' 	
> > > -'
> > > +'"$(printf '')"
> > 
> > On Linux, printf '' produces no output.  From my understanding of the
> > POSIX spec, this is the correct behavior.   Does it behave differently
> > on Windows?  If so, it might be nice to explain that in the commit
> > messgae.
> 
> Hrm. This is apparently a bug in the script I tried to write for three
> days now (because the mailing list-based code submission is really *so*
> much more tedious than the Pull Request-based process I got so used to).
> 
> The '' should really read '\r'.

Aargh. It is 'dash'. Which is the default /bin/sh on Ubuntu. Try to run the following script through dash and bash, compare the outputs, and weep:

-- snip -- x="$(echo "printf '\\n'")" echo "$x" -- snap --

Ciao, Johannes

P.S.: At least here, the output differs as following:

Bash: printf '\n'

Dash: printf ' '

(!!!)
Previous: Johannes Schindelin
Message 31 of 31 in “Fix interactive rebase when the editor saves with CR/LF”
  1. 0/2 Fix interactive rebase when the editor saves with CR/LFJohannes Schindelin, Oct 25, 2015
  2. 1/2 Demonstrate rebase fails when the editor saves with CR/LFJohannes Schindelin, Oct 25, 2015
  3. 2/2 sh-setup: explicitly mark CR as a field separatorJohannes Schindelin, Oct 25, 2015
  4. Philip OakleyOct 25, 2015
  5. Johannes SchindelinOct 25, 2015
  6. 0/2 Fix interactive rebase when the editor saves with CR/LFJohannes Schindelin, Oct 25, 2015
  7. 1/2 Demonstrate rebase fails when the editor saves with CR/LFJohannes Schindelin, Oct 25, 2015
  8. 2/2 sh-setup: explicitly mark CR as a field separatorJohannes Schindelin, Oct 25, 2015
  9. Matthieu MoyOct 26, 2015
  10. Junio C HamanoOct 26, 2015
  11. Junio C HamanoOct 26, 2015
  12. Johannes SchindelinOct 27, 2015
  13. Johannes SchindelinOct 27, 2015
  14. Junio C HamanoOct 27, 2015
  15. Matthieu MoyOct 27, 2015
  16. Junio C HamanoOct 25, 2015
  17. Johannes SchindelinOct 26, 2015
  18. Junio C HamanoOct 26, 2015
  19. Johannes SchindelinOct 27, 2015
  20. 0/2 Fix interactive rebase when the editor saves with CR/LFJohannes Schindelin, Oct 27, 2015
  21. 1/2 Demonstrate rebase fails when the editor saves with CR/LFJohannes Schindelin, Oct 27, 2015
  22. 2/2 rebase-i: work around Windows CRLF line endingsJohannes Schindelin, Oct 27, 2015
  23. Johannes SchindelinOct 27, 2015
  24. Junio C HamanoOct 27, 2015
  25. Johannes SchindelinOct 28, 2015
  26. 0/2 Fix interactive rebase when the editor saves with CR/LFJohannes Schindelin, Oct 28, 2015
  27. 1/2 Demonstrate rebase fails when the editor saves with CR/LFJohannes Schindelin, Oct 28, 2015
  28. 2/2 rebase-i: work around Windows CRLF line endingsJohannes Schindelin, Oct 28, 2015
  29. Junio C HamanoOct 28, 2015
  30. Johannes SchindelinOct 25, 2015
  31. shell scripting woes, was Re: [PATCH 2/2] sh-setup: explicitly mark CR as a field separatorJohannes Schindelin, Oct 25, 2015

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.