Closed rickhofstede closed 4 years ago
Hi @rickhofstede, I can't seem to reproduce this.
1) What python version are you using? 2) What platform are you on? 3) What version of click-shell & click are you using?
Here is the example app I whipped up to try to reproduce your issue: (for me this gives the expected output on python 2.7.11 / macOS with click-shell 1.0 and click 6.7)
import click
import click_shell
@click_shell.shell(prompt='prompt > ')
def main():
pass
@main.command()
def test():
click.echo('This line is returned.')
if __name__ == '__main__':
main()
Thanks for coming back to this so quickly! I've just tested the provided example and this is the output:
prompt > test
prompt > This line is returned.
<new line>
This is my environment, running on mac OS:
(click-shell-test) $ python --version
Python 3.6.0
(click-shell-test) $ pip freeze
appdirs==1.4.3
click==6.7
click-shell==1.0
packaging==16.8
pyparsing==2.2.0
six==1.10.0
Can you please test your example using Python3 too?
Hmm... that's very odd. I just tested out python 3.6, and I still can't seem to reproduce this.
Here is the output I get:
(click-shell-36) $ python --version
Python 3.6.0
(click-shell-36) $ pip freeze
appdirs==1.4.3
click==6.7
click-shell==1.0
packaging==16.8
pyparsing==2.2.0
six==1.10.0
(click-shell-36) $ python test_app.py
prompt > test
This line is returned.
prompt >
That output looks exactly like mine. I did some more testing but no luck so far. Do you have any further idea(s) on what to try next?
Something else that I noticed, in the same environment and example file:
(click-shell-test) $ python --version
Python 3.6.0
(click-shell-test) $ pip freeze
appdirs==1.4.3
click==6.7
click-shell==1.0
packaging==16.8
pyparsing==2.2.0
six==1.10.0
(click-shell-test) $ python click-shell-test.py
prompt > test
prompt > This line is returned.
exit
prompt > (click-shell-test) $ (click-shell-test) $ (click-shell-test) $ (click-shell-test) $
So I run the example file, use the test
command, and see that there's the 'new line problem'. When I exit the shell then, the obtained (new) shell is totally broken:
I can only restore my shell by issuing a reset
command. This problems happens without issuing the test
command too:
python --version
Python 3.6.0
(click-shell-test) $ pip freeze
appdirs==1.4.3
click==6.7
click-shell==1.0
packaging==16.8
pyparsing==2.2.0
six==1.10.0
(click-shell-test) $ python click-shell-test.py
prompt > exit
prompt > (click-shell-test) $ (click-shell-test) $ (click-shell-test) $ (click-shell-test) $
I'm mentioning this problem here, since it's likely related. By the way, I'm using a Bash shell:
$ echo $SHELL
/bin/bash
$ bash --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.4.0)
<snip>
Hi @rickhofstede, I'm so sorry I haven't looked at this in 3 years. Are you still seeing this issue?
@clarkperkins -- I don't know, to be honest, since I'm not working on this project anymore. I'll therefore close this bug report.
When shell commands are being executed and return one or more lines of output,
click-shell
currently prints a (new) prompt before the output is printed. Example:test
This line is returned.
prompt >
Have you seen this behaviour before? After some debugging, my impression is that the described behaviour is a side-effect of this
get_input()
call.