Erreur de syntaxe près du symbole inattendu « fi »
Fermé
BashLinux
-
9 nov. 2015 à 15:37
jisisv Messages postés 3645 Date d'inscription dimanche 18 mars 2001 Statut Modérateur Dernière intervention 15 janvier 2017 - 10 nov. 2015 à 23:57
jisisv Messages postés 3645 Date d'inscription dimanche 18 mars 2001 Statut Modérateur Dernière intervention 15 janvier 2017 - 10 nov. 2015 à 23:57
A voir également:
- Erreur de syntaxe près du symbole inattendu « ( »
- Erreur 0x80070643 - Guide
- Symbole attention word ✓ - Forum Word
- Symbole environ ✓ - Forum Graphisme
- Numéro symbole ✓ - Forum Word
- Iptv erreur de lecture - Forum TV & Vidéo
3 réponses
jisisv
Messages postés
3645
Date d'inscription
dimanche 18 mars 2001
Statut
Modérateur
Dernière intervention
15 janvier 2017
933
Modifié par jisisv le 9/11/2015 à 18:10
Modifié par jisisv le 9/11/2015 à 18:10
Remarque ton nom de variable exists n'est pas très heureux (ressemble au mot-clé exit. Utilide plutôt des noms en UPPERCASE_WITH_UNDERSCORES
Ceci dit,
Pour ton test, ton utilisation est erronée , examine ceci:
johand@bata:~$ unset truc
johand@bata:~$ if [ -z $truc ] ; then echo BAD; fi
BAD
johand@bata:~$ if [ -z = "$truc" ] ; then echo BAD; fi
johand@bata:~$ truc=123
johand@bata:~$ if [ -z $truc ] ; then echo BAD; fi ; echo OK
OK
[ -z = $BLAH ] retourne toujours faux !
En outre, et c'est le plus important, le corps du else est vide ce qui fournit une erreur. Supprime cette branche ou mets-y une instruction valide.
exemple:
Gates gave ^W sold you the windows.
GNU gave us the whole house.(Alexandrin)
Ceci dit,
Pour ton test, ton utilisation est erronée , examine ceci:
johand@bata:~$ unset truc
johand@bata:~$ if [ -z $truc ] ; then echo BAD; fi
BAD
johand@bata:~$ if [ -z = "$truc" ] ; then echo BAD; fi
johand@bata:~$ truc=123
johand@bata:~$ if [ -z $truc ] ; then echo BAD; fi ; echo OK
OK
[ -z = $BLAH ] retourne toujours faux !
En outre, et c'est le plus important, le corps du else est vide ce qui fournit une erreur. Supprime cette branche ou mets-y une instruction valide.
exemple:
#!/bin/sh if [ -z $1 ] ; then echo "No param" else # TTT echo "Param1 is $1" fi
Gates gave ^W sold you the windows.
GNU gave us the whole house.(Alexandrin)