Skip to content

Commit

Permalink
[builtin/declare] Use .tag_() instead of .tag
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Mar 21, 2020
1 parent e2c89a0 commit 0bd3c4a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions osh/builtin_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _PrintVariables(mem, cmd_val, arg, print_flags, readonly=False, exported=Fal
cells = {}
for pair in cmd_val.pairs:
name = pair.lval.name
if pair.rval and pair.rval.tag == value_e.Str:
if pair.rval and pair.rval.tag_() == value_e.Str:
name += "=" + cast(value__Str, pair.rval).s
names.append(name)
cells[name] = None
Expand All @@ -67,7 +67,7 @@ def _PrintVariables(mem, cmd_val, arg, print_flags, readonly=False, exported=Fal
if cell is None: continue
val = cell.val

if val.tag == value_e.Undef: continue
if val.tag_() == value_e.Undef: continue
if readonly and not cell.readonly: continue
if exported and not cell.exported: continue
if flag_n == '-' and not cell.nameref: continue
Expand All @@ -76,28 +76,28 @@ def _PrintVariables(mem, cmd_val, arg, print_flags, readonly=False, exported=Fal
if flag_r == '+' and cell.readonly: continue
if flag_x == '-' and not cell.exported: continue
if flag_x == '+' and cell.exported: continue
if flag_a and val.tag != value_e.MaybeStrArray: continue
if flag_A and val.tag != value_e.AssocArray: continue
if flag_a and val.tag_() != value_e.MaybeStrArray: continue
if flag_A and val.tag_() != value_e.AssocArray: continue

if print_flags:
flags = '-'
if cell.nameref: flags += 'n'
if cell.readonly: flags += 'r'
if cell.exported: flags += 'x'
if val.tag == value_e.MaybeStrArray:
if val.tag_() == value_e.MaybeStrArray:
flags += 'a'
elif val.tag == value_e.AssocArray:
elif val.tag_() == value_e.AssocArray:
flags += 'A'
if flags == '-': flags += '-'

decl = 'declare ' + flags + ' ' + name
else:
decl = name

if val.tag == value_e.Str:
if val.tag_() == value_e.Str:
str_val = cast(value__Str, val)
decl += "=" + string_ops.ShellQuote(str_val.s)
elif val.tag == value_e.MaybeStrArray:
elif val.tag_() == value_e.MaybeStrArray:
array_val = cast(value__MaybeStrArray, val)
if None in array_val.strs:
# Note: Arrays with unset elements are printed in the form:
Expand All @@ -116,7 +116,7 @@ def _PrintVariables(mem, cmd_val, arg, print_flags, readonly=False, exported=Fal
if body: body += ' '
body += string_ops.ShellQuote(element or '')
decl += "=(" + body + ")"
elif val.tag == value_e.AssocArray:
elif val.tag_() == value_e.AssocArray:
assoc_val = cast(value__AssocArray, val)
body = ''
for key in sorted(assoc_val.d):
Expand Down

0 comments on commit 0bd3c4a

Please sign in to comment.