Re: strictly posix shell mode ?




Stephane CHAZELAS wrote:
2006-11-02, 08:25(-05), Barry Margolin:
[....]
That's not the right question to ask, I'd say.

What's the best way to confirm that a script is POSIX. POSIX
specifies both the shell behavior and also (and actually more
that) how a script should be written. (the script is refered to
as "an application" in POSIX).

I think the only way is to read the POSIX/SUS specification,
and to double check the script with that in hand.

And is that the same answer you'd give if someone asked how to check
whether your program has some other type of bug? Just double check it
by reading it?

I never said that. What I meant is that there was no tool
available to verify the conformance of a script to POSIX or SUS.
And writing such a tool would reveal a complicate task, given
that the shell syntax is not very rigorous, that it is
an interpreted language (can't use a lint type tool, you need to
execute the script to verify it), that the POSIX and SUS
specifications are subject to interpretations and have plenty of
blur/dark areas.

None of these arguments consitute an irrefutable objection against
developing or using a tool which catches a subset of all possible
errors.

In the abstract, the output of a checker is a tri-state value: program
bad/nonconforming, program good/conforming, or undecided. The undecided
state exists because of the dynamic aspects of the language: showing
that a program is free of errors runs into the halting problem.

However, just because the "undecided" output exists does not mean that
a checker is incapable of providing value to the developer.

.



Relevant Pages

  • Re: function definition syntax
    ... :>:>: The latter is POSIX, as well as portable to Bourne shell. ... Or you want to IFS parse without having to save ... In which case it might as well be a separate script - you don't need a function. ... On every POSIX shell I've seen, though I don't thik it's a POSIX ...
    (comp.unix.shell)
  • Re: strictly posix shell mode ?
    ... What's the best way to confirm that a script is POSIX. ... specifies both the shell behavior and also (and actually more ...
    (comp.unix.shell)
  • Re: Need help correcting this Bash function
    ... not need extra code to be portable or efficient. ... >> Why is it better to write a bash script than a script that runs ... >> any POSIX shell. ...
    (comp.unix.shell)
  • Re: 3d question about the POSIX shell specification
    ... Yes, POSIX scripts are executed (by sh, or execvp/execlp, env, ... If they are executed by sh as in "sh script" then the #! ... POSIX sh will execute the script? ... interpreter is specified after #! ...
    (comp.unix.shell)
  • Re: function definition syntax
    ... :> In which case it might as well be a separate script - you don't need a function. ... :>: That's much more reliable than having to remember which syntax ... Always using POSIX ... :> not overlook restoring IFS. ...
    (comp.unix.shell)