Is it possible to prompt for user input when calling a function in bash?
Take this for example:
#!/bin/bash
test1(){
echo "Do you wish to install this program?"
select yn in "Yes" "No"; do
case $yn in
Yes ) make install; break;;
No ) exit;;
esac
done
}
pip list 2>/dev/null | if grep httplib2; then echo 2>/dev/null; else test1; fi
Disregard the fact I'm checking for httplib2 because I know that works fine if you else echo "Test". I've tried this with examples from stackoverflow and tldp, so I'm kind of confused now.
Can you not catch user input from a piped if statement?
Just tested with
pip list 2>/dev/null | if grep httplib2; then
echo 2>/dev/null;
else
echo "Type the year that you want to check (4 digits), followed by [ENTER]:"
read year
echo $year
fi
as well and had the same effect.
Aucun commentaire:
Enregistrer un commentaire