Re: incorrect cursor position when navigating with 'ALT-b'

2024-02-02 Thread Chet Ramey

On 2/1/24 7:55 AM, Korneel Dumon wrote:


Bash Version: 5.1
Patch Level: 16
Release Status: release

Description:
For a specific command, the result of navigating with 'ALT-b' to go back
one word at a time ends up being wrong. If I make a change after navigating
with 'ALT-b' the text looks correct, but if I then afterwards recall the
command I just executed with "arrow up", I can see that the text change was
different than what I did. I suspect the problem is caused by the
combination of single and double quotes in the last part of the command
(see below).

Repeat-By:
 Execute the following command:
 > curl -X POST -H "Content-Type: application/json"
https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-test-service
-d '{"countryCode":"BE", "vatNumber":"00"}'


This particular curl command returns a JSON message that does not end with
a newline. Bash (readline) starts reading the next command with the
physical cursor at column 1, which it has no way of knowing. Readline
assumes the cursor starts at column 0 when it computes where the cursor
needs to be for redisplay. You can hit newline or use ^L to redraw the
line and make sure it starts in column 0.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: incorrect cursor position when navigating with 'ALT-b'

2024-02-01 Thread Greg Wooledge
On Thu, Feb 01, 2024 at 01:55:50PM +0100, Korneel Dumon wrote:
> Repeat-By:
> Execute the following command:
> > curl -X POST -H "Content-Type: application/json"
> https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-test-service
> -d '{"countryCode":"BE", "vatNumber":"00"}'
> Then use "arrow up" to recall the command and use "ALT-b" to navigate
> to 'test-service' and
> change it to 'number'. Execute this command. It will fail and if you
> recall it again using "arrow up"
> you should see that the text was changed in the wrong place (offset of
> one character).

This might be caused by an incorrect PS1 (prompt) variable.  You must
ensure that any non-printing sequences in PS1 (colors, etc.) are
enclosed in \[ \] characters.  See
 for details.

If changing to PS1='\$ ' or something similar makes the problem go away,
then you know it's your PS1 causing it.



incorrect cursor position when navigating with 'ALT-b'

2024-02-01 Thread Korneel Dumon
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -flto=auto -ffat-lto-objects -flto=auto
-ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security
-Wall
uname output: Linux jarvis 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14
13:30:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.1
Patch Level: 16
Release Status: release

Description:
For a specific command, the result of navigating with 'ALT-b' to go back
one word at a time ends up being wrong. If I make a change after navigating
with 'ALT-b' the text looks correct, but if I then afterwards recall the
command I just executed with "arrow up", I can see that the text change was
different than what I did. I suspect the problem is caused by the
combination of single and double quotes in the last part of the command
(see below).

Repeat-By:
Execute the following command:
> curl -X POST -H "Content-Type: application/json"
https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-test-service
-d '{"countryCode":"BE", "vatNumber":"00"}'
Then use "arrow up" to recall the command and use "ALT-b" to navigate
to 'test-service' and
change it to 'number'. Execute this command. It will fail and if you
recall it again using "arrow up"
you should see that the text was changed in the wrong place (offset of
one character).