Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/sqlcmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`
}
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sqlcmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions pkg/sqlcmd/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down