shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

$HOME gets resolved as . (current directory)

Open palapapa opened this issue 10 months ago • 2 comments

I'm trying to set my session environment variables in KDE. You put in those files what you would normally put in ~/.profile or ~/.bash_profile, but KDE doesn't read those on login, so you need to put them under $HOME/.config/plasma-workspace/env/.

I have the following line in $HOME/.config/plasma-workspace/env/environment-variables.sh:

. "${HOME}/.bash_environment_variables"

and I have a file named .bash_environment_variables in my home directory. This script is executed correctly by KDE and my environment variables are indeed set on login, but shellcheck complains:

Not following: ./.bash_environment_variables: openBinaryFile: does not exist (No such file or directory)

It seems like shellcheck thinks that ${HOME} is .. Is this normal behavior?

palapapa avatar Mar 02 '25 06:03 palapapa

It seems like shellcheck thinks that ${HOME} is .. Is this normal behavior?

in short; yes it is intentional.

You can use the source directive with additional files. https://github.com/koalaman/shellcheck/wiki/Directive#source

brother avatar Mar 04 '25 08:03 brother

Is there a reason why it can't expand $HOME?

palapapa avatar Mar 04 '25 08:03 palapapa