0

In the following code, it seems that {} are removed from inside single quotes when using set but not when using alias. How can I stop set from removing the braces?

set variable = "middle"
set string = 'echo ${ENVVAR}_'$variable'_end'
echo $string

When running the script I would expect to see:

echo ${ENVVAR}_middle_end

But instead I get:

echo $ENVVAR_middle_end

How can I stop csh from removing my braces?

1

The braces are not within quotes when you echo the string, so quote the variable expansion in the last echo:

set variable = "middle"
set string = 'echo ${ENVVAR}_'$variable'_end'
echo "$string"

Result with csh:

echo ${ENVVAR}_middle_end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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