Permalink
Browse files
EvalLhs() must be public; fix bug introduced in a previous commit.
Unrelated: Add error when the declare/typeset builtins aren't passed any
arguments.
- Loading branch information...
Showing
with
26 additions
and
16 deletions.
-
+22
−14
core/builtin.py
-
+4
−2
core/expr_eval.py
|
|
@@ -947,23 +947,31 @@ def DeclareTypeset(argv, mem, funcs): |
|
|
# osh, they're identical and behave like -F.
|
|
|
|
|
|
if arg.f or arg.F: # Lookup and print functions.
|
|
|
for name in argv[i:]:
|
|
|
if name in funcs:
|
|
|
print(name)
|
|
|
# TODO: Could print LST, or render LST. Bash does this.
|
|
|
#print(funcs[name])
|
|
|
else:
|
|
|
status = 1
|
|
|
names = argv[i:]
|
|
|
if names:
|
|
|
for name in names:
|
|
|
if name in funcs:
|
|
|
print(name)
|
|
|
# TODO: Could print LST, or render LST. Bash does this.
|
|
|
#print(funcs[name])
|
|
|
else:
|
|
|
status = 1
|
|
|
else:
|
|
|
raise NotImplementedError('declare/typeset -f without args')
|
|
|
|
|
|
elif arg.p: # Lookup and print variables.
|
|
|
|
|
|
for name in argv[i:]:
|
|
|
val = mem.GetVar(name)
|
|
|
if val.tag != value_e.Undef:
|
|
|
# TODO: Print flags.
|
|
|
print(name)
|
|
|
else:
|
|
|
status = 1
|
|
|
names = argv[i:]
|
|
|
if names:
|
|
|
for name in names:
|
|
|
val = mem.GetVar(name)
|
|
|
if val.tag != value_e.Undef:
|
|
|
# TODO: Print flags.
|
|
|
print(name)
|
|
|
else:
|
|
|
status = 1
|
|
|
else:
|
|
|
raise NotImplementedError('declare/typeset -p without args')
|
|
|
|
|
|
else:
|
|
|
raise NotImplementedError
|
|
|
|
|
|
@@ -136,9 +136,11 @@ def _LookupVar(name, mem, exec_opts): |
|
|
return val
|
|
|
|
|
|
|
|
|
def _EvalLhs(node, arith_ev, mem, exec_opts):
|
|
|
def EvalLhs(node, arith_ev, mem, exec_opts):
|
|
|
"""Evaluate the operand for a++ a[0]++ as an R-value.
|
|
|
|
|
|
Used by Executor as well.
|
|
|
|
|
|
Args:
|
|
|
node: osh_ast.lhs_expr
|
|
|
|
|
|
@@ -225,7 +227,7 @@ def _EvalLhsToArith(self, node): |
|
|
Returns:
|
|
|
int or list of strings, runtime.lvalue
|
|
|
"""
|
|
|
val, lval = _EvalLhs(node, self, self.mem, self.exec_opts)
|
|
|
val, lval = EvalLhs(node, self, self.mem, self.exec_opts)
|
|
|
#log('Evaluating node %r -> %r', node, val)
|
|
|
return self._ValToArithOrError(val), lval
|
|
|
|
|
|
|
0 comments on commit
f782759