Trabajo con un script de shell, funciona bien. Pero cuando la función onLogout está activa, no puedo obtener ningún cuadro de diálogo de osascript. ¿Es posible interrumpir o salir de la función y cuando un usuario hace clic en Aceptar, la función continúa?
#!/bin/bash
onLogout() {
# that works:
if [ "$USER" != "admin" ] && [ "$USER" != "Administrator" ]; then
rm -Rf ~/Downloads/*
rm -Rf ~/Movies/*
rm -Rf ~/Music/*
rm -Rf ~/Pictures/*
rm -Rf ~/Public/*
rm -Rf ~/Desktop/*
fi
# it doesn't work:
res=$(osascript -e 'tell app "System Events" to display dialog "Please save yout Data!" buttons {"Cancel", "OK"} default button 1 with icon caution with title "Important Information!"' 2>/dev/null)
if [[ $res == *OK* ]]; then
# continue logout?
else
# break logout?
fi
exit
}
trap 'onLogout' SIGINT SIGHUP SIGTERM
while true; do
sleep 86400 &
wait $!
done