git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[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
Previous: Chris TorekNext: Carlo Arenas
Message 5 of 6 in “gitk: macOS improvements”
  1. 0/3 gitk: macOS improvementsCarlo Marcelo Arenas Belón, Aug 4, 2021
  2. 1/3 gitk: skip calling osascript to set frontmost for tk >= 8.6Carlo Marcelo Arenas Belón, Aug 4, 2021
  3. 3/3 gitk: check main window visibility before waiting for it to showCarlo Marcelo Arenas Belón, Aug 4, 2021
  4. Chris TorekAug 4, 2021
  5. 2/3 gitk: avoid fatal error if `exec osascript` failsCarlo Marcelo Arenas Belón, Aug 4, 2021
  6. Carlo ArenasAug 4, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.