diff --git a/cmd/sqlcmd/main.go b/cmd/sqlcmd/main.go index 6ee9f7c7..765ad425 100644 --- a/cmd/sqlcmd/main.go +++ b/cmd/sqlcmd/main.go @@ -58,6 +58,8 @@ type SQLCmdArguments struct { ColumnSeparator string `short:"s" help:"Specifies the column separator character. Sets the SQLCMDCOLSEP variable."` ScreenWidth *int `short:"w" help:"Specifies the screen width for output. Sets the SQLCMDCOLWIDTH variable."` TrimSpaces bool `short:"W" help:"Remove trailing spaces from a column."` + MultiSubnetFailover bool `short:"M" help:"Provided for backward compatibility. Sqlcmd always optimizes detection of the active replica of a SQL Failover Cluster."` + Password string `short:"P" help:"Obsolete. The initial passwords must be set using the SQLCMDPASSWORD environment variable or entered at the password prompt."` // Keep Help at the end of the list Help bool `short:"?" help:"Show syntax summary."` } @@ -74,6 +76,9 @@ func (a *SQLCmdArguments) Validate() error { if a.ScreenWidth != nil && (*a.ScreenWidth < 9 || *a.ScreenWidth > 65535) { return fmt.Errorf(`'-w %d': value must be greater than 8 and less than 65536.`, *a.ScreenWidth) } + if a.Password != "" { + return fmt.Errorf(`'-P' is obsolete. The initial passwords must be set using the SQLCMDPASSWORD environment variable or entered at the password prompt.`) + } return nil } diff --git a/pkg/sqlcmd/commands.go b/pkg/sqlcmd/commands.go index f7816864..2a4c1b5b 100644 --- a/pkg/sqlcmd/commands.go +++ b/pkg/sqlcmd/commands.go @@ -91,7 +91,7 @@ func newCommands() Commands { name: "CONNECT", }, "EXEC": { - regex: regexp.MustCompile(`(?im)^[ \t]*?:?!!(?:[ \t]+(.*$)|$)`), + regex: regexp.MustCompile(`(?im)^[ \t]*?:?!!(.*$)`), action: execCommand, name: "EXEC", isSystem: true, diff --git a/pkg/sqlcmd/commands_test.go b/pkg/sqlcmd/commands_test.go index c574bbc9..584867ba 100644 --- a/pkg/sqlcmd/commands_test.go +++ b/pkg/sqlcmd/commands_test.go @@ -46,8 +46,10 @@ func TestCommandParsing(t *testing.T) { {`EXIT `, "EXIT", []string{""}}, {`:Connect someserver -U someuser`, "CONNECT", []string{"someserver -U someuser"}}, {`:r c:\$(var)\file.sql`, "READFILE", []string{`c:\$(var)\file.sql`}}, - {`:!! notepad`, "EXEC", []string{"notepad"}}, - {` !! dir c:\`, "EXEC", []string{`dir c:\`}}, + {`:!! notepad`, "EXEC", []string{" notepad"}}, + {`:!!notepad`, "EXEC", []string{"notepad"}}, + {` !! dir c:\`, "EXEC", []string{` dir c:\`}}, + {`!!dir c:\`, "EXEC", []string{`dir c:\`}}, } for _, test := range commands {