4 ms·
waves Great article about shell hackery. It's good to clear up the misconception that shells know what's on the screen. They don't even know where the cursor is
by ridiculous_fish 6y ago
waves Great article about shell hackery. It's good to clear up the misconception that shells know what's on the screen. They don't even know where the cursor is!
One important reason for this hack is right prompts. If rprompt has width 7, the shell moves right by $COLUMNS-7, outputs the rprompt, and then moves left to return the cursor. What happens if during the move-right phase, the cursor wraps to the next line? move-left doesn't "wrap back", it just pins against the left side! So your prompts get split across lines, your right prompt floats somewhere in space, and your input may even overlap it. It's quite confusing to the user.
So if you have a right prompt, the shell has to be very sure it's on a new line when it starts!
- JdeBP 6y agoCUB does not wrap at left margin, but BS sometimes does. * https://unix.stackexchange.com/a/198445/5132 https://unix.stackexchange.com/a/198445/5132