From 985211fd9510f7e476f329d212723b2b1bc5a8c8 Mon Sep 17 00:00:00 2001 From: lif <1835304752@qq.com> Date: Fri, 27 Mar 2026 04:50:29 +0800 Subject: fix: use printf to append fish shell init block (#3346) ## Summary - The existing sed-based fish config injection produced malformed output on some systems, concatenating 'atuin init fish | source' and 'end' onto the same line (issue #3192) - Replace the GNU/BSD sed detection block with a single printf append that writes a self-contained 'if status is-interactive' block - Remove the now-unnecessary sed dependency check from the installer ## Root cause sed backslash-newline replacement behaves inconsistently across GNU and BSD (macOS) implementations, causing the newline to be dropped on some systems. ## Fix Use printf to append a new 'if status is-interactive' block, consistent with how bash/zsh init lines are already added. ## Test plan - shellcheck -e SC2148 install.sh passes with no warnings - Idempotency preserved via existing grep -q duplicate guard Fixes #3192 Signed-off-by: majiayu000 <1835304752@qq.com> --- install.sh | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'install.sh') diff --git a/install.sh b/install.sh index 0dc0419f..e9fea408 100755 --- a/install.sh +++ b/install.sh @@ -46,9 +46,6 @@ __atuin_install_binary(){ if ! command -v curl > /dev/null; then echo "curl not installed. Please install curl." exit -elif ! command -v sed > /dev/null; then - echo "sed not installed. Please install sed." - exit fi @@ -71,19 +68,9 @@ if ! grep -q "atuin init bash" ~/.bashrc; then fi if [ -f "$HOME/.config/fish/config.fish" ]; then - # Check if the line already exists to prevent duplicates if ! grep -q "atuin init fish" "$HOME/.config/fish/config.fish"; then - # Detect BSD or GNU sed - if sed --version >/dev/null 2>&1; then - # GNU - sed -i '/if status is-interactive/,/end/ s/end$/ atuin init fish | source\ -end/' "$HOME/.config/fish/config.fish" - else - # BSD (macOS) - sed -i '' '/if status is-interactive/,/end/ s/end$/ atuin init fish | source\ -end/' "$HOME/.config/fish/config.fish" - fi - fi + printf '\nif status is-interactive\n atuin init fish | source\nend\n' >> "$HOME/.config/fish/config.fish" + fi fi ATUIN_BIN="$HOME/.atuin/bin/atuin" -- cgit v1.3.1