[net.unix-wizards] 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

daven@LLL-CRG.ARPA (09/07/84)

From:  Dave Nelson <daven@LLL-CRG.ARPA>

As I recall, the caret is an old, abandoned equivalent to the pipe character |.
Thus, to quote your message:

	Example:
	
	            ls ^date
	
	gives the date and nothing more.
	
	Also:
	
	            date ^pwd
	
	shows the current directory and nothing more.

I thought this was documented somewhere (maybe in old V7 documentation?),
but a quick glance in the obvious places revealed nothing.

Oh well....

Dave Nelson (daven@lll-crg)	"But you were expected to KNOW that!"

smh@SRI-PRISM.ARPA (09/07/84)

From:  "Scott M. Hinnrichs" <smh@SRI-PRISM.ARPA>

	The Bourne shell treats ^ as a | (pipe).  It is useful to
know this if you terminal does not have the | char.

Scott

gwyn@BRL-VLD.ARPA (09/07/84)

From:      Doug Gwyn (VLD/VMB) <gwyn@BRL-VLD.ARPA>

The Bourne shell accepts ^ as a synonym for |.
This is for "historical reasons"; you should not deliberately
start using ^ instead of |.