Permalink
Browse files
Bug fix: use default of ' \t\n' if IFS is unset.
- Loading branch information...
Showing
with
26 additions
and
4 deletions.
-
+1
−3
core/cmd_exec.py
-
+1
−1
core/legacy.py
-
+24
−0
spec/word-split.test.sh
|
|
@@ -1121,10 +1121,8 @@ def Execute(self, node, fork_external=True): |
|
|
ui.PrettyPrintError(e, self.arena)
|
|
|
print('osh failed: %s' % e.UserErrorString(), file=sys.stderr)
|
|
|
status = e.exit_status if e.exit_status is not None else 1
|
|
|
# TODO: dump self.mem if requested. Maybe speify with OIL_DUMP_PREFIX.
|
|
|
|
|
|
# TODO: Hook this up
|
|
|
#print('break / continue can only be used inside loop')
|
|
|
#status = 129 # TODO: Fix this. Use correct macros
|
|
|
return status
|
|
|
|
|
|
def RunCommandSub(self, node):
|
|
|
|
|
|
@@ -96,7 +96,7 @@ def _GetSplitter(self): |
|
|
"""Based on the current stack frame, get the splitter."""
|
|
|
val = self.mem.GetVar('IFS')
|
|
|
if val.tag == value_e.Undef:
|
|
|
ifs = ''
|
|
|
ifs = DEFAULT_IFS
|
|
|
elif val.tag == value_e.Str:
|
|
|
ifs = val.s
|
|
|
else:
|
|
|
|
|
|
@@ -150,6 +150,29 @@ IFS=_ |
|
|
argv.py 1${undefined:-"2_3"x_x"4_5"}6
|
|
|
# stdout: ['12_3x', 'x4_56']
|
|
|
|
|
|
### IFS empty doesn't do splitting
|
|
|
IFS=''
|
|
|
x=$(echo -e ' a b\tc\n')
|
|
|
argv $x
|
|
|
## STDOUT:
|
|
|
[' a b\tc']
|
|
|
## END
|
|
|
## N-I dash STDOUT:
|
|
|
['-e a b\tc']
|
|
|
## END
|
|
|
|
|
|
|
|
|
### IFS unset behaves like $' \t\n'
|
|
|
unset IFS
|
|
|
x=$(echo -e ' a b\tc\n')
|
|
|
argv $x
|
|
|
## STDOUT:
|
|
|
['a', 'b', 'c']
|
|
|
## END
|
|
|
## N-I dash STDOUT:
|
|
|
['-e', 'a', 'b', 'c']
|
|
|
## END
|
|
|
|
|
|
|
|
|
# TODO:
|
|
|
# - unquoted args of whitespace are not elided (when IFS = null)
|
|
|
@@ -171,3 +194,4 @@ space=" " |
|
|
AB="A B"
|
|
|
X="X"
|
|
|
Yspaces=" Y "
|
|
|
|
0 comments on commit
ee94047