All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.
@ 2010-08-06 12:56 Asgeir S. Nilsen
  2010-08-06 16:00 ` Junio C Hamano
  2010-08-08  3:11 ` Jonathan Nieder
  0 siblings, 2 replies; 7+ messages in thread
From: Asgeir S. Nilsen @ 2010-08-06 12:56 UTC (permalink / raw)
  To: git, gitster; +Cc: Asgeir S. Nilsen

Signed-off-by: Asgeir S. Nilsen <asgeir@twingine.no>
---
 contrib/ciabot/ciabot.sh           |    2 +-
 contrib/examples/git-checkout.sh   |    2 +-
 contrib/examples/git-clean.sh      |    2 +-
 contrib/examples/git-clone.sh      |    2 +-
 contrib/examples/git-commit.sh     |    2 +-
 contrib/examples/git-fetch.sh      |    2 +-
 contrib/examples/git-gc.sh         |    2 +-
 contrib/examples/git-ls-remote.sh  |    2 +-
 contrib/examples/git-merge.sh      |    2 +-
 contrib/examples/git-notes.sh      |    2 +-
 contrib/examples/git-reset.sh      |    2 +-
 contrib/examples/git-resolve.sh    |    2 +-
 contrib/examples/git-revert.sh     |    2 +-
 contrib/examples/git-tag.sh        |    2 +-
 contrib/examples/git-verify-tag.sh |    2 +-
 contrib/fast-import/git-import.sh  |    2 +-
 contrib/git-resurrect.sh           |    2 +-
 contrib/hooks/post-receive-email   |    2 +-
 contrib/hooks/pre-auto-gc-battery  |    2 +-
 contrib/remotes2config.sh          |    2 +-
 contrib/rerere-train.sh            |    2 +-
 contrib/workdir/git-new-workdir    |    2 +-
 22 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/contrib/ciabot/ciabot.sh b/contrib/ciabot/ciabot.sh
index eb87bba..d3f5ded 100755
--- a/contrib/ciabot/ciabot.sh
+++ b/contrib/ciabot/ciabot.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Distributed under the terms of the GNU General Public License v2
 # Copyright (c) 2006 Fernando J. Pereda <ferdy@gentoo.org>
 # Copyright (c) 2008 Natanael Copa <natanael.copa@gmail.com>
diff --git a/contrib/examples/git-checkout.sh b/contrib/examples/git-checkout.sh
index 1a7689a..5130736 100755
--- a/contrib/examples/git-checkout.sh
+++ b/contrib/examples/git-checkout.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 OPTIONS_KEEPDASHDASH=t
 OPTIONS_SPEC="\
diff --git a/contrib/examples/git-clean.sh b/contrib/examples/git-clean.sh
index 01c95e9..e75bfc2 100755
--- a/contrib/examples/git-clean.sh
+++ b/contrib/examples/git-clean.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2005-2006 Pavel Roskin
 #
diff --git a/contrib/examples/git-clone.sh b/contrib/examples/git-clone.sh
index 547228e..2287f14 100755
--- a/contrib/examples/git-clone.sh
+++ b/contrib/examples/git-clone.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2005, Linus Torvalds
 # Copyright (c) 2005, Junio C Hamano
diff --git a/contrib/examples/git-commit.sh b/contrib/examples/git-commit.sh
index 5c72f65..ccc0497 100755
--- a/contrib/examples/git-commit.sh
+++ b/contrib/examples/git-commit.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2005 Linus Torvalds
 # Copyright (c) 2006 Junio C Hamano
diff --git a/contrib/examples/git-fetch.sh b/contrib/examples/git-fetch.sh
index a314273..285f155 100755
--- a/contrib/examples/git-fetch.sh
+++ b/contrib/examples/git-fetch.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 
 USAGE='<fetch-options> <repository> <refspec>...'
diff --git a/contrib/examples/git-gc.sh b/contrib/examples/git-gc.sh
index 1597e9f..8c32571 100755
--- a/contrib/examples/git-gc.sh
+++ b/contrib/examples/git-gc.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2006, Shawn O. Pearce
 #
