On 8/4/2022 4:06 PM, Dan Espen wrote:
[email protected] writes:
On Thu, 04 Aug 2022 20:28:06 GMT
[email protected] (Scott Lurndal) wrote:
[email protected] writes:
Should. How often do you see it in practice?
100%. As noted in other posts, we use a number of different interactive >>>> shells, and a number of scripting languages (tcsh, ksh, bash, perl, python,
tcl, et alia). And that's been true for every POE I've worked in for
the last three plus decades (system or processor OEMs primarily).
Don't believe you. I've seen more scripts than I can count that didn't
have the hash bang at the start. No idea what a she-bang is. Sounds like >>> a service for sailors in a port.
Well, where I worked, every shell script we shipped to customers had
a hash bang. Feel free to not believe me too.
Likewise, 100% of the shell scripts shipped to customers or used as a
tool has a shebang.
Where I work 100% of (hundreds of) shell scripts shipped to customers
do not have a #! line. That's because they are required to conform to
POSIX, and POSIX says that if the first line starts with #! the results
are unspecified.
John McCue <[email protected]> writes:
Geoff Clare <[email protected]d> wrote:
<snip>
Where I work 100% of (hundreds of) shell scripts shipped to customers
do not have a #! line. That's because they are required to conform to
POSIX, and POSIX says that if the first line starts with #! the results
are unspecified.
I never read POSIX, but '#!' statement is very odd. I do
not doubt POSIX says that since I think it was first done
many decades ago by a US Gov committee.
IEEE, not the US Government.
That statement would make my head spin, as you know, a '#'
is a comment in all the shells I am aware of.
The phrase "good enough for Gov Work" comes to mind :)
Yes, # introduces a comment in most shells.
I haven't found that statement in POSIX about #!, but I presume the
reason is that saying it's unspecified allows the usual implementation
while not requiring POSIX to specify the behavior.
If POSIX said nothing about #! then it would imply that it has to be
treated as an ordinary comment.
Since the #! feature is nearly universal for Unix-like systems and
predates POSIX, I'm not sure why POSIX didn't standardize it.
Geoff Clare <[email protected]d> wrote:
<snip>
Where I work 100% of (hundreds of) shell scripts shipped to customers
do not have a #! line. That's because they are required to conform to
POSIX, and POSIX says that if the first line starts with #! the results
are unspecified.
I never read POSIX, but '#!' statement is very odd. I do
not doubt POSIX says that since I think it was first done
many decades ago by a US Gov committee.
That statement would make my head spin, as you know, a '#'
is a comment in all the shells I am aware of.
The phrase "good enough for Gov Work" comes to mind :)
On Fri, 05 Aug 2022 12:32:01 -0700, Keith Thompson wrote:
Yes, # introduces a comment in most shells.
I haven't found that statement in POSIX about #!, but I presume the
reason is that saying it's unspecified allows the usual implementation
while not requiring POSIX to specify the behavior.
I'd assume this as well.
In comp.unix.shell, Lew Pitcher <[email protected]> wrote:
On Fri, 05 Aug 2022 12:32:01 -0700, Keith Thompson wrote:
Yes, # introduces a comment in most shells.
And indeed, #! is a comment _to the shell_. It's not a comment to the
kernel running exec(), there it specifies what intrepreter to use. (ELF
and a.out are other interpreters that have different file identification methods.)
I haven't found that statement in POSIX about #!, but I presume the
reason is that saying it's unspecified allows the usual implementation
while not requiring POSIX to specify the behavior.
I'd assume this as well.
Some unix systems have required a space, eg '#! /bin/sh' and some
require no space, so right away I can imagine POSIX has trouble. Then there's the
issue of arguments on the #! line.
Tools like Perl might examine the #! line and do intelligent things with
it. Or may see ^# and just treat it as another comment.
$ cat > /tmp/eg
#!/bin/ksh
ps -lp $$
^D
$ perl /tmp/eg
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
13785 7025 2460 0 85 0 18036 1836 pause S+ pts/34 0:00.01 /bin/ksh
$
Elijah
------
#!/bin/env is another fun quirk
Ed Morton wrote:
On 8/4/2022 4:06 PM, Dan Espen wrote:
[email protected] writes:
On Thu, 04 Aug 2022 20:28:06 GMT
[email protected] (Scott Lurndal) wrote:
[email protected] writes:
Should. How often do you see it in practice?
100%. As noted in other posts, we use a number of different interactive >>>>> shells, and a number of scripting languages (tcsh, ksh, bash, perl, python,
tcl, et alia). And that's been true for every POE I've worked in for >>>>> the last three plus decades (system or processor OEMs primarily).
Don't believe you. I've seen more scripts than I can count that didn't >>>> have the hash bang at the start. No idea what a she-bang is. Sounds like >>>> a service for sailors in a port.
Well, where I worked, every shell script we shipped to customers had
a hash bang. Feel free to not believe me too.
Likewise, 100% of the shell scripts shipped to customers or used as a
tool has a shebang.
Where I work 100% of (hundreds of) shell scripts shipped to customers
do not have a #! line. That's because they are required to conform to
POSIX, and POSIX says that if the first line starts with #! the results
are unspecified.
John McCue <[email protected]> writes:
Geoff Clare <[email protected]d> wrote:
<snip>
Where I work 100% of (hundreds of) shell scripts shipped to customers
do not have a #! line. That's because they are required to conform to
POSIX, and POSIX says that if the first line starts with #! the results
are unspecified.
I never read POSIX, but '#!' statement is very odd. I do
not doubt POSIX says that since I think it was first done
many decades ago by a US Gov committee.
IEEE, not the US Government.
That statement would make my head spin, as you know, a '#'
is a comment in all the shells I am aware of.
The phrase "good enough for Gov Work" comes to mind :)
Yes, # introduces a comment in most shells.
I haven't found that statement in POSIX about #!, but I presume the
reason is that saying it's unspecified allows the usual implementation
while not requiring POSIX to specify the behavior.
Since the #! feature is nearly universal for Unix-like systems and
predates POSIX, I'm not sure why POSIX didn't standardize it.
Keith Thompson wrote:
Since the #! feature is nearly universal for Unix-like systems and
predates POSIX, I'm not sure why POSIX didn't standardize it.
I think it is mainly because POSIX doesn't specify pathnames for
utilities. It is very common to start a shell script with #! /bin/sh
but on Solaris 10 and earlier that would get you an old Bourne shell,
not a POSIX conforming shell (which would need #! /usr/xpg4/bin/sh).
So even if POSIX specified #!, portable applications wouldn't be
able to hard-code that line. They would need a config/install process
that finds the right version of sh (or whatever utility) and adds or
updates the #! line.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 714 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 140:49:16 |
| Calls: | 12,087 |
| Files: | 14,998 |
| Messages: | 6,517,428 |