@@ -131,12 +131,12 @@ func (p *printer) bslashNewl() {
131
131
p .incLine ()
132
132
}
133
133
134
- func (p * printer ) spacedString (s string , spaceAfter bool ) {
134
+ func (p * printer ) spacedString (s string ) {
135
135
if p .wantSpace {
136
136
p .WriteByte (' ' )
137
137
}
138
138
p .WriteString (s )
139
- p .wantSpace = spaceAfter
139
+ p .wantSpace = true
140
140
}
141
141
142
142
func (p * printer ) semiOrNewl (s string , pos Pos ) {
@@ -376,7 +376,7 @@ func (p *printer) loop(loop Loop) {
376
376
case * WordIter :
377
377
p .WriteString (x .Name .Value )
378
378
if len (x .List ) > 0 {
379
- p .spacedString (" in" , true )
379
+ p .spacedString (" in" )
380
380
p .wordJoin (x .List , true )
381
381
}
382
382
case * CStyleLoop :
@@ -506,7 +506,7 @@ func (p *printer) wordJoin(ws []*Word, backslash bool) {
506
506
507
507
func (p * printer ) stmt (s * Stmt ) {
508
508
if s .Negated {
509
- p .spacedString ("!" , true )
509
+ p .spacedString ("!" )
510
510
}
511
511
p .assigns (s .Assigns )
512
512
var startRedirs int
@@ -585,7 +585,7 @@ func (p *printer) command(cmd Command, redirs []*Redirect) (startRedirs int) {
585
585
p .nestedStmts (x .Stmts , x .Rbrace )
586
586
p .semiRsrv ("}" , x .Rbrace , true )
587
587
case * IfClause :
588
- p .spacedString ("if" , true )
588
+ p .spacedString ("if" )
589
589
p .nestedStmts (x .CondStmts , 0 )
590
590
p .semiOrNewl ("then" , x .Then )
591
591
p .nestedStmts (x .ThenStmts , 0 )
@@ -608,13 +608,13 @@ func (p *printer) command(cmd Command, redirs []*Redirect) (startRedirs int) {
608
608
p .nestedStmts (x .Stmts , x .Rparen )
609
609
p .sepTok (")" , x .Rparen )
610
610
case * WhileClause :
611
- p .spacedString ("while" , true )
611
+ p .spacedString ("while" )
612
612
p .nestedStmts (x .CondStmts , 0 )
613
613
p .semiOrNewl ("do" , x .Do )
614
614
p .nestedStmts (x .DoStmts , 0 )
615
615
p .semiRsrv ("done" , x .Done , true )
616
616
case * ForClause :
617
- p .spacedString ("for " , false )
617
+ p .WriteString ("for " )
618
618
p .loop (x .Loop )
619
619
p .semiOrNewl ("do" , x .Do )
620
620
p .nestedStmts (x .DoStmts , 0 )
@@ -651,7 +651,7 @@ func (p *printer) command(cmd Command, redirs []*Redirect) (startRedirs int) {
651
651
p .bslashNewl ()
652
652
p .indent ()
653
653
}
654
- p .spacedString (x .Op .String (), true )
654
+ p .spacedString (x .Op .String ())
655
655
p .incLines (x .Y .Pos ())
656
656
p .stmt (x .Y )
657
657
if indent {
@@ -667,15 +667,15 @@ func (p *printer) command(cmd Command, redirs []*Redirect) (startRedirs int) {
667
667
p .incLines (x .Body .Pos ())
668
668
p .stmt (x .Body )
669
669
case * CaseClause :
670
- p .spacedString ("case " , false )
670
+ p .WriteString ("case " )
671
671
p .word (x .Word )
672
672
p .WriteString (" in" )
673
673
p .incLevel ()
674
674
for _ , pl := range x .List {
675
675
p .commentsAndSeparate (pl .Patterns [0 ].Pos ())
676
676
for i , w := range pl .Patterns {
677
677
if i > 0 {
678
- p .spacedString ("|" , true )
678
+ p .spacedString ("|" )
679
679
}
680
680
if p .wantSpace {
681
681
p .WriteByte (' ' )
@@ -691,7 +691,7 @@ func (p *printer) command(cmd Command, redirs []*Redirect) (startRedirs int) {
691
691
p .commentsUpTo (pl .OpPos )
692
692
p .newlines (pl .OpPos )
693
693
}
694
- p .spacedString (pl .Op .String (), true )
694
+ p .spacedString (pl .Op .String ())
695
695
p .incLines (pl .OpPos )
696
696
p .level --
697
697
if sep || pl .OpPos == x .Esac {
@@ -701,7 +701,7 @@ func (p *printer) command(cmd Command, redirs []*Redirect) (startRedirs int) {
701
701
p .decLevel ()
702
702
p .semiRsrv ("esac" , x .Esac , len (x .List ) == 0 )
703
703
case * UntilClause :
704
- p .spacedString ("until" , true )
704
+ p .spacedString ("until" )
705
705
p .nestedStmts (x .CondStmts , 0 )
706
706
p .semiOrNewl ("do" , x .Do )
707
707
p .nestedStmts (x .DoStmts , 0 )
@@ -711,34 +711,34 @@ func (p *printer) command(cmd Command, redirs []*Redirect) (startRedirs int) {
711
711
p .arithmExpr (x .X , false )
712
712
p .WriteString ("))" )
713
713
case * TestClause :
714
- p .spacedString ("[[ " , false )
714
+ p .WriteString ("[[ " )
715
715
p .testExpr (x .X )
716
- p .spacedString ("]]" , true )
716
+ p .spacedString ("]]" )
717
717
case * DeclClause :
718
718
name := x .Variant
719
719
if name == "" {
720
720
name = "declare"
721
721
}
722
- p .spacedString (name , true )
722
+ p .spacedString (name )
723
723
for _ , w := range x .Opts {
724
724
p .WriteByte (' ' )
725
725
p .word (w )
726
726
}
727
727
p .assigns (x .Assigns )
728
728
case * EvalClause :
729
- p .spacedString ("eval" , true )
729
+ p .spacedString ("eval" )
730
730
if x .Stmt != nil {
731
731
p .stmt (x .Stmt )
732
732
}
733
733
case * CoprocClause :
734
- p .spacedString ("coproc" , true )
734
+ p .spacedString ("coproc" )
735
735
if x .Name != nil {
736
736
p .WriteByte (' ' )
737
737
p .WriteString (x .Name .Value )
738
738
}
739
739
p .stmt (x .Stmt )
740
740
case * LetClause :
741
- p .spacedString ("let" , true )
741
+ p .spacedString ("let" )
742
742
for _ , n := range x .Exprs {
743
743
p .WriteByte (' ' )
744
744
p .arithmExpr (n , true )
0 commit comments