git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
To: git@vger.kernel.org, paulus@samba.org
Cc: pietzsch@mycroft.speedport.ip, sunshine@sunshineco.com,
	tair.sabirgaliev@bee.kz, lists@haller-berlin.de,
	"Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Subject: [PATCH 2/3] gitk: avoid fatal error if `exec osascript` fails
Date: Tue,  3 Aug 2021 18:08:59 -0700	[thread overview]
Message-ID: <20210804010900.33133-3-carenas@gmail.com> (raw)
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


  parent reply	other threads:[~2021-08-04  1:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04  1:08 [PATCH 0/3] gitk: macOS improvements Carlo Marcelo Arenas Belón
2021-08-04  1:08 ` [PATCH 1/3] gitk: skip calling osascript to set frontmost for tk >= 8.6 Carlo Marcelo Arenas Belón
2021-08-04  1:08 ` Carlo Marcelo Arenas Belón [this message]
2021-08-04  1:09 ` [PATCH 3/3] gitk: check main window visibility before waiting for it to show Carlo Marcelo Arenas Belón
2021-08-04  6:27   ` Chris Torek
2021-08-04  2:37 ` [PATCH 0/3] gitk: macOS improvements Carlo Arenas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210804010900.33133-3-carenas@gmail.com \
    --to=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=lists@haller-berlin.de \
    --cc=paulus@samba.org \
    --cc=pietzsch@mycroft.speedport.ip \
    --cc=sunshine@sunshineco.com \
    --cc=tair.sabirgaliev@bee.kz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).