Skip to content
Snippets Groups Projects
Commit 328008aa authored by Thomas Wolf's avatar Thomas Wolf Committed by Matthias Sohn
Browse files

FS_POSIX.runInShell(): on MacOS use a login shell


On Mac, $PATH for UI programs is not the same as in a shell (terminal).
It is typically much shorter. This may lead to surprises when hooks that
work fine via the command-line git do not work when run via JGit in a UI
application, such as EGit in Eclipse.

Therefore use a login shell to run hooks and other commands spawned by
git if we're on MacOS. This will give the hooks the same environment as
in a terminal.

Bug: egit-16
Change-Id: Id2e5485c6d3080d3ef8baa61ad7f6f198f77c590
Signed-off-by: default avatarThomas Wolf <twolf@apache.org>
parent da7a88bc
No related branches found
No related tags found
No related merge requests found
......@@ -250,8 +250,12 @@ private static void apply(Set<PosixFilePermission> set,
/** {@inheritDoc} */
@Override
public ProcessBuilder runInShell(String cmd, String[] args) {
List<String> argv = new ArrayList<>(4 + args.length);
List<String> argv = new ArrayList<>(5 + args.length);
argv.add("sh"); //$NON-NLS-1$
if (SystemReader.getInstance().isMacOS()) {
// Use a login shell to get the full normal $PATH
argv.add("-l"); //$NON-NLS-1$
}
argv.add("-c"); //$NON-NLS-1$
argv.add(cmd + " \"$@\""); //$NON-NLS-1$
argv.add(cmd);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment