Bill Gradwohl wrote: > On Fri, 2009-04-24 at 18:54 -0400, Chet Ramey wrote: >> I'm not quite sure what this is supposed to demonstrate. In the cases >> where you have specified the tab character correctly ($'\t'), it's >> converted into a tab before matching is attempted. > I respectfully disagree, and I believe I have proof below. >> You can tell this >> because in the cases where you have not, either the literal `$' gets >> removed, or the literal instances of \t in the value of parameter are >> removed. Since there are no tab characters in $parameter, no tabs get >> removed when you specify $'\t' correctly. >> > I did a hex dump to prove that there were Hex '09' (tab) characters in > the original parm field and that field gets reused again and again. The > original dump also shows the $'s in evidence.
No, there really aren't any tabs in the value of ${parameter}. For some reason, you use `echo -e' to send input to `dumpit'. The whole reason the -e option to echo exists is to expand backslash escapes, and it dutifully expands \t to tab. All of your conclusions result from a faulty premise. To restate: the \t in the pattern will remove the literal \t in $parameter. (As a sort of side effect -- the backslashes and `t's are matched and removed separately. You just don't notice because the rest of the string doesn't contain any `t's.). The $'\t' doesn't remove anything, since there are no tabs in $parameter. The $ '\t' removes the dollar signs and instances of \t in $parameter. The space matches and removes space characters. I prefer the `recho' program built as part of the bash test suite to hexdump. When I change your script to use recho instead of `echo -e' piped to hexdump, I get the following: argv[1] = <hello \t and \t $ $good \t bye.> argv[1] = <helloand$$goodbye.> argv[1] = <helloand$$goodbye.> argv[1] = <hello\tand\t$$good\tbye.> argv[1] = <hello\tand\t$$good\tbye.> argv[1] = <helloandgoodbye.> argv[1] = <helloandgoodbye.> I think that makes the effects clear. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/