]> git.openfabrics.org - ~adrianc/mstflint.git/commitdiff
fixed RM#415018 - mstflint would not take default response on prompt
authorAdrian Chiris <adrianc@mellanox.com>
Thu, 14 Aug 2014 12:40:12 +0000 (15:40 +0300)
committerAdrian Chiris <adrianc@mellanox.com>
Thu, 14 Aug 2014 12:40:12 +0000 (15:40 +0300)
flint/subcommands.cpp

index ca1759efe5474e7a8690d2c780c1d6c6e9f1f7d6..09f07de56fc868ffd6e35675a6a24c741873a940 100644 (file)
@@ -638,37 +638,28 @@ bool SubCommand::askUser(const char *question, bool printAbrtMsg) {
     if (_flintParams.yes)
         printf("y\n");
     else {
-        char ansbuff[32];
-        ansbuff[0] = '\0';
         if (_flintParams.no) {
             printf("n\n");
             reportErr(false, "-no flag is set\n");
             return false;
         }
-        /*for future tracer dev
-         *
-        if (_ignore_tty == false) {
-            if (!isatty(0)) {
-                sprintf(_err_msg, "Not on tty - Can not interact. assuming \"no\"\n");
-                return false;
-            }
-        }
-        */
+
         fflush(stdout);
+        std::string answer;
+        std::getline(std::cin, answer);
         //fgets(ansbuff, 30, stdin);
-        if (!fscanf(stdin, "%30s", ansbuff)) {
-               return false;
-        }
+        //if (!fscanf(stdin, "%[^\n]30s", ansbuff)) {
+        //  return false;
+        //}
 
-        if (  strcasecmp(ansbuff, "y") &&
-              strcasecmp(ansbuff, "yes"))  {
+        if (  strcasecmp(answer.c_str(), "y") &&
+              strcasecmp(answer.c_str(), "yes"))  {
 
             if (printAbrtMsg) {
             reportErr(true, "Aborted by user\n");
             }
             return false;
         }
-
     }
     return true;
 }