Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hey superuser, I’m a novice here but stackoverflow has helped me in the past.

I’m writing a bash shell script to generate a makefile (starting small).

echo "\
include \$(GNUSTEP_MAKEFILES)/common.make

APP_NAME = $PRODUCT_NAME
$PRODUCT_NAME_OBJC_FILES = source.m

include \$(GNUSTEP_MAKEFILES)/application.make"\
> GNUmakefile

The environment variable set by the IDE where this is used is $PRODUCT_NAME. Now, bash obviously treats this script as referencing an environment variable $PRODUCT_NAME_OBJC_FILES. I see why, but I don’t know how to get around it. Any pointers?

$PRODUCT_NAME is evaluated as appropriate when the underscore isn’t following immediately afterwards, but the extra space messes things up down the line.

share|improve this question
    
If you want to get serious about bash shell scripts, you might want to read the Advanced Bash Scripting Guide (aka as "ABS"). – JanC Aug 23 '10 at 22:12
up vote 2 down vote accepted

Use ${PRODUCT_NAME}_OBJC_FILES. The curly braces tell Bash explicitly where the variable name ends.

share|improve this answer
    
Thanks. This was surprisingly hard to find. – Not Rick Astley Aug 25 '10 at 4:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .