Wierd shell bug could be useful
    DaviD W. Sanderson 
    dws at margay.cs.wisc.edu
       
    Thu Jan 31 08:17:15 AEST 1991
    
    
  
In article <618 at tndsyd.oz> root at tndsyd.oz (the main man) writes:
>Try this out:
>	$ echo > foo '
>	> garbage
>	> ...
>	> '
[...]
>A user friendly bug !!!
It isn't a bug.  The shell allows i/o redirections to occur anywhere on
the command line (it even says so in the man page), and it also allows
multiline quoted strings.  So the example you gave was simply an echo
of a single quoted string redirected into a file.  Putting the
redirection in the middle is unusual but perfectly legal.  You could
equally well have given
	$ > foo echo '		or	$ echo '
	junk				junk
	'				' > foo
Note that if you substitute "cat" for "echo" you will get an error from
cat because presumably cat will not be able to find a file whose name
is given by the multiline quoted string.  Unless you like pathological
file names! :-)
-- 
       ___
      / __\  U N S H I N E	           DaviD W. Sanderson
     |  |  | I N E			    dws at cs.wisc.edu
_____|  |  |_____  ________
\      / \   |__/ /////__	Fusion Powered Locomotives Made to Order
 \____/   \__|_/  \\\\\______	 (TARDIS model available at extra cost)
    
    
More information about the Comp.unix.shell
mailing list