From: Ilya Dryomov Date: Fri, 13 Jun 2014 08:08:45 +0000 (+0400) Subject: ceph: output prompt only if stdin is tty X-Git-Tag: v0.83~85^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=64f623260a9f348673e58240896ae6d3ff915a86;p=ceph.git 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 --- diff --git a/src/ceph.in b/src/ceph.in index 0978882d8c1..c4c1e499364 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]