Skip to content

read clears last line if it doesn't end with a new line #12296

@Yutsuten

Description

@Yutsuten

fish, version 4.3.3
Kernel: Linux 6.12.63-1-lts
Terminal: Alacritty

The issue happens even without third-party customizations (sh -c 'env HOME=$(mktemp -d) XDG_CONFIG_HOME= XDG_DATA_DIRS= fish')


This issue would not happen before 4.3.

If you use read in a line that contains text, for example after echo -n, read will clear that line's text and put itself at the first column of that line.

For example:

echo -n 'Press ENTER to continue...' && read --prompt-str ''

Before 4.3, it would print Press ENTER to continue... and put the cursor at the end (| bellow symbolizes the cursor):

Press ENTER to continue...|

In 4.3, that line's text is erased by read and output becomes:

|

It happens even without --prompt-str:

echo -n 'Press ENTER to continue...' && read
read> |

(Yes, I know there are better ways to use read, but this is not the expected behavior nevertheless)

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