diff --git a/contrib/examples/git-ls-remote.sh b/contrib/examples/git-ls-remote.sh
index fec70bb..c6fea33 100755
--- a/contrib/examples/git-ls-remote.sh
+++ b/contrib/examples/git-ls-remote.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 
 usage () {
diff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh
index 8f617fc..1b8c611 100755
--- a/contrib/examples/git-merge.sh
+++ b/contrib/examples/git-merge.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2005 Junio C Hamano
 #
diff --git a/contrib/examples/git-notes.sh b/contrib/examples/git-notes.sh
index e642e47..b4932e3 100755
--- a/contrib/examples/git-notes.sh
+++ b/contrib/examples/git-notes.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 USAGE="(edit [-F <file> | -m <msg>] | show) [commit]"
 . git-sh-setup
diff --git a/contrib/examples/git-reset.sh b/contrib/examples/git-reset.sh
index bafeb52..fc4b0f1 100755
--- a/contrib/examples/git-reset.sh
+++ b/contrib/examples/git-reset.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
 #
diff --git a/contrib/examples/git-resolve.sh b/contrib/examples/git-resolve.sh
index 8f98142..7606065 100755
--- a/contrib/examples/git-resolve.sh
+++ b/contrib/examples/git-resolve.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2005 Linus Torvalds
 #
diff --git a/contrib/examples/git-revert.sh b/contrib/examples/git-revert.sh
index 49f0032..dcd085a 100755
--- a/contrib/examples/git-revert.sh
+++ b/contrib/examples/git-revert.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2005 Linus Torvalds
 # Copyright (c) 2005 Junio C Hamano
diff --git a/contrib/examples/git-tag.sh b/contrib/examples/git-tag.sh
index 2c15bc9..194bd52 100755
--- a/contrib/examples/git-tag.sh
+++ b/contrib/examples/git-tag.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Copyright (c) 2005 Linus Torvalds
 
 USAGE='[-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'
diff --git a/contrib/examples/git-verify-tag.sh b/contrib/examples/git-verify-tag.sh
index 0902a5c..fbe94fd 100755
--- a/contrib/examples/git-verify-tag.sh
+++ b/contrib/examples/git-verify-tag.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 USAGE='<tag>'
 SUBDIRECTORY_OK='Yes'
diff --git a/contrib/fast-import/git-import.sh b/contrib/fast-import/git-import.sh
index 0ca7718..0723c69 100755
--- a/contrib/fast-import/git-import.sh
+++ b/contrib/fast-import/git-import.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Performs an initial import of a directory. This is the equivalent
 # of doing 'git init; git add .; git commit'. It's a lot slower,
diff --git a/contrib/git-resurrect.sh b/contrib/git-resurrect.sh
index a4ed4c3..599d807 100755
--- a/contrib/git-resurrect.sh
+++ b/contrib/git-resurrect.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 USAGE="[-a] [-r] [-m] [-t] [-n] [-b <newname>] <name>"
 LONG_USAGE="git-resurrect attempts to find traces of a branch tip
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 30ae63d..dc58d64 100755
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2007 Andy Parkins
 #
diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
index 1f914c9..bbf0aa9 100644
--- a/contrib/hooks/pre-auto-gc-battery
+++ b/contrib/hooks/pre-auto-gc-battery
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # An example hook script to verify if you are on battery, in case you
 # are running Linux or OS X. Called by git-gc --auto with no arguments.
diff --git a/contrib/remotes2config.sh b/contrib/remotes2config.sh
index 1cda19f..ed4aaf9 100755
--- a/contrib/remotes2config.sh
+++ b/contrib/remotes2config.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Use this tool to rewrite your .git/remotes/ files into the config.
 
diff --git a/contrib/rerere-train.sh b/contrib/rerere-train.sh
index 2cfe1b9..654aec4 100755
--- a/contrib/rerere-train.sh
+++ b/contrib/rerere-train.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Copyright (c) 2008, Nanako Shiraishi
 # Prime rerere database from existing merge commits
 
diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
index 993cacf..a84c7ad 100755
--- a/contrib/workdir/git-new-workdir
+++ b/contrib/workdir/git-new-workdir
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 usage () {
 	echo "usage:" $@
-- 
1.7.2.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.
  2010-08-06 12:56 [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris Asgeir S. Nilsen
@ 2010-08-06 16:00 ` Junio C Hamano
       [not found]   ` <AANLkTi=niNfKy0JgOG4hqNtXYQPfbkd10NRDDKM1rhfB@mail.gmail.com>
  2010-08-08  3:11 ` Jonathan Nieder
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2010-08-06 16:00 UTC (permalink / raw)
  To: Asgeir S. Nilsen; +Cc: git

"Asgeir S. Nilsen" <asgeir@twingine.no> writes:

> Signed-off-by: Asgeir S. Nilsen <asgeir@twingine.no>
> ---
>  contrib/ciabot/ciabot.sh           |    2 +-
>  contrib/examples/git-checkout.sh   |    2 +-
>  ...
>  contrib/examples/git-verify-tag.sh |    2 +-
>  contrib/fast-import/git-import.sh  |    2 +-
>  contrib/git-resurrect.sh           |    2 +-
>  contrib/hooks/post-receive-email   |    2 +-
>  contrib/hooks/pre-auto-gc-battery  |    2 +-
>  contrib/remotes2config.sh          |    2 +-
>  contrib/rerere-train.sh            |    2 +-
>  contrib/workdir/git-new-workdir    |    2 +-

Thanks.

The ones in contrib/examples used to be part of git and they were meant to
get their shebang "#!/bin/sh" line replaced by the toplevel Makefile to
whatever shell suitable on the platform.  As you already know, /bin/sh on
Solaris is non-POSIX and we recommend people to use a POSIX compilant
shell.  The current Makefile suggests /bin/bash on Solaris, but either ksh
or /usr/xpg[46]/bin/sh should work.

So a NAK on contrib/examples/ part.

And replacing /bin/sh with /bin/bash for everybody is _wrong_, as bash is
not the only POSIX compliant shell.

Some of the scripts in contrib/ may be using bash-specific construct, but
I think they are already marked with "#!/bin/bash" on their first lines.
If there are some that use bash-ism without "#!/bin/bash", we should first
try to see if we can reasonably rewrite them to avoid bash-ism, and mark
them as bash scripts if we can't.  I wounld't be so surprised if there are
some, but what I sampled randomly while writing this response were pure
POSIX as far as I can tell.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.
  2010-08-06 12:56 [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris Asgeir S. Nilsen
  2010-08-06 16:00 ` Junio C Hamano
@ 2010-08-08  3:11 ` Jonathan Nieder
  2010-08-09 16:57   ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Nieder @ 2010-08-08  3:11 UTC (permalink / raw)
  To: Asgeir S. Nilsen; +Cc: git, gitster

Asgeir S. Nilsen wrote:

> +++ b/contrib/ciabot/ciabot.sh
> @@ -1,4 +1,4 @@
> -#!/bin/sh
> +#!/bin/bash

Maybe, relying on a sane $PATH:

	#!/usr/bin/env sh

Not sure what would happen on the less unixy platforms.

Relying on POSIX execlp:

	# shebang line omitted for portability

Simplest of all is to tweak the #! lines in whatever script is used to
deploy the scripts from contrib.  I would not mind seeing an
install-contrib target incorporated into the Makefile that does that.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.
       [not found]   ` <AANLkTi=niNfKy0JgOG4hqNtXYQPfbkd10NRDDKM1rhfB@mail.gmail.com>
@ 2010-08-09 16:44     ` Junio C Hamano
  2010-08-10 12:33       ` Greg Troxel
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2010-08-09 16:44 UTC (permalink / raw)
  To: Asgeir Storesund Nilsen; +Cc: git

Asgeir Storesund Nilsen <asgeir@twingine.no> writes:

> I absolutely agree on the idea of using pure POSIX, but in reality I guess
> most of both developer and user base are using (GNU/)Linux and thus an
> environment where /bin/sh is in fact Bash?

For example, dash is a much lighter alternative than bash, and groks POSIX
fine.

I think a safer assumption is that /bin/sh is POSIX, and we make sure that
the builder can countermand it with SHELL_PATH; as platforms whose /bin/sh
is _not_ POSIX does not have to have bash as /bin/bash but somewhere else
(e.g. /usr/local/bin/bash).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.
  2010-08-08  3:11 ` Jonathan Nieder
@ 2010-08-09 16:57   ` Junio C Hamano
  2010-08-09 20:16     ` Jonathan Nieder
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2010-08-09 16:57 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Asgeir S. Nilsen, git, gitster

Jonathan Nieder <jrnieder@gmail.com> writes:

> Asgeir S. Nilsen wrote:
>
>> +++ b/contrib/ciabot/ciabot.sh
>> @@ -1,4 +1,4 @@
>> -#!/bin/sh
>> +#!/bin/bash
>
> Maybe, relying on a sane $PATH:
>
> 	#!/usr/bin/env sh

That's even worse.  Please don't go there.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.
  2010-08-09 16:57   ` Junio C Hamano
@ 2010-08-09 20:16     ` Jonathan Nieder
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Nieder @ 2010-08-09 20:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Asgeir S. Nilsen, git

Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:

>> Maybe, relying on a sane $PATH:
>>
>> 	#!/usr/bin/env sh
>
> That's even worse.  Please don't go there.

Okay.  I was trying to be exhaustive, even if most of the strategies I
mentioned are insane (“maybe” was probably too strong of a word :)).
(For example, I remember some version of Cygwin requiring the #! line,
so I fear it is dangerous to leave that off.)

After-the-fact s,/bin/sh,$SHELL_THE_USER_WANTS, substitution is the
only sane strategy I have seen used in practice.  POSIX has even
blessed something like it, at last.

http://www.opengroup.org/onlinepubs/9699919799/utilities/sh.html#tag_20_117_16

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.
  2010-08-09 16:44     ` Junio C Hamano
@ 2010-08-10 12:33       ` Greg Troxel
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Troxel @ 2010-08-10 12:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Asgeir Storesund Nilsen, git

[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]


Junio C Hamano <gitster@pobox.com> writes:

> Asgeir Storesund Nilsen <asgeir@twingine.no> writes:
>
>> I absolutely agree on the idea of using pure POSIX, but in reality I guess
>> most of both developer and user base are using (GNU/)Linux and thus an
>> environment where /bin/sh is in fact Bash?

The various BSDs have shells that are not bash, but which are believed
to be fully POSIX-compliant.  Putting #!/bin/bash in scripts is
nonportable and just creates work for packagers to undo this.

> For example, dash is a much lighter alternative than bash, and groks POSIX
> fine.

I believe that some GNU/Linux distributions have a /bin/sh that is not
bash.  Plus there is the /bin/sh on BSD, which is vastly smaller even if
one counts libedit:

   text    data     bss     dec     hex filename
 109602    1192    5836  116630   1c796 /bin/sh
   text    data     bss     dec     hex filename
  96523    4248    7488  108259   1a6e3 /lib/libedit.so.2.11

   text    data     bss     dec     hex filename
 716381   18328   11880  746589   b645d /usr/pkg/bin/bash


> I think a safer assumption is that /bin/sh is POSIX, and we make sure that
> the builder can countermand it with SHELL_PATH; as platforms whose /bin/sh
> is _not_ POSIX does not have to have bash as /bin/bash but somewhere else
> (e.g. /usr/local/bin/bash).

Agreed.  The current sources work well on NetBSD w.r.t. sh usage.

[-- Attachment #2: Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-08-10 12:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-06 12:56 [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris Asgeir S. Nilsen
2010-08-06 16:00 ` Junio C Hamano
     [not found]   ` <AANLkTi=niNfKy0JgOG4hqNtXYQPfbkd10NRDDKM1rhfB@mail.gmail.com>
2010-08-09 16:44     ` Junio C Hamano
2010-08-10 12:33       ` Greg Troxel
2010-08-08  3:11 ` Jonathan Nieder
2010-08-09 16:57   ` Junio C Hamano
2010-08-09 20:16     ` Jonathan Nieder

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.