Am 07.05.2012 22:46, schrieb Chet Ramey: > On 5/3/12 5:53 AM, Ruediger Kuhlmann wrote: >> Hi, >> >> please try the following bash script: >> >> a=x >> del="$(echo -e "\\x7f")" >> >> echo "$del${a#x}" | od -ta >> echo "$del ${a#x}" | od -ta >> echo " $del${a#x}" | od -ta >> >> Using bash 3.2, the output is: >> >> 0000000 del nl >> 0000002 >> 0000000 del sp nl >> 0000003 >> 0000000 sp del nl >> 0000003 >> >> however with bash 4.1 and bash 4.2.20, the output is only: >> >> 0000000 del nl >> 0000002 >> 0000000 sp nl >> 0000002 >> 0000000 sp nl >> 0000002 >> >> ... so in the second and third line, the delete character magically >> disappears. Neither OS nor locale seem to influence this. Using a delete >> character directly in the script instead of $del also has no impact, either. > It's a case of one part of the code violating assumptions made by (and > conditions imposed by) another. Try the attached patch; it fixes the > issue for me. > > Chet > It also works for me.
"$del${a#x}" =[$'\177'] " $del${a%x}" =[$' \177'] " $del""${a:0:0}" =[$' \177'] " ${del}${a:0:0}" =[$' \177'] "${del:0:1}${a#d}" =[$'\177x'] "${del:0:1} ${a#d}" =[$'\177 x'] "${del:0:1} ${a:+}" =[$'\177 '] "$del ${a#x}" =[$'\177 '] " $del${a:0:0}" =[$' \177'] " $del${a}" =[$' \177x'] " ${del:0:1}${a:0:0}" =[$' \177'] "${del:0:1}${a#x}" =[$'\177'] "${del:0:1} ${a#x}" =[$'\177 '] " $del${a#x}" =[$' \177'] " $del"${a:0:0} =[$' \177'] " $del" =[$' \177'] " ${del:0:1}${a}" =[$' \177x'] "${del:0:1} ${a}" =[$'\177 x'] "${del:0:1} ${a:-}" =[$'\177 x']