Command line editing give a wrong result for me on hush shell 1.9.1
Denys Vlasenko
vda.linux at googlemail.com
Mon Feb 18 22:17:41 UTC 2008
On Monday 18 February 2008 22:36, Martinb_ARM_NOMMU_KISSDVD wrote:
> sorry, bug still there
So, with this code (where I made a slight mistake):
if (cmdedit_x >= num) {
const char *bbbb = "\b\b\b\b";
cmdedit_x -= num;
if (num <= 4) {
bbbb -= num;
asm volatile("# HERE");
bb_error_msg("\n bbbb=%02x %02x %02x %02x (%p)", bbbb[0], bbbb[1], bbbb[2], bbbb[3], bbbb);
printf(bbbb);
return;
}
printf("\033[%uD", num);
return;
}
You see:
>this is "asdf{backspace}"
>/hdd/newscript # ./hush
>/hdd/newscript # asdfhush:
> bbbb=00 08 08 08 (0x15b4c7f)
and it absolutely correct - bbbb points to a string of
four backspaces, and when num == 1, bbbb is moved back one char.
Your debug output shows exactly this - we moved back, and we see
"xx 08 08 08 08 00" (xx happens to be 00).
BUT NOW I correct that slight mistake:
if (cmdedit_x >= num) {
const char *bbbb = "\b\b\b\b";
cmdedit_x -= num;
bbbb += 4;
if (num <= 4) {
bbbb -= num;
asm volatile("# HERE");
bb_error_msg("\n bbbb=%02x %02x %02x %02x (%p)", bbbb[0], bbbb[1], bbbb[2], bbbb[3], bbbb);
printf(bbbb);
return;
}
printf("\033[%uD", num);
return;
}
bbbb should point to THE END (zero byte) of a string of four backspaces,
and when num == 1, bbbb is moved back one char... so it should point
to a string of one backspace and then zero byte - we should see "08 00"
But you see something bogus instead:
> a{backspace}
> /hdd/newscript # ahush:
> bbbb=20 25 73 00 (0x1559bf7)
I don't understand what's going on.
Can you add yet another debug printout?
if (cmdedit_x >= num) {
const char *bbbb = "\b\b\b\b";
bb_error_msg("\n initial bbbb=%02x %02x %02x %02x (%p)", bbbb[0], bbbb[1], bbbb[2], bbbb[3], bbbb);
cmdedit_x -= num;
bbbb += 4;
if (num <= 4) {
bbbb -= num;
asm volatile("# HERE");
bb_error_msg("\n bbbb=%02x %02x %02x %02x (%p)", bbbb[0], bbbb[1], bbbb[2], bbbb[3], bbbb);
printf(bbbb);
return;
}
printf("\033[%uD", num);
return;
}
and show "a{backspace}" result.
--
vda
More information about the busybox
mailing list