Skip to content

Commit

Permalink
ceph: output prompt only if stdin is tty
Browse files Browse the repository at this point in the history
In loop mode, output prompt only if stdin is tty, i.e. if we are
interactive.

Signed-off-by: Ilya Dryomov <[email protected]>
  • Loading branch information
idryomov committed Jun 16, 2014
1 parent 82c5479 commit 64f6232
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ceph.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 64f6232

Please sign in to comment.