Is there some way to make su
ask for the password again in case of a wrong password (just as sudo
does)?
Initially I thought of this:
while ! su -c foo; do
read -n 1 -p "Retry(y/n)?" ch
if [[ "$ch" != "y" ]]; then
break
fi
done
But foo
returns 1 in some cases as well, making it impossible to detect whether a wrong password was entered or if foo
failed.
sudo
in the first place? – terdon Jun 20 '14 at 12:36sudo
on them. (I don't have control over the boxes on which this script will be run). – Jun 20 '14 at 12:39foo
then? Not to keep the root shell open? In that case @psimon's answer should work for you. – terdon Jun 20 '14 at 12:42