On 26.12.2011 05:45, David Combs wrote:
> In article <
1cf9r8-...@leafnode-msgid.gclare.org.uk>,
> Geoff Clare <ge...@clare.See-My-Signature.invalid> wrote:
>> Ed Morton wrote:
>>
>>> sed 's/\([^[:space:]]*[[:space:]]*[^[:space:]]*\)[[:space:]]*\(.*\)/\1\t\t\2/'
>>
>> The use of \t in the replacement string is not portable. Use a real TAB
>> character if you want it to work on other versions of sed.
>>
> Please explain, in some detail if you have time, the danger of
> using \t in the replacement string -- as not being portable.
The "danger" is simply that you could not get what you expect; e.g.
two characters '\' 't', or an escaped [literal] 't', instead of the
TAB character.
>
> Does it not generate a tab char, eg a ^I. How that translates
> to spaces depends on some env variable, eg usually 8 or maybe 4?
The poster said just warned that "other versions" of sed may not
support what you expect. And that's completely unrelated with any
"expansion" to spaces or indent levels that other tools or displays
or printers may handle as they like.
>
> Isn't there some arg to the expand tool that says what to do
> with a tab char?
I am nor sure what you're asking here; WRT the above substitution
the statement was that a \t does not necessarily be translated to
a TAB character by some version of sed(1).
>
> Since many of us, I suppose, use \t all the time, some explicit
> warnings would really be helpful.
Whenever you use escaped characters you should know or check whether
the respective tools support it.
Janis