read builtin: timeout setting valid is next read

2022-11-23 Thread Csaba
Hello!

If I use timeout with read shell command, next read command use it too.
See my test shell program:

#!/bin/bash

read -rest 2
od -An -tx1 <<<"${REPLY}"
read -ren2 -p $'---\nIs this OK? [y/N] '
echo
od -An -tx1 <<<"${REPLY}"
[ x"${REPLY,}" != x'y' ] && exit 1
exit 0

In second read command I not use timeout, but have 2s timeout from
first read setting.


bash-5.2.9-3.fc37.x86_64
GNU bash, version 5.2.9(1)-release (x86_64-redhat-linux-gnu)


How reproducible:

See my test script.


Expected results:

The second read is independent of the first.


Additional info:

This problem since bash-5.2. 5.1 versions is OK.

Thanks



bug in 4.2

2014-01-29 Thread Csaba Toth

Hi,

If you set PROMPT_DIRTRIM, in some cases strange output displayed in the 
prompt. I found an issue inside the trim_pathname() function, that uses 
memcpy() to copy head and tail together. That should not be used if the 
memory is overlapped and memmove() shall be used instead.


Please find my enclosed patch.

Have a nice day!

Csaba
--- orig/bash-4.2/general.c	2010-12-12 21:06:27.0 +0100
+++ modified/bash-4.2/general.c	2014-01-29 12:45:49.762326928 +0100
@@ -766,7 +766,7 @@
   *nbeg++ = '.';
 
   nlen = nend - ntail;
-  memcpy (nbeg, ntail, nlen);
+  memmove(nbeg, ntail, nlen);
   nbeg[nlen] = '\0';
 
   return name;