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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Brian,

On Sun, 25 Oct 2015, Johannes Schindelin wrote:

> 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@xxxxxx>
> > > ---
> > >  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 '
'

(!!!)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]