Skip to content

Conversation

apoorvdeshmukh
Copy link
Contributor

@apoorvdeshmukh apoorvdeshmukh commented Jul 8, 2022

Summary:
This PR addresses the issue #101.
An appropriate exit code has been set and error is printed if the input file specified for '-i' is missing.

Validation

go-sqlcmd>sqlcmd.exe -i missing.sql >stdout.txt 2>stderr.txt

go-sqlcmd>type stderr.txt
Sqlcmd: Error:  Error occurred while opening or operating on file missing.sql (Reason: open missing.sql: The system cannot find the file specified.).

go-sqlcmd>echo %ERRORLEVEL%
1

@apoorvdeshmukh apoorvdeshmukh requested a review from stuartpa July 8, 2022 15:56
@apoorvdeshmukh apoorvdeshmukh merged commit 4e0b95c into main Jul 12, 2022
@apoorvdeshmukh apoorvdeshmukh deleted the issue101 branch July 12, 2022 11:19
@@ -266,6 +266,8 @@ func run(vars *sqlcmd.Variables, args *SQLCmdArguments) (int, error) {
} else {
for f := range args.InputFile {
if err = s.IncludeFile(args.InputFile[f], true); err != nil {
_, _ = os.Stderr.Write([]byte(err.Error() + sqlcmd.SqlcmdEol))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the :r command handler print the error returned by IncludeFile too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is handled here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants