Skip to content

sendline does not send a newline to fish #755

@NiklasKappel

Description

@NiklasKappel

I noticed the following unexpected behavior using poetry (which uses pexpect internally) in fish. Here is a minimal example using only pexpect:

# file test.py
import pexpect

child = pexpect.spawn("fish")  # replace with "bash" to see different behavior
child.sendline("echo hello")
child.interact()
child.close()

Running the above results in the following terminal output (| represents the cursor position):

$ python test.py
$ echo hello|

Replacing "fish" with "bash" instead results in (I only press return after typing the first line):

$ python test.py
echo hello
$ echo hello
hello
$|

Apart from the duplicate echo hello command in the second output, the difference is that with bash the command sent via sendline is immediately executed, while with fish the command is just appended to the command line of the spawned shell.

With a single command, this is mildly inconvenient. However, if I use multiple sendline calls, bash executes them correctly in succession, while fish appends them together forming an invalid command!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions