{"thread":{"id":"9352","subject":"Shell script cleanups/style changes?","startedAt":"2007-08-02T10:44:22Z","lastAt":"2007-08-04T20:39:09Z","messageCount":42,"participants":["David Kastrup","Robert Schiele","Bradford Smith","Johannes Schindelin","Sam Ravnborg","Junio C Hamano","Nguyen Thai Ngoc Duy","Uwe Kleine-König","Florian Weimer"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"49411","messageId":"86bqdqkygp.fsf@lola.quinscape.zz","threadId":"9352","inReplyTo":null,"subject":"Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T10:44:22Z","receivedAt":"2007-08-02T10:44:22Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"\nHi, I wanted to ask what the general stance towards shell script\ncleanups and simplifications would be.  For example, I find the expr\nusage quite inscrutable in commit, and there is no necessity of\nputting \"shift\" in every case branch instead of once behind it, and a\nlot of conditionals and other manipulations can be made much easier on\nthe eye by using parameter expansion patterns that are, as far as I\ncan see, available with every reasonable Bourne Shell and clones.\n\nHere is an example context diff (in this case, I find it more readable\nthan unified) to illustrate (untested!, please don't apply without a\nregular formatted git patch).\n\nShould I bother doing such cleanups as I read up on code, or should I\njust leave things alone?\n\n\n\ndiff --git a/git-commit.sh b/git-commit.sh\nindex d7e7028..bdf20be 100755\n*** a/git-commit.sh\n--- b/git-commit.sh\n***************\n*** 97,101 ****\n  \t\tno_edit=t\n  \t\tlog_given=t$log_given\n  \t\tlogfile=\"$1\"\n- \t\tshift\n  \t\t;;\n--- 97,100 ----\n***************\n*** 102,107 ****\n  \t-F*|-f*)\n  \t\tno_edit=t\n  \t\tlog_given=t$log_given\n! \t\tlogfile=`expr \"z$1\" : 'z-[Ff]\\(.*\\)'`\n! \t\tshift\n  \t\t;;\n--- 101,105 ----\n  \t-F*|-f*)\n  \t\tno_edit=t\n  \t\tlog_given=t$log_given\n! \t\tlogfile=\"${1#-?}\"\n  \t\t;;\n***************\n*** 108,113 ****\n  \t--F=*|--f=*|--fi=*|--fil=*|--file=*)\n  \t\tno_edit=t\n  \t\tlog_given=t$log_given\n! \t\tlogfile=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n! \t\tshift\n  \t\t;;\n--- 106,110 ----\n  \t--F=*|--f=*|--fi=*|--fil=*|--file=*)\n  \t\tno_edit=t\n  \t\tlog_given=t$log_given\n! \t\tlogfile=\"${1#*=}\"\n  \t\t;;\n***************\n*** 114,117 ****\n  \t-a|--a|--al|--all)\n  \t\tall=t\n- \t\tshift\n  \t\t;;\n--- 111,113 ----\n***************\n*** 118,127 ****\n  \t--au=*|--aut=*|--auth=*|--autho=*|--author=*)\n! \t\tforce_author=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n! \t\tshift\n  \t\t;;\n  \t--au|--aut|--auth|--autho|--author)\n  \t\tcase \"$#\" in 1) usage ;; esac\n  \t\tshift\n  \t\tforce_author=\"$1\"\n- \t\tshift\n  \t\t;;\n--- 114,121 ----\n  \t--au=*|--aut=*|--auth=*|--autho=*|--author=*)\n! \t\tforce_author=\"${1#*=}\"\n  \t\t;;\n  \t--au|--aut|--auth|--autho|--author)\n  \t\tcase \"$#\" in 1) usage ;; esac\n  \t\tshift\n  \t\tforce_author=\"$1\"\n  \t\t;;\n***************\n*** 128,144 ****\n  \t-e|--e|--ed|--edi|--edit)\n  \t\tedit_flag=t\n- \t\tshift\n  \t\t;;\n  \t-i|--i|--in|--inc|--incl|--inclu|--includ|--include)\n  \t\talso=t\n- \t\tshift\n  \t\t;;\n  \t--int|--inte|--inter|--intera|--interac|--interact|--interacti|\\\n  \t--interactiv|--interactive)\n  \t\tinteractive=t\n- \t\tshift\n  \t\t;;\n  \t-o|--o|--on|--onl|--only)\n  \t\tonly=t\n- \t\tshift\n  \t\t;;\n--- 122,134 ----\n***************\n*** 145,159 ****\n  \t-m|--m|--me|--mes|--mess|--messa|--messag|--message)\n  \t\tcase \"$#\" in 1) usage ;; esac\n- \t\tshift\n  \t\tlog_given=m$log_given\n! \t\tif test \"$log_message\" = ''\n! \t\tthen\n! \t\t    log_message=\"$1\"\n! \t\telse\n! \t\t    log_message=\"$log_message\n  \n! $1\"\n! \t\tfi\n  \t\tno_edit=t\n- \t\tshift\n  \t\t;;\n--- 135,142 ----\n  \t-m|--m|--me|--mes|--mess|--messa|--messag|--message)\n  \t\tcase \"$#\" in 1) usage ;; esac\n  \t\tlog_given=m$log_given\n! \t\tlog_message=\"${log_message}${log_message:+\n  \n! }$1\"\n  \t\tno_edit=t\n  \t\t;;\n***************\n*** 160,172 ****\n  \t-m*)\n  \t\tlog_given=m$log_given\n! \t\tif test \"$log_message\" = ''\n! \t\tthen\n! \t\t    log_message=`expr \"z$1\" : 'z-m\\(.*\\)'`\n! \t\telse\n! \t\t    log_message=\"$log_message\n  \n! `expr \"z$1\" : 'z-m\\(.*\\)'`\"\n! \t\tfi\n  \t\tno_edit=t\n- \t\tshift\n  \t\t;;\n--- 143,149 ----\n  \t-m*)\n  \t\tlog_given=m$log_given\n! \t\tlog_message=\"${log_message}${log_message:+\n  \n! }${1#-m}\"\n  \t\tno_edit=t\n  \t\t;;\n***************\n*** 173,185 ****\n  \t--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*)\n  \t\tlog_given=m$log_given\n! \t\tif test \"$log_message\" = ''\n! \t\tthen\n! \t\t    log_message=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n! \t\telse\n! \t\t    log_message=\"$log_message\n  \n! `expr \"z$1\" : 'zq-[^=]*=\\(.*\\)'`\"\n! \t\tfi\n  \t\tno_edit=t\n- \t\tshift\n  \t\t;;\n--- 150,156 ----\n  \t--m=*|--me=*|--mes=*|--mess=*|--messa=*|--messag=*|--message=*)\n  \t\tlog_given=m$log_given\n! \t\tlog_message=\"${log_message}${log_message:+\n  \n! }${1#*=}\"\n  \t\tno_edit=t\n  \t\t;;\n***************\n*** 186,197 ****\n  \t-n|--n|--no|--no-|--no-v|--no-ve|--no-ver|--no-veri|--no-verif|\\\n  \t--no-verify)\n  \t\tverify=\n- \t\tshift\n  \t\t;;\n  \t--a|--am|--ame|--amen|--amend)\n  \t\tamend=t\n  \t\tuse_commit=HEAD\n- \t\tshift\n  \t\t;;\n  \t-c)\n  \t\tcase \"$#\" in 1) usage ;; esac\n--- 157,166 ----\n***************\n*** 199,203 ****\n  \t\tlog_given=t$log_given\n  \t\tuse_commit=\"$1\"\n  \t\tno_edit=\n- \t\tshift\n  \t\t;;\n--- 168,171 ----\n***************\n*** 204,213 ****\n  \t--ree=*|--reed=*|--reedi=*|--reedit=*|--reedit-=*|--reedit-m=*|\\\n  \t--reedit-me=*|--reedit-mes=*|--reedit-mess=*|--reedit-messa=*|\\\n  \t--reedit-messag=*|--reedit-message=*)\n  \t\tlog_given=t$log_given\n! \t\tuse_commit=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n  \t\tno_edit=\n- \t\tshift\n  \t\t;;\n  \t--ree|--reed|--reedi|--reedit|--reedit-|--reedit-m|--reedit-me|\\\n  \t--reedit-mes|--reedit-mess|--reedit-messa|--reedit-messag|\\\n--- 172,180 ----\n  \t--ree=*|--reed=*|--reedi=*|--reedit=*|--reedit-=*|--reedit-m=*|\\\n  \t--reedit-me=*|--reedit-mes=*|--reedit-mess=*|--reedit-messa=*|\\\n  \t--reedit-messag=*|--reedit-message=*)\n  \t\tlog_given=t$log_given\n! \t\tuse_commit=\"${1#*=}\"\n  \t\tno_edit=\n  \t\t;;\n  \t--ree|--reed|--reedi|--reedit|--reedit-|--reedit-m|--reedit-me|\\\n  \t--reedit-mes|--reedit-mess|--reedit-messa|--reedit-messag|\\\n***************\n*** 217,223 ****\n  \t\tlog_given=t$log_given\n  \t\tuse_commit=\"$1\"\n  \t\tno_edit=\n- \t\tshift\n  \t\t;;\n  \t-C)\n  \t\tcase \"$#\" in 1) usage ;; esac\n--- 184,189 ----\n***************\n*** 225,229 ****\n  \t\tlog_given=t$log_given\n  \t\tuse_commit=\"$1\"\n  \t\tno_edit=t\n- \t\tshift\n  \t\t;;\n--- 191,194 ----\n***************\n*** 230,239 ****\n  \t--reu=*|--reus=*|--reuse=*|--reuse-=*|--reuse-m=*|--reuse-me=*|\\\n  \t--reuse-mes=*|--reuse-mess=*|--reuse-messa=*|--reuse-messag=*|\\\n  \t--reuse-message=*)\n  \t\tlog_given=t$log_given\n! \t\tuse_commit=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n  \t\tno_edit=t\n- \t\tshift\n  \t\t;;\n  \t--reu|--reus|--reuse|--reuse-|--reuse-m|--reuse-me|--reuse-mes|\\\n  \t--reuse-mess|--reuse-messa|--reuse-messag|--reuse-message)\n--- 195,203 ----\n  \t--reu=*|--reus=*|--reuse=*|--reuse-=*|--reuse-m=*|--reuse-me=*|\\\n  \t--reuse-mes=*|--reuse-mess=*|--reuse-messa=*|--reuse-messag=*|\\\n  \t--reuse-message=*)\n  \t\tlog_given=t$log_given\n! \t\tuse_commit=\"${1#*=}\"\n  \t\tno_edit=t\n  \t\t;;\n  \t--reu|--reus|--reuse|--reuse-|--reuse-m|--reuse-me|--reuse-mes|\\\n  \t--reuse-mess|--reuse-messa|--reuse-messag|--reuse-message)\n***************\n*** 242,273 ****\n  \t\tlog_given=t$log_given\n  \t\tuse_commit=\"$1\"\n  \t\tno_edit=t\n- \t\tshift\n  \t\t;;\n  \t-s|--s|--si|--sig|--sign|--signo|--signof|--signoff)\n  \t\tsignoff=t\n- \t\tshift\n  \t\t;;\n  \t-t|--t|--te|--tem|--temp|--templ|--templa|--templat|--template)\n  \t\tcase \"$#\" in 1) usage ;; esac\n  \t\tshift\n  \t\ttemplatefile=\"$1\"\n  \t\tno_edit=\n- \t\tshift\n  \t\t;;\n  \t-q|--q|--qu|--qui|--quie|--quiet)\n  \t\tquiet=t\n- \t\tshift\n  \t\t;;\n  \t-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)\n  \t\tverbose=t\n- \t\tshift\n  \t\t;;\n  \t-u|--u|--un|--unt|--untr|--untra|--untrac|--untrack|--untracke|\\\n  \t--untracked|--untracked-|--untracked-f|--untracked-fi|--untracked-fil|\\\n  \t--untracked-file|--untracked-files)\n  \t\tuntracked_files=t\n- \t\tshift\n  \t\t;;\n  \t--)\n  \t\tshift\n--- 206,231 ----\n***************\n*** 280,285 ****\n--- 238,244 ----\n  \t\tbreak\n  \t\t;;\n  \tesac\n+ \tshift\n  done\n  case \"$edit_flag\" in t) no_edit= ;; esac\n  \n***************\n*** 437,448 ****\n  \n  if test t = \"$verify\" && test -x \"$GIT_DIR\"/hooks/pre-commit\n  then\n! \tif test \"$TMP_INDEX\"\n! \tthen\n! \t\tGIT_INDEX_FILE=\"$TMP_INDEX\" \"$GIT_DIR\"/hooks/pre-commit\n! \telse\n! \t\tGIT_INDEX_FILE=\"$USE_INDEX\" \"$GIT_DIR\"/hooks/pre-commit\n! \tfi || exit\n  fi\n  \n  if test \"$log_message\" != ''\n--- 396,403 ----\n  \n  if test t = \"$verify\" && test -x \"$GIT_DIR\"/hooks/pre-commit\n  then\n!     GIT_INDEX_FILE=\"${TMP_INDEX:-${USE_INDEX}}\" \"$GIT_DIR\"/hooks/pre-commit \\\n!     || exit\n  fi\n  \n  if test \"$log_message\" != ''\n\n\n\n\n-- \nDavid Kastrup\n"},{"id":"49422","messageId":"20070802140011.GN29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"86bqdqkygp.fsf@lola.quinscape.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-02T14:00:11Z","receivedAt":"2007-08-02T14:00:11Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Thu, Aug 02, 2007 at 12:44:22PM +0200, David Kastrup wrote:\n> ! \t\tlogfile=\"${1#-?}\"\n\nYou can't do something like that on /bin/sh on many systems (for instance\nSolaris).\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49424","messageId":"86sl72j9vn.fsf@lola.quinscape.zz","threadId":"9352","inReplyTo":"20070802140011.GN29424@schiele.dyndns.org","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T14:20:44Z","receivedAt":"2007-08-02T14:20:44Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Robert Schiele <rschiele@gmail.com> writes:\n\n> On Thu, Aug 02, 2007 at 12:44:22PM +0200, David Kastrup wrote:\n>> ! \t\tlogfile=\"${1#-?}\"\n>\n> You can't do something like that on /bin/sh on many systems (for\n> instance Solaris).\n\nSigh.  It's in Posix.\n\nI've seen a lot of \"modern\" constructs in the Shell scripts of git\n(not least of all the eval hackery that is currently used instead of\nthis), so do you actually have positive knowledge that the existing\ngit stuff runs fine on such systems, and this wouldn't?\n\nI don't have access to Solaris systems, so I have to take your word on\nit, but I find it somewhat surprising that they would not follow Posix\nhere.\n\n-- \nDavid Kastrup\n"},{"id":"49427","messageId":"f158199e0708020748o5cac4505ic76bfb39f25ab1f8@mail.gmail.com","threadId":"9352","inReplyTo":"86bqdqkygp.fsf@lola.quinscape.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Bradford Smith","fromEmail":"bradford.carl.smith@gmail.com","sentAt":"2007-08-02T14:48:58Z","receivedAt":"2007-08-02T14:48:58Z","isPatch":false,"sender":{"key":"bradford.carl.smith@gmail.com","avatar":"https://gravatar.com/avatar/699930ad8ca562e38156ee60270b2fee830cc0cb5d94c2f70c6db4a705723c54?d=mp&s=160"},"body":"On 8/2/07, David Kastrup <dak@gnu.org> wrote:\n> Hi, I wanted to ask what the general stance towards shell script\n> cleanups and simplifications would be.  For example, I find the expr\n> usage quite inscrutable in commit, and there is no necessity of\n> putting \"shift\" in every case branch instead of once behind it, and a\n> lot of conditionals and other manipulations can be made much easier on\n> the eye by using parameter expansion patterns that are, as far as I\n> can see, available with every reasonable Bourne Shell and clones.\n>\n> Here is an example context diff (in this case, I find it more readable\n> than unified) to illustrate (untested!, please don't apply without a\n> regular formatted git patch).\n>\n> Should I bother doing such cleanups as I read up on code, or should I\n> just leave things alone?\n\nI have no authority over the git project, but please consider this argument:\n\nEvery time you submit a patch there are three costs:\n1. The time you put into making the patch.\n2. The time required for the maintainer to review the patch and\npossibly merge it into the code base.\n3. The risk that you may have accidentally broken something.\n\nObviously, you aren't too concerned about 1 (the cost to you), because\nyou're willing to do that work.  However, if I were Junio, I wouldn't\nbe willing to \"spend\" costs 2 and 3 on a patch that didn't either fix\na problem or provide a new feature.\n\nSo, I recommend you do the clean-up that you want to do on your own\nlocal branch.  This will no doubt be fun and educational for you.  I\nknow I've learned a lot in the past by experimentally \"cleaning up\"\nold ugly code on other projects, even though the result never made it\ninto the official code base.\n\nAlong the way, you will probably find real bugs.  When you do, submit\npatches for them based on the current master branch.  You can probably\nmanage to sneak a bit of clean-up into those bug-fixing patches, as\nlong as you make sure it is all relevant to fixing the bugs and you\nkeep the patches readable.\n\nBest Wishes,\n\nBradford C Smith\n\np.s. I should also point out that writing portable shell scripts is\nfar from trivial, so it is very difficult to be certain that what\nworks for you will work for someone with a different shell.\n"},{"id":"49441","messageId":"20070802161902.GP29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"86sl72j9vn.fsf@lola.quinscape.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-02T16:19:02Z","receivedAt":"2007-08-02T16:19:02Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Thu, Aug 02, 2007 at 04:20:44PM +0200, David Kastrup wrote:\n> Sigh.  It's in Posix.\n\nIt is in latest POSIX but latest POSIX is not in Solaris.\n\n> I've seen a lot of \"modern\" constructs in the Shell scripts of git\n> (not least of all the eval hackery that is currently used instead of\n> this), so do you actually have positive knowledge that the existing\n> git stuff runs fine on such systems, and this wouldn't?\n\nI can't say for sure for every corner case but for the most important stuff\nthe answer is \"yes\".  If you have specific doubts about some construct you may\nask me for that.  Then I would check.\n\n> I don't have access to Solaris systems, so I have to take your word on\n> it, but I find it somewhat surprising that they would not follow Posix\n> here.\n\nNowadays you can download it for free if you like to test with it.\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49443","messageId":"Pine.LNX.4.64.0708021804090.14781@racer.site","threadId":"9352","inReplyTo":"20070802161902.GP29424@schiele.dyndns.org","subject":"Re: Shell script cleanups/style changes?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-02T17:05:00Z","receivedAt":"2007-08-02T17:05:00Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 2 Aug 2007, Robert Schiele wrote:\n\n> On Thu, Aug 02, 2007 at 04:20:44PM +0200, David Kastrup wrote:\n> > Sigh.  It's in Posix.\n> \n> It is in latest POSIX but latest POSIX is not in Solaris.\n\nIt has been a really long standing tradition in git development to not \ncare about POSIX if it disagrees with reality.  A good tradition.\n\nCiao,\nDscho\n"},{"id":"49446","messageId":"20070802172225.GR29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"Pine.LNX.4.64.0708021804090.14781@racer.site","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-02T17:22:25Z","receivedAt":"2007-08-02T17:22:25Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Thu, Aug 02, 2007 at 06:05:00PM +0100, Johannes Schindelin wrote:\n> Hi,\n> \n> On Thu, 2 Aug 2007, Robert Schiele wrote:\n> \n> > On Thu, Aug 02, 2007 at 04:20:44PM +0200, David Kastrup wrote:\n> > > Sigh.  It's in Posix.\n> > \n> > It is in latest POSIX but latest POSIX is not in Solaris.\n> \n> It has been a really long standing tradition in git development to not \n> care about POSIX if it disagrees with reality.  A good tradition.\n\nSure.  I mean if Solaris was really a system nobody uses nowadays there would\nbe no reason to care about it but it actually still is one of the mayor\nplatforms availlable and thus not supporting it would be quite stupid.\n\nIt would actually draw away my interest (and most likely the one of many\nothers) from git since I need a system that works on _all_ systems we support.\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49453","messageId":"20070802181315.GE2431@uranus.ravnborg.org","threadId":"9352","inReplyTo":"f158199e0708020748o5cac4505ic76bfb39f25ab1f8@mail.gmail.com","subject":"Re: Shell script cleanups/style changes?","fromName":"Sam Ravnborg","fromEmail":"sam@ravnborg.org","sentAt":"2007-08-02T18:13:15Z","receivedAt":"2007-08-02T18:13:15Z","isPatch":false,"sender":{"key":"sam@ravnborg.org","avatar":"https://gravatar.com/avatar/168a912606ed0742d840bb365e3cc21db390c36531a58341dc7a069cc1f15f62?d=mp&s=160"},"body":"> \n> Obviously, you aren't too concerned about 1 (the cost to you), because\n> you're willing to do that work.  However, if I were Junio, I wouldn't\n> be willing to \"spend\" costs 2 and 3 on a patch that didn't either fix\n> a problem or provide a new feature.\n\nFor any decent codebase there is a need to keep the code clean.\nBeing part of the linux-kernel community we see clean-up patches \neach day and a lot are applied.\nEven spelling errors in comments are sometimes applied.\n\nDo not underestimate the value of a clean codebase.\n\n\tSam\n"},{"id":"49475","messageId":"7vlkctvfk9.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"86bqdqkygp.fsf@lola.quinscape.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-02T20:37:10Z","receivedAt":"2007-08-02T20:37:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kastrup <dak@gnu.org> writes:\n\n> Hi, I wanted to ask what the general stance towards shell script\n> cleanups and simplifications would be.  For example, I find the expr\n> usage quite inscrutable in commit, and there is no necessity of\n> putting \"shift\" in every case branch instead of once behind it, and a\n> lot of conditionals and other manipulations can be made much easier on\n> the eye by using parameter expansion patterns that are, as far as I\n> can see, available with every reasonable Bourne Shell and clones.\n\nThe shift in parameter parsing case arms were originally\ngenerated by an automated tool.  If it bothers you, feel free to\nmove them at the end, I would not mind.  In fact, handcrafted\nparameter parser in other scripts do use shift-at-the-end.\n\nAs to Bourne-ness of the shell script, please realize that your\nmaintainer is very old fashioned ;-), but is willing to be\ntaught new tricks within reason.\n\nWe try to limit ourselves to -, =, ?, + (and their colon \"if\nempty\" variants when it really make sense) in parameter\nexpansion of shell variables.  We also use % and # (and their\n\"match largest\" variants).\n\nNon POSIX substitions such as ${parameter/pattern/string} and\n${parameter:offset} are not to be used.  We do not want to\ndepend on bash.\n\nWe try to avoid [ ] and instead spell \"test\" explicitly; this is\njust a personal taste, and not about portability but more about\nreadability.\n\nAfter 1.5.3 git-commit.sh will hopefully become built-in, so I\nwould rather not touch the script.  Certainly, the kind of\nchange that is \"intended to be style-only but somebody needs to\nmake sure it does not introduce regression to everybody's shell\"\nis very unwelcome at this point.\n"},{"id":"49480","messageId":"fcaeb9bf0708021356v57b29a70yb69a2fa000bd5b55@mail.gmail.com","threadId":"9352","inReplyTo":"7vlkctvfk9.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-08-02T20:56:48Z","receivedAt":"2007-08-02T20:56:48Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 8/2/07, Junio C Hamano <gitster@pobox.com> wrote:\n> Non POSIX substitions such as ${parameter/pattern/string} and\n> ${parameter:offset} are not to be used.  We do not want to\n> depend on bash.\n\nThere is in a test (t5300-pack-objects.sh) but I guess the\nrestrictions do not apply on tests.\n-- \nDuy\n"},{"id":"49481","messageId":"85odhpzmbo.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"7vlkctvfk9.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T20:57:31Z","receivedAt":"2007-08-02T20:57:31Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> David Kastrup <dak@gnu.org> writes:\n>\n>> Hi, I wanted to ask what the general stance towards shell script\n>> cleanups and simplifications would be.  For example, I find the\n>> expr usage quite inscrutable in commit, and there is no necessity\n>> of putting \"shift\" in every case branch instead of once behind it,\n>> and a lot of conditionals and other manipulations can be made much\n>> easier on the eye by using parameter expansion patterns that are,\n>> as far as I can see, available with every reasonable Bourne Shell\n>> and clones.\n>\n> As to Bourne-ness of the shell script, please realize that your\n> maintainer is very old fashioned ;-), but is willing to be taught\n> new tricks within reason.\n\nMost of the \"new tricks\" I try on bash, dash and ash.\n\n> We try to limit ourselves to -, =, ?, + (and their colon \"if\n> empty\" variants when it really make sense) in parameter\n> expansion of shell variables.  We also use % and # (and their\n> \"match largest\" variants).\n\nYou do?\n\nIndeed:\n\n-*- mode: grep; default-directory: \"/home/tmp/git/\" -*-\nGrep started at Thu Aug  2 22:47:30\n\ngrep -nH -e '\\${[a-zA-Z0-9_]*[#%]' *.sh\ngit-am.sh:146:\tresolvemsg=${1#--resolvemsg=}; shift ;;\ngit-clone.sh:358:\t\t\tdestname=\"refs/$branch_top/${name#refs/heads/}\" ;;\ngit-clone.sh:360:\t\t\tdestname=\"refs/$tag_top/${name#refs/tags/}\" ;;\ngit-filter-branch.sh:361:\t\tref=\"${ref#refs/tags/}\"\ngit-pull.sh:98:\tcurr_branch=${curr_branch#refs/heads/}\ngit-rebase.sh:93:\teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\ngit-stash.sh:52:\t\tbranch=${branch#refs/heads/}\n\nGrep finished (matches found) at Thu Aug  2 22:47:31\n\nI am confused now: a different poster adamantly stated that /bin/sh on\nSolaris did not support those constructs, and that every functionality\nof git was working fine for him.\n\n> Non POSIX substitions such as ${parameter/pattern/string} and\n> ${parameter:offset} are not to be used.  We do not want to\n> depend on bash.\n\nSure.  What about the git-rebase line using $(($end - $msgnum)) ?\nThat's even more risque than ##.\n\n> After 1.5.3 git-commit.sh will hopefully become built-in, so I would\n> rather not touch the script.\n\nToo bad: this should mean that $EDITOR can get called from C...  I've\nbeen glad to see that so far this could be avoided.\n\n> Certainly, the kind of change that is \"intended to be style-only but\n> somebody needs to make sure it does not introduce regression to\n> everybody's shell\" is very unwelcome at this point.\n\nUnderstood.  But using ${...#...} and ${...:+...} does not exactly\nseem to be news in the git code base.  Even though we have the claim\nthat Solaris' sh won't deal with the former.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49482","messageId":"85ir7xzm46.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"fcaeb9bf0708021356v57b29a70yb69a2fa000bd5b55@mail.gmail.com","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T21:02:01Z","receivedAt":"2007-08-02T21:02:01Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"\"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n\n> On 8/2/07, Junio C Hamano <gitster@pobox.com> wrote:\n>> Non POSIX substitions such as ${parameter/pattern/string} and\n>> ${parameter:offset} are not to be used.  We do not want to\n>> depend on bash.\n>\n> There is in a test (t5300-pack-objects.sh) but I guess the\n> restrictions do not apply on tests.\n\nOh, but they definitely should.  Precisely on those platforms with\nshells not generally in use by the developers it becomes _most_\nimportant to reliably be able to trace failed tests to problems with\nthe _commands_, not problems with the tests.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49484","messageId":"7v1welvdxh.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"fcaeb9bf0708021356v57b29a70yb69a2fa000bd5b55@mail.gmail.com","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-02T21:12:26Z","receivedAt":"2007-08-02T21:12:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n\n> On 8/2/07, Junio C Hamano <gitster@pobox.com> wrote:\n>> Non POSIX substitions such as ${parameter/pattern/string} and\n>> ${parameter:offset} are not to be used.  We do not want to\n>> depend on bash.\n>\n> There is in a test (t5300-pack-objects.sh) but I guess the\n> restrictions do not apply on tests.\n\nThat would have been an earlier mistake.  Keeping tests portable\nis important, perhaps it might be of lessor importance but\nstill.\n"},{"id":"49486","messageId":"7vsl71tyyq.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"85odhpzmbo.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-02T21:21:01Z","receivedAt":"2007-08-02T21:21:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kastrup <dak@gnu.org> writes:\n\n> Sure.  What about the git-rebase line using $(($end - $msgnum)) ?\n> That's even more risque than ##.\n\nIs it really risque?  I do not think we have heard trouble with\nthe arith expansion from anybody.  A few mistakes in the past\nmade that said things like:\n\n\t$((end - 1))\t    ;# wrong... say \"$end\" if you mean variable\n\t$((cd ...; pwd))    ;# wrong... say $( (...)) if command substitution\n                             # that involves subshell\n\nbut I think we fixed them.\n\n> Understood.  But using ${...#...} and ${...:+...} does not exactly\n> seem to be news in the git code base.  Even though we have the claim\n> that Solaris' sh won't deal with the former.\n\nI do not think we have trouble with ${parameter#word}.  Much\nless with ${parameter+word}; it has been in /bin/sh forever.\n"},{"id":"49488","messageId":"7vodhptyk3.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"7vsl71tyyq.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-02T21:29:48Z","receivedAt":"2007-08-02T21:29:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"You might find this thread amusing.\n\n    http://thread.gmane.org/gmane.comp.version-control.git/7116/focus=7136\n\nHistorically, I have even avoided accepting ${var#word}, ${var%word},\nand arithmetic expansions.\n\nI would still reject shell arrays.\n"},{"id":"49490","messageId":"20070802214103.GT29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"7vsl71tyyq.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-02T21:41:03Z","receivedAt":"2007-08-02T21:41:03Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Thu, Aug 02, 2007 at 10:57:31PM +0200, David Kastrup wrote:\n> Most of the \"new tricks\" I try on bash, dash and ash.\n\nWell, those are not really the most challenging one.  Thus you should either\ntest on more or just believe those people that have other shells that it does\nnot work.\n\n> I am confused now: a different poster adamantly stated that /bin/sh on\n> Solaris did not support those constructs, and that every functionality\n> of git was working fine for him.\n\nNo, you should read the mails you are refering to.  I said that the most\nimportant stuff does work.  Apparently this did not yet hurt me on the\nplatform.  Thus we have to decide whether we want some textbook example code\nand thus break this platform completely or whether we want to fix the issues\nyou have listed and thus have a more portable application.\n\n> Sure.  What about the git-rebase line using $(($end - $msgnum)) ?\n\nBad on Solaris:\n\n$ uname -a\nSunOS solaris10-x64 5.10 Generic i86pc i386 i86pc\n$ end=1\n$ msgnum=5\n$ echo $(($end - $msgnum))\nsyntax error: `(' unexpected\n$ \n\n> Too bad: this should mean that $EDITOR can get called from C...  I've\n> been glad to see that so far this could be avoided.\n\nWhy is it bad to call the editor from C?\n\nOn Thu, Aug 02, 2007 at 02:21:01PM -0700, Junio C Hamano wrote:\n> David Kastrup <dak@gnu.org> writes:\n> \n> > Sure.  What about the git-rebase line using $(($end - $msgnum)) ?\n> > That's even more risque than ##.\n> \n> Is it really risque?  I do not think we have heard trouble with\n> the arith expansion from anybody.  A few mistakes in the past\n\nSee above.\n\n> I do not think we have trouble with ${parameter#word}.  Much\n\n$ uname -a\nSunOS solaris10-x64 5.10 Generic i86pc i386 i86pc\n$ parameter=bla\n$ echo ${parameter#word}\nbad substitution\n$ \n\n> less with ${parameter+word}; it has been in /bin/sh forever.\n\nThat one is ok for Solaris.\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49491","messageId":"857iodzk8n.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"7vsl71tyyq.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T21:42:32Z","receivedAt":"2007-08-02T21:42:32Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> David Kastrup <dak@gnu.org> writes:\n>\n>> Understood.  But using ${...#...} and ${...:+...} does not exactly\n>> seem to be news in the git code base.  Even though we have the\n>> claim that Solaris' sh won't deal with the former.\n>\n> I do not think we have trouble with ${parameter#word}.  Much less\n> with ${parameter+word}; it has been in /bin/sh forever.\n\nBasically this should mean that the proposed cleanups (apart from a\nforgotten shift I had to add) are tenable.\n\nGiven that another poster claimed that Solaris /bin/sh does not\nsupport ${parameter#word}, making the suggested changes to git-commit\nmight actually be a good idea: ${parameter#word} is used in half a\ndozen other (likely less used) utilities in various other places.  If\nthis is an overlooked regression, we want to make it non-overlookable\nwhile we are still in testing, and git-commit would appear to be the\nperfect candidate for that...\n\nDepending on the feedback, we can either replace _all_ uses\neverywhere, or accept it for good.\n\nWhile I would think it perfectly understandable if you wanted to avoid\nmaking an infamous \"breaks all of Solaris release\", _if_ ${...#...}\nwould indeed be fishy (and I somewhat doubt it), we are already there.\nI have this cleaned-up version of git-commit.sh on a computer I can't\naccess right now.  I'll post the patch tomorrow.  Whether you want to\napply it to git.git remains at your discretion.  I would, however,\nstrongly urge Solaris and potentially other POSIXly impaired users to\naplly and test this patch: if it breaks (and it will do so pretty\nobviously, pretty much being unable to parse any option), then this is\n_quite_ alarming with regard to existing uses of ${...#...} and would\nneed to get addressed _very_ soon.\n\nFrankly, I doubt that this would have escaped notice so far, however.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49494","messageId":"85zm19y4qk.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"7vodhptyk3.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T22:02:43Z","receivedAt":"2007-08-02T22:02:43Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> You might find this thread amusing.\n>\n>     http://thread.gmane.org/gmane.comp.version-control.git/7116/focus=7136\n>\n> Historically, I have even avoided accepting ${var#word}, ${var%word},\n> and arithmetic expansions.\n\nI learnt Unix with a Banaham/Rutter primer in the early eighties.  I\ngot hit so often by the \"this is now supposed to work in Bourne\nshells?\" surprise it wasn't funny.\n\nThe first time I saw \"for ((i=0; i<$NR; i++)) ...\"  I thought the\nauthor had been smoking too much C and got things confused.  It still\ncreeps me out.  I am more comfortable doing arithmetic with dc rather\nthan sh.\n\nEmploying the existing globbing machinery for # and %, on the other\nhand, seems quite bournesque (still-bourne sounds so ugly) to me.  And\nit is certainly quite more readable than the regexp/expr stuff.\n\nIf it works.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49499","messageId":"85vebxy47e.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"20070802214103.GT29424@schiele.dyndns.org","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T22:14:13Z","receivedAt":"2007-08-02T22:14:13Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Robert Schiele <rschiele@gmail.com> writes:\n\n> No, you should read the mails you are refering to.  I said that the\n> most important stuff does work.  Apparently this did not yet hurt me\n> on the platform.\n\nA non-working rebase would seem rather tough.\n\n> Thus we have to decide whether we want some textbook example code\n> and thus break this platform completely or whether we want to fix\n> the issues you have listed and thus have a more portable\n> application.\n\nThe \"issues\" are with Solaris, apparently.  There is always a price\nfor portability.  If Solaris users can fix their problems with a\nglobal search and replace of the first line in *.sh, the question is\nwhether it is worth the hassle of having unreadable but \"portable\"\ncode.  After all, it has to be read also by humans.\n\n>> Sure.  What about the git-rebase line using $(($end - $msgnum)) ?\n>\n> Bad on Solaris:\n>\n> $ uname -a\n> SunOS solaris10-x64 5.10 Generic i86pc i386 i86pc\n> $ end=1\n> $ msgnum=5\n> $ echo $(($end - $msgnum))\n> syntax error: `(' unexpected\n> $\n\nYou are missing the line\n$ echo $0\nwhich is probably the most interesting one...  we don't need to be\ncompatible with everything having a \"$ \" prompt, just with everything\ncalled \"/bin/sh\".\n\n>> Too bad: this should mean that $EDITOR can get called from C...  I've\n>> been glad to see that so far this could be avoided.\n>\n> Why is it bad to call the editor from C?\n\nSee the rationale in my recently posted patch for implementing\nEDITOR/VISUAL support.  One needs to shell-quote stuff properly, and\nthe shell is better at shell-quote magic than C is.\n\n>> I do not think we have trouble with ${parameter#word}.  Much\n>\n> $ uname -a\n> SunOS solaris10-x64 5.10 Generic i86pc i386 i86pc\n> $ parameter=bla\n> $ echo ${parameter#word}\n> bad substitution\n> $ \n>\n>> less with ${parameter+word}; it has been in /bin/sh forever.\n>\n> That one is ok for Solaris.\n\nIf you prepare a patch replacing all existing ${parameter#word} uses\nand get it accepted, I will not push for inclusion of my cleanup.\n\nBut you _really_ should go for it _now_.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49508","messageId":"7vwswdsfjp.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"85vebxy47e.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-02T23:05:46Z","receivedAt":"2007-08-02T23:05:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kastrup <dak@gnu.org> writes:\n\n> Robert Schiele <rschiele@gmail.com> writes:\n> ...\n>> Thus we have to decide whether we want some textbook example code\n>> and thus break this platform completely or whether we want to fix\n>> the issues you have listed and thus have a more portable\n>> application.\n>\n> The \"issues\" are with Solaris, apparently.  There is always a price\n> for portability.  If Solaris users can fix their problems with a\n> global search and replace of the first line in *.sh, the question is\n> whether it is worth the hassle of having unreadable but \"portable\"\n> code.  After all, it has to be read also by humans.\n\nI am in the camp of avoiding \"it is even in POSIX so it's your\nfault if your shell does not support it\".  We do not take POSIX\ntoo seriously in that way, although we do say \"let's not use it,\nit is not even in POSIX\".  In other words, I've been trying to\nbe, and as a result of that we are, fairly conservative.\n\nHowever, there is a line we need to draw when bending bacwards\nfor compatibility, and I think a system that does not have a\nworking command substitution $( ... )  is on the other side of\nthat line.\n"},{"id":"49511","messageId":"85ps25y1ac.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"7vwswdsfjp.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T23:17:15Z","receivedAt":"2007-08-02T23:17:15Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> However, there is a line we need to draw when bending bacwards for\n> compatibility, and I think a system that does not have a working\n> command substitution $( ... )  is on the other side of that line.\n\nNot an issue.  But apparently, ${parameter#word} is for Solaris.  I'd\nstill like to get confirmation that it is indeed /bin/sh, but if it\nis, the current code is not good for Solaris.\n\nSo the line of compatibility is much more interesting for this one.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49513","messageId":"20070802232126.GU29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"7vwswdsfjp.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-02T23:21:27Z","receivedAt":"2007-08-02T23:21:27Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Thu, Aug 02, 2007 at 04:05:46PM -0700, Junio C Hamano wrote:\n> However, there is a line we need to draw when bending bacwards\n> for compatibility, and I think a system that does not have a\n> working command substitution $( ... )  is on the other side of\n> that line.\n\nWell, I have now a patch ready for submission that would replace all\noccurences of ${PARAMETER#WORD}, ${PARAMETER%WORD}, and $(( EXPRESSION )).\nBut if you say that you won't accept replacement of $( ... ) then this is not\nworth the effort since this one isn't accepted as well.\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49514","messageId":"20070802232754.GV29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"85vebxy47e.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-02T23:27:54Z","receivedAt":"2007-08-02T23:27:54Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Fri, Aug 03, 2007 at 12:14:13AM +0200, David Kastrup wrote:\n> A non-working rebase would seem rather tough.\n\nIt depends on how you work.  I for example always just push any change to a\nlinux machine where I do the actual integration work.  Thus I don't need much\ncommands on the Solaris machine.\n\n> The \"issues\" are with Solaris, apparently.  There is always a price\n> for portability.  If Solaris users can fix their problems with a\n> global search and replace of the first line in *.sh, the question is\n> whether it is worth the hassle of having unreadable but \"portable\"\n> code.  After all, it has to be read also by humans.\n\nOk, but then we needed an infrastructure to replace the shell with a\nconfiguration parameter.\n\n> You are missing the line\n> $ echo $0\n> which is probably the most interesting one...  we don't need to be\n> compatible with everything having a \"$ \" prompt, just with everything\n> called \"/bin/sh\".\n\nYour way of telling people that you are considering everybody besides you to\nbe a moron is somehow insulting.  You might wish to change that.\n\nSure I tested in on /bin/sh!\n\n> See the rationale in my recently posted patch for implementing\n> EDITOR/VISUAL support.  One needs to shell-quote stuff properly, and\n> the shell is better at shell-quote magic than C is.\n\nOk, will look up that later.\n\n> If you prepare a patch replacing all existing ${parameter#word} uses\n> and get it accepted, I will not push for inclusion of my cleanup.\n> \n> But you _really_ should go for it _now_.\n\nI have it ready now.  Just waiting for the answer of Junio to my last mail.\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49515","messageId":"85k5sdy0lk.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"20070802232126.GU29424@schiele.dyndns.org","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T23:32:07Z","receivedAt":"2007-08-02T23:32:07Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Robert Schiele <rschiele@gmail.com> writes:\n\n> On Thu, Aug 02, 2007 at 04:05:46PM -0700, Junio C Hamano wrote:\n>> However, there is a line we need to draw when bending bacwards\n>> for compatibility, and I think a system that does not have a\n>> working command substitution $( ... )  is on the other side of\n>> that line.\n>\n> Well, I have now a patch ready for submission that would replace all\n> occurences of ${PARAMETER#WORD}, ${PARAMETER%WORD}, and $((\n> EXPRESSION )).  But if you say that you won't accept replacement of\n> $( ... ) then this is not worth the effort since this one isn't\n> accepted as well.\n\nI absolutely can't understand your claim that most things work for\nyou, then.  Are you _really_, _really_ sure you are talking about\n/bin/sh here?\n\nLook:\n\n-*- mode: grep; default-directory: \"/home/tmp/git/\" -*-\nGrep started at Fri Aug  3 01:29:41\n\nfgrep -nH -e '$(' *.sh\ncheck-builtins.sh:6:\t$(foreach b,$(BUILT_INS),echo XXX $b YYY;)\ngit-am.sh:24:    cmdline=$(basename $0)\ngit-am.sh:83:    his_tree=$(GIT_INDEX_FILE=\"$dotest/patch-merge-index\" git write-tree) &&\ngit-am.sh:84:    orig_tree=$(cat \"$dotest/patch-merge-base\") &&\ngit-am.sh:160:   last=$(cat \"$dotest/last\") &&\ngit-am.sh:161:   next=$(cat \"$dotest/next\") &&\ngit-am.sh:216:\tfiles=$(git diff-index --cached --name-only HEAD) || exit\ngit-am.sh:223:if test \"$(cat \"$dotest/binary\")\" = t\ngit-am.sh:227:if test \"$(cat \"$dotest/utf8\")\" = t\ngit-am.sh:233:if test \"$(cat \"$dotest/keep\")\" = t\ngit-am.sh:238:if test \"$(cat \"$dotest/sign\")\" = t\ngit-am.sh:301:\tGIT_AUTHOR_NAME=\"$(sed -n '/^Author/ s/Author: //p' \"$dotest/info\")\"\ngit-am.sh:302:\tGIT_AUTHOR_EMAIL=\"$(sed -n '/^Email/ s/Email: //p' \"$dotest/info\")\"\ngit-am.sh:303:\tGIT_AUTHOR_DATE=\"$(sed -n '/^Date/ s/Date: //p' \"$dotest/info\")\"\ngit-am.sh:313:\tSUBJECT=\"$(sed -n '/^Subject/ s/Subject: //p' \"$dotest/info\")\"\ngit-am.sh:415:\t\tunmerged=$(git ls-files -u)\ngit-am.sh:453:\ttree=$(git write-tree) &&\ngit-am.sh:455:\tparent=$(git rev-parse --verify HEAD) &&\ngit-am.sh:456:\tcommit=$(git commit-tree $tree -p $parent <\"$dotest/final-commit\") &&\ngit-bisect.sh:59:\thead=$(GIT_DIR=\"$GIT_DIR\" git symbolic-ref HEAD) ||\ngit-bisect.sh:92:\torig_args=$(sq \"$@\")\ngit-bisect.sh:102:\t        rev=$(git rev-parse --verify \"$arg^{commit}\" 2>/dev/null) || {\ngit-bisect.sh:127:\t\trev=$(git rev-parse --verify HEAD) ;;\ngit-bisect.sh:129:\t\trev=$(git rev-parse --verify \"$1^{commit}\") ;;\ngit-bisect.sh:141:\techo \"# bad: \"$(git show-branch $rev) >>\"$GIT_DIR/BISECT_LOG\"\ngit-bisect.sh:147:\t0)    revs=$(git rev-parse --verify HEAD) || exit ;;\ngit-bisect.sh:148:\t*)    revs=$(git rev-parse --revs-only --no-flags \"$@\") &&\ngit-bisect.sh:153:\t\trev=$(git rev-parse --verify \"$rev^{commit}\") || exit\ngit-bisect.sh:164:\techo \"# good: \"$(git show-branch $rev) >>\"$GIT_DIR/BISECT_LOG\"\ngit-bisect.sh:170:\ttest -n \"$(git for-each-ref \"refs/bisect/good-*\")\" || missing_good=t\ngit-bisect.sh:187:\t\t\tcase \"$(read yesno)\" in [Nn]*) exit 1 ;; esac\ngit-bisect.sh:214:\tbad=$(git rev-parse --verify refs/bisect/bad) &&\ngit-bisect.sh:215:\tgood=$(git for-each-ref --format='^%(objectname)' \\\ngit-bisect.sh:218:\teval=\"$eval $(cat \"$GIT_DIR/BISECT_NAMES\")\" &&\ngit-bisect.sh:219:\teval=$(eval \"$eval\") &&\ngit-bisect.sh:243:\teval gitk bisect/bad --not $not -- $(cat \"$GIT_DIR/BISECT_NAMES\")\ngit-bisect.sh:291:\t\t\techo \"# good: \"$(git show-branch $rev) >>\"$GIT_DIR/BISECT_LOG\"\ngit-bisect.sh:296:\t\t\techo \"# bad: \"$(git show-branch $rev) >>\"$GIT_DIR/BISECT_LOG\"\ngit-checkout.sh:9:old=$(git rev-parse --verify $old_name 2>/dev/null)\ngit-checkout.sh:10:oldbranch=$(git symbolic-ref $old_name 2>/dev/null)\ngit-checkout.sh:60:\t\tif rev=$(git rev-parse --verify \"$arg^0\" 2>/dev/null)\ngit-checkout.sh:69:\t\t\t\trev=$(git rev-parse --verify \"refs/heads/$arg^0\")\ngit-checkout.sh:73:\t\telif rev=$(git rev-parse --verify \"$arg^{tree}\" 2>/dev/null)\ngit-checkout.sh:206:    merge_error=$(git read-tree -m -u --exclude-per-directory=.gitignore $old $new 2>&1) || (\ngit-clone.sh:147:\t\tupload_pack=--upload-pack=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\ngit-clone.sh:181:if base=$(get_repo_base \"$repo\"); then\ngit-clone.sh:188:[ -z \"$dir\" ] && dir=$(echo \"$repo\" | sed -e 's|/$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\ngit-clone.sh:205:mkdir -p \"$dir\" && D=$(cd \"$dir\" && pwd) || usage\ngit-clone.sh:207:W=$(cd \"$GIT_WORK_TREE\" && pwd) && export GIT_WORK_TREE=\"$W\"\ngit-clone.sh:231:\t\tref_git=$(cd \"$ref_git\" && pwd)\ngit-clone.sh:260:\t    sample_file=$(cd \"$repo\" && \\\ngit-clone.sh:391:\thead_points_at=$(\ngit-commit.sh:463:\tencoding=$(git config i18n.commitencoding || echo UTF-8)\ngit-commit.sh:479:\tsign=$(git-var GIT_COMMITTER_IDENT | sed -e '\ngit-commit.sh:506:\teval \"$(get_author_ident_from_commit \"$use_commit\")\"\ngit-commit.sh:528:\t\tPARENTS=$(git cat-file commit HEAD |\ngit-commit.sh:531:\tcurrent=\"$(git rev-parse --verify HEAD)\"\ngit-commit.sh:533:\tif [ -z \"$(git ls-files)\" ]; then\ngit-commit.sh:625:\t\ttree=$(GIT_INDEX_FILE=\"$USE_INDEX\" git write-tree)\ngit-commit.sh:627:\t\ttree=$(GIT_INDEX_FILE=\"$TMP_INDEX\" git write-tree) &&\ngit-commit.sh:630:\tcommit=$(git commit-tree $tree $PARENTS <\"$GIT_DIR/COMMIT_MSG\") &&\ngit-commit.sh:631:\trlogm=$(sed -e 1q \"$GIT_DIR\"/COMMIT_MSG) &&\ngit-fetch.sh:43:\t\texec=--upload-pack=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)')\ngit-fetch.sh:88:\torigin=$(get_default_remote)\ngit-fetch.sh:89:\ttest -n \"$(get_remote_url ${origin})\" ||\ngit-fetch.sh:97:\texec=\"--upload-pack=$(get_uploadpack $1)\"\ngit-fetch.sh:101:remote=$(get_remote_url \"$@\")\ngit-fetch.sh:112:ls_remote_result=$(git ls-remote $exec \"$remote\") ||\ngit-fetch.sh:125:if test -z \"$update_head_ok\" && test $(is_bare_repository) = false\ngit-fetch.sh:127:\torig_head=$(git rev-parse --verify HEAD 2>/dev/null)\ngit-fetch.sh:133:\tcase \"$(git config --get \"remote.$1.tagopt\")\" in\ngit-fetch.sh:144:reflist=$(get_remote_refs_for_fetch \"$@\")\ngit-fetch.sh:166:  eval=$(echo \"$1\" | git fetch--tool parse-reflist \"-\")\ngit-fetch.sh:192:\t\t\ttheirs=$(echo \"$ls_remote_result\" | \\\ngit-fetch.sh:242:\t  ref=$(expr \"z$ref\" : 'z\\.\\(.*\\)')\ngit-fetch.sh:249:\t  ref=$(expr \"z$ref\" : 'z+\\(.*\\)')\ngit-fetch.sh:253:      remote_name=$(expr \"z$ref\" : 'z\\([^:]*\\):')\ngit-fetch.sh:254:      local_name=$(expr \"z$ref\" : 'z[^:]*:\\(.*\\)')\ngit-fetch.sh:273:\t  head=$(echo \"$ls_remote_result\" | \\\ngit-fetch.sh:286:\t  head=$(git rev-parse --verify TMP_HEAD)\ngit-fetch.sh:343:\t\ttaglist=$(IFS='\t' &&\ngit-fetch.sh:368:\tcurr_head=$(git rev-parse --verify HEAD 2>/dev/null)\ngit-filter-branch.sh:43:\tlid=\"$(echo \"$1\" | tr \"A-Z\" \"a-z\")\"\ngit-filter-branch.sh:44:\tuid=\"$(echo \"$1\" | tr \"a-z\" \"A-Z\")\"\ngit-filter-branch.sh:154:tempdir=\"$(cd \"$tempdir\"; pwd)\" &&\ngit-filter-branch.sh:156:workdir=\"$(pwd)\" ||\ngit-filter-branch.sh:177:\tGIT_DIR=\"$(pwd)/../../$GIT_DIR\"\ngit-filter-branch.sh:190:\t\tref=\"$(git symbolic-ref \"$ref\")\"\ngit-filter-branch.sh:195:\t\tref=\"$(git for-each-ref --format='%(refname)' |\ngit-filter-branch.sh:205:export GIT_INDEX_FILE=\"$(pwd)/../index\"\ngit-filter-branch.sh:222:commits=$(wc -l <../revs | tr -d \" \")\ngit-filter-branch.sh:230:\ti=$(($i+1))\ngit-filter-branch.sh:245:\teval \"$(set_ident AUTHOR <../commit)\" ||\ngit-filter-branch.sh:247:\teval \"$(set_ident COMMITTER <../commit)\" ||\ngit-filter-branch.sh:272:\t\tfor reparent in $(map \"$parent\"); do\ngit-filter-branch.sh:277:\t\tparentstr=\"$(echo \"$parentstr\" | eval \"$filter_parent\")\" ||\ngit-filter-branch.sh:285:\t\t$(git write-tree) $parentstr < ../message > ../map/$commit\ngit-filter-branch.sh:296:\tsha1=$(git rev-parse \"$ref\"^0)\ngit-filter-branch.sh:301:\tfor p in $( (cd \"$workdir\"/../map; ls | sed \"s/^/^/\") |\ngit-filter-branch.sh:320:\tsha1=$(git rev-parse \"$ref\"^0)\ngit-filter-branch.sh:321:\trewritten=$(map $sha1)\ngit-filter-branch.sh:344:\t\trewritten=$(echo \"$rewritten\" | head -n 1)\ngit-filter-branch.sh:351:\tcount=$(($count+1))\ngit-filter-branch.sh:370:\t\t\tsha1=\"$(git rev-parse \"$sha1\"^{commit} 2>/dev/null)\" || continue\ngit-filter-branch.sh:374:\t\tnew_sha1=\"$(cat \"../map/$sha1\")\"\ngit-filter-branch.sh:376:\t\tnew_ref=\"$(echo \"$ref\" | eval \"$filter_tag_name\")\" ||\ngit-ls-remote.sh:30:\texec=--upload-pack=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)')\ngit-ls-remote.sh:48:peek_repo=\"$(get_remote_url \"$@\")\"\ngit-ls-remote.sh:75:\thead=$(cat \"$tmpdir/HEAD\") &&\ngit-ls-remote.sh:78:\t\thead=$(expr \"z$head\" : 'zref: \\(.*\\)') &&\ngit-ls-remote.sh:79:\t\thead=$(cat \"$tmpdir/$head\") || exit\ngit-merge-octopus.sh:48:MRT=$(git write-tree)\ngit-merge-octopus.sh:64:\tcommon=$(git merge-base --all $MRC $SHA1) ||\ngit-merge-octopus.sh:86:\t\tMRC=$SHA1 MRT=$(git write-tree)\ngit-merge-octopus.sh:94:\tnext=$(git write-tree 2>/dev/null)\ngit-merge-octopus.sh:100:\t\tnext=$(git write-tree 2>/dev/null)\ngit-merge-one-file.sh:36:\t\trmdir -p \"$(expr \"z$4\" : 'z\\(.*\\)/')\" 2>/dev/null || :\ngit-merge-resolve.sh:43:if result_tree=$(git write-tree  2>/dev/null)\ngit-merge.sh:13:test -z \"$(git ls-files -u)\" ||\ngit-merge.sh:102:\trh=$(git rev-parse --verify \"$remote^0\" 2>/dev/null) || return\ngit-merge.sh:103:\tbh=$(git show-ref -s --verify \"refs/heads/$remote\" 2>/dev/null)\ngit-merge.sh:107:\telif truname=$(expr \"$remote\" : '\\(.*\\)~[1-9][0-9]*$') &&\ngit-merge.sh:173:    test \"$(git config --bool merge.diffstat)\" = false && show_diffstat=false\ngit-merge.sh:184:\tsecond_token=$(git rev-parse --verify \"$2^0\" 2>/dev/null) &&\ngit-merge.sh:185:\thead_commit=$(git rev-parse --verify \"HEAD\" 2>/dev/null) &&\ngit-merge.sh:203:\trh=$(git rev-parse --verify \"$1^0\") ||\ngit-merge.sh:219:\tmerge_name=$(for remote\ngit-merge.sh:226:head=$(git rev-parse --verify \"$head_arg\"^0) || usage\ngit-merge.sh:235:\tremotehead=$(git rev-parse --verify \"$remote\"^0 2>/dev/null) ||\ngit-merge.sh:281:\tcommon=$(git merge-base --all $head \"$@\")\ngit-merge.sh:284:\tcommon=$(git show-branch --merge-base $head \"$@\")\ngit-merge.sh:304:\techo \"Updating $(git rev-parse --short $head)..$(git rev-parse --short $1)\"\ngit-merge.sh:311:\tnew_head=$(git rev-parse --verify \"$1^0\") &&\ngit-merge.sh:334:\t\t   result_tree=$(git write-tree)\ngit-merge.sh:337:\t\t\tresult_commit=$(\ngit-merge.sh:353:\t\tcommon_one=$(git merge-base --all $head $remote)\ngit-merge.sh:435:    result_tree=$(git write-tree) && break\ngit-merge.sh:442:    parents=$(git show-branch --independent \"$head\" \"$@\" | sed -e 's/^/-p /')\ngit-merge.sh:443:    result_commit=$(printf '%s\\n' \"$merge_msg\" | git commit-tree $result_tree $parents) || exit\ngit-merge-stupid.sh:69:if result_tree=$(git write-tree  2>/dev/null)\ngit-mergetool.sh:51:\techo \"a symbolic link -> '$(cat \"$file\")'\"\ngit-mergetool.sh:266:\t\teval \"${eval_candidate}\" --eval '\"$(emacs-string \"(ediff-merge-files-with-ancestor\" @ \"$LOCAL\" @ \"$REMOTE\" @ \"$BASE\" \"(lambda()(setq ediff-keep-variants nil))\" @ \"$path\" \")\")\"'\ngit-mergetool.sh:268:\t\teval \"${eval_candidate}\" --eval '\"$(emacs-string \"(ediff-merge-files\" @ \"$LOCAL\" @ \"$REMOTE\" \"(lambda()(setq ediff-keep-variants nil))\" @ \"$path\" \")\")\"'\ngit-mergetool.sh:314:\tfor i in \"$GIT_EDITOR\" \"$(git config core.editor)\" \"$VISUAL\" \"$EDITOR\"\ngit-parse-remote.sh:5:GIT_DIR=$(git rev-parse --git-dir 2>/dev/null) || :;\ngit-parse-remote.sh:16:\t\tif test \"$(git config --get \"remote.$1.url\")\"\ngit-parse-remote.sh:32:\tdata_source=$(get_data_source \"$1\")\ngit-parse-remote.sh:58:\tcurr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')\ngit-parse-remote.sh:59:\torigin=$(git config --get \"branch.$curr_branch.remote\")\ngit-parse-remote.sh:64:\tdata_source=$(get_data_source \"$1\")\ngit-parse-remote.sh:105:\t\tset $(expand_refs_wildcard \"$remote\" \"$@\")\ngit-parse-remote.sh:108:\t\tif test \"$remote\" = \"$(get_default_remote)\"\ngit-parse-remote.sh:110:\t\t\tcurr_branch=$(git symbolic-ref -q HEAD | \\\ngit-parse-remote.sh:112:\t\t\tmerge_branches=$(git config \\\ngit-parse-remote.sh:125:\t\t\tref=$(expr \"z$ref\" : 'z+\\(.*\\)')\ngit-parse-remote.sh:130:\t\tremote=$(expr \"z$ref\" : 'z\\([^:]*\\):')\ngit-parse-remote.sh:131:\t\tlocal=$(expr \"z$ref\" : 'z[^:]*:\\(.*\\)')\ngit-parse-remote.sh:157:\t\tif local_ref_name=$(expr \"z$local\" : 'zrefs/\\(.*\\)')\ngit-parse-remote.sh:168:\tdata_source=$(get_data_source \"$1\")\ngit-parse-remote.sh:174:\t\t\t$(git for-each-ref --format='%(refname):')\ngit-parse-remote.sh:178:\t\t\t$(git config --get-all \"remote.$1.fetch\") ;;\ngit-parse-remote.sh:180:\t\tremote_branch=$(sed -ne '/#/s/.*#//p' \"$GIT_DIR/branches/$1\")\ngit-parse-remote.sh:185:\t\tcanon_refs_list_for_fetch -d \"$1\" $(sed -ne '/^Pull: */{\ngit-parse-remote.sh:254:\tdata_source=$(get_data_source \"$1\")\ngit-parse-remote.sh:257:\t\tuplp=$(git config --get \"remote.$1.uploadpack\")\ngit-pull.sh:15:test -z \"$(git ls-files -u)\" ||\ngit-pull.sh:57:orig_head=$(git rev-parse --verify HEAD 2>/dev/null)\ngit-pull.sh:60:curr_head=$(git rev-parse --verify HEAD 2>/dev/null)\ngit-pull.sh:83:merge_head=$(sed -e '/\tnot-for-merge\t/d' \\\ngit-pull.sh:89:\tcurr_branch=$(git symbolic-ref -q HEAD)\ngit-pull.sh:121:merge_name=$(git fmt-merge-msg <\"$GIT_DIR/FETCH_HEAD\") || exit\ngit-quiltimport.sh:12:\t\tquilt_author=$(expr \"z$1\" : 'z-[^=]*\\(.*\\)')\ngit-quiltimport.sh:29:\t\tQUILT_PATCHES=$(expr \"z$1\" : 'z-[^=]*\\(.*\\)')\ngit-quiltimport.sh:48:\tquilt_author_name=$(expr \"z$quilt_author\" : 'z\\(.*[^ ]\\) *<.*') &&\ngit-quiltimport.sh:49:\tquilt_author_email=$(expr \"z$quilt_author\" : '.*<\\([^>]*\\)') &&\ngit-quiltimport.sh:70:commit=$(git rev-parse HEAD)\ngit-quiltimport.sh:73:for patch_name in $(grep -v '^#' < \"$QUILT_PATCHES/series\" ); do\ngit-quiltimport.sh:83:\texport GIT_AUTHOR_NAME=$(sed -ne 's/Author: //p' \"$tmp_info\")\ngit-quiltimport.sh:84:\texport GIT_AUTHOR_EMAIL=$(sed -ne 's/Email: //p' \"$tmp_info\")\ngit-quiltimport.sh:102:\t\t\tpatch_author_name=$(expr \"z$patch_author\" : 'z\\(.*[^ ]\\) *<.*') &&\ngit-quiltimport.sh:103:\t\t\tpatch_author_email=$(expr \"z$patch_author\" : '.*<\\([^>]*\\)') &&\ngit-quiltimport.sh:110:\texport GIT_AUTHOR_DATE=$(sed -ne 's/Date: //p' \"$tmp_info\")\ngit-quiltimport.sh:111:\texport SUBJECT=$(sed -ne 's/Subject: //p' \"$tmp_info\")\ngit-quiltimport.sh:113:\t\tSUBJECT=$(echo $patch_name | sed -e 's/.patch$//')\ngit-quiltimport.sh:118:\t\ttree=$(git write-tree) &&\ngit-quiltimport.sh:119:\t\tcommit=$( (echo \"$SUBJECT\"; echo; cat \"$tmp_msg\") | git commit-tree $tree -p $commit) &&\ngit-rebase--interactive.sh:29:test -f \"$DOTEST\"/strategy && STRATEGY=\"$(cat \"$DOTEST\"/strategy)\"\ngit-rebase--interactive.sh:73:\tcount=$(($(wc -l < \"$DONE\")))\ngit-rebase--interactive.sh:74:\ttotal=$(($count+$(wc -l < \"$TODO\")))\ngit-rebase--interactive.sh:80:\tparent_sha1=$(git rev-parse --verify \"$1\"^ 2> /dev/null)\ngit-rebase--interactive.sh:103:\tparent_sha1=$(git rev-parse --verify $sha1^ 2>/dev/null)\ngit-rebase--interactive.sh:104:\tcurrent_sha1=$(git rev-parse --verify HEAD)\ngit-rebase--interactive.sh:108:\t\tsha1=$(git rev-parse --short $sha1)\ngit-rebase--interactive.sh:117:\tsha1=$(git rev-parse $sha1)\ngit-rebase--interactive.sh:121:\t\tcurrent_commit=$(cat \"$DOTEST\"/current-commit) &&\ngit-rebase--interactive.sh:131:\tfor p in $(git rev-list --parents -1 $sha1 | cut -d\\  -f2-)\ngit-rebase--interactive.sh:136:\t\t\tnew_p=$(cat \"$REWRITTEN\"/$p)\ngit-rebase--interactive.sh:154:\t\tfirst_parent=$(expr \"$new_parents\" : \" \\([^ ]*\\)\")\ngit-rebase--interactive.sh:163:\t\t\tauthor_script=$(get_author_ident_from_commit $sha1)\ngit-rebase--interactive.sh:165:\t\t\tmsg=\"$(git cat-file commit $sha1 | \\\ngit-rebase--interactive.sh:192:\t\tCOUNT=$(($(sed -n \"s/^# This is [^0-9]*\\([0-9]\\+\\).*/\\1/p\" \\\ngit-rebase--interactive.sh:204:\techo \"# This is the $(nth_string $COUNT) commit message:\"\ngit-rebase--interactive.sh:245:\t\ttest -z \"$(grep -ve '^$' -e '^#' < $DONE)\" &&\ngit-rebase--interactive.sh:250:\t\tcase \"$(peek_next_command)\" in\ngit-rebase--interactive.sh:265:\t\tauthor_script=$(get_author_ident_from_commit $sha1)\ngit-rebase--interactive.sh:288:\tHEADNAME=$(cat \"$DOTEST\"/head-name) &&\ngit-rebase--interactive.sh:289:\tOLDHEAD=$(cat \"$DOTEST\"/head) &&\ngit-rebase--interactive.sh:290:\tSHORTONTO=$(git rev-parse --short $(cat \"$DOTEST\"/onto)) &&\ngit-rebase--interactive.sh:294:\t\t\tcurrent_commit=$(cat \"$DOTEST\"/current-commit) &&\ngit-rebase--interactive.sh:296:\t\tNEWHEAD=$(cat \"$REWRITTEN\"/$OLDHEAD)\ngit-rebase--interactive.sh:298:\t\tNEWHEAD=$(git rev-parse HEAD)\ngit-rebase--interactive.sh:304:\t\t\tgit diff --stat $(cat \"$DOTEST\"/head)..HEAD\ngit-rebase--interactive.sh:344:\t\tHEADNAME=$(cat \"$DOTEST\"/head-name)\ngit-rebase--interactive.sh:345:\t\tHEAD=$(cat \"$DOTEST\"/head)\ngit-rebase--interactive.sh:400:\t\t\tONTO=$(git rev-parse --verify \"$2\") ||\ngit-rebase--interactive.sh:417:\t\tHEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\ngit-rebase--interactive.sh:418:\t\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\ngit-rebase--interactive.sh:441:\t\t\tfor c in $(git merge-base --all $HEAD $UPSTREAM)\ngit-rebase--interactive.sh:451:\t\tSHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)\ngit-rebase--interactive.sh:452:\t\tSHORTHEAD=$(git rev-parse --short $HEAD)\ngit-rebase--interactive.sh:453:\t\tSHORTONTO=$(git rev-parse --short $ONTO)\ngit-rebase--interactive.sh:470:\t\ttest -z \"$(grep -ve '^$' -e '^#' < $TODO)\" &&\ngit-rebase--interactive.sh:477:\t\ttest -z \"$(grep -ve '^$' -e '^#' < $TODO)\" &&\ngit-rebase.sh:54:\tunmerged=$(git ls-files -u)\ngit-rebase.sh:82:\tmsgnum=$(($msgnum + 1))\ngit-rebase.sh:87:\tcmt=\"$(cat $dotest/cmt.$1)\"\ngit-rebase.sh:89:\thd=$(git rev-parse --verify HEAD)\ngit-rebase.sh:90:\tcmt_name=$(git symbolic-ref HEAD)\ngit-rebase.sh:91:\tmsgnum=$(cat $dotest/msgnum)\ngit-rebase.sh:92:\tend=$(cat $dotest/end)\ngit-rebase.sh:93:\teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\ngit-rebase.sh:94:\teval GITHEAD_$hd='\"$(cat $dotest/onto_name)\"'\ngit-rebase.sh:167:\t\t\tmsgnum=$(($msgnum + 1))\ngit-rebase.sh:257:diff=$(git diff-index --cached --name-status -r HEAD)\ngit-rebase.sh:272:onto=$(git rev-parse --verify \"${onto_name}^0\") || exit\ngit-rebase.sh:298:branch=$(git rev-parse --verify \"${branch_name}^0\") || exit\ngit-rebase.sh:304:mb=$(git merge-base \"$onto\" \"$branch\")\ngit-rebase.sh:351:\tmsgnum=$(($msgnum + 1))\ngit-repack.sh:67:names=$(git pack-objects --non-empty --all --reflog $args </dev/null \"$PACKTMP\") ||\ngit-reset.sh:27:\t\trev=$(git rev-parse --verify \"$1\") || exit\ngit-reset.sh:36:rev=$(git rev-parse --verify $rev^0) || exit\ngit-reset.sh:69:\t   test \"\" != \"$(git ls-files --unmerged)\"\ngit-reset.sh:78:if orig=$(git rev-parse --verify HEAD 2>/dev/null)\ngit-sh-setup.sh:32:\t: \"${GIT_EDITOR:=$(git config core.editor)}\"\ngit-sh-setup.sh:52:\tcdup=$(git rev-parse --show-cdup)\ngit-sh-setup.sh:63:\ttest $(git rev-parse --is-inside-work-tree) = true ||\ngit-sh-setup.sh:89:\tencoding=$(git config i18n.commitencoding || echo UTF-8)\ngit-sh-setup.sh:113:\tGIT_DIR=$(GIT_DIR=\"$GIT_DIR\" git rev-parse --git-dir) || {\ngit-sh-setup.sh:119:\tGIT_DIR=$(git rev-parse --git-dir) || exit\ngit-stash.sh:22:\tif current=$(git rev-parse --verify $ref_stash 2>/dev/null)\ngit-stash.sh:43:\tif b_commit=$(git rev-parse --verify HEAD)\ngit-stash.sh:45:\t\thead=$(git log --abbrev-commit --pretty=oneline -n 1 HEAD)\ngit-stash.sh:50:\tif branch=$(git symbolic-ref -q HEAD)\ngit-stash.sh:56:\tmsg=$(printf '%s: %s' \"$branch\" \"$head\")\ngit-stash.sh:59:\ti_tree=$(git write-tree) &&\ngit-stash.sh:60:\ti_commit=$(printf 'index on %s' \"$msg\" |\ngit-stash.sh:65:\tw_tree=$( (\ngit-stash.sh:80:\t\tstash_msg=$(printf 'WIP on %s' \"$msg\")\ngit-stash.sh:82:\t\tstash_msg=$(printf 'On %s: %s' \"$branch\" \"$stash_msg\")\ngit-stash.sh:84:\tw_commit=$(printf '%s\\n' \"$stash_msg\" |\ngit-stash.sh:104:\tflags=$(git rev-parse --no-revs --flags \"$@\")\ngit-stash.sh:109:\ts=$(git rev-parse --revs-only --no-flags --default $ref_stash \"$@\")\ngit-stash.sh:111:\tw_commit=$(git rev-parse --verify \"$s\") &&\ngit-stash.sh:112:\tb_commit=$(git rev-parse --verify \"$s^\") &&\ngit-stash.sh:128:\tc_tree=$(git write-tree) ||\ngit-stash.sh:133:\ts=$(git rev-parse --revs-only --no-flags --default $ref_stash \"$@\") &&\ngit-stash.sh:134:\tw_tree=$(git rev-parse --verify \"$s:\") &&\ngit-stash.sh:135:\tb_tree=$(git rev-parse --verify \"$s^1:\") &&\ngit-stash.sh:136:\ti_tree=$(git rev-parse --verify \"$s^2:\") ||\ngit-stash.sh:145:\t\tunstashed_index_tree=$(git-write-tree) ||\ngit-submodule.sh:50:\tre=$(printf '%s' \"$1\" | sed -e 's/\\([^a-zA-Z0-9_]\\)/\\\\\\1/g')\ngit-submodule.sh:51:\tname=$( GIT_CONFIG=.gitmodules \\\ngit-submodule.sh:108:\tif base=$(get_repo_base \"$repo\"); then\ngit-submodule.sh:114:\t\tpath=$(echo \"$repo\" | sed -e 's|/*$||' -e 's|:*/*\\.git$||' -e 's|.*[/:]||g')\ngit-submodule.sh:116:\t\tpath=$(echo \"$path\" | sed -e 's|/*$||')\ngit-submodule.sh:148:\t\tname=$(module_name \"$path\") || exit\ngit-submodule.sh:149:\t\turl=$(git config submodule.\"$name\".url)\ngit-submodule.sh:152:\t\turl=$(GIT_CONFIG=.gitmodules git config submodule.\"$name\".url)\ngit-submodule.sh:173:\t\tname=$(module_name \"$path\") || exit\ngit-submodule.sh:174:\t\turl=$(git config submodule.\"$name\".url)\ngit-submodule.sh:189:\t\t\tsubsha1=$(unset GIT_DIR && cd \"$path\" &&\ngit-submodule.sh:206:\trevname=$( (\ngit-submodule.sh:232:\t\tname=$(module_name \"$path\") || exit\ngit-submodule.sh:233:\t\turl=$(git config submodule.\"$name\".url)\ngit-submodule.sh:246:\t\t\t\tsha1=$(unset GIT_DIR && cd \"$path\" && git rev-parse --verify HEAD)\ngit-tag.sh:39:\t\tLINES=$(expr \"$1\" : '\\([0-9]*\\)')\ngit-tag.sh:64:\t\tOBJTYPE=$(git cat-file -t \"$TAG\")\ngit-tag.sh:67:\t\t\tANNOTATION=$(git cat-file tag \"$TAG\" |\ngit-tag.sh:100:\t    message=\"$(cat \"$1\")\"\ngit-tag.sh:121:\t\tcur=$(git show-ref --verify --hash -- \"refs/tags/$tag\") || {\ngit-tag.sh:137:\ttag=$(git show-ref --verify --hash -- \"refs/tags/$tag_name\") ||\ngit-tag.sh:165:object=$(git rev-parse --verify --default HEAD \"$@\") || exit 1\ngit-tag.sh:166:type=$(git cat-file -t $object) || exit 1\ngit-tag.sh:167:tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1\ngit-tag.sh:170:\tusername=$(git repo-config user.signingkey) ||\ngit-tag.sh:171:\tusername=$(expr \"z$tagger\" : 'z\\(.*>\\)')\ngit-tag.sh:202:    object=$(git-mktag < \"$GIT_DIR\"/TAG_TMP)\ngit-verify-tag.sh:24:type=\"$(git cat-file -t \"$1\" 2>/dev/null)\" ||\n\nGrep finished (matches found) at Fri Aug  3 01:29:41\n\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49518","messageId":"20070802234515.GW29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"85k5sdy0lk.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-02T23:45:15Z","receivedAt":"2007-08-02T23:45:15Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Fri, Aug 03, 2007 at 01:32:07AM +0200, David Kastrup wrote:\n> Robert Schiele <rschiele@gmail.com> writes:\n> > Well, I have now a patch ready for submission that would replace all\n> > occurences of ${PARAMETER#WORD}, ${PARAMETER%WORD}, and $((\n> > EXPRESSION )).  But if you say that you won't accept replacement of\n> > $( ... ) then this is not worth the effort since this one isn't\n> > accepted as well.\n> \n> I absolutely can't understand your claim that most things work for\n> you, then.  Are you _really_, _really_ sure you are talking about\n> /bin/sh here?\n\nI started wondering myself and it turned out that we just didn't look in the\nright place.  Actually we _have_ an infrastructure in place to replace the\nshell.  (SHELL_PATH in the Makefile)  In that case I would not consider this\nan issue and you might go on with the cleanup from my point of view.\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49520","messageId":"85d4y5xznj.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"20070802234515.GW29424@schiele.dyndns.org","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-02T23:52:32Z","receivedAt":"2007-08-02T23:52:32Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Robert Schiele <rschiele@gmail.com> writes:\n\n> On Fri, Aug 03, 2007 at 01:32:07AM +0200, David Kastrup wrote:\n>> Robert Schiele <rschiele@gmail.com> writes:\n>> > Well, I have now a patch ready for submission that would replace all\n>> > occurences of ${PARAMETER#WORD}, ${PARAMETER%WORD}, and $((\n>> > EXPRESSION )).  But if you say that you won't accept replacement of\n>> > $( ... ) then this is not worth the effort since this one isn't\n>> > accepted as well.\n>> \n>> I absolutely can't understand your claim that most things work for\n>> you, then.  Are you _really_, _really_ sure you are talking about\n>> /bin/sh here?\n>\n> I started wondering myself and it turned out that we just didn't\n> look in the right place.  Actually we _have_ an infrastructure in\n> place to replace the shell.  (SHELL_PATH in the Makefile) In that\n> case I would not consider this an issue and you might go on with the\n> cleanup from my point of view.\n\nI was starting to doubt my sanity here.  Sorry that this thread\nresulted in wasted work for you.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49523","messageId":"20070803000113.GX29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"85d4y5xznj.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-03T00:01:13Z","receivedAt":"2007-08-03T00:01:13Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Fri, Aug 03, 2007 at 01:52:32AM +0200, David Kastrup wrote:\n> I was starting to doubt my sanity here.  Sorry that this thread\n> resulted in wasted work for you.\n\nThat's ok.  I mean I didn't spot the SHELL_PATH thing in the first place\nalthough I already had seen that one before (what I remember now).\n\nAt least in that case I don't have to worry any longer since I always can put\nsome compliant shell at some random place and use that one.\n\nBut at least you have learned now that not everything in the real world looks\nlike as it is written in some standard books. ;-)\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49525","messageId":"857iodxyrc.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"20070803000113.GX29424@schiele.dyndns.org","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-03T00:11:51Z","receivedAt":"2007-08-03T00:11:51Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Robert Schiele <rschiele@gmail.com> writes:\n\n> On Fri, Aug 03, 2007 at 01:52:32AM +0200, David Kastrup wrote:\n>> I was starting to doubt my sanity here.  Sorry that this thread\n>> resulted in wasted work for you.\n>\n> That's ok.  I mean I didn't spot the SHELL_PATH thing in the first\n> place although I already had seen that one before (what I remember\n> now).\n>\n> At least in that case I don't have to worry any longer since I\n> always can put some compliant shell at some random place and use\n> that one.\n>\n> But at least you have learned now that not everything in the real\n> world looks like as it is written in some standard books. ;-)\n\nYou are aware that I am the maintainer of AUCTeX?  Which has an\nautoconf-based setup that works under AIX, Solaris, MinGW, Cygwin,\nHP/UX and a few other oddities, all with the respective native tools?\n\nI know more about stupid shells than I really want to.  But that does\nnot change that I could not imagine a shell such as yours to work\n\"mostly\" with the current git code base.\n\nFor autoconf, it is fine to call sed (and you would probably not\nbelieve how small the portable language subset for sed is) all the\ntime.  Performance is not an issue.  For normal user commands, this is\ndifferent.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49526","messageId":"7vk5sdscfr.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"85ps25y1ac.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-03T00:12:56Z","receivedAt":"2007-08-03T00:12:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kastrup <dak@gnu.org> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> However, there is a line we need to draw when bending bacwards for\n>> compatibility, and I think a system that does not have a working\n>> command substitution $( ... )  is on the other side of that line.\n>\n> Not an issue.  But apparently, ${parameter#word} is for Solaris.  I'd\n> still like to get confirmation that it is indeed /bin/sh, but if it\n> is, the current code is not good for Solaris.\n\nI happen to feel ${parameter#word} is more esoteric than $(cmd).\nIf a system does not even do the latter, then avoiding the\nformer to help such a system is a futile effort.\n\nAnd /bin/sh my Solaris box does not understand $(cmd) and wants\nyou to say `cmd`.  Of course % and # parameter substition do not\nwork there.\n\nPeople could probably say SHELL_PATH=/usr/xpg4/bin/sh there to\nget a saner shell, even if they do not like bash, though.\n"},{"id":"49527","messageId":"85wswdwjll.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"7vk5sdscfr.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-03T00:24:38Z","receivedAt":"2007-08-03T00:24:38Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> David Kastrup <dak@gnu.org> writes:\n>\n>> Junio C Hamano <gitster@pobox.com> writes:\n>>\n>>> However, there is a line we need to draw when bending bacwards for\n>>> compatibility, and I think a system that does not have a working\n>>> command substitution $( ... )  is on the other side of that line.\n>>\n>> Not an issue.  But apparently, ${parameter#word} is for Solaris.  I'd\n>> still like to get confirmation that it is indeed /bin/sh, but if it\n>> is, the current code is not good for Solaris.\n>\n> I happen to feel ${parameter#word} is more esoteric than $(cmd).\n> If a system does not even do the latter, then avoiding the\n> former to help such a system is a futile effort.\n\nThe situation is that we currently don't avoid the former.  Robert\nsaid that he had prepared a patch that would do so.\n\nIt would make sense to either encourage him to present his patch\n(though we probably don't know for sure that there are indeed shells\nfor which the former works worse than the latter), or permit further\nuse of ${parameter#word} where it makes things more readable.\n\nBut \"only a little bit of ${parameter#word}, please\" seems pointless.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49528","messageId":"7vabt9sasl.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"85wswdwjll.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-03T00:48:26Z","receivedAt":"2007-08-03T00:48:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kastrup <dak@gnu.org> writes:\n\n>> I happen to feel ${parameter#word} is more esoteric than $(cmd).\n>> If a system does not even do the latter, then avoiding the\n>> former to help such a system is a futile effort.\n>\n> The situation is that we currently don't avoid the former.  Robert\n> said that he had prepared a patch that would do so.\n> ...\n> But \"only a little bit of ${parameter#word}, please\" seems pointless.\n\nAbsolutely.  And we started to adopt #/% substititions some time\nago.  Undoing them just feels going backwards, and we need to\njudge what the merits of going backwards are.\n\nFor that discussion, /bin/sh on Solaris does not count.  There\nare huge downside of rewriting scripts to work with stock\nSolaris /bin/sh:\n\n (1) that shell does not even grok $(cmd) substitution.\n\n     I won't accept a half-baked patch that replaces \"$(\" with a\n     backtick and matching \")\" with another backtick.  You need\n     to at least make sure your interpolated variables within\n     the backtick pair work sensibly, and you haven't broken\n     existing nesting of command interpolations, if any.  I do\n     not even want to inspect, comment on and reject that kind\n     of changes.  Quite frankly, it's not worth my time.\n\n (2) Rewriting $(cmd) to `cmd`, and ${parameter#word} with sed\n     or expr would reduce readability, at least to other people.\n\n     Remember, I was the one who originally avoided modern\n     ${parameter#word} substitutions, and older scripts had many\n     more invocations of expr than we currently have.  Reading\n     such a backward rewrite would not be too much of a problem\n     for *me*, but other people also need to read and understand\n     scripts, if only to be able to rewrite them in C.\n\n     There may still be many old parts of the scripts that could\n     be made more readable and efficient using ${parameter#word}\n     substitutions. If we were to rewrite scripts, more use of\n     them could be a good thing, not the other way around.\n\nBesides, on that platform there are more reasonable shells\navailable via SHELL_PATH, and it is not limited to going to\nbash.\n"},{"id":"49533","messageId":"20070803022828.GY29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"85wswdwjll.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-03T02:28:28Z","receivedAt":"2007-08-03T02:28:28Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Fri, Aug 03, 2007 at 02:24:38AM +0200, David Kastrup wrote:\n> The situation is that we currently don't avoid the former.  Robert\n> said that he had prepared a patch that would do so.\n> \n> It would make sense to either encourage him to present his patch\n\nWell, if you want to see it, just tell me.  Do you want to have it with or\nwithout the arithmetic replacements I did as well?\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49543","messageId":"85lkctw3sl.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"7vabt9sasl.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-03T06:06:02Z","receivedAt":"2007-08-03T06:06:02Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> David Kastrup <dak@gnu.org> writes:\n>\n>>> I happen to feel ${parameter#word} is more esoteric than $(cmd).\n>>> If a system does not even do the latter, then avoiding the\n>>> former to help such a system is a futile effort.\n>>\n>> The situation is that we currently don't avoid the former.  Robert\n>> said that he had prepared a patch that would do so.\n>> ...\n>> But \"only a little bit of ${parameter#word}, please\" seems pointless.\n>\n> Absolutely.  And we started to adopt #/% substititions some time\n> ago.  Undoing them just feels going backwards, and we need to judge\n> what the merits of going backwards are.\n\nOk, seems like the sort of cleanups I proposed would not clash with\ncurrent git policies.  I'll readily agree that the timing of their\nadoption might not really fit with a rc4, but posting them for the\nqueue does not seem outrageous.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49544","messageId":"85hcnhw3oc.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"20070803022828.GY29424@schiele.dyndns.org","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-03T06:08:35Z","receivedAt":"2007-08-03T06:08:35Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Robert Schiele <rschiele@gmail.com> writes:\n\n> On Fri, Aug 03, 2007 at 02:24:38AM +0200, David Kastrup wrote:\n>> The situation is that we currently don't avoid the former.  Robert\n>> said that he had prepared a patch that would do so.\n>> \n>> It would make sense to either encourage him to present his patch\n>\n> Well, if you want to see it, just tell me.  Do you want to have it with or\n> without the arithmetic replacements I did as well?\n\n>From Junio's answer, I gather that indeed this would seem pointless.\n$(...) is not going away anytime soon, and I have seen no evidence\nthat there is a shell in widespread use that supports it, but doesn't\nsupport ${...#...}.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49545","messageId":"85d4y5w3gm.fsf@lola.goethe.zz","threadId":"9352","inReplyTo":"7vabt9sasl.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-03T06:13:13Z","receivedAt":"2007-08-03T06:13:13Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>  (1) that shell does not even grok $(cmd) substitution.\n>\n>      I won't accept a half-baked patch that replaces \"$(\" with a\n>      backtick and matching \")\" with another backtick.  You need\n>      to at least make sure your interpolated variables within\n>      the backtick pair work sensibly, and you haven't broken\n>      existing nesting of command interpolations, if any.  I do\n>      not even want to inspect, comment on and reject that kind\n>      of changes.  Quite frankly, it's not worth my time.\n\nAnd that's actually not even _half_ of the deal: we are talking about\npandering to legacy shells here, and the amount of variance of just\nwhat level of quoting/backslashing is needed on the inside of `...` in\norder to get stuff through with just the right level of quoting is\nactually stunning.\n\nI've had my fair share of bad surprises with portable scripts.\nGetting a backquote mechanism running on one shell does not mean it\nwill work on another.  Basically, you have to forego nesting stuff and\nsplit it out into small units in separate commands.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"49554","messageId":"7vir7xozxs.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"857iodxyrc.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-03T07:11:11Z","receivedAt":"2007-08-03T07:11:11Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kastrup <dak@gnu.org> writes:\n\n> ... For autoconf, it is fine to call sed (and you would probably not\n> believe how small the portable language subset for sed is) all the\n> time.  Performance is not an issue.  For normal user commands, this is\n> different.\n\nWow, you made me recall a painful past for myself.  AIX's sed\nwas so bad that I had to send in a few bugfixes to autoconf to\nwork it around.  I do not know if I should feel happy to find\nsomebody to commiserate with...\n"},{"id":"49558","messageId":"7v3az1oyjn.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"85lkctw3sl.fsf@lola.goethe.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-03T07:41:16Z","receivedAt":"2007-08-03T07:41:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kastrup <dak@gnu.org> writes:\n\n> Ok, seems like the sort of cleanups I proposed would not clash with\n> current git policies.  I'll readily agree that the timing of their\n> adoption might not really fit with a rc4, but posting them for the\n> queue does not seem outrageous.\n\nYeah, except that Kristian's C-rewrite of git-commit.sh may well\njump the queue before such a patch would touch the file it\nintends to replace...\n"},{"id":"49565","messageId":"86tzrhhuxg.fsf@lola.quinscape.zz","threadId":"9352","inReplyTo":"7v3az1oyjn.fsf@assigned-by-dhcp.cox.net","subject":"Re: Shell script cleanups/style changes?","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-03T08:41:15Z","receivedAt":"2007-08-03T08:41:15Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> David Kastrup <dak@gnu.org> writes:\n>\n>> Ok, seems like the sort of cleanups I proposed would not clash with\n>> current git policies.  I'll readily agree that the timing of their\n>> adoption might not really fit with a rc4, but posting them for the\n>> queue does not seem outrageous.\n>\n> Yeah, except that Kristian's C-rewrite of git-commit.sh may well\n> jump the queue before such a patch would touch the file it\n> intends to replace...\n\nWell, since the work has already been done, I guess I might as well\npost it.\n\nWith regard to C rewrites: I would hazard a guess that git's\nperformance might actually be improved by splitting some primitives\ninto even smaller C building blocks and tying them all together with\npipes (which makes shell scripts a natural container).  As long as one\ndesigns the C chunks carefully enough that no bulk processing is done\nin the scripts themselves, this could actually lead to better\nschedulable pieces of software.  I think that most index processing\ncan be done in a list-merge style on sorted lists.  That implies pipes\nand files on input and output, and a small memory footprint.  With a\ngood scheduler (the current Linux scheduler sucks at exploiting the\nasynchronicity of pipes; this should be better with CFS), this should\nmake things work rather efficiently, be flexible for extension, and\nmake good use of multi-core systems.\n\nWe have seen a recent example on this list: hand-chaining git-ls-files\nand a few other tools into a pipeline beat the pants off\nbuiltin-add.c.\n\nGiven that portability goes down the drain if we want to use similarly\nor more efficient constellations in C (multithreading and asynchronous\nI/O come to mind), I would not replace shell scripts (and the\nassociated flexibility in extending functionality) lightly right now.\nAs long as the main data flow is only managed rather than processed by\nthe scripts, I think we would have more to gain by restructuring into\npipelineable pieces.  It will still be possible to ultimately tie\nthose together in a single process image (with multiple threads\npresumably).  But that immediately takes away a lot of flexibility.\n\n-- \nDavid Kastrup\n"},{"id":"49619","messageId":"20070803192942.GA23432@informatik.uni-freiburg.de","threadId":"9352","inReplyTo":"86sl72j9vn.fsf@lola.quinscape.zz","subject":"Re: Shell script cleanups/style changes?","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-08-03T19:29:42Z","receivedAt":"2007-08-03T19:29:42Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"David Kastrup wrote:\n> Robert Schiele <rschiele@gmail.com> writes:\n> \n> > On Thu, Aug 02, 2007 at 12:44:22PM +0200, David Kastrup wrote:\n> >> ! \t\tlogfile=\"${1#-?}\"\n> >\n> > You can't do something like that on /bin/sh on many systems (for\n> > instance Solaris).\n> \n> Sigh.  It's in Posix.\nWell Solaris is (kind of) Posix compliant---you need some extra effort\nto get it into Posix \"mode\":\n\n\tlogin@~ > uname -a\n\tSunOS login 5.10 Generic_125100-10 sun4u sparc\n\tlogin@~ > sh\n\t$ set tralala\n\t$ echo \"${1#tra}\"\n\tlala\n\t$ ^D\n\nthe \"problem\" here is, that my PATH includes /usr/xpg4/bin before\n/usr/bin and that's non-standard (for Solaris).  That is\n/usr/xpg4/bin/sh is Posix compliant and /usr/bin/sh is compatible to\nformer versions of Solaris/SunOS and this one doesn't support these\nsubstitutions:\n\n\tlogin@~ > /usr/bin/sh\n\t$ set tralala\n\t$ echo \"${1#tra}\"\n\tbad substitution\n\nHaving \n\n\tlogin@~ > ls -l /bin\n\tlrwxrwxrwx 1 root root 9 2006-07-03 09:29 /bin -> ./usr/bin\n\nsadly the Solaris sh is used for shell scripts that use a shebang line\ncalling /bin/sh.\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\nhttp://www.google.com/search?q=5+choose+3\n"},{"id":"49676","messageId":"873ayzojw7.fsf@mid.deneb.enyo.de","threadId":"9352","inReplyTo":"20070802214103.GT29424@schiele.dyndns.org","subject":"Re: Shell script cleanups/style changes?","fromName":"Florian Weimer","fromEmail":"fw@deneb.enyo.de","sentAt":"2007-08-04T07:10:00Z","receivedAt":"2007-08-04T07:10:00Z","isPatch":false,"sender":{"key":"fw@deneb.enyo.de","avatar":null},"body":"* Robert Schiele:\n\n>> Sure.  What about the git-rebase line using $(($end - $msgnum)) ?\n>\n> Bad on Solaris:\n>\n> $ uname -a\n> SunOS solaris10-x64 5.10 Generic i86pc i386 i86pc\n> $ end=1\n> $ msgnum=5\n> $ echo $(($end - $msgnum))\n> syntax error: `(' unexpected\n> $ \n\nIs this with /usr/xpg4/bin/sh or /bin/sh?  The latter is not POSIX and\nshould not be used by GIT, IMHO, otherwise there will be endless\nissues in less-well-tested code paths.  Is rewriting the shebang lines\nto use the POSIX shell an option for GIT?\n"},{"id":"49776","messageId":"20070804203220.GZ29424@schiele.dyndns.org","threadId":"9352","inReplyTo":"873ayzojw7.fsf@mid.deneb.enyo.de","subject":"Re: Shell script cleanups/style changes?","fromName":"Robert Schiele","fromEmail":"rschiele@gmail.com","sentAt":"2007-08-04T20:32:20Z","receivedAt":"2007-08-04T20:32:20Z","isPatch":false,"sender":{"key":"rschiele@gmail.com","avatar":"https://gravatar.com/avatar/409473567eb2287d5f0157b51f5b703994b347f24f92172e3a0588741c27a492?d=mp&s=160"},"body":"On Sat, Aug 04, 2007 at 09:10:00AM +0200, Florian Weimer wrote:\n> * Robert Schiele:\n> \n> >> Sure.  What about the git-rebase line using $(($end - $msgnum)) ?\n> >\n> > Bad on Solaris:\n> >\n> > $ uname -a\n> > SunOS solaris10-x64 5.10 Generic i86pc i386 i86pc\n> > $ end=1\n> > $ msgnum=5\n> > $ echo $(($end - $msgnum))\n> > syntax error: `(' unexpected\n> > $ \n> \n> Is this with /usr/xpg4/bin/sh or /bin/sh?  The latter is not POSIX and\n> should not be used by GIT, IMHO, otherwise there will be endless\n> issues in less-well-tested code paths.  Is rewriting the shebang lines\n> to use the POSIX shell an option for GIT?\n\nHi Florian,\n\nI recommend you read the other mails in this thread.  This issue is already\ncompletely resolved.\n\nRobert\n\n-- \nRobert Schiele\nDipl.-Wirtsch.informatiker\tmailto:rschiele@gmail.com\n\n\"Quidquid latine dictum sit, altum sonatur.\"\n"},{"id":"49777","messageId":"7v3ayzjaqa.fsf@assigned-by-dhcp.cox.net","threadId":"9352","inReplyTo":"20070804203220.GZ29424@schiele.dyndns.org","subject":"Re: Shell script cleanups/style changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-04T20:39:09Z","receivedAt":"2007-08-04T20:39:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robert Schiele <rschiele@gmail.com> writes:\n\n> Hi Florian,\n>\n> I recommend you read the other mails in this thread.  This issue is already\n> completely resolved.\n\nTo be a bit more helpful, a short summary is:\n\n * SHELL_PATH in Makefile lets you munge installed scripts;\n\n * /bin/ksh is usable on Solaris and xpg4 is fine too;\n\n * We need to draw a line somewhere, and the current rule is\n   that we cannot afford to support a shell that does not\n   understand $(cmd) substitution, as we haven't seen a shell\n   that supports ${parameter#word} but not $(cmd).\n"}]}