Skip to Content.
Sympa Menu

freetds - [freetds] [PATCH] Make fisql exit with failure when it fails.

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Craig A. Berry" <craigberry AT mac.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] [PATCH] Make fisql exit with failure when it fails.
  • Date: Fri, 30 May 2014 13:34:29 -0500

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:craigberry AT mac.com

"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser

Attachment: 0003-Make-fisql-exit-with-failure-when-it-fails.patch
Description: Binary data



  • [freetds] [PATCH] Make fisql exit with failure when it fails., Craig A. Berry, 05/30/2014

Archive powered by MHonArc 2.6.24.

Top of Page