8.12 Which One Will the C Shell Use?
[Article
8.11
shows how to control whether
bash
uses a built-in
command, a shell function, or an external command.
The way you do that in the C shell is a little, errr, different.
Chris Torek explains why, for example,
The C shell first breaks each input line into a
word vector
.
It then matches against aliases.
Since
The C shell implements quoting by setting the 8th bit (bit 7) of each
byte of a quoted character.
Since
Eventually, the shell has a fully "parsed" line.
It then compares
This means that:
\cd not only bypasses any alias, but also reaches the built-in scanner as:
'c'|0x80, 'd', '\0' which does not match the built-in command:
'c', 'd', '\0' and so does not run the cd builtin. It is later stripped and the shell looks for an external program called cd . If you want to avoid alias substitution, but not built-in matching, you can replace:
\cd foo or \rm foo with:
''cd foo or ""rm foo These do not match the aliases - during alias scanning they have quote pairs in front of them - but do match any builtin since the quotes have by then been stripped (setting bit 7 of all the characters contained between the two quotes, here none). Incidentally, since alias expansion occurs early, you can do some peculiar things with it:
% (alias expansion occurs before globbing)
% (unalias globs its arguments!)
% (the C shell attempts caution...)
% (but fails!)
% (Fortunately, there is an exit.) - on Usenet, 14 November 1990 |
|