Mark,
the relevent section in the Bash Info page on Here Documents states:

Here Documents
--------------

  This type of redirection instructs the shell to read input from the
current source until a line containing only WORD (with no trailing
blanks) is seen.  All of the lines read up to that point are then used
as the standard input for a command.

  The format of here-documents is:
    <<[-]WORD
            HERE-DOCUMENT
    DELIMITER

  No parameter expansion, command substitution, arithmetic expansion,
or filename expansion is performed on WORD.  If any characters in WORD
are quoted, the DELIMITER is the result of quote removal on WORD, and
the lines in the here-document are not expanded.  If WORD is unquoted,
all lines of the here-document are subjected to parameter expansion,
command substitution, and arithmetic expansion.  In the latter case,
the character sequence `\newline' is ignored, and `\' must be used to
quote the characters `\', `$', and ``'.


Regards Mike Moss




Post, Mark K wrote:


Ok, this is going to require some level of bash expertise, just to warn
everyone.  I have a script that writes data to a file.  One version of it
works, the other does not.  By "works," I mean that a symbolic substitution
is performed.  In detail, if I do this:
#!/bin/sh
VERSION=3.3
  cat > doinst.sh << EOF
( cd usr/bin ; ln -sf gcc-$VERSION gcc )
( cd usr/bin ; rm -rf s390-slackware-linux-gcc-$VERSION )
( cd usr/bin ; ln -sf gcc-$VERSION s390-slackware-linux-gcc-$VERSION )
EOF

When the output file, doinst.sh, is examined, the $VERSION variables have
been properly substituted with the value 3.3.  When I do this:
#!/bin/sh
VERSION=3.3
  cat > doinst1.sh << "EOF"
( cd usr/bin ; ln -sf gcc-$VERSION gcc )
( cd usr/bin ; rm -rf s390-slackware-linux-gcc-$VERSION )
( cd usr/bin ; ln -sf gcc-$VERSION s390-slackware-linux-gcc-$VERSION )
EOF

When the output file is examined, the $VERSION variables appear just like
that, as $VERSION, and not as 3.3.

So, can someone explain to me why this works the way it does?  Pointing to
the relevant passage(s) in the Bash man page should be sufficient.  If that
doesn't clear it up for me, I'll ask more questions later.

Thanks,

Mark Post



Reply via email to