Permalink
Browse files

Many bug fixes, new tests, and test reorganization.

- Many bug fixes and code improvements for prefix ops like ${#a},
  suffix ops like ${a%suffix}, and test operations like ${a:-}.  Rewrite
  _EvalBracedVarSub to use value instead of part_value.  More consistent
  undefined handling, etc.

- Partial bug fix for $? of pipelines.  This uncovered a
  nondeterministic bug in $PIPESTATUS which still needs to be fixed.

- Various array bug fixes.

- Add new special-vars test for $?, $#, etc.

- Move array-decay to its own test, since it's a non-Oil feature.
  • Loading branch information...
Andy Chu
Andy Chu committed Mar 22, 2017
1 parent 5f24348 commit 5502d07695e819401ef50d7e5f1c1b00c58b1f3a
View
@@ -695,6 +695,7 @@ def _RunPipeline(self, node):
# TODO: Set PipeStatus() in self.mem
pipe_status = pi.Run()
#log('pipe_status %s', pipe_status)
if self.exec_opts.pipefail:
# If any process failed, the status of the entire pipeline is 1.
@@ -734,15 +735,6 @@ def _Execute(self, node):
p = Process(thunk, fd_state=self.fd_state, redirects=redirects)
status = p.Run()
if os.WIFEXITED(status):
status = os.WEXITSTATUS(status)
#print('exited with code', code)
else:
sig = os.WTERMSIG(status)
#print('exited with signal', sig)
# TODO: Is this right?
status = 0
else: # Internal
for r in redirects:
r.ApplyInParent(self.fd_state)
View
@@ -14,7 +14,7 @@
import os
import sys
from core import util # log
from core.util import log
from core.id_kind import REDIR_DEFAULT_FD
@@ -310,8 +310,8 @@ def RunInParent(self):
try:
os.execvpe(self.argv[0], self.argv, env)
except OSError as e:
util.log('Unexpected error in execvpe(%r, %r, ...): %s', self.argv[0],
self.argv, e)
log('Unexpected error in execvpe(%r, %r, ...): %s', self.argv[0],
self.argv, e)
# Command not found means 127. TODO: Are there other cases?
sys.exit(127)
# no return
@@ -471,11 +471,18 @@ def Start(self):
for r in self.redirects: # here docs
r.AfterForkInParent()
# TODO: Should be a free function. Not using self!
def Wait(self):
# NOTE: Need to check errors
wait_pid, status = os.wait()
# TODO: split up status?
# TODO: change status in more cases.
if os.WIFSIGNALED(status):
pass
elif os.WIFEXITED(status):
status = os.WEXITSTATUS(status)
#log('exit status: %s', status)
return status
def Run(self):
@@ -537,13 +544,17 @@ def Run(self):
for p in self.procs:
#print('start', p)
p.Start()
# TODO: Return pid
pipe_status = []
# TODO: Could do some sort of garbage collection here too.
for p in self.procs:
#print('Wait', p)
pipe_status.append(p.Wait())
# BUG: This doesn't do things in order! It just calls os.wait()!
# Need to key off wait_pid
status = p.Wait()
#log('Process %s returned status %s', p, status)
pipe_status.append(status)
return pipe_status
Oops, something went wrong.

0 comments on commit 5502d07

Please sign in to comment.