I'm trying to create a script .sh
to capture the action of a dialog on Mac that shows the buttons No
and Si
, and then execute code depending on the answer, I have not managed to make it take the actions of the user.
This is what I have achieved:
#!/bin/sh
#!/usr/bin/env bash
# error "Message"
function advertencia() {
osascript <<EOT
tell app "System Events"
display dialog "$1" buttons {"No","Si"} default button 2 with icon caution with title "$(basename $0)"
return result
end tell
EOT
}
resultado=$(advertencia "Selecciona una opcion:")
if ["$resultado" == "Si"]; then
advertencia "Seleccionaste Si"
else
advertencia "Seleccionaste no"
fi
But it does not work.