From 042087ff25b0fab61e8a691bbb6f5b82cbfe4ff7 Mon Sep 17 00:00:00 2001 From: David Shiflet Date: Thu, 27 Oct 2022 14:56:23 -0400 Subject: [PATCH 1/3] stub -M --- cmd/sqlcmd/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/sqlcmd/main.go b/cmd/sqlcmd/main.go index 6ee9f7c7..bb787b96 100644 --- a/cmd/sqlcmd/main.go +++ b/cmd/sqlcmd/main.go @@ -58,6 +58,7 @@ 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."` // Keep Help at the end of the list Help bool `short:"?" help:"Show syntax summary."` } From dd255b721c1b58cf3328fffc3f70e490d7f0477a Mon Sep 17 00:00:00 2001 From: David Shiflet Date: Thu, 27 Oct 2022 14:56:36 -0400 Subject: [PATCH 2/3] support no space after !! --- pkg/sqlcmd/commands.go | 2 +- pkg/sqlcmd/commands_test.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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 { From 16b9008552545d03712c9071ac20d824ea4e70b8 Mon Sep 17 00:00:00 2001 From: David Shiflet Date: Fri, 28 Oct 2022 09:21:31 -0400 Subject: [PATCH 3/3] add more flag help --- cmd/sqlcmd/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/sqlcmd/main.go b/cmd/sqlcmd/main.go index bb787b96..765ad425 100644 --- a/cmd/sqlcmd/main.go +++ b/cmd/sqlcmd/main.go @@ -58,7 +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."` + 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."` } @@ -75,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 }