File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -62,13 +62,20 @@ func initializeEnvVars() {
6262 if os .Getenv ("SQLCMDSERVER" ) == "" {
6363 os .Setenv ("SQLCMDSERVER" , server )
6464 }
65- if os .Getenv ("SQLCMDUSER" ) == "" {
66- os .Setenv ("SQLCMDUSER" , username )
67- }
68- if os .Getenv ("SQLCMDPASSWORD" ) == "" {
69- os .Setenv ("SQLCMDPASSWORD" , password )
65+
66+ // Username and password should come together, either from the environment
67+ // variables set by the user before the sqlcmd process started, or from the sqlconfig
68+ // for the current context, but if just the environment variable SQLCMDPASSWORD
69+ // is set before the process starts we do not use it, if the user and password is set in sqlconfig.
70+ if username != "" && password != "" { // If not trusted auth
71+ if os .Getenv ("SQLCMDUSER" ) == "" {
72+ os .Setenv ("SQLCMDUSER" , username )
73+ os .Setenv ("SQLCMDPASSWORD" , password )
74+ }
7075 }
76+
7177 }
78+
7279}
7380
7481// isFirstArgModernCliSubCommand is TEMPORARY code, to be removed when
You can’t perform that action at this time.
0 commit comments