/bin/sh portability question

5 messages, 4 authors, 2016-06-15 · open the first message on its own page

/bin/sh portability question

From: Peter Eriksen <hidden>
Date: 2016-06-15 22:42:07

Hello,

It seems things are progressing nicely with regard to
Solaris portability.  However, I still have a few problems:

1) Maybe I didn't notice some new configuration option,
   but strcasestr is still not found with a simple "gmake".

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)?

/Peter

Re: /bin/sh portability question

From: "H. Peter Anvin" <hpa@zytor.com>
Date: 2016-06-15 22:42:07

Peter Eriksen wrote:
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

Re: /bin/sh portability question

From: Morten Welinder <hidden>
Date: 2016-06-15 22:42:07

I think $(foo) is required by POSIX.
Indeed, but Solaris really does not have it.

Morten

Re: /bin/sh portability question

From: Joel Becker <hidden>
Date: 2016-06-15 22:42:07

On Fri, Sep 23, 2005 at 12:48:39PM -0700, H. Peter Anvin wrote:
Peter Eriksen wrote:
quoted
     path=$(dirname $0)
...
     ./git.sh: syntax error at line 4: `path=$' unexpected
I think $(foo) is required by POSIX.
	I believe that Solaris and others (AIX IIRC) have /bin/sh linked
to /bin/ksh, and it behaves as the POSIX shell when run as /bin/ksh, but
behaves as a much more true-to-bourne shell when run as /bin/sh.

Joel

-- 

"Nearly all men can stand adversity, but if you really want to
 test a man's character, give him power."
	- Abraham Lincoln

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127

Re: /bin/sh portability question

From: "H. Peter Anvin" <hpa@zytor.com>
Date: 2016-06-15 22:42:07

Joel Becker wrote:
On Fri, Sep 23, 2005 at 12:48:39PM -0700, H. Peter Anvin wrote:
quoted
Peter Eriksen wrote:
quoted
    path=$(dirname $0)
...
    ./git.sh: syntax error at line 4: `path=$' unexpected
I think $(foo) is required by POSIX.

	I believe that Solaris and others (AIX IIRC) have /bin/sh linked
to /bin/ksh, and it behaves as the POSIX shell when run as /bin/ksh, but
behaves as a much more true-to-bourne shell when run as /bin/sh.
But "sh" is required to be the POSIX shell (XSH page 850.)

Thus, they might have some braindamage where /usr/bin/sh is the POSIX 
shell and /bin/sh is a braindead shell.  Sigh.

	-hpa
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help