Skip to content

Commit

Permalink
[osh-language] Change the 'unset' builtin to delete the cell.
Browse files Browse the repository at this point in the history
We don't set the cell to Undef.

Changed assertions in 'spec/assign'.

We no longer match dash/zsh in most cases.

- Case 24 we have unique behavior, but we always did (/)
- We match bash with one case
- We match mksh with two cases

Addresses issue #706.

This is sort of an experiment.  Let's see if ble.sh runs.  Either way
the semantics are simple, and this appears to be closer to what it
wants.
  • Loading branch information
Andy Chu committed Apr 17, 2020
1 parent d7834ef commit 234fa67
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ def Unset(self, lval, lookup_mode, strict):

with tagswitch(lval) as case:
if case(lvalue_e.Named): # unset x
if 1: # flip this to experiment
if 0: # flip this to experiment
# This behavior is good for test/spec.sh assign -r 24-27
name_map[cell_name].val = value.Undef()
cell.exported = False
Expand Down
19 changes: 13 additions & 6 deletions spec/assign.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ echo "x=$x"
x=temp-binding
x=mutated-temp
x=local
x=mutated-temp
x=global
## END
## OK dash/zsh STDOUT:
x=temp-binding
x=mutated-temp
x=local
x=
x=global
## END
Expand Down Expand Up @@ -343,7 +350,7 @@ x=global
x=temp-binding f
echo "x=$x"

## STDOUT:
## OK dash/zsh STDOUT:
x=temp-binding
x=mutated-temp
x=
Expand All @@ -355,7 +362,7 @@ x=mutated-temp
x=
x=
## END
## BUG bash STDOUT:
## STDOUT:
x=temp-binding
x=mutated-temp
x=global
Expand All @@ -373,13 +380,13 @@ f() {
}
x=global
f
## STDOUT:
## OK dash/bash/zsh STDOUT:
x=global
x=local
- operator = default
:- operator = default
## END
## BUG mksh STDOUT:
## STDOUT:
x=global
x=local
- operator = global
Expand All @@ -397,13 +404,13 @@ f() {
}
x=global
x=temp-binding f
## STDOUT:
## OK dash/zsh STDOUT:
x=temp-binding
x=local
- operator = default
:- operator = default
## END
## BUG mksh STDOUT:
## STDOUT:
x=temp-binding
x=local
- operator = temp-binding
Expand Down
2 changes: 1 addition & 1 deletion test/spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ builtin-dirs() {
}

builtin-vars() {
sh-spec spec/builtin-vars.test.sh --osh-failures-allowed 2 \
sh-spec spec/builtin-vars.test.sh --osh-failures-allowed 1 \
${REF_SHELLS[@]} $ZSH $OSH_LIST "$@"
}

Expand Down

0 comments on commit 234fa67

Please sign in to comment.