*BSD News Article 9960


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA6873 ; Fri, 15 Jan 93 10:37:56 EST
Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!sdd.hp.com!elroy.jpl.nasa.gov!ames!olivea!uunet!ferkel.ucsb.edu!oinker!chupchup
From: chupchup@ferkel.ucsb.edu (Robert Earl)
Newsgroups: comp.unix.bsd
Subject: Re: Differences with here documents
Message-ID: <chupchup.727173903@oinker>
Date: 16 Jan 93 08:45:03 GMT
References: <1993Jan15.230023.5307@cm.cf.ac.uk> <1993Jan15.233635.6000@cm.cf.ac.uk>
Organization: (EVIL!)
Lines: 44

paul@isl.cf.ac.uk (Paul) writes:

| In article <1993Jan15.230023.5307@cm.cf.ac.uk> paul@isl.cf.ac.uk (Paul) writes:
| >I came across some problems with a script that worked on ultrix but not
| >386bsd, it came down to differences in command expansion in here
| >documents. The test prog I used was
| >
| >cat <<EOF
| >$(CHNFILES)
| >EOF
| >
| >which on 386bsd would give the following error.
| >
| >CHNFILES: command not found

| I've looked at this a bit more since the above isn't what I wanted
| after all. The problem is slightly more involved. This is a bit of the
| original script :

[ Here document is used to generate Makefile ]

| On ultrix substitution doesn't take place when the word is in brackets,
| whereas with ash and bash it does.

You need to quote the "$" symbols that aren't supposed to be touched by
the shell.  On Ultrix, /bin/sh probably assumes that since "$(" is an
invalid variable, it won't expand anything.  However, ash and bash use
"$()" for backquote-like command execution.

Try something like:

cat <<EOF
foo=$bar
baz=$stuff
target:	\$(CHNFILES)
EOF

This way you will get the expansion you need from most of the variables
but not from "$(CHNFILES)".  You might need to backslash "(" and ")"
too, but this worked on SunOS /bin/sh.
-- 
robert earl           |
rearl@ucsd.edu        |        Dyslexics of the world, untie!
rearl@oinker.ucsb.edu |