ksh bugs

Guy Harris guy at auspex.auspex.com
Thu Aug 17 03:36:10 AEST 1989


>Nor is it, as someone ludicrously suggested without checking, the here
>document doing filename expansions, because the shell only does $ expansion
>on here documents [unless the sentinel (EOF) is quoted, even partially
>('EOF' or \EOF)], NOT ` or filename expansions.

That may be true of filename expansion - I don't have a Korn shell handy
to check - but it is definitely *not* true of ` expansions, which are
referred to as "command substitution" in the Bourne shell manual page. 
At least in the S5R3 Bourne shell, command substitution is performed in
here documents.  (Try

	$ sed 's/Wed/Wednesday/' << EOF
	> `date`
	> EOF

I got "Wednesday Aug 16 10:15:53 PDT 1989" printed out.  This happened
with both the Bourne and C shells.)

You can also check the manual page:

     <<[-]word     After parameter and  command  substitution  is
                   done  on "word", the shell input is read up to
                   the first  line  that  literally  matches  the
                   resulting word, or to an end-of-file. If, however,
		   `-' is appended to <<:

		   1)   leading tabs are stripped from "word" before
			the shell input is read (but after parameter
			and command substitution is done on "word"),

                   2)   leading tabs are stripped from the shell
			input as it is read and before each line
			is compared with "word", and

		   3)   shell input is read up to the first line that
			literally matches the resulting "word", or to
			an end-of-file.

		   If any character of "word" is quoted (see "Quoting",
		   later), no  additional processing is done to the shell
		   input.  If no characters of word are quoted:

		   1)   parameter  and  command  substitution
			occurs,

		   2)   (escaped) \new-line is ignored, and

		   3)   \ must be used to quote the characters
			\, $, and `.

		   The resulting document becomes the standard input.

or you can check the code, and they all agree that command substitution
*IS* done in here documents.

If the Korn shell doesn't do command substitution in here documents, I
would consider that to be a bug, since the Bourne shell does it....



More information about the Comp.bugs.sys5 mailing list