Skip to content

Commit a2b500c

Browse files
Initialize console if -U is specified
In absence of console or when console reference line is set to nil, noPwd is set to true which disables password prompt and when console is not initialized, password cannot be read from user. This is why when -i is specified, console is not initialized and we do not see password prompt. This commit initializes console even if -U is specified so that password can be read interactively from user.
1 parent d378b4b commit a2b500c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cmd/sqlcmd/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ func run(vars *sqlcmd.Variables, args *SQLCmdArguments) (int, error) {
208208
}
209209

210210
iactive := args.InputFile == nil && args.Query == ""
211+
uactive := args.UserName != ""
211212
var line sqlcmd.Console = nil
212-
if iactive {
213+
if iactive || uactive {
213214
line = console.NewConsole("")
214215
defer line.Close()
215216
}
@@ -257,7 +258,7 @@ func run(vars *sqlcmd.Variables, args *SQLCmdArguments) (int, error) {
257258
s.Query = args.Query
258259
}
259260
// connect using no overrides
260-
err = s.ConnectDb(nil, !iactive)
261+
err = s.ConnectDb(nil, line == nil)
261262
if err != nil {
262263
return 1, err
263264
}

0 commit comments

Comments
 (0)