commit a89f2fd08cdd5d3e8a0f9c26dc676df38fedae91
Author: Stephan Witt <[email protected]>
Date:   Mon Aug 8 10:36:46 2022 +0200

    Make "open -a" implicit on macOS
    
    Fix for bug #12570 - add simple check for app bundle name and prefix it 
with macOS open command if name matches
---
 src/support/Systemcall.cpp |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp
index 6c96de1..d339e11 100644
--- a/src/support/Systemcall.cpp
+++ b/src/support/Systemcall.cpp
@@ -217,6 +217,21 @@ string const parsecmd(string const & incmd, string & 
infile, string & outfile,
                        }
                } else if (c == '<' && !(in_double_quote || escaped)) {
                        o = 3;
+#if defined (USE_MACOSX_PACKAGING)
+               } else if (o == 0 && i > 4 && c == ' ' && !(in_double_quote || 
escaped)) {
+                       // if a macOS app is detected with an additional 
argument
+                       // use open command as prefix to get it work
+                       const size_t apos = outcmd[o].rfind(".app");
+                       const size_t len = outcmd[o].length();
+                       const bool quoted = outcmd[o].at(len - 1) == '"' && 
outcmd[o].at(0) == '"';
+                       const string & ocmd = "open -a ";
+                       if (apos != string::npos &&
+                               (apos == (len - 4) || (apos == (len - 5) && 
quoted)) &&
+                               !prefixIs(trim(outcmd[o]), ocmd)) {
+                               outcmd[o] = ocmd + outcmd[o];
+                       }
+                       outcmd[o] += c;
+#endif
                } else {
                        if (escaped && in_double_quote)
                                outcmd[o] += '\\';
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to