eth-cscs / stackinator

https://eth-cscs.github.io/stackinator/
BSD 3-Clause "New" or "Revised" License
19 stars 15 forks source link

Set HOME variable in a more generic way #157

Closed albestro closed 5 months ago

albestro commented 5 months ago

Symbol ~ (tilde) might not get expanded in some shells (POSIX, zsh, see this for reference)

Using HOME=$HOME makes it more generic and it should work with more shell interpreters.

➜  ~ for shell in bash sh zsh; do echo -n "$shell => " ; $shell -c 'env -i - HOME=~ printenv HOME'; done
bash => /users/ialberto
sh => ~
zsh => ~
➜  ~ for shell in bash sh zsh; do echo -n "$shell => " ; $shell -c 'env -i - HOME=$HOME printenv HOME'; done
bash => /users/ialberto
sh => /users/ialberto
zsh => /users/ialberto

font-util

Since the workaround was about a problem with font-util (#143) I double-checked it still works.

# BASH
➜ bash -c "env -i - fc-cache -v 1>/dev/null"
/usr/share/fonts: failed to write cache
➜ bash -c "env -i - HOME=$HOME fc-cache -v 1>/dev/null"
# ZSH
➜ zsh -c "env -i - fc-cache -v 1>/dev/null"
/usr/share/fonts: failed to write cache
➜ zsh -c "env -i - HOME=$HOME fc-cache -v 1>/dev/null"

Moreover, in the cases where tilde is not expanded, as a side-effect a directory with name ~ is actually created.

➜ find .
.
➜ bash -c "env -i - HOME=~ fc-cache -v 1>/dev/null"
➜ find .
.
➜ zsh -c "env -i - HOME=~ fc-cache -v 1>/dev/null"
➜ find .
.
./~
./~/.cache
./~/.cache/fontconfig
./~/.cache/fontconfig/CACHEDIR.TAG
./~/.cache/fontconfig/3830d5c3ddfd5cd38a049b759396e72e-x86_64.cache-7