Skip to content

Commit

Permalink
all: apply minor suggestions from gopls
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdan committed Jun 10, 2023
1 parent 5e44798 commit 39a33f6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
5 changes: 3 additions & 2 deletions expand/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,10 @@ formatLoop:
case 'x', 'u', 'U':
i++
max := 2
if c == 'u' {
switch c {
case 'u':
max = 4
} else if c == 'U' {
case 'U':
max = 8
}
digits := readDigits(max, true)
Expand Down
3 changes: 1 addition & 2 deletions expand/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ func (cfg *Config) paramExp(pe *syntax.ParamExp) (string, error) {
if pe.Slice.Length != nil {
str = str[:slicePos(sliceLen)]
}
} else { // elems are already sliced
}
} // else, elems are already sliced
case pe.Repl != nil:
orig, err := Pattern(cfg, pe.Repl.Orig)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions interp/os_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func hasPermissionToDir(info os.FileInfo) bool {
}
uid, err := strconv.Atoi(user.Uid)
if err != nil {
return false // on POSIX systems, Uid should always be a decimal number
}
if uid == 0 {
return true // super-user
Expand Down
5 changes: 1 addition & 4 deletions syntax/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,7 @@ func (p *Parser) extendedGlob() bool {
// We do this after peeking for just one byte, so that the input `echo *`
// followed by a newline does not hang an interactive shell parser until
// another byte is input.
if p.peekBytes("()") {
return false
}
return true
return !p.peekBytes("()")
}
return false
}
Expand Down
2 changes: 1 addition & 1 deletion syntax/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,7 @@ func (p *Parser) caseClause(s *Stmt) {

func (p *Parser) caseItems(stop string) (items []*CaseItem) {
p.got(_Newl)
for p.tok != _EOF && !(p.tok == _LitWord && p.val == stop) {
for p.tok != _EOF && (p.tok != _LitWord || p.val != stop) {
ci := &CaseItem{}
ci.Comments, p.accComs = p.accComs, nil
p.got(leftParen)
Expand Down

0 comments on commit 39a33f6

Please sign in to comment.