Created
April 2, 2024 23:15
-
-
Save mamemomonga/11a94a4f8cd939f901547264ada4da9d to your computer and use it in GitHub Desktop.
macOSとシェルスクリプトでダイアログを表示する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# macOSとシェルスクリプトでダイアログを表示する | |
set -eu | |
osadialog() { | |
local text=$1 | |
set +e | |
osascript 2>&1 > /dev/null << EOS | |
tell me | |
activate | |
display dialog "$text" | |
end tell | |
EOS | |
local retval=$? | |
set -e | |
if [ "$retval" == "0" ]; then echo "OK"; else echo "CANCEL"; fi | |
} | |
if [ "$(osadialog 'おはようございます')" == "OK" ]; then | |
echo "OKがおされました" | |
else | |
echo "CANCELがおされました" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment