git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git stash syntax error under AIX 5.3

From
BRBrian Riehman <briehman@gmail.com>
Date
Nov 3, 2010, 14:05 UTC
Message-ID
<AANLkTimSpPLfqv07+Tmcj-iM0W+p86V2-HRrq71Umdtr@mail.gmail.com>

The stash command relies on bash-specific shell scripting techniques when the shebang line lists Bourne shell.  This was introduced in b0f0ecd97924ee775e7f3b29366133448f4f8e15.  The error was noticed when running under AIX 5.3:

$ /bin/sh -n git-stash.sh git-stash.sh[63]: syntax error at line 498 : `"' unmatched $ /bin/sh -n git-stash-modified.sh $ diff git-stash.sh git-stash-modified.sh 314,321c314,321 <       if test "${REV}" != "${REV%{*\}}" <       then <               # maintainers: it would be better if git rev-parse indicated <               # this condition with a non-zero status code but as of 1.7.2.1 it <               # it did not. So, we use non-empty stderr output as a proxy for the <               # condition of interest. <               test -z "$(git rev-parse "$REV" 2>&1 >/dev/null)" || die "$REV does not exist in the stash log" <       fi ---

Show 8 quoted lines
> #     if test "${REV}" != "${REV%{*\}}"
> #     then
> #             # maintainers: it would be better if git rev-parse indicated
> #             # this condition with a non-zero status code but as of 1.7.2.1 it
> #             # it did not. So, we use non-empty stderr output as a proxy for the
> #             # condition of interest.
> #             test -z "$(git rev-parse "$REV" 2>&1 >/dev/null)" || die "$REV does not exist in the stash log"
> #     fi

$ head -1 git-stash.sh #!/bin/sh

Removing the code from that commit causes the stash command to work properly.  I am not sure if other systems have /bin/sh symbolically linked to /bin/bash, but in AIX the /bin/sh fails to properly parse the default git-stash.sh.

I am not sure how to correct this logic since Bourne shell does not have an equally powerful search and replace variable substitution operator nor do I know exactly what this is meant to filter out of the variable.  For now, I have simply patched the source to comment out those lines.

Brian Riehman
Next: Jonathan Nieder
Message 1 of 3 in “git stash syntax error under AIX 5.3”
  1. Brian RiehmanNov 3, 2010
  2. Jonathan NiederNov 3, 2010
  3. Brian RiehmanNov 3, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.