From 3b5ac91ae8c935a2ec93001d38ebdfd3233b7a5f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 2 Aug 2023 14:13:44 +0200 Subject: [PATCH] Only add ~/.local/bin to PATH if it exists Without existence check, the `find` command prints a fail message to stderr, and leaves stdout empty. This means only the prefix `:` is appended to the `$PATH` variable. Leaving a trailing `:` in `$PATH` is however something we really don't want to be doing, as it makes the current directory get treated as a part of `$PATH`. While the `~/.local/bin` directory is generally going to exist, during installation and in some other edge cases, it might not yet be there, and we need to account for that. --- home/.config/shell/profile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/home/.config/shell/profile b/home/.config/shell/profile index e9e6d8a..2d7a924 100755 --- a/home/.config/shell/profile +++ b/home/.config/shell/profile @@ -8,7 +8,9 @@ # Add all folders in ~/.local/bin into PATH # Some window managers require this line to be in profile # not in .zshenv -PATH+=":${$(find -L ~/.local/bin -type d | tr '\n' ':')%%:}" +if [ -d "$HOME/.local/bin" ]; then + PATH+=":${$(find -L ~/.local/bin -type d | tr '\n' ':')%%:}" +fi if [ -d "$HOME/.local/share/pyenv/shims" ]; then PATH+=":$HOME/.local/share/pyenv/shims"