Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"--" option in bourne shell

Status
Not open for further replies.

CarlK

Programmer
Dec 15, 2000
3
US
Howdy.

I'm trying to run a bourne shell script that runs fine on other
machines, but when run on HP gives the message "A specified
flag is not valid for this command." The flag on the shebang
line giving the grief is "--".

The general bourne-shell help file for that option (off the web) reads:
-- Does not change any of the flags. This is useful in setting the $1
positional parameter to a string beginning with a - (dash).

Why is this not a valid flag on HP-UX? Or am I missing something?

Further details given below; *any* help much appreciated.

Carl



System info for the machine I'm running on: HP-UX B.11.00 U 9000/800

After experimenting a bit, the following file exhibits the problem:

#!/bin/sh -- -f
echo "OK..."

So does:

#!/bin/sh -- # A comment
echo "OK..."

But this seems to run fine:

#!/bin/sh --
echo "OK..."
 
Is it legal to have more than one argument for shebang? Is it legal to have a comment on shebang line? These may be stupid questions, I've written a few scripts, but haven't ever passed more than one argument to sheband and I've never commented on the same line as shebang. That seems to be the only difference in these scripts is the fact that there is more info to read after "--" in the first two entries. Maybe the "--" is not supposed to have anything after it.
Jon Zimmer
jon.zimmer@pf.net
The software required `Windows 95 or better', so I installed Linux.

 
But bourne-shell is bourne-shell, right? As I say, all three of the forms given
run fine on a Sun...
 
Yes, Bourne is bourne and I have no experience on HP-UX. I was just trying to cover bases. A lot of times what is obvious to one person isn't to another because the other is looking to deeply to see the obvious. Have you tried using another shell scripting language? KSH, CSH ? That script should work just as well under KSH.
Jon Zimmer
jon.zimmer@pf.net
The software required `Windows 95 or better', so I installed Linux.

 
It's illegal to put more than ONE argument in a shebang line. Simply that.
 
On HPUX that's not the bourne shell, that's the POSIX shell ('/usr/bin/sh'), if you specifically need to use the bourne shell set your shell to '/usr/old/bin/sh'.
Mike
michael.j.lacey@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top