Skip to content

Commit 4c737fa

Browse files
committed
Revert "syntax: simplify unset-or-null with null default to just unset"
Per #970, even if the change is technically correct, it can easily lead to confusion for users or unintentional bugs when they tweak the code without noticing the subtlety between null (empty) and unset values. This reverts commit e8ee47f. Fixes #970.
1 parent 450d401 commit 4c737fa

File tree

2 files changed

+0
-9
lines changed

2 files changed

+0
-9
lines changed

syntax/simplify.go

-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import "bytes"
1616
// Remove redundant quotes [[ "$var" == str ]]
1717
// Merge negations with unary operators [[ ! -n $var ]]
1818
// Use single quotes to shorten literals "\$foo"
19-
// Remove redundant param expansion colons ${foo:-}
2019
func Simplify(n Node) bool {
2120
s := simplifier{}
2221
Walk(n, s.visit)
@@ -38,10 +37,6 @@ func (s *simplifier) visit(node Node) bool {
3837
x.Index = s.removeParensArithm(x.Index)
3938
// don't inline params - same as above.
4039

41-
if x.Exp != nil && x.Exp.Op == DefaultUnsetOrNull && x.Exp.Word == nil {
42-
s.modified = true
43-
x.Exp.Op = DefaultUnset
44-
}
4540
if x.Slice == nil {
4641
break
4742
}

syntax/simplify_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ var simplifyTests = [...]simplifyTest{
6767
{"\"fo\\`o\"", "'fo`o'"},
6868
noSimple(`fo"o"bar`),
6969
noSimple(`foo""bar`),
70-
71-
// param expansions
72-
{`${foo:-}`, `${foo-}`},
73-
noSimple(`${foo:-bar}`),
7470
}
7571

7672
func TestSimplify(t *testing.T) {

0 commit comments

Comments
 (0)