Csh, alias substitution, & backslash

Arthur Evans arthur at sgi.com
Wed Nov 14 12:17:17 AEST 1990


In article <6663 at ge-dab.ge.com> brooks at ge-dab.ge.com (Stephen Brooks) writes:
>
>  In the C-shell, you can prevent alias substitution by preceding the
>aliased command with a backslash.  For example, you might have:
>
>        % alias rm
>        rm -i
>        % alias cd
>        cd !* ; pwd
>
>However, why does "\rm" work, but "\cd" does not?  Yes, I realize that
>"cd" is a C-shell builtin command, but I haven't been able to find any
>discussion on how the \ prevents alias substitution.  

Well, here's my shot in the dark.  The csh is setting the high
bit on the first character of your command to "quote" it--prevent
it from matching a metacharacter when the shell does filename
substitution.  So your command, with high bit set, is searched
for in the list of builtin commands.  When the shell doesn't 
find it there it does filename substitution--"globbing"--in the
course of which it strips the high bit.  Then it searches for
your command, sans high bit, in the hash list and/or search path.
In the case of "rm," the shell finds what it's looking for.  In 
the case of "cd," it doesn't.

OK
-arthur

--
"If I had all the money I'd spent on drink ... I'd spend it on drink."
					-- Sir Henry Rawlinson

Arthur Evans 					arthur at rawlinson.wpd.sgi.com



More information about the Comp.unix.questions mailing list