[PATCH] Make fisql exit with failure when it fails.
"Craig A. Berry" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
It seems that the Sybase flavor of isql does not do this, but the
Microsoft flavor of isql and its descendants do. But it's gosh
darn convenient when running fisql from a script to be able to
check whether it succeeded, and it isn't going to cause any trouble
for the interactive user, who is highly unlikely to be looking at
the exit status after running fisql.
---
src/apps/fisql/fisql.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/apps/fisql/fisql.c b/src/apps/fisql/fisql.c
index ea420a1..f3fc4c0 100644
--- a/src/apps/fisql/fisql.c
+++ b/src/apps/fisql/fisql.c
@@ -268,6 +268,7 @@ main(int argc, char *argv[])
int printedcompute = 0;
char adash;
const char *database_name = NULL;
+ int default_exit = EXIT_SUCCESS;
setlocale(LC_ALL, "");
@@ -588,7 +589,7 @@ main(int argc, char *argv[])
|| (!(strcasecmp(firstword, "quit")))) {
reset_term();
dbexit();
- exit(EXIT_SUCCESS);
+ exit(default_exit);
}
if (!(strcasecmp(firstword, "reset"))) {
for (i = 0; i < ibuflines; i++) {
@@ -800,6 +801,11 @@ main(int argc, char *argv[])
}
}
}
+ } else {
+ /* Something failed, so change the default
+ * exit status to reflect that.
+ */
+ default_exit = EXIT_FAILURE;
}
}
reset_term();
--
1.8.4.2
________________________________________
Craig A. Berry
mailto:[email protected]
"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
0003-Make-fisql-exit-with-failure-when-it-fails.patch
(application/octet-stream, 1.5 KB)
From ed0476b977dc844004002e36f549ba1f4c48b990 Mon Sep 17 00:00:00 2001 From: "Craig A. Berry" <[email protected]> Date: Fri, 30 May 2014 13:13:26 -0500 Subject: [PATCH 3/3] Make fisql exit with failure when it fails. It seems that the Sybase flavor of isql does not do this, but the Microsoft flavor of isql and its descendants do. But it's gosh darn convenient when running fisql from a script to be able to check whether it succeeded, and it isn't going to cause any trouble for the interactive user, who is highly unlikely to be looking at the exit status after running fisql. --- src/apps/fisql/fisql.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/apps/fisql/fisql.c b/src/apps/fisql/fisql.c index ea420a1..f3fc4c0 100644 --- a/src/apps/fisql/fisql.c +++ b/src/apps/fisql/fisql.c @@ -268,6 +268,7 @@ main(int argc, char *argv[]) int printedcompute = 0; char adash; const char *database_name = NULL; + int default_exit = EXIT_SUCCESS; setlocale(LC_ALL, ""); @@ -588,7 +589,7 @@ main(int argc, char *argv[]) || (!(strcasecmp(firstword, "quit")))) { reset_term(); dbexit(); - exit(EXIT_SUCCESS); + exit(default_exit); } if (!(strcasecmp(firstword, "reset"))) { for (i = 0; i < ibuflines; i++) { @@ -800,6 +801,11 @@ main(int argc, char *argv[]) } } } + } else { + /* Something failed, so change the default + * exit status to reflect that. + */ + default_exit = EXIT_FAILURE; } } reset_term(); -- 1.8.4.2