{"thread":{"id":"25628","subject":"git stash syntax error under AIX 5.3","startedAt":"2010-11-03T14:05:38Z","lastAt":"2010-11-03T15:29:09Z","messageCount":3,"participants":["Brian Riehman","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"155045","messageId":"AANLkTimSpPLfqv07+Tmcj-iM0W+p86V2-HRrq71Umdtr@mail.gmail.com","threadId":"25628","inReplyTo":null,"subject":"git stash syntax error under AIX 5.3","fromName":"Brian Riehman","fromEmail":"briehman@gmail.com","sentAt":"2010-11-03T14:05:38Z","receivedAt":"2010-11-03T14:05:38Z","isPatch":false,"sender":{"key":"briehman@gmail.com","avatar":null},"body":"The stash command relies on bash-specific shell scripting techniques\nwhen the shebang line lists Bourne shell.  This was introduced in\nb0f0ecd97924ee775e7f3b29366133448f4f8e15.  The error was noticed when\nrunning under AIX 5.3:\n\n$ /bin/sh -n git-stash.sh\ngit-stash.sh[63]: syntax error at line 498 : `\"' unmatched\n$ /bin/sh -n git-stash-modified.sh\n$ diff git-stash.sh git-stash-modified.sh\n314,321c314,321\n<       if test \"${REV}\" != \"${REV%{*\\}}\"\n<       then\n<               # maintainers: it would be better if git rev-parse indicated\n<               # this condition with a non-zero status code but as of\n1.7.2.1 it\n<               # it did not. So, we use non-empty stderr output as a\nproxy for the\n<               # condition of interest.\n<               test -z \"$(git rev-parse \"$REV\" 2>&1 >/dev/null)\" ||\ndie \"$REV does not exist in the stash log\"\n<       fi\n---\n> #     if test \"${REV}\" != \"${REV%{*\\}}\"\n> #     then\n> #             # maintainers: it would be better if git rev-parse indicated\n> #             # this condition with a non-zero status code but as of 1.7.2.1 it\n> #             # it did not. So, we use non-empty stderr output as a proxy for the\n> #             # condition of interest.\n> #             test -z \"$(git rev-parse \"$REV\" 2>&1 >/dev/null)\" || die \"$REV does not exist in the stash log\"\n> #     fi\n$ head -1 git-stash.sh\n#!/bin/sh\n\nRemoving the code from that commit causes the stash command to work\nproperly.  I am not sure if other systems have /bin/sh symbolically\nlinked to /bin/bash, but in AIX the /bin/sh fails to properly parse\nthe default git-stash.sh.\n\nI am not sure how to correct this logic since Bourne shell does not\nhave an equally powerful search and replace variable substitution\noperator nor do I know exactly what this is meant to filter out of the\nvariable.  For now, I have simply patched the source to comment out\nthose lines.\n\nBrian Riehman\n"},{"id":"155046","messageId":"20101103150718.GA12733@burratino","threadId":"25628","inReplyTo":"AANLkTimSpPLfqv07+Tmcj-iM0W+p86V2-HRrq71Umdtr@mail.gmail.com","subject":"Re: git stash syntax error under AIX 5.3","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-03T15:07:18Z","receivedAt":"2010-11-03T15:07:18Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Brian,\n\nBrian Riehman wrote:\n\n> The stash command relies on bash-specific shell scripting techniques\n\nGit actually uses the ${var%glob} syntax pretty widely, and it is\nfairly portable (see http://unix.org/2008edition/ and search for \"sh -\"\nfor details).  I suspect the problem is rather the seemingly-unbalanced\nbraces:\n\n> <       if test \"${REV}\" != \"${REV%{*\\}}\"\n\nHow about this patch?\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\ndiff --git a/git-stash.sh b/git-stash.sh\nindex 5fb1245..0a41226 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -311,7 +311,7 @@ parse_flags_and_rev()\n \ttest \"$ref_stash\" = \"$(git rev-parse --symbolic-full-name \"${REV%@*}\")\" &&\n \tIS_STASH_REF=t\n \n-\tif test \"${REV}\" != \"${REV%{*\\}}\"\n+\tif test \"${REV}\" != \"${REV%\\{*\\}}\"\n \tthen\n \t\t# maintainers: it would be better if git rev-parse indicated\n \t\t# this condition with a non-zero status code but as of 1.7.2.1 it\n"},{"id":"155047","messageId":"AANLkTi=V7nu98xHVrVJuZqt_3hajMPvkk=AKB0HnOD-_@mail.gmail.com","threadId":"25628","inReplyTo":"20101103150718.GA12733@burratino","subject":"Re: git stash syntax error under AIX 5.3","fromName":"Brian Riehman","fromEmail":"briehman@gmail.com","sentAt":"2010-11-03T15:29:09Z","receivedAt":"2010-11-03T15:29:09Z","isPatch":false,"sender":{"key":"briehman@gmail.com","avatar":null},"body":"Thanks, Jonathan.  That did indeed fix it. Thanks for your help and\nclarification that it does indeed work in my shell when escaped\nproperly.\n\nOn Wed, Nov 3, 2010 at 10:07 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Hi Brian,\n>\n> Brian Riehman wrote:\n>\n>> The stash command relies on bash-specific shell scripting techniques\n>\n> Git actually uses the ${var%glob} syntax pretty widely, and it is\n> fairly portable (see http://unix.org/2008edition/ and search for \"sh -\"\n> for details).  I suspect the problem is rather the seemingly-unbalanced\n> braces:\n>\n>> <       if test \"${REV}\" != \"${REV%{*\\}}\"\n>\n> How about this patch?\n>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n> diff --git a/git-stash.sh b/git-stash.sh\n> index 5fb1245..0a41226 100755\n> --- a/git-stash.sh\n> +++ b/git-stash.sh\n> @@ -311,7 +311,7 @@ parse_flags_and_rev()\n>        test \"$ref_stash\" = \"$(git rev-parse --symbolic-full-name \"${REV%@*}\")\" &&\n>        IS_STASH_REF=t\n>\n> -       if test \"${REV}\" != \"${REV%{*\\}}\"\n> +       if test \"${REV}\" != \"${REV%\\{*\\}}\"\n>        then\n>                # maintainers: it would be better if git rev-parse indicated\n>                # this condition with a non-zero status code but as of 1.7.2.1 it\n>\n"}]}