bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash bug interpolating delete characters


From: John Kearney
Subject: Re: Bash bug interpolating delete characters
Date: Tue, 08 May 2012 02:01:05 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1

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']




reply via email to

[Prev in Thread] Current Thread [Next in Thread]