From 42fd25bd11f8dd5bb7663d14447f7c694556b02c Mon Sep 17 00:00:00 2001 From: Alexandra Spillane Date: Tue, 28 Apr 2026 14:34:28 +1000 Subject: [PATCH] fix(shell-init): suppress `cd` output If `cd` causes output on stdout (e.g., via the use of noisy `chpwd` hooks on zsh), then the resultant `PATH` exported to the shell will be polluted with that output, and `safe-chain` will not function. To prevent this, this PR updates `init-posix.sh` and `unix-wrapper.template.sh` to suppress any output on stdout during `cd`. --- .../path-wrappers/templates/unix-wrapper.template.sh | 2 +- .../src/shell-integration/startup-scripts/init-posix.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/safe-chain/src/shell-integration/path-wrappers/templates/unix-wrapper.template.sh b/packages/safe-chain/src/shell-integration/path-wrappers/templates/unix-wrapper.template.sh index 5b318ff..efa54b6 100644 --- a/packages/safe-chain/src/shell-integration/path-wrappers/templates/unix-wrapper.template.sh +++ b/packages/safe-chain/src/shell-integration/path-wrappers/templates/unix-wrapper.template.sh @@ -4,7 +4,7 @@ # Function to remove shim from PATH (POSIX-compliant) remove_shim_from_path() { - _safe_chain_phys=$(CDPATH= cd -- "$(dirname -- "$0")" 2>/dev/null && pwd -P) + _safe_chain_phys=$(CDPATH= cd -- "$(dirname -- "$0")" >/dev/null 2>/dev/null && pwd -P) if [ -z "$_safe_chain_phys" ]; then echo "$PATH" return diff --git a/packages/safe-chain/src/shell-integration/startup-scripts/init-posix.sh b/packages/safe-chain/src/shell-integration/startup-scripts/init-posix.sh index 452e62d..8959a47 100644 --- a/packages/safe-chain/src/shell-integration/startup-scripts/init-posix.sh +++ b/packages/safe-chain/src/shell-integration/startup-scripts/init-posix.sh @@ -7,7 +7,7 @@ elif [ -n "${ZSH_VERSION:-}" ]; then else _sc_script_path="$0" fi -_sc_scripts_dir=$(CDPATH= cd -- "$(dirname -- "$_sc_script_path")" 2>/dev/null && pwd -P) +_sc_scripts_dir=$(CDPATH= cd -- "$(dirname -- "$_sc_script_path")" >/dev/null 2>/dev/null && pwd -P) _sc_base=$(dirname -- "$_sc_scripts_dir") export PATH="$PATH:${_sc_base}/bin" unset _sc_base _sc_script_path _sc_scripts_dir