Add a fallback when the "ps" command fail in coriolisEnv.py.
This commit is contained in:
parent
87fd1fa7b6
commit
b4fe1a3686
|
@ -157,10 +157,14 @@ def guessShell ( forcedShell ):
|
||||||
, u'/usr/local/bin/csh'
|
, u'/usr/local/bin/csh'
|
||||||
]
|
]
|
||||||
if shellName is None:
|
if shellName is None:
|
||||||
psCommand = subprocess.Popen ( ['ps', '-p', str(os.getppid()) ], stdout=subprocess.PIPE )
|
try:
|
||||||
shell = psCommand.stdout.readlines()[1].decode('utf8')[:-1].split()[3].lstrip('-')
|
psResult = subprocess.run( ['ps', '-p', str(os.getppid()) ], capture_output=True, check=True )
|
||||||
whichCommand = subprocess.Popen ( ['which', shell ], stdout=subprocess.PIPE )
|
shell = psResult.stdout.splitlines()[1].decode('utf8').split()[3].lstrip('-')
|
||||||
shellPath = whichCommand.stdout.readlines()[0][:-1].decode('utf8')
|
whichCommand = subprocess.run( ['which', shell ], capture_output=True, check=True )
|
||||||
|
shellPath = whichCommand.stdout.splitlines()[0].decode('utf8')
|
||||||
|
except Exception:
|
||||||
|
shellPath = u'/bin/bash'
|
||||||
|
print( 'echo "Shell *NOT* guessed, using {}";'.format(shellPath) )
|
||||||
#print( 'GUESSED shellPath={}'.format(shellPath) )
|
#print( 'GUESSED shellPath={}'.format(shellPath) )
|
||||||
else:
|
else:
|
||||||
shellPath = forcedShell
|
shellPath = forcedShell
|
||||||
|
|
Loading…
Reference in New Issue