Skip to content

Commit d491c8b

Browse files
committed
RF: Use shlex to correctly identify the executable
1 parent 73e4d9a commit d491c8b

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

nipype/interfaces/base/core.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import platform
2727
import select
2828
import subprocess as sp
29+
import shlex
2930
import sys
3031
from textwrap import wrap
3132
import simplejson as json
@@ -987,27 +988,15 @@ def _run_interface(self, runtime, correct_return_codes=(0, )):
987988
runtime.environ.update(out_environ)
988989

989990
# which $cmd
990-
executable_name = self.cmd.split()[0]
991-
992-
prefix_parts = self._cmd_prefix.split()
993-
r_pre = prefix_parts.pop() if prefix_parts else ''
994-
995-
cmd_path = which(r_pre + executable_name, env=runtime.environ)
991+
executable_name = shlex.split(self._cmd_prefix + self.cmd)[0]
992+
cmd_path = which(executable_name, env=runtime.environ)
996993

997994
if cmd_path is None:
998995
raise IOError(
999996
'No command "%s" found on host %s. Please check that the '
1000997
'corresponding package is installed.' % (executable_name,
1001998
runtime.hostname))
1002999

1003-
if prefix_parts:
1004-
helper_command = which(prefix_parts[0], env=runtime.environ)
1005-
if helper_command is None:
1006-
raise IOError(
1007-
'No command "%s" found on host %s. Please check that the '
1008-
'corresponding package is installed.' % (helper_command,
1009-
runtime.hostname))
1010-
10111000
runtime.command_path = cmd_path
10121001
runtime.dependencies = (get_dependencies(executable_name,
10131002
runtime.environ)

0 commit comments

Comments
 (0)