{"thread":{"id":"24646","subject":"[PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.","startedAt":"2010-08-06T12:56:05Z","lastAt":"2010-08-10T12:33:28Z","messageCount":7,"participants":["Asgeir S. Nilsen","Junio C Hamano","Jonathan Nieder","Greg Troxel"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"147310","messageId":"1281099365-11978-1-git-send-email-asgeir@twingine.no","threadId":"24646","inReplyTo":null,"subject":"[PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.","fromName":"Asgeir S. Nilsen","fromEmail":"asgeir@twingine.no","sentAt":"2010-08-06T12:56:05Z","receivedAt":"2010-08-06T12:56:05Z","isPatch":true,"sender":{"key":"asgeir@twingine.no","avatar":null},"body":"Signed-off-by: Asgeir S. Nilsen <asgeir@twingine.no>\n---\n contrib/ciabot/ciabot.sh           |    2 +-\n contrib/examples/git-checkout.sh   |    2 +-\n contrib/examples/git-clean.sh      |    2 +-\n contrib/examples/git-clone.sh      |    2 +-\n contrib/examples/git-commit.sh     |    2 +-\n contrib/examples/git-fetch.sh      |    2 +-\n contrib/examples/git-gc.sh         |    2 +-\n contrib/examples/git-ls-remote.sh  |    2 +-\n contrib/examples/git-merge.sh      |    2 +-\n contrib/examples/git-notes.sh      |    2 +-\n contrib/examples/git-reset.sh      |    2 +-\n contrib/examples/git-resolve.sh    |    2 +-\n contrib/examples/git-revert.sh     |    2 +-\n contrib/examples/git-tag.sh        |    2 +-\n contrib/examples/git-verify-tag.sh |    2 +-\n contrib/fast-import/git-import.sh  |    2 +-\n contrib/git-resurrect.sh           |    2 +-\n contrib/hooks/post-receive-email   |    2 +-\n contrib/hooks/pre-auto-gc-battery  |    2 +-\n contrib/remotes2config.sh          |    2 +-\n contrib/rerere-train.sh            |    2 +-\n contrib/workdir/git-new-workdir    |    2 +-\n 22 files changed, 22 insertions(+), 22 deletions(-)\n\ndiff --git a/contrib/ciabot/ciabot.sh b/contrib/ciabot/ciabot.sh\nindex eb87bba..d3f5ded 100755\n--- a/contrib/ciabot/ciabot.sh\n+++ b/contrib/ciabot/ciabot.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n # Distributed under the terms of the GNU General Public License v2\n # Copyright (c) 2006 Fernando J. Pereda <ferdy@gentoo.org>\n # Copyright (c) 2008 Natanael Copa <natanael.copa@gmail.com>\ndiff --git a/contrib/examples/git-checkout.sh b/contrib/examples/git-checkout.sh\nindex 1a7689a..5130736 100755\n--- a/contrib/examples/git-checkout.sh\n+++ b/contrib/examples/git-checkout.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n \n OPTIONS_KEEPDASHDASH=t\n OPTIONS_SPEC=\"\\\ndiff --git a/contrib/examples/git-clean.sh b/contrib/examples/git-clean.sh\nindex 01c95e9..e75bfc2 100755\n--- a/contrib/examples/git-clean.sh\n+++ b/contrib/examples/git-clean.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Copyright (c) 2005-2006 Pavel Roskin\n #\ndiff --git a/contrib/examples/git-clone.sh b/contrib/examples/git-clone.sh\nindex 547228e..2287f14 100755\n--- a/contrib/examples/git-clone.sh\n+++ b/contrib/examples/git-clone.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Copyright (c) 2005, Linus Torvalds\n # Copyright (c) 2005, Junio C Hamano\ndiff --git a/contrib/examples/git-commit.sh b/contrib/examples/git-commit.sh\nindex 5c72f65..ccc0497 100755\n--- a/contrib/examples/git-commit.sh\n+++ b/contrib/examples/git-commit.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Copyright (c) 2005 Linus Torvalds\n # Copyright (c) 2006 Junio C Hamano\ndiff --git a/contrib/examples/git-fetch.sh b/contrib/examples/git-fetch.sh\nindex a314273..285f155 100755\n--- a/contrib/examples/git-fetch.sh\n+++ b/contrib/examples/git-fetch.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n \n USAGE='<fetch-options> <repository> <refspec>...'\ndiff --git a/contrib/examples/git-gc.sh b/contrib/examples/git-gc.sh\nindex 1597e9f..8c32571 100755\n--- a/contrib/examples/git-gc.sh\n+++ b/contrib/examples/git-gc.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Copyright (c) 2006, Shawn O. Pearce\n #\ndiff --git a/contrib/examples/git-ls-remote.sh b/contrib/examples/git-ls-remote.sh\nindex fec70bb..c6fea33 100755\n--- a/contrib/examples/git-ls-remote.sh\n+++ b/contrib/examples/git-ls-remote.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n \n usage () {\ndiff --git a/contrib/examples/git-merge.sh b/contrib/examples/git-merge.sh\nindex 8f617fc..1b8c611 100755\n--- a/contrib/examples/git-merge.sh\n+++ b/contrib/examples/git-merge.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Copyright (c) 2005 Junio C Hamano\n #\ndiff --git a/contrib/examples/git-notes.sh b/contrib/examples/git-notes.sh\nindex e642e47..b4932e3 100755\n--- a/contrib/examples/git-notes.sh\n+++ b/contrib/examples/git-notes.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n \n USAGE=\"(edit [-F <file> | -m <msg>] | show) [commit]\"\n . git-sh-setup\ndiff --git a/contrib/examples/git-reset.sh b/contrib/examples/git-reset.sh\nindex bafeb52..fc4b0f1 100755\n--- a/contrib/examples/git-reset.sh\n+++ b/contrib/examples/git-reset.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano\n #\ndiff --git a/contrib/examples/git-resolve.sh b/contrib/examples/git-resolve.sh\nindex 8f98142..7606065 100755\n--- a/contrib/examples/git-resolve.sh\n+++ b/contrib/examples/git-resolve.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Copyright (c) 2005 Linus Torvalds\n #\ndiff --git a/contrib/examples/git-revert.sh b/contrib/examples/git-revert.sh\nindex 49f0032..dcd085a 100755\n--- a/contrib/examples/git-revert.sh\n+++ b/contrib/examples/git-revert.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Copyright (c) 2005 Linus Torvalds\n # Copyright (c) 2005 Junio C Hamano\ndiff --git a/contrib/examples/git-tag.sh b/contrib/examples/git-tag.sh\nindex 2c15bc9..194bd52 100755\n--- a/contrib/examples/git-tag.sh\n+++ b/contrib/examples/git-tag.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n # Copyright (c) 2005 Linus Torvalds\n \n USAGE='[-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg>] <tagname> [<head>]'\ndiff --git a/contrib/examples/git-verify-tag.sh b/contrib/examples/git-verify-tag.sh\nindex 0902a5c..fbe94fd 100755\n--- a/contrib/examples/git-verify-tag.sh\n+++ b/contrib/examples/git-verify-tag.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n \n USAGE='<tag>'\n SUBDIRECTORY_OK='Yes'\ndiff --git a/contrib/fast-import/git-import.sh b/contrib/fast-import/git-import.sh\nindex 0ca7718..0723c69 100755\n--- a/contrib/fast-import/git-import.sh\n+++ b/contrib/fast-import/git-import.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Performs an initial import of a directory. This is the equivalent\n # of doing 'git init; git add .; git commit'. It's a lot slower,\ndiff --git a/contrib/git-resurrect.sh b/contrib/git-resurrect.sh\nindex a4ed4c3..599d807 100755\n--- a/contrib/git-resurrect.sh\n+++ b/contrib/git-resurrect.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n \n USAGE=\"[-a] [-r] [-m] [-t] [-n] [-b <newname>] <name>\"\n LONG_USAGE=\"git-resurrect attempts to find traces of a branch tip\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 30ae63d..dc58d64 100755\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # Copyright (c) 2007 Andy Parkins\n #\ndiff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery\nindex 1f914c9..bbf0aa9 100644\n--- a/contrib/hooks/pre-auto-gc-battery\n+++ b/contrib/hooks/pre-auto-gc-battery\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n #\n # An example hook script to verify if you are on battery, in case you\n # are running Linux or OS X. Called by git-gc --auto with no arguments.\ndiff --git a/contrib/remotes2config.sh b/contrib/remotes2config.sh\nindex 1cda19f..ed4aaf9 100755\n--- a/contrib/remotes2config.sh\n+++ b/contrib/remotes2config.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n \n # Use this tool to rewrite your .git/remotes/ files into the config.\n \ndiff --git a/contrib/rerere-train.sh b/contrib/rerere-train.sh\nindex 2cfe1b9..654aec4 100755\n--- a/contrib/rerere-train.sh\n+++ b/contrib/rerere-train.sh\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n # Copyright (c) 2008, Nanako Shiraishi\n # Prime rerere database from existing merge commits\n \ndiff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir\nindex 993cacf..a84c7ad 100755\n--- a/contrib/workdir/git-new-workdir\n+++ b/contrib/workdir/git-new-workdir\n@@ -1,4 +1,4 @@\n-#!/bin/sh\n+#!/bin/bash\n \n usage () {\n \techo \"usage:\" $@\n-- \n1.7.2.1\n"},{"id":"147324","messageId":"7veiebafzn.fsf@alter.siamese.dyndns.org","threadId":"24646","inReplyTo":"1281099365-11978-1-git-send-email-asgeir@twingine.no","subject":"Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-06T16:00:12Z","receivedAt":"2010-08-06T16:00:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Asgeir S. Nilsen\" <asgeir@twingine.no> writes:\n\n> Signed-off-by: Asgeir S. Nilsen <asgeir@twingine.no>\n> ---\n>  contrib/ciabot/ciabot.sh           |    2 +-\n>  contrib/examples/git-checkout.sh   |    2 +-\n>  ...\n>  contrib/examples/git-verify-tag.sh |    2 +-\n>  contrib/fast-import/git-import.sh  |    2 +-\n>  contrib/git-resurrect.sh           |    2 +-\n>  contrib/hooks/post-receive-email   |    2 +-\n>  contrib/hooks/pre-auto-gc-battery  |    2 +-\n>  contrib/remotes2config.sh          |    2 +-\n>  contrib/rerere-train.sh            |    2 +-\n>  contrib/workdir/git-new-workdir    |    2 +-\n\nThanks.\n\nThe ones in contrib/examples used to be part of git and they were meant to\nget their shebang \"#!/bin/sh\" line replaced by the toplevel Makefile to\nwhatever shell suitable on the platform.  As you already know, /bin/sh on\nSolaris is non-POSIX and we recommend people to use a POSIX compilant\nshell.  The current Makefile suggests /bin/bash on Solaris, but either ksh\nor /usr/xpg[46]/bin/sh should work.\n\nSo a NAK on contrib/examples/ part.\n\nAnd replacing /bin/sh with /bin/bash for everybody is _wrong_, as bash is\nnot the only POSIX compliant shell.\n\nSome of the scripts in contrib/ may be using bash-specific construct, but\nI think they are already marked with \"#!/bin/bash\" on their first lines.\nIf there are some that use bash-ism without \"#!/bin/bash\", we should first\ntry to see if we can reasonably rewrite them to avoid bash-ism, and mark\nthem as bash scripts if we can't.  I wounld't be so surprised if there are\nsome, but what I sampled randomly while writing this response were pure\nPOSIX as far as I can tell.\n"},{"id":"147412","messageId":"20100808031142.GA20077@burratino","threadId":"24646","inReplyTo":"1281099365-11978-1-git-send-email-asgeir@twingine.no","subject":"Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-08T03:11:42Z","receivedAt":"2010-08-08T03:11:42Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Asgeir S. Nilsen wrote:\n\n> +++ b/contrib/ciabot/ciabot.sh\n> @@ -1,4 +1,4 @@\n> -#!/bin/sh\n> +#!/bin/bash\n\nMaybe, relying on a sane $PATH:\n\n\t#!/usr/bin/env sh\n\nNot sure what would happen on the less unixy platforms.\n\nRelying on POSIX execlp:\n\n\t# shebang line omitted for portability\n\nSimplest of all is to tweak the #! lines in whatever script is used to\ndeploy the scripts from contrib.  I would not mind seeing an\ninstall-contrib target incorporated into the Makefile that does that.\n"},{"id":"147514","messageId":"7vmxsv7n3d.fsf@alter.siamese.dyndns.org","threadId":"24646","inReplyTo":"AANLkTi=niNfKy0JgOG4hqNtXYQPfbkd10NRDDKM1rhfB@mail.gmail.com","subject":"Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-09T16:44:06Z","receivedAt":"2010-08-09T16:44:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Asgeir Storesund Nilsen <asgeir@twingine.no> writes:\n\n> I absolutely agree on the idea of using pure POSIX, but in reality I guess\n> most of both developer and user base are using (GNU/)Linux and thus an\n> environment where /bin/sh is in fact Bash?\n\nFor example, dash is a much lighter alternative than bash, and groks POSIX\nfine.\n\nI think a safer assumption is that /bin/sh is POSIX, and we make sure that\nthe builder can countermand it with SHELL_PATH; as platforms whose /bin/sh\nis _not_ POSIX does not have to have bash as /bin/bash but somewhere else\n(e.g. /usr/local/bin/bash).\n"},{"id":"147520","messageId":"7vvd7j67wo.fsf@alter.siamese.dyndns.org","threadId":"24646","inReplyTo":"20100808031142.GA20077@burratino","subject":"Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-09T16:57:27Z","receivedAt":"2010-08-09T16:57:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Asgeir S. Nilsen wrote:\n>\n>> +++ b/contrib/ciabot/ciabot.sh\n>> @@ -1,4 +1,4 @@\n>> -#!/bin/sh\n>> +#!/bin/bash\n>\n> Maybe, relying on a sane $PATH:\n>\n> \t#!/usr/bin/env sh\n\nThat's even worse.  Please don't go there.\n"},{"id":"147547","messageId":"20100809201629.GB2888@burratino","threadId":"24646","inReplyTo":"7vvd7j67wo.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-09T20:16:29Z","receivedAt":"2010-08-09T20:16:29Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n\n>> Maybe, relying on a sane $PATH:\n>>\n>> \t#!/usr/bin/env sh\n>\n> That's even worse.  Please don't go there.\n\nOkay.  I was trying to be exhaustive, even if most of the strategies I\nmentioned are insane (“maybe” was probably too strong of a word :)).\n(For example, I remember some version of Cygwin requiring the #! line,\nso I fear it is dangerous to leave that off.)\n\nAfter-the-fact s,/bin/sh,$SHELL_THE_USER_WANTS, substitution is the\nonly sane strategy I have seen used in practice.  POSIX has even\nblessed something like it, at last.\n\nhttp://www.opengroup.org/onlinepubs/9699919799/utilities/sh.html#tag_20_117_16\n"},{"id":"147629","messageId":"rmiy6cezlyf.fsf@fnord.ir.bbn.com","threadId":"24646","inReplyTo":"7vmxsv7n3d.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] contrib: Replaced /bin/sh with /bin/bash to make scripts with Bash syntax work on Solaris.","fromName":"Greg Troxel","fromEmail":"gdt@ir.bbn.com","sentAt":"2010-08-10T12:33:28Z","receivedAt":"2010-08-10T12:33:28Z","isPatch":true,"sender":{"key":"gdt@ir.bbn.com","avatar":null},"body":"\nJunio C Hamano <gitster@pobox.com> writes:\n\n> Asgeir Storesund Nilsen <asgeir@twingine.no> writes:\n>\n>> I absolutely agree on the idea of using pure POSIX, but in reality I guess\n>> most of both developer and user base are using (GNU/)Linux and thus an\n>> environment where /bin/sh is in fact Bash?\n\nThe various BSDs have shells that are not bash, but which are believed\nto be fully POSIX-compliant.  Putting #!/bin/bash in scripts is\nnonportable and just creates work for packagers to undo this.\n\n> For example, dash is a much lighter alternative than bash, and groks POSIX\n> fine.\n\nI believe that some GNU/Linux distributions have a /bin/sh that is not\nbash.  Plus there is the /bin/sh on BSD, which is vastly smaller even if\none counts libedit:\n\n   text    data     bss     dec     hex filename\n 109602    1192    5836  116630   1c796 /bin/sh\n   text    data     bss     dec     hex filename\n  96523    4248    7488  108259   1a6e3 /lib/libedit.so.2.11\n\n   text    data     bss     dec     hex filename\n 716381   18328   11880  746589   b645d /usr/pkg/bin/bash\n\n\n> I think a safer assumption is that /bin/sh is POSIX, and we make sure that\n> the builder can countermand it with SHELL_PATH; as platforms whose /bin/sh\n> is _not_ POSIX does not have to have bash as /bin/bash but somewhere else\n> (e.g. /usr/local/bin/bash).\n\nAgreed.  The current sources work well on NetBSD w.r.t. sh usage.\n"}]}