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

Craig A. Berry craigberry at mac.com
Fri May 30 14:34:29 EDT 2014


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Make-fisql-exit-with-failure-when-it-fails.patch
Type: application/octet-stream
Size: 1528 bytes
Desc: not available
URL: <http://lists.ibiblio.org/pipermail/freetds/attachments/20140530/d7d08700/attachment.obj>


More information about the FreeTDS mailing list