J'l'aime mieux comme ca moi ton script = þ
#!/bin/sh
### déclaration de fonction
CHOIX_FAVORIS () {
echo "1:google"
echo "2:journaldugeek"
echo "3:frandroid"
echo "4:site du zéro"
echo "5:communaute ubuntu"
echo "quitter ( ou ctrl C ) : quitter"
read -p "choix ? " CHOIX
}
### Corps du script
CHOIX_FAVORIS # ici on appel la fonction déclarée ci-dessus et qui sert à afficher les choix possibles de favoris et à en sélectionner un
### Ici on compare le choix aux options disponibles
case $CHOIX in
1) FAVORI="www.google.fr" ;;
2) FAVORI="www.journaldugeek.com" ;;
3) FAVORI="www.frandroid.com" ;;
4) FAVORI="www.siteduzero.com" ;;
5) FAVORI="www.ubuntu-fr.org" ;;
quitter) exit 0 ;;
*) echo "Choix invalide" ; CHOIX_FAVORIS
esac
exec w3m $FAVORI
Pas testé avec w3m mais testé avec firefox et le script fonctionne... = )
Voila une petite modif au cas où tu souhaiterais une boucle infinie plutot qu'une boucle simple:
#!/bin/sh
### déclaration de fonction
CHOIX_FAVORIS() {
echo "1:google"
echo "2:journaldugeek"
echo "3:frandroid"
echo "4:site du zéro"
echo "5:communaute ubuntu"
echo "quitter ( ou ctrl C ) : quitter"
read -p "choix ? " CHOIX
TEST
}
TEST() {
case $CHOIX in
1) FAVORI="www.google.fr" ;;
2) FAVORI="www.journaldugeek.com" ;;
3) FAVORI="www.frandroid.com" ;;
4) FAVORI="www.siteduzero.com" ;;
5) FAVORI="www.ubuntu-fr.org" ;;
quitter) exit 0 ;;
*) echo "Choix invalide" ; CHOIX_FAVORIS
esac
}
### Corps du script
CHOIX_FAVORIS