Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.