[net.unix] That Crazy Caret

mlip@NADC.ARPA (09/07/84)

[ What's up, Doc?]

I have found an interesting feature with Berkeley's 4.1 Bourne shell.
Valid command arguments that begin with '^' (the caret character)
evince strange behavior.  The output of such commands are first sent
to limbo, and then the shell strips the '^' from the argument and tries
to execute the argument.

Example:

            ls ^date

gives the date and nothing more.

Also:

            date ^pwd

shows the current directory and nothing more.

Try:

            fred ^any_valid_command


The shell behaves correctly when the caret is protected with
quotes.  Switching tty drivers does not solve the problem.
Is the caret an undocumented metacharacter or is this a side 
effect of Berkeley's "history" feature in the cshell?


Michael Lipczynski
mlip@nadc

lwa@MIT-MRCLEAN.ARPA (09/07/84)

From:  Larry Allen <lwa@MIT-MRCLEAN.ARPA>

You've probably gotten 20 answers to this by now, but the caret used
to be a synonym for vertical bar, for use on terminals (TTY33's I think)
that didn't have a convenient vertical bar character.  So
foo ^date
will run foo piping the standard output to date.

craig@LOKI.ARPA (09/07/84)

From:  Craig Partridge <craig@LOKI.ARPA>

	Caret is the old pipe character from way back.  Typing

	ls ^date

is equivalent to typing

	ls |date

and ls's output is correctly thrown away.  I do note, however, that the
4.2 manuals (both SUN and Berkeley) and presumably the 4.1 manuals too,
do not appear to mention this.

Craig Partridge
craig@bbn-unix

moss@BRL-VLD.ARPA (09/09/84)

From:      "Gary S. Moss (AMXBR-VLD-V)" <moss@BRL-VLD.ARPA>

I am surprised nobody mentioned that '^' has significance to CSH as
a substitute operator.  An example :

% ls -l fobar
fobar not found
% ^o^oo
ls -l foobar
...

And an example of misuse of '^' in the CSH :

% ^sanka
Bad substitute.

I forget what the original symptoms were, but I don't think they would
result from improper use of the '|' symbol.

mjs@rabbit.UUCP (M. J. Shannon, Jr.) (09/12/84)

The caret (`^') is a synonym for the vertical bar (`|'), and was the
pipe metacharacter in earlier shells.  Why, you ask?  Well, many
keyboards in those days didn't require the typist to shift to get to
the `^', and that made it more convenient to use the caret than the
vertical bar.  I don't know about the System V shell, but the UNIX
Eight Edition shell treats `^' as a non-special character.
-- 
	Marty Shannon
UUCP:	{alice,rabbit,research}!mjs
Phone:	201-582-3199