Skip to content

Commit

Permalink
[osh] Fix ${a[@]@A} to generate an attribute for each element
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 1, 2025
1 parent c493cd2 commit 91ce829
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion osh/word_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,18 @@ def _Nullary(self, val, op, var_name, vsub_token, vsub_state):
if cell.nameref:
chars.append('n')

result = value.Str(''.join(chars))
count = 1
with tagswitch(val) as case:
if case(value_e.Undef):
count = 0
elif case(value_e.BashArray):
val = cast(value.BashArray, UP_val)
count = bash_impl.BashArray_Count(val)
elif case(value_e.BashAssoc):
val = cast(value.BashAssoc, UP_val)
count = bash_impl.BashAssoc_Count(val)

result = value.BashArray([''.join(chars)] * count)

else:
e_die('Var op %r not implemented' % lexer.TokenVal(op), op)
Expand Down
2 changes: 1 addition & 1 deletion spec/var-op-bash.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ status=0
status=1
a $'b\\nc'
status=0
a
a a a
status=0
## END

Expand Down

0 comments on commit 91ce829

Please sign in to comment.