[svlug] How to print a tab with echo?

Greg Olszewski noop at nwonknu.org
Tue Jul 25 12:30:02 PDT 2000


begin  Rick Kwan <kenobi at lightsaber.com> quotation:
> 
> I used to not use "\t" with "echo" because of portability concerns.
> 15 minutes ago, I was about to switch... until I saw this.
> Any explanations?  (BTW, I got the same results for RH 5.1 and
> RH 6.1.)

Yup. You're using the builtins shell echos.

Reading the tcsh man page, it claims that bsd-style is to not expand
escape sequences, and that sysv style is to expand escape sequences.

tcsh has sysv turned on by default (at least here with tcsh 6.09.00)

When you use bash, you get GNU style. Which is to act like bsd, and
only expand when given -e (documented in man bash(1) and man echo(1)).

However, according to man bash:

      xpg_echo
              If set, the echo builtin expands backslash-
              escape sequences by default.

and this can be set with 
shopt -s xpg_echo


And the only way to get GNU echo,not the shell builtin, to expand
escaped characters by default is to recompile it with V9_DEFAULT
#defined

have fun,

greg

-- 
this signature intentionally left blank




More information about the svlug mailing list