diff --git a/changes/bashrc-noninteractive.md b/changes/bashrc-noninteractive.md new file mode 100644 index 00000000..566a0a7f --- /dev/null +++ b/changes/bashrc-noninteractive.md @@ -0,0 +1,7 @@ +bump: patch +type: fix +The installer also covers a non-login interactive `bash` — the shell most Linux +terminal emulators start, which reads only `~/.bashrc`. That file is now created +when it is missing (its presence changes nothing else about how bash starts), +while `~/.bash_profile` is still only appended to when it already exists, since +creating that one would stop bash reading `~/.profile`. diff --git a/install.sh b/install.sh index 5e930734..f4bc70c5 100755 --- a/install.sh +++ b/install.sh @@ -267,7 +267,7 @@ add_line() { return 0 fi mkdir -p "$(dirname "$_file")" 2>/dev/null || true - printf '\n# ludic\n%s\n' "$_line" >> "$_file" || { + printf '\n# ludic\n%s\n' "$_line" >> "$_file" 2>/dev/null || { warn "could not write ${_file}" return 0 } @@ -281,9 +281,14 @@ add_to_path() { add_line "${HOME}/.profile" "$_posix" add_line "${ZDOTDIR:-$HOME}/.zshenv" "$_posix" - # bash: only files that already exist, so we never shadow ~/.profile + # bash reads ~/.bashrc for a non-login interactive shell — what most Linux + # terminal emulators start — and it is safe to create, since its presence + # changes nothing else. ~/.bash_profile is only appended to when it already + # exists: creating that one would stop bash reading ~/.profile. [ -f "${HOME}/.bash_profile" ] && add_line "${HOME}/.bash_profile" "$_posix" - [ -f "${HOME}/.bashrc" ] && add_line "${HOME}/.bashrc" "$_posix" + if [ -f "${HOME}/.bashrc" ] || have bash; then + add_line "${HOME}/.bashrc" "$_posix" + fi if have fish || [ -f "${HOME}/.config/fish/config.fish" ]; then add_line "${HOME}/.config/fish/config.fish" "source \"${INSTALL_DIR}/env.fish\"" fi