fix issues with csh redirection
This commit is contained in:
parent
b525eedb8e
commit
5a65dce6fb
2 changed files with 6 additions and 4 deletions
|
@ -23,6 +23,7 @@ class ShellModule(ShModule):
|
||||||
|
|
||||||
# How to end lines in a python script one-liner
|
# How to end lines in a python script one-liner
|
||||||
_SHELL_EMBEDDED_PY_EOL = '\\\n'
|
_SHELL_EMBEDDED_PY_EOL = '\\\n'
|
||||||
|
_SHELL_REDIRECT_ALLNULL = '>& /dev/null'
|
||||||
|
|
||||||
def env_prefix(self, **kwargs):
|
def env_prefix(self, **kwargs):
|
||||||
return 'env %s' % super(ShellModule, self).env_prefix(**kwargs)
|
return 'env %s' % super(ShellModule, self).env_prefix(**kwargs)
|
||||||
|
|
|
@ -30,6 +30,7 @@ class ShellModule(object):
|
||||||
|
|
||||||
# How to end lines in a python script one-liner
|
# How to end lines in a python script one-liner
|
||||||
_SHELL_EMBEDDED_PY_EOL = '\n'
|
_SHELL_EMBEDDED_PY_EOL = '\n'
|
||||||
|
_SHELL_REDIRECT_ALLNULL = '> /dev/null 2>&1'
|
||||||
|
|
||||||
def env_prefix(self, **kwargs):
|
def env_prefix(self, **kwargs):
|
||||||
'''Build command prefix with environment variables.'''
|
'''Build command prefix with environment variables.'''
|
||||||
|
@ -53,10 +54,10 @@ class ShellModule(object):
|
||||||
|
|
||||||
def remove(self, path, recurse=False):
|
def remove(self, path, recurse=False):
|
||||||
path = pipes.quote(path)
|
path = pipes.quote(path)
|
||||||
|
cmd = 'rm -f '
|
||||||
if recurse:
|
if recurse:
|
||||||
return "rm -rf %s >/dev/null 2>&1" % path
|
cmd += '-r '
|
||||||
else:
|
return cmd + "%s %s" % (path, self._SHELL_REDIRECT_ALLNULL)
|
||||||
return "rm -f %s >/dev/null 2>&1" % path
|
|
||||||
|
|
||||||
def mkdtemp(self, basefile=None, system=False, mode=None):
|
def mkdtemp(self, basefile=None, system=False, mode=None):
|
||||||
if not basefile:
|
if not basefile:
|
||||||
|
@ -139,5 +140,5 @@ class ShellModule(object):
|
||||||
cmd_parts = [env_string.strip(), shebang.replace("#!", "").strip(), cmd]
|
cmd_parts = [env_string.strip(), shebang.replace("#!", "").strip(), cmd]
|
||||||
new_cmd = " ".join(cmd_parts)
|
new_cmd = " ".join(cmd_parts)
|
||||||
if rm_tmp:
|
if rm_tmp:
|
||||||
new_cmd = '%s; rm -rf "%s" >/dev/null 2>&1' % (new_cmd, rm_tmp)
|
new_cmd = '%s; rm -rf "%s" %s' % (new_cmd, rm_tmp, self._SHELL_REDIRECT_ALLNULL)
|
||||||
return new_cmd
|
return new_cmd
|
||||||
|
|
Loading…
Reference in a new issue