[augeas-devel] [PATCH] Detect if stdin is a tty and make augtool's output quiet otherwise.

Raphaël Pinson raphink at gmail.com
Mon Mar 30 17:20:22 UTC 2009


From: Raphaël Pinson <raphink at raphink.net>

---
 src/augtool.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/augtool.c b/src/augtool.c
index 0869960..63ea9ef 100644
--- a/src/augtool.c
+++ b/src/augtool.c
@@ -45,6 +45,7 @@ static augeas *aug = NULL;
 static const char *const progname = "augtool";
 static unsigned int flags = AUG_NONE;
 const char *root = NULL;
+const char *prompt = "";
 char *loadpath = NULL;
 
 static char *cleanpath(char *path) {
@@ -626,7 +627,7 @@ static int main_loop(void) {
     while(1) {
         char *dup_line;
 
-        line = readline("augtool> ");
+        line = readline(prompt);
         if (line == NULL) {
             printf("\n");
             return ret;
@@ -660,6 +661,8 @@ int main(int argc, char **argv) {
         fprintf(stderr, "Failed to initialize Augeas\n");
         exit(EXIT_FAILURE);
     }
+    if (isatty(fileno(stdin)))
+        prompt = "augtool> ";
     readline_init();
     if (optind < argc) {
         // Accept one command from the command line
-- 
1.5.6.3




More information about the augeas-devel mailing list