Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set HOME variable in a more generic way #157

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

albestro
Copy link
Contributor

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.

# BASHbash -c "env -i - fc-cache -v 1>/dev/null"
/usr/share/fonts: failed to write cachebash -c "env -i - HOME=$HOME fc-cache -v 1>/dev/null"
# ZSHzsh -c "env -i - fc-cache -v 1>/dev/null"
/usr/share/fonts: failed to write cachezsh -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

@simonpintarelli simonpintarelli self-requested a review January 23, 2024 13:14
Copy link
Member

@simonpintarelli simonpintarelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks good to me.

@bcumming bcumming merged commit f8cba46 into eth-cscs:master Jan 24, 2024
7 checks passed
@albestro albestro deleted the alby/generic-home-workaround branch January 24, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants