diff --git a/expand/expand.go b/expand/expand.go index 7b225180..996d496f 100644 --- a/expand/expand.go +++ b/expand/expand.go @@ -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) diff --git a/expand/param.go b/expand/param.go index bf0d2382..1f1a475f 100644 --- a/expand/param.go +++ b/expand/param.go @@ -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 { diff --git a/interp/os_unix.go b/interp/os_unix.go index 1a14e465..e393399c 100644 --- a/interp/os_unix.go +++ b/interp/os_unix.go @@ -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 diff --git a/syntax/lexer.go b/syntax/lexer.go index 583abb61..6e9aef44 100644 --- a/syntax/lexer.go +++ b/syntax/lexer.go @@ -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 } diff --git a/syntax/parser.go b/syntax/parser.go index 048a919c..feeae949 100644 --- a/syntax/parser.go +++ b/syntax/parser.go @@ -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)