Am 03.05.2012 15:01, schrieb Greg Wooledge: >> Yours, RĂ¼diger. >> a=x >> del="$(echo -e "\\x7f")" >> >> echo "$del${a#x}" | od -ta >> echo "$del ${a#x}" | od -ta >> echo " $del${a#x}" | od -ta > Yup, confirmed that it breaks here, and only when the # parameter expansion > is included. > > imadev:~$ del=$'\x7f' a=x b= > imadev:~$ echo " $del$b" | od -ta > 0000000 sp del nl > 0000003 > imadev:~$ echo " $del${b}" | od -ta > 0000000 sp del nl > 0000003 > imadev:~$ echo " $del${b#x}" | od -ta > 0000000 sp del nl > 0000003 > imadev:~$ echo " $del${a#x}" | od -ta > 0000000 sp nl > 0000002 > > Bash 4.2.24. > Also Confirmed, but my output is a bit wackier. printf %q seems to get confused, and do invalid things as well.
the \x7f becomes a \ function printTests { while [ $# -gt 0 ]; do printf "%-20s=[%q]\n" "${1}" "$(eval echo "${1}")" shift done } a=x del=$'\x7f' printTests '"$del${a#x}"' '"$del ${a#x}"' '" $del${a#x}"' '" $del${a%x}"' printTests '" $del${a:0:0}"' '" $del"${a:0:0}' '" $del""${a:0:0}"' printTests '" $del${a}"' '" $del"' '" ${del}${a:0:0}"' '" ${del:0:1}${a:0:0}"' printTests '" ${del:0:1}${a}"' '"${del:0:1}${a#d}"' '"${del:0:1}${a#x}"' printTests '" ${del:0:1} ${a}"' '"${del:0:1} ${a#d}"' '"${del:0:1} ${a#x}"' output "$del${a#x}" =[$'\177'] "$del ${a#x}" =[\ ] " $del${a#x}" =[\ ] " $del${a%x}" =[\ ] " $del${a:0:0}" =[\ ] " $del"${a:0:0} =[$' \177'] " $del""${a:0:0}" =[$' \177'] " $del${a}" =[$' \177x'] " $del" =[$' \177'] " ${del}${a:0:0}" =[\ ] " ${del:0:1}${a:0:0}"=[\ ] " ${del:0:1}${a}" =[$' \177x'] "${del:0:1}${a#d}" =[$'\177x'] "${del:0:1}${a#x}" =[$'\177'] " ${del:0:1} ${a}" =[$' \177 x'] "${del:0:1} ${a#d}" =[$'\177 x'] "${del:0:1} ${a#x}" =[\ ]