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

Re: /bin/sh portability question

From
HAH. Peter Anvin <hpa@zytor.com>
Date
Sep 23, 2005, 19:48 UTC
Message-ID
<43345C17.7060402@zytor.com>
In-Reply-To
<20050923075058.GA25473@bohr.gbar.dtu.dk>
Peter Eriksen wrote:
Show 22 quoted lines
> 
> 2) In many of the shell scripts there is the idiom:
> 
>       #!/bin/sh
>       
>       cmd=
>       path=$(dirname $0)
>       case "$#" in
>       0)      ;;
>       *)      cmd="$1"
>               shift
>  
>    When run, this gives the error:
> 
>       ./git.sh: syntax error at line 4: `path=$' unexpected
> 
>    I think it's because (on my Solaris at least), sh is really 
>    sh and is not symlinked to bash, and sh doesn't like that 
>    syntax.  Are there any good solutions to this other than
>    making the administrators actually change sh to a symlink,
>    (which I tried)?
> 
I think $(foo) is required by POSIX.
	-hpa
Previous: Patrick MauritzNext: Morten Welinder
Message 10 of 16 in “/bin/sh portability question”
  1. Peter EriksenSep 23, 2005
  2. Junio C HamanoSep 23, 2005
  3. SeanSep 23, 2005
  4. Junio C HamanoSep 23, 2005
  5. SeanSep 23, 2005
  6. Junio C HamanoSep 23, 2005
  7. Peter EriksenSep 23, 2005
  8. Junio C HamanoSep 24, 2005
  9. Patrick MauritzSep 24, 2005
  10. H. Peter AnvinSep 23, 2005
  11. Morten WelinderSep 23, 2005
  12. Joel BeckerSep 23, 2005
  13. H. Peter AnvinSep 23, 2005
  14. Junio C HamanoSep 24, 2005
  15. Nico -telmich- SchotteliusSep 25, 2005
  16. SeanSep 25, 2005

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.