summaryrefslogtreecommitdiffstats
path: root/shell/source/unix/exec/shellexec.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:27:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:27:30 +0000
commita2baea7faff31d26459dab3668a39eae85e4991b (patch)
treeeaa2048ce9c715481f932dcfe20368e252b77d2f /shell/source/unix/exec/shellexec.cxx
parentAdding upstream version 4:24.2.0. (diff)
downloadlibreoffice-a2baea7faff31d26459dab3668a39eae85e4991b.tar.xz
libreoffice-a2baea7faff31d26459dab3668a39eae85e4991b.zip
Adding upstream version 4:24.2.1.upstream/4%24.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'shell/source/unix/exec/shellexec.cxx')
-rw-r--r--shell/source/unix/exec/shellexec.cxx30
1 files changed, 25 insertions, 5 deletions
diff --git a/shell/source/unix/exec/shellexec.cxx b/shell/source/unix/exec/shellexec.cxx
index 71137c7d67..153827a003 100644
--- a/shell/source/unix/exec/shellexec.cxx
+++ b/shell/source/unix/exec/shellexec.cxx
@@ -207,12 +207,32 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar
+ aCommand,
getXWeak(), 0);
} else {
+#if defined MACOSX
+ auto usingOpen = false;
+ if (OString pathname8;
+ aCommand.convertToString(
+ &pathname8, RTL_TEXTENCODING_UTF8,
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))
+ {
+ if (struct stat st; stat(pathname8.getStr(), &st) == 0 && S_ISDIR(st.st_mode)) {
+ usingOpen = true;
+ aBuffer.append("open -a ");
+ }
+ }
+#endif
escapeForShell(aBuffer, OUStringToOString(aCommand, osl_getThreadTextEncoding()));
- aBuffer.append(" ");
- if( nFlags != 42 )
- escapeForShell(aBuffer, OUStringToOString(aParameter, osl_getThreadTextEncoding()));
- else
- aBuffer.append(OUStringToOString(aParameter, osl_getThreadTextEncoding()));
+ if (!aParameter.isEmpty()) {
+ aBuffer.append(" ");
+#if defined MACOSX
+ if (usingOpen) {
+ aBuffer.append("--args ");
+ }
+#endif
+ if( nFlags != 42 )
+ escapeForShell(aBuffer, OUStringToOString(aParameter, osl_getThreadTextEncoding()));
+ else
+ aBuffer.append(OUStringToOString(aParameter, osl_getThreadTextEncoding()));
+ }
}
// Prefer DESKTOP_LAUNCH when available