0

I need to write both variables like ${myvar} and their values.

This code makes no substitutes and writes text as is:

cat >${PROGNAME_APPDIR}/AppRun <<'EOF'
#!/bin/bash

HERE=$(dirname $(readlink -f "${0}"))
export LD_PRELOAD="${HERE}"/lib/exec_wrapper.so
export BIN_DIR="${HERE}${DIR}"
exec "${BIN_DIR}"/binary "$@"
EOF

When I change << 'EOF' to << EOF the code substitutes all. But I need substitute just value of ${DIR}.

How to make a mixed write without crazy coding?

1 Answer 1

4

You have to escape the $ sign, change $ to \$ so it is treated as a normal character:

cat >${PROGNAME_APPDIR}/AppRun <<EOF
#!/bin/bash                                                                                                                                                                                                                                        

HERE=\$(dirname \$(readlink -f "\${0}"))                                                                                                                                                                                                              
export LD_PRELOAD="\${HERE}"/lib/exec_wrapper.so                                                                                                                                                                                                    
export BIN_DIR="\${HERE}${DIR}"                                                                                                                                                                                                                
exec "\${BIN_DIR}"/binary "\$@"                                                                                                                                                                                                                   
EOF
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.