Re: [PATCH 0/5] some shell portability fixes

13 messages, 6 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 0/5] some shell portability fixes

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:47

All missing Signed-off-by: lines.

[1/5] In addition to take advantage of the fact that the RHS of
      assignment is not split, I'd prefer replacing `` with $()
      with these cases.	 Much easier to read if your shell
      supports it (and all the modern ones do).

[2/5] Gaah, AIX sed X-<.  I am not opposed to this patch but
      would want to get Yays from people with non GNU sed.  Is
      busybox sed good enough to grok our scripts these days?
      Please ask help and collect Acks at least from folks on
      Solaris, MacOS, FBSD, and OBSD.

[3/5] Arithmetic expansion.  Have you caught _all_ of them, or
      is this patch about only the ones you noticed?

      We used to have expr all over the place as I was one of
      the primary authors of our shell scripts, and I am
      "80-ish" old fashioned.  There was a long discussion on
      scripts in the past and we ruled that $(( ... )) is easier
      to read and supported widely enough to be acceptable.

      This patch goes backwards.  Will drop, unless you can
      demonstrate that an implementation does not support it and
      convince people that the implementation is important.
      /bin/sh on Solaris does not count as you can configure
      SHELL_PATH to point at xpg4 shell or ksh on that platform.

[4/5] I wonder if use of fgrep would be easier to read and more
      portable with this one:

	name=$( GIT_CONFIG=.gitmodules \
		git config --get-regexp '^submodule\..*\.path$' |
		fgrep "submodule.$1.path" |
		sed -e 's/^submodule\.\(.*\)\.path$/\1/'
	)

[5/5] Again, have you covered all of them?  I am not opposed to
      this one, although I am a bit curious who lacks -a/-o in
      practice.

Re: [PATCH 0/5] some shell portability fixes

From: Mike Hommey <hidden>
Date: 2016-06-15 22:43:47

On Tue, Nov 06, 2007 at 12:46:35PM -0800, Junio C Hamano wrote:
[5/5] Again, have you covered all of them?  I am not opposed to
      this one, although I am a bit curious who lacks -a/-o in
      practice.
Solaris's /bin/sh, but it already doesn't support $() and other stuff
used all over the place in git, so it's not like it's changing anything.

Maybe some other obscure old crappy shell ?

Mike

Re: [PATCH 0/5] some shell portability fixes

From: Ralf Wildenhues <hidden>
Date: 2016-06-15 22:43:47

Hello Junio,

* Junio C Hamano wrote on Tue, Nov 06, 2007 at 09:46:35PM CET:
All missing Signed-off-by: lines.
Oops.  Sorry.
[1/5] In addition to take advantage of the fact that the RHS of
      assignment is not split, I'd prefer replacing `` with $()
      with these cases.	 Much easier to read if your shell
      supports it (and all the modern ones do).
OK.
[2/5] Gaah, AIX sed X-<.  I am not opposed to this patch but
      would want to get Yays from people with non GNU sed.  Is
      busybox sed good enough to grok our scripts these days?
      Please ask help and collect Acks at least from folks on
      Solaris, MacOS, FBSD, and OBSD.
FWIW, I have little experience with busybox sed, but for the others here
you go:  With

echo axbyc | sed 's,x,\n,; s,y,\
,'

I get on OpenBSD, FreeBSD, Solaris, and Darwin (minus indentation):
  anb
  c

GNU sed gives
  a
  b
  c
[3/5] Arithmetic expansion.  Have you caught _all_ of them, or
      is this patch about only the ones you noticed?
I have grepped *.sh.  But let's drop that, I see that it goes backwards.
[4/5] I wonder if use of fgrep would be easier to read and more
      portable with this one:

	name=$( GIT_CONFIG=.gitmodules \
		git config --get-regexp '^submodule\..*\.path$' |
		fgrep "submodule.$1.path" |
		sed -e 's/^submodule\.\(.*\)\.path$/\1/'
	)
Certainly easier to read.  But fgrep itself is not portable (it could be
grep -F).  Also, isn't the $1 to be matched at the end, after a "="
here?  FWIW the pattern I posted has survived a few years in Automake,
so there is some hope that it works.
[5/5] Again, have you covered all of them?
No, oops again.  As I searched for `test.*-[oa]' I have missed line
wraps and [ ... -o ... ].
      I am not opposed to
      this one, although I am a bit curious who lacks -a/-o in
      practice.
Hmm, good question.  I actually don't know whether there is a shell
that isn't ruled out by $() anyway.  Let's drop that one, too, then.

Cheers,
Ralf

Re: [PATCH 0/5] some shell portability fixes

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:47

Hi,

On Tue, 6 Nov 2007, Mike Hommey wrote:
On Tue, Nov 06, 2007 at 12:46:35PM -0800, Junio C Hamano wrote:
quoted
[5/5] Again, have you covered all of them?  I am not opposed to
      this one, although I am a bit curious who lacks -a/-o in
      practice.
Solaris's /bin/sh, but it already doesn't support $() and other stuff
used all over the place in git, so it's not like it's changing anything.

Maybe some other obscure old crappy shell ?
As Junio commented in the part you did not quote, there are better shells 
in Solaris.  Use those.

Ciao,
Dscho

Re: [PATCH 0/5] some shell portability fixes

From: Mike Ralphson <hidden>
Date: 2016-06-15 22:43:48

Junio C Hamano wrote on Tue, Nov 06, 2007 at 09:46:35PM CET:
[2/5] Gaah, AIX sed X-<.  I am not opposed to this patch but
      would want to get Yays from people with non GNU sed.  Is
      busybox sed good enough to grok our scripts these days?
      Please ask help and collect Acks at least from folks on
      Solaris, MacOS, FBSD, and OBSD.
On Nov 6, 2007 11:25 PM, Johannes Schindelin [off-list ref] wrote:
As Junio commented in the part you did not quote, there are better shells
in Solaris.  Use those.
Equally GNU sed is available as a drop-in rpm for AIX. I wonder if it
would be worth adding
Makefile support for a PATH prefix for the git scripts, so they could
prepend (in this case)
something like /opt/freeware/bin or /usr/linux/bin ?

In our AIX environment many GNU tools are installed but I can't
guarantee they come first
in the paths of the git users.

I'm willing to work up a patch if there's any interest.

Mike

Re: [PATCH 0/5] some shell portability fixes

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:48

Hi,

On Wed, 7 Nov 2007, Mike Ralphson wrote:
Junio C Hamano wrote on Tue, Nov 06, 2007 at 09:46:35PM CET:
quoted
[2/5] Gaah, AIX sed X-<.  I am not opposed to this patch but
      would want to get Yays from people with non GNU sed.  Is
      busybox sed good enough to grok our scripts these days?
      Please ask help and collect Acks at least from folks on
      Solaris, MacOS, FBSD, and OBSD.
On Nov 6, 2007 11:25 PM, Johannes Schindelin [off-list ref] wrote:
quoted
As Junio commented in the part you did not quote, there are better shells
in Solaris.  Use those.
Equally GNU sed is available as a drop-in rpm for AIX. I wonder if it
would be worth adding
Makefile support for a PATH prefix for the git scripts, so they could
prepend (in this case)
something like /opt/freeware/bin or /usr/linux/bin ?

In our AIX environment many GNU tools are installed but I can't
guarantee they come first
in the paths of the git users.

I'm willing to work up a patch if there's any interest.
Would that be a task for configure?  Because I am not sure if the GNU 
tools are installed in the same place on all AIX boxen...

Ciao,
Dscho

Re: [PATCH 0/5] some shell portability fixes

From: Mike Ralphson <hidden>
Date: 2016-06-15 22:43:48

On Nov 7, 2007 2:47 PM, Johannes Schindelin [off-list ref] wrote:
quoted
Equally GNU sed is available as a drop-in rpm for AIX. I wonder if it
would be worth adding Makefile support for a PATH prefix for the git
scripts, so they could prepend (in this case) something like
/opt/freeware/bin or /usr/linux/bin ?

In our AIX environment many GNU tools are installed but I can't
guarantee they come first in the paths of the git users.

I'm willing to work up a patch if there's any interest.
Would that be a task for configure?  Because I am not sure if the GNU
tools are installed in the same place on all AIX boxen...
Well let's say the patch would arrive earlier if it was based on the
shipped Makefile rather than the unholy abomination that is
autoconf... If the GNU tools have been installed via the IBM AIX
Toolbox for Linux Applications[1] then they'll be installed in
/opt/freeware/bin and /usr/linux/bin will be a set of symlinks to
them.

That said, there may be 32/64bit differences and of course anyone
could have rolled their own sed, awk, diff, patch, grep, sort etc in
/usr/local/bin or anywhere else, and I'd guess this might be useful
for Solaris / HPUX users etc.

I was thinking along the lines of the existing $SHELL_PATH, i.e. a
build-time manually-set Makefile/environment variable. I'd also like
to be able to override gitexecdir in the same way without having my
builds marked dirty.

Cheers, Mike

[1] http://www-03.ibm.com/systems/p/os/aix/linux/download.html

Re: [PATCH 0/5] some shell portability fixes

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:48

Hi,

On Wed, 7 Nov 2007, Mike Ralphson wrote:
On Nov 7, 2007 2:47 PM, Johannes Schindelin [off-list ref] wrote:
quoted
I am not sure if the GNU tools are installed in the same place on all 
AIX boxen...
Well let's say the patch would arrive earlier if it was based on the
shipped Makefile rather than the unholy abomination that is
autoconf... If the GNU tools have been installed via the IBM AIX
Toolbox for Linux Applications[1] then they'll be installed in
/opt/freeware/bin and /usr/linux/bin will be a set of symlinks to
them.
I guess Makefile is the better place, then.  You are the expert on AIX.

Ciao,
Dscho

Re: [PATCH 0/5] some shell portability fixes

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:43:48

On 11/7/07, Junio C Hamano [off-list ref] wrote:
[2/5] Gaah, AIX sed X-<.  I am not opposed to this patch but
      would want to get Yays from people with non GNU sed.  Is
      busybox sed good enough to grok our scripts these days?
      Please ask help and collect Acks at least from folks on
      Solaris, MacOS, FBSD, and OBSD.
I haven't extensively used all the scripts. There seems to be no
sed-related failure from git testsuite results in my git-box branch.
So I would say for now it's good enough.
-- 
Duy

Re: [PATCH 0/5] some shell portability fixes

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:43:48

On 11/7/07, Nguyen Thai Ngoc Duy [off-list ref] wrote:
On 11/7/07, Junio C Hamano [off-list ref] wrote:
quoted
[2/5] Gaah, AIX sed X-<.  I am not opposed to this patch but
      would want to get Yays from people with non GNU sed.  Is
      busybox sed good enough to grok our scripts these days?
      Please ask help and collect Acks at least from folks on
      Solaris, MacOS, FBSD, and OBSD.
I haven't extensively used all the scripts. There seems to be no
sed-related failure from git testsuite results in my git-box branch.
So I would say for now it's good enough.
Argh, should have made it clear, busybox sed is good enough.

-- 
Duy

Re: [PATCH 0/5] some shell portability fixes

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:48

"Nguyen Thai Ngoc Duy" [off-list ref] writes:
On 11/7/07, Nguyen Thai Ngoc Duy [off-list ref] wrote:
quoted
On 11/7/07, Junio C Hamano [off-list ref] wrote:
quoted
[2/5] Gaah, AIX sed X-<.  I am not opposed to this patch but
      would want to get Yays from people with non GNU sed.  Is
      busybox sed good enough to grok our scripts these days?
      Please ask help and collect Acks at least from folks on
      Solaris, MacOS, FBSD, and OBSD.
I haven't extensively used all the scripts. There seems to be no
sed-related failure from git testsuite results in my git-box branch.
So I would say for now it's good enough.
Argh, should have made it clear, busybox sed is good enough.
Thanks.  And you can also happy grok Ralf's rewritten construct,
right?

That is, existing

        $ sed -e 's/foo/\n/' file

will be rewritten by the patch [2/5] to

        $ sed -e 's/foo/\
        /' file

Re: [PATCH 0/5] some shell portability fixes

From: Ralf Wildenhues <hidden>
Date: 2016-06-15 22:43:48

* Junio C Hamano wrote on Wed, Nov 07, 2007 at 09:42:41PM CET:
"Nguyen Thai Ngoc Duy" [off-list ref] writes:
quoted
Argh, should have made it clear, busybox sed is good enough.
Thanks.  And you can also happy grok Ralf's rewritten construct,
right?

That is, existing

        $ sed -e 's/foo/\n/' file

will be rewritten by the patch [2/5] to

        $ sed -e 's/foo/\
        /' file
The original was something like
  sed 's/[|]/\n/g'

Using instead
  tr '|' '\n'

should work for the original construct, and AFAIK only /usr/ucb/tr on
Solaris fails to understand \n correctly.  Would that be better for you?
Or even
  tr '|' '\012'

which fails only on EBCDIC, which I don't think git targets.

I'll resend the patches tonight.

Cheers,
Ralf

Re: [PATCH 0/5] some shell portability fixes

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:43:49

On Nov 8, 2007 3:42 AM, Junio C Hamano [off-list ref] wrote:
"Nguyen Thai Ngoc Duy" [off-list ref] writes:
quoted
On 11/7/07, Nguyen Thai Ngoc Duy [off-list ref] wrote:
quoted
On 11/7/07, Junio C Hamano [off-list ref] wrote:
quoted
[2/5] Gaah, AIX sed X-<.  I am not opposed to this patch but
      would want to get Yays from people with non GNU sed.  Is
      busybox sed good enough to grok our scripts these days?
      Please ask help and collect Acks at least from folks on
      Solaris, MacOS, FBSD, and OBSD.
I haven't extensively used all the scripts. There seems to be no
sed-related failure from git testsuite results in my git-box branch.
So I would say for now it's good enough.
Argh, should have made it clear, busybox sed is good enough.
Thanks.  And you can also happy grok Ralf's rewritten construct,
right?

That is, existing

        $ sed -e 's/foo/\n/' file

will be rewritten by the patch [2/5] to

        $ sed -e 's/foo/\
        /' file
Yes it worked well

-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help