diff options
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java | 15 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 8 |
2 files changed, 19 insertions, 4 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java index 4061b5600b..2c8273d03c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FSTest.java @@ -172,9 +172,18 @@ public class FSTest { FS fs = FS.DETECTED.newInstance(); assumeTrue(fs instanceof FS_POSIX); - String r = FS.readPipe(fs.userHome(), - new String[] { "bash", "--login", "-c", "foobar" }, + FS.readPipe(fs.userHome(), + new String[] { "/bin/sh", "-c", "exit 1" }, Charset.defaultCharset().name()); - System.out.println(r); + } + + @Test(expected = CommandFailedException.class) + public void testReadPipeCommandStartFailure() + throws CommandFailedException { + FS fs = FS.DETECTED.newInstance(); + + FS.readPipe(fs.userHome(), + new String[] { "this-command-does-not-exist" }, + Charset.defaultCharset().name()); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index 229355c50a..1cc39bd46c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -497,7 +497,13 @@ public abstract class FS { if (env != null) { pb.environment().putAll(env); } - Process p = pb.start(); + Process p; + try { + p = pb.start(); + } catch (IOException e) { + // Process failed to start + throw new CommandFailedException(-1, e.getMessage(), e); + } p.getOutputStream().close(); GobblerThread gobbler = new GobblerThread(p, command, dir); gobbler.start(); |