From 64f623260a9f348673e58240896ae6d3ff915a86 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Fri, 13 Jun 2014 12:08:45 +0400 Subject: [PATCH] ceph: output prompt only if stdin is tty In loop mode, output prompt only if stdin is tty, i.e. if we are interactive. Signed-off-by: Ilya Dryomov --- src/ceph.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ceph.in b/src/ceph.in index 0978882d8c1d..c4c1e4993647 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -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] -- 2.47.3