Skip to content

Commit

Permalink
Use eval to handle any valid bash script and correctly propagate errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Jun 18, 2019
1 parent 2657b41 commit f8dc4d1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions functions/__bass.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ def gen_script():
pipe_r, pipe_w = os.pipe()
if sys.version_info >= (3, 4):
os.set_inheritable(pipe_w, True)
command = '{}\n({}; alias) >&{}'.format(
' '.join(sys.argv[1:]).rstrip().rstrip(';'),
command = 'eval $1 && ({}; alias) >&{}'.format(
env_reader,
pipe_w
)
args = [BASH, '-c', command]
args = [BASH, '-c', command, 'bass', ' '.join(sys.argv[1:])]
subprocess.check_call(args, universal_newlines=True, close_fds=False)
os.close(pipe_w)
with os.fdopen(pipe_r) as f:
Expand Down

0 comments on commit f8dc4d1

Please sign in to comment.