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 > Bash POSIX mode and ${var/PATTERN/STRING}
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Bash POSIX mode and ${var/PATTERN/STRING}

Réponse
 
LinkBack Outils de la discussion
Vieux 09/01/2008, 14h53   #1
Eze
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Bash POSIX mode and ${var/PATTERN/STRING}

Greetings,

Correct me if I am wrong, but the parameter expansion ${var/PATTERN/
STRING} (as well as ${var:OFFSET:LENGTH}) is not defined in the POSIX
specification [http://www.opengroup.org/onlinepubs/...399/utilities/
xcu_chap02.html#tag_02_06_02]. I don't understand why running Bash
under POSIX mode [http://theory.uwinnipeg.ca/gnu/bash/bashref_66.html]
does not yield an error when such a substitution is used.

Thanks in advance for your .

Best regards,

Ezequiel
  Réponse avec citation
Vieux 09/01/2008, 15h19   #2
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Bash POSIX mode and ${var/PATTERN/STRING}

On Wed, 9 Jan 2008 06:53:11 -0800 (PST), Eze wrote:
[...]
> Correct me if I am wrong, but the parameter expansion ${var/PATTERN/
> STRING} (as well as ${var:OFFSET:LENGTH}) is not defined in the POSIX
> specification [http://www.opengroup.org/onlinepubs/...399/utilities/
> xcu_chap02.html#tag_02_06_02]. I don't understand why running Bash
> under POSIX mode [http://theory.uwinnipeg.ca/gnu/bash/bashref_66.html]
> does not yield an error when such a substitution is used.

[...]

bash --posix enables the POSIX mode of bash. That is bash will
interpret POSIX scripts the way it is specified by the POSIX
specification.

The ${var:OFFSET:LENGTH} syntax is not POSIX, so an interpreter
is allowed to behave however it wants, wether issuing a syntax
error message or playing a tune or behaving as bash does.

--
Stephane
  Réponse avec citation
Vieux 09/01/2008, 16h29   #3
Eze
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Bash POSIX mode and ${var/PATTERN/STRING}

Thanks Stephane,

My next question then is whether there is a shell that you would
recommend that adheres as closely as possible to POSIX (that is, POSIX
and nothing else) under a suitable mode.
  Réponse avec citation
Vieux 09/01/2008, 17h59   #4
Icarus Sparry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Bash POSIX mode and ${var/PATTERN/STRING}

On Wed, 09 Jan 2008 08:29:39 -0800, Eze wrote:

> Thanks Stephane,
>
> My next question then is whether there is a shell that you would
> recommend that adheres as closely as possible to POSIX (that is, POSIX
> and nothing else) under a suitable mode.


A common answer is ash or dash.
http://gondor.apana.org.au/~herbert/dash/
  Réponse avec citation
Vieux 09/01/2008, 23h33   #5
Eze
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Bash POSIX mode and ${var/PATTERN/STRING}

Thanks to both of you.

  Réponse avec citation
Vieux 10/01/2008, 05h40   #6
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Bash POSIX mode and ${var/PATTERN/STRING}

On Wed, 9 Jan 2008 08:29:39 -0800 (PST), Eze wrote:
[...]
> My next question then is whether there is a shell that you would
> recommend that adheres as closely as possible to POSIX (that is, POSIX
> and nothing else) under a suitable mode.


See debian's posh (policy orientated shell). It's based on
pdksh, and the maintainers tried to remove the features that
were not POSIX.

--
Stephane
  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 19h16.


É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 ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13440 seconds with 14 queries