# \[bash\]Boucle contenant read infinie

**URL:** <https://www.debian-fr.org/t/bash-boucle-contenant-read-infinie/60319>\
**Category:** Programmation\
**Created:** [Février 21, 2016, 7:19 UTC](https://www.debian-fr.org/t/bash-boucle-contenant-read-infinie/60319 "2016-02-21T19:19:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thuban](https://www.debian-fr.org/user_avatar/www.debian-fr.org/thuban/32/4177_2.png) [@thuban](https://www.debian-fr.org/u/thuban)\
**Post date:** [Février 21, 2016, 7:19 UTC](https://www.debian-fr.org/t/bash-boucle-contenant-read-infinie/60319/1 "2016-02-21T19:19:30Z")

</div>

Je cherche à récupérer ce qu’un utilisateur tape avec [mono]read[/mono]. Cependant, je ne veux pas que ce qu’il écrit soit vide. J’ai donc mis une boucle while :

`local NOMDHOTE=""
while [-z "$NOMDHOTE"]; do
    getndd NOMDHOTE
done`

Ceci fait appel à la fonction [mono]getndd[/mono] suivante :

[code]getndd() {

# met dans $1 le nom de domaine

```
echo "Quel est votre nom de domaine (sans http://)? (ex : mondomaine.com) " 
read -p "Nom de domaine " "$1"

```

}  
[/code]  
Résultat : boucle infinie.  
Je ne comprend pas, et je commence à vouloir quitter bash pour python là… 😒

---

<div class="post-metadata">

**Author:** ![thuban](https://www.debian-fr.org/user_avatar/www.debian-fr.org/thuban/32/4177_2.png) [@thuban](https://www.debian-fr.org/u/thuban)\
**Post date:** [Février 21, 2016, 7:19 UTC](https://www.debian-fr.org/t/bash-boucle-contenant-read-infinie/60319/2 "2016-02-21T19:19:30Z")

</div>

J’ai rien dit, j’avais une autre boucle avant… Du coup il fallait la lancer ainsi : `while read -u 3 LINE
do
  ...
done 3< "${fichier}"`
