I have set up the following variable:

root# PATH_TO_CLANG="~/my_project/llvm_install/bin/clang"

If I use this like so I get an error:

root# ${PATH_TO_CLANG} sample.c
bash: ~/my_project/llvm_install/bin/clang: No such file or directory

However, these work fine:

root# ~/my_project/llvm_install/bin/clang sample.c    
root# bash -c "${PATH_TO_CLANG} sample.c"

This is somehow related to "~", because I can use the variable:

root# PATH_TO_CLANG="/root/my_project/llvm_install/bin/clang"
root# ${PATH_TO_CLANG} sample.c

(I have trimmed the terminal prompt above for readability. I am root and using bash as my shell in all cases)

  • 1
    Use $HOME instead of ~. – ajgringo619 Aug 30 '19 at 0:37

Browse other questions tagged or ask your own question.