#1 Le 30/11/2016, à 10:51
- Arbiel
[Résolu] Une toute petite erreur que je ne parviens pas à trouver
Bonjour
Je ne parviens pas à trouver mon erreur
remi@remi-Vostro-3550:~$ function aa () {
> declare -a Gbl_forum;
> Gbl_forum[0]='https://forum.ubuntu-fr.org';
> }
remi@remi-Vostro-3550:~$ aa
remi@remi-Vostro-3550:~$ echo ${Gbl_forum[0]}
remi@remi-Vostro-3550:~$
remi@remi-Vostro-3550:~$ Gbl_forum[0]='https://forum.ubuntu-fr.org';
remi@remi-Vostro-3550:~$ echo ${Gbl_forum[0]}
https://forum.ubuntu-fr.org
remi@remi-Vostro-3550:~$
Ma variable Gbl_forum dans la fonction aa n'est pourtant pas "local".
Pourquoi n'est-elle initialisée dans la procédure principale ?
Merci d'avance
Arbiel
Dernière modification par Arbiel (Le 30/11/2016, à 11:51)
Arbiel Perlacremaz
LDLC Aurore NK3S-8-S4 Ubuntu 20.04, GNOME 3.36.8
24.04 en cours de tests
Abandon d'azerty au profit de bépo, de google au profit de Lilo et de la messagerie électronique violable au profit de Protonmail, une messagerie chiffrée de poste de travail à poste de travail.
Hors ligne
#2 Le 30/11/2016, à 11:50
- Arbiel
Re : [Résolu] Une toute petite erreur que je ne parviens pas à trouver
A priori, à l'intérieur d'une fonction, local est implicite avec declare.
Using ‘+’ instead of ‘-’ turns off the attribute instead, with the exceptions that ‘+a’ may not be used to destroy an array variable and ‘+r’ will not remove the readonly attribute. When used in a function, declare makes each name local, as with the local command. If a variable name is followed by =value, the value of the variable is set to value.
remi@remi-Vostro-3550:~$ declare -a Gbl_forum;
remi@remi-Vostro-3550:~$ function aa () {
> Gbl_forum[0]='https://forum.ubuntu-fr.org';
> }
remi@remi-Vostro-3550:~$ aa
remi@remi-Vostro-3550:~$ echo "$Gbl_forum[0]}"
https://forum.ubuntu-fr.org[0]}
remi@remi-Vostro-3550:~$
Arbiel
Dernière modification par Arbiel (Le 30/11/2016, à 11:56)
Arbiel Perlacremaz
LDLC Aurore NK3S-8-S4 Ubuntu 20.04, GNOME 3.36.8
24.04 en cours de tests
Abandon d'azerty au profit de bépo, de google au profit de Lilo et de la messagerie électronique violable au profit de Protonmail, une messagerie chiffrée de poste de travail à poste de travail.
Hors ligne