PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > strictly posix shell mode ?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

strictly posix shell mode ?

Réponse
 
LinkBack Outils de la discussion
Vieux 01/11/2006, 21h14   #1
Yakov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut strictly posix shell mode ?

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

  Réponse avec citation
Vieux 01/11/2006, 22h07   #2
Jordan Abel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: strictly posix shell mode ?

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.
  Réponse avec citation
Vieux 01/11/2006, 22h46   #3
Kaz Kylheku
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: strictly posix shell mode ?

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.

  Réponse avec citation
Vieux 01/11/2006, 23h31   #4
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: strictly posix shell mode ?

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
  Réponse avec citation
Vieux 01/11/2006, 23h35   #5
Jordan Abel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: strictly posix shell mode ?

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?
  Réponse avec citation
Vieux 02/11/2006, 04h27   #6
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: strictly posix shell mode ?

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 ***
  Réponse avec citation
Vieux 02/11/2006, 08h46   #7
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: strictly posix shell mode ?

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
  Réponse avec citation
Vieux 02/11/2006, 09h26   #8
Yakov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: strictly posix shell mode ?

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

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h01.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15813 seconds with 16 queries