Skip to content

Commit 24a3d00

Browse files
committed
Fix PATH handling in install script
1 parent 9880c60 commit 24a3d00

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

install.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,29 +126,28 @@ rm -rf "$TMP_DIR"
126126
if ! command -v copilot >/dev/null 2>&1; then
127127
echo ""
128128
echo "Notice: $INSTALL_DIR is not in your PATH"
129-
export PATH="$PATH:$INSTALL_DIR"
130-
echo "✓ Added $INSTALL_DIR to PATH for this session"
131129

132130
# Detect shell rc file
133131
case "$(basename "${SHELL:-/bin/sh}")" in
134132
zsh) RC_FILE="$HOME/.zshrc" ;;
135-
bash)
136-
if [ -f "$HOME/.bash_profile" ]; then
137-
RC_FILE="$HOME/.bash_profile"
138-
else
139-
RC_FILE="$HOME/.bashrc"
140-
fi
141-
;;
133+
bash) RC_FILE="$HOME/.bashrc" ;;
142134
*) RC_FILE="$HOME/.profile" ;;
143135
esac
144136

145-
# Prompt user to add to shell rc file
146-
echo ""
147-
printf "Would you like to add it to %s? [y/N] " "$RC_FILE"
148-
read -r REPLY </dev/tty
149-
if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then
150-
echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$RC_FILE"
151-
echo "✓ Added PATH export to $RC_FILE"
137+
# Prompt user to add to shell rc file (only if interactive)
138+
if [ -t 0 ] || [ -e /dev/tty ]; then
139+
echo ""
140+
printf "Would you like to add it to %s? [y/N] " "$RC_FILE"
141+
if read -r REPLY </dev/tty 2>/dev/null; then
142+
if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ]; then
143+
echo "export PATH=\"$INSTALL_DIR:\$PATH\"" >> "$RC_FILE"
144+
echo "✓ Added PATH export to $RC_FILE"
145+
fi
146+
fi
147+
else
148+
echo ""
149+
echo "To add $INSTALL_DIR to your PATH permanently, add this to $RC_FILE:"
150+
echo " export PATH=\"$INSTALL_DIR:\$PATH\""
152151
fi
153152
fi
154153

0 commit comments

Comments
 (0)