Skip to content

Commit

Permalink
[cleanup] Remove sys.stdout.flush() in builtin implementations.
Browse files Browse the repository at this point in the history
We now do it after ALL builtins in osh/cmd_exec.py.
  • Loading branch information
Andy Chu committed May 16, 2019
1 parent 0fc1f1b commit 5d54361
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions osh/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,6 @@ def Echo(arg_vec):
if not arg.n:
sys.stdout.write('\n')

# I think the flush fixes a problem with command sub. But it causes
# IOError non-deterministically, when spec/background.test.sh is run in
# parallel with other tests. So just silence it.

# File "/home/andy/git/oil/bin/../core/cmd_exec.py", line 251, in _RunBuiltin
# status = builtin.Echo(argv)
# File "/home/andy/git/oil/bin/../core/builtin.py", line 431, in Echo
# sys.stdout.flush()
# IOError: [Errno 32] Broken pipe
try:
sys.stdout.flush()
except IOError as e:
pass

return 0


Expand Down Expand Up @@ -630,8 +616,6 @@ def _PrintDirStack(dir_stack, style, home_dir):
s = ' '.join(ui.PrettyDir(entry, home_dir) for entry in dir_stack.Iter())
print(s)

sys.stdout.flush()


class Pushd(object):
def __init__(self, mem, dir_stack, errfmt):
Expand Down Expand Up @@ -1102,9 +1086,6 @@ def __call__(self, arg_vec):
# bash prints the function body, busybox ash doesn't.
pass

# REQUIRED because of Python's buffering. A command sub may give the wrong
# result otherwise.
sys.stdout.flush()
return status


Expand Down Expand Up @@ -1159,7 +1140,6 @@ def __call__(self, arg_vec):
else:
raise NotImplementedError

sys.stdout.flush()
return status


Expand Down Expand Up @@ -1328,7 +1308,6 @@ def __call__(self, arg_vec):
# bash prints a line that can be re-parsed.
print('%s %s' % (name, value.__class__.__name__))

sys.stdout.flush()
return 0

if arg.l: # List valid signals and hooks
Expand All @@ -1340,7 +1319,6 @@ def __call__(self, arg_vec):
for name, int_val in ordered:
print('%2d %s' % (int_val, name))

sys.stdout.flush()
return 0

arg_r = args.Reader(arg_vec.strs, spids=arg_vec.spids)
Expand Down

0 comments on commit 5d54361

Please sign in to comment.