def _DEPREC_bash_run(cmd, suppress_err=0):
if not U.f_exists('~/.bashrc'):
print('WARNING: ~/.bashrc not found. '
'bash_output() will not be able to read the aliases.', file=sys.stderr)
# hack: if you don't echo something first, your alias such as `ll` will
# kill the script after it's run.
# https://stackoverflow.com/questions/45558993/subprocess-interactive-bash-behavior
cmd = 'printf ""; ' + cmd
err = pc.DEVNULL if suppress_err else pc.STDOUT
proc = pc.check_output(['/bin/bash', '-i', '-c', cmd],
stderr=err,
).decode()
# try:
# err = pc.DEVNULL if suppress_err else None
# return pc.check_output(['/bin/bash', '-i', '-c', cmd],
# stderr=err,
# ).decode()
# except pc.CalledProcessError as exc:
# if suppress_err:
# print('Failed bash call:\n', exc.output.decode(), file=sys.stderr)
# raise
评论列表
文章目录