|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I'm looking for the flag (in bash or ksh or zsh) that disables all
extensions above posix and make shell strictly posix-compliant (without any additions). I found '--posix' flag of bash, but it's something different: it doesn't seem to disable bash-specific extensions. It "Changes the behavior of bash where the default operation *differs* from the POSIX". For example, the ((...)) construct is still interpreted with --posix. So, is there "restrict to posix" flag to bash/ksg/zsh ? (I don't have ash) Thanks Yakov |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
2006-11-01 <1162415665.951538.186790@m73g2000cwd.googlegroups .com>,
Yakov wrote: > I'm looking for the flag (in bash or ksh or zsh) that disables all > extensions above posix and make shell strictly posix-compliant > (without any additions). > > I found '--posix' flag of bash, but it's something different: > it doesn't seem to disable bash-specific extensions. It > "Changes the behavior of bash where the default operation *differs* > from the POSIX". For example, the ((...)) construct is still > interpreted > with --posix. > > So, is there "restrict to posix" flag to bash/ksg/zsh ? (I don't have > ash) Why do you want this? As long as your script doesn't use extensions, it'll run just fine with or without them enabled. ...or are you trying to test your script for posix-compliance by trial and error? don't do that. that's not the way to write a good script. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Jordan Abel wrote:
> Why do you want this? As long as your script doesn't use extensions, > it'll run just fine with or without them enabled. ...or are you trying > to test your script for posix-compliance by trial and error? don't do > that. that's not the way to write a good script. Right! Real Programmers don't need any diagnostics whatsoever. They cat something from the tty into a file, and it not only runs, but is 100% standard-conforming. And they are exempt from ever running tools to find problems in other people's code. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
2006-11-1, 13:14(-08), Yakov:
> I'm looking for the flag (in bash or ksh or zsh) that disables all > extensions above posix and make shell strictly posix-compliant > (without any additions). > > I found '--posix' flag of bash, but it's something different: > it doesn't seem to disable bash-specific extensions. It > "Changes the behavior of bash where the default operation *differs* > from the POSIX". For example, the ((...)) construct is still > interpreted > with --posix. > > So, is there "restrict to posix" flag to bash/ksg/zsh ? (I don't have > ash) [...] There's no such thing as *a* strictly POSIX shell. POSIX allows many different behaviors for the shell, and tells the *script* writer to not rely on this or that behavior of a shell as it is /unspecified/. posh (Policy-compliant Ordinary SHell, based on pdksh) is an attempt at writing a shell with as few extensions as possible. That's probably the closest you can get for your requirement. If your script works ok with ksh88, pdksh, ksh93, bash, and zsh is sh mode and the sh from the *BSDs (ash based POSIX shells), then it may not be POSIX conformant, but you should be safe (as far as portability to POSIX shells is concerned as those are basically the only existing POSIX shell implementations). -- Stéphane |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
2006-11-01 <1162421181.066939.217790@i42g2000cwa.googlegroups .com>,
Kaz Kylheku wrote: > Jordan Abel wrote: >> Why do you want this? As long as your script doesn't use extensions, >> it'll run just fine with or without them enabled. ...or are you trying >> to test your script for posix-compliance by trial and error? don't do >> that. that's not the way to write a good script. > > Right! Real Programmers don't need any diagnostics whatsoever. They cat > something from the tty into a file, and it not only runs, but is 100% > standard-conforming. And they are exempt from ever running tools to > find problems in other people's code. Trial and error isn't the right way to find it. What if your script uses a _command_ that's not in posix? |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
In article <slrnekibq7.dgd.random@rlaptop.random.yi.org>,
Jordan Abel <random@random.yi.org> wrote: > 2006-11-01 <1162421181.066939.217790@i42g2000cwa.googlegroups .com>, > Kaz Kylheku wrote: > > Jordan Abel wrote: > >> Why do you want this? As long as your script doesn't use extensions, > >> it'll run just fine with or without them enabled. ...or are you trying > >> to test your script for posix-compliance by trial and error? don't do > >> that. that's not the way to write a good script. > > > > Right! Real Programmers don't need any diagnostics whatsoever. They cat > > something from the tty into a file, and it not only runs, but is 100% > > standard-conforming. And they are exempt from ever running tools to > > find problems in other people's code. > > Trial and error isn't the right way to find it. What's the better way to confirm that a script only uses POSIX shell features? -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group *** |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
2006-11-01, 23:27(-05), Barry Margolin:
[...] >> Trial and error isn't the right way to find it. > > What's the better way to confirm that a script only uses POSIX shell > features? 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. -- Stéphane |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Stephane CHAZELAS wrote:
> 2006-11-1, 13:14(-08), Yakov: > > I'm looking for the flag (in bash or ksh or zsh) that disables all > > extensions above posix and make shell strictly posix-compliant > > (without any additions). > > > > I found '--posix' flag of bash, but it's something different: > > it doesn't seem to disable bash-specific extensions. It > > "Changes the behavior of bash where the default operation *differs* > > from the POSIX". For example, the ((...)) construct is still > > interpreted > > with --posix. > > > > So, is there "restrict to posix" flag to bash/ksg/zsh ? (I don't have > > ash) > [...] > > posh (Policy-compliant Ordinary SHell, based on pdksh) is an > attempt at writing a shell with as few extensions as possible. > That's probably the closest you can get for your requirement. posh turns out to be the true answer to my question. Thanks Stéphane, you did it again. Yakov |
|
![]() |
| Outils de la discussion | |
|
|