[PATCH 2/3] gitk: avoid fatal error if `exec osascript` fails
- From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
- Date
- Aug 4, 2021, 01:08 UTC
- Message-ID
- <20210804010900.33133-3-carenas@gmail.com>
- In-Reply-To
- <20210804010900.33133-1-carenas@gmail.com>
starting with macOS 10.14 calling "System Events" requires an "Automation" grant, that will result in a fatal error showing:
Error in startup script: 66:111: execution error: Not authorized to send Apple events to System Events. (-1743)
instead of aborting catch the error and print a suitable warning.
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> --- gitk | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/gitk b/gitk index f68d983..b62c12f 100755 --- a/gitk +++ b/gitk @@ -12291,11 +12291,15 @@ if {[catch {package require Tk 8.4} err]} { # on macOS bring the current Wish process window to front if needed if {[tk windowingsystem] eq "aqua"} { if {$tcl_version < 8.6} { - exec osascript -e [format { - tell application "System Events" - set frontmost of processes whose unix id is %d to true - end tell - } [pid] ] + if {[catch { + exec osascript -e [format { + tell application "System Events" + set frontmost of processes whose unix id is %d to true + end tell + } [pid] ] + } ]} { + puts stderr [mc "Warning: 'System Events' access denied"] + } } }
-- 2.33.0.rc0.433.g9a510e7e11