]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: output prompt only if stdin is tty 1968/head
authorIlya Dryomov <ilya.dryomov@inktank.com>
Fri, 13 Jun 2014 08:08:45 +0000 (12:08 +0400)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Mon, 16 Jun 2014 09:12:40 +0000 (13:12 +0400)
In loop mode, output prompt only if stdin is tty, i.e. if we are
interactive.

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
src/ceph.in

index 0978882d8c1d1cbe72a9e4c99ff237d98d177769..c4c1e4993647189d1f9478e31bd3bc5c1e907600 100755 (executable)
@@ -355,6 +355,8 @@ def ceph_conf(field, name):
         raise RuntimeError('unable to get conf option %s for %s: %s' % (field, name, errdata))
     return outdata.rstrip()
 
+PROMPT = 'ceph> '
+
 def new_style_command(parsed_args, cmdargs, target, sigdict, inbuf, verbose):
     """
     Do new-style command dance.
@@ -385,8 +387,14 @@ def new_style_command(parsed_args, cmdargs, target, sigdict, inbuf, verbose):
             # do the command-interpreter looping
             # for raw_input to do readline cmd editing
             import readline
+
+            if sys.stdin.isatty():
+                prompt = PROMPT
+            else:
+                prompt = ''
+
             while True:
-                interactive_input = raw_input('ceph> ')
+                interactive_input = raw_input(prompt)
                 if interactive_input in ['q', 'quit', 'Q']:
                     return 0, '', ''
                 cmdargs = parse_cmdargs(interactive_input.split())[2]