Skip to content

Commit

Permalink
handle error from osuser.Current (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
shueybubbles authored Jan 25, 2024
1 parent bd4012d commit a02c6d7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/sqlcmd/sqlcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ func (s *Sqlcmd) ConnectDb(connect *ConnectSettings, nopw bool) error {
s.vars.Set(SQLCMDUSER, connect.UserName)
} else {
u, e := osuser.Current()
if e != nil {
panic("Unable to get user name")
// osuser.Current() returns an error in some restricted environments
if e == nil {
s.vars.Set(SQLCMDUSER, u.Username)
}
s.vars.Set(SQLCMDUSER, u.Username)
}
if newConnection {
s.Connect = connect
Expand Down

0 comments on commit a02c6d7

Please sign in to comment.