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 -n ignores shopt lines in script
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

bash -n ignores shopt lines in script

Réponse
 
LinkBack Outils de la discussion
Vieux 29/07/2007, 14h50   #1
Fred Ma
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut bash -n ignores shopt lines in script

I have a Temp.bash script:

#!/bin/bash

shopt -s extglob
echo * .!(|.|lyx|ddd|lftp|lyx|qt)

If I do

bash -n Temp.bash

the shopt command is ignored, so the following line becomes an error rather than
being properly expanded. I have to do

bash -n -O extglob Temp.bash

A more complicated script may turn various shopt switches on and off at various
points in the script, so fixing the switch position at invocation may not solve
the problem. Is there a simple work around, or is this simply a limitation that
one has to live with? My end goal is simply to check the sanity of syntax
without any side effects.

Thanks.

Fred
  Réponse avec citation
Vieux 29/07/2007, 20h51   #2
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash -n ignores shopt lines in script

2007-07-29, 09:50(-04), Fred Ma:
> I have a Temp.bash script:
>
> #!/bin/bash
>
> shopt -s extglob
> echo * .!(|.|lyx|ddd|lftp|lyx|qt)
>
> If I do
>
> bash -n Temp.bash
>
> the shopt command is ignored, so the following line becomes an error rather than
> being properly expanded. I have to do

[...]

That's what bash -n does. It does *n*ot run the commands, just
parses them.

--
Stéphane
  Réponse avec citation
Vieux 30/07/2007, 03h40   #3
Fred Ma
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: bash -n ignores shopt lines in script

Stephane CHAZELAS wrote:
> 2007-07-29, 09:50(-04), Fred Ma:
>> I have a Temp.bash script:
>>
>> #!/bin/bash
>>
>> shopt -s extglob
>> echo * .!(|.|lyx|ddd|lftp|lyx|qt)
>>
>> If I do
>>
>> bash -n Temp.bash
>>
>> the shopt command is ignored, so the following line becomes an error rather than
>> being properly expanded. I have to do

> [...]
>
> That's what bash -n does. It does *n*ot run the commands, just
> parses them.


OK, thanks.
  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 14h39.


É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,10394 seconds with 11 queries