Fix: read -p prompts not displaying with curl | bash
Root Cause: When script is executed via `curl | bash`, the prompt text
from `read -p "prompt"` is not displayed. The user sees nothing and
thinks the script is stuck/hanging, when it's actually waiting for input.
Solution: Use explicit `echo` statements for prompts instead of `read -p`:
Before (prompt hidden):
read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r var < /dev/tty
After (prompt visible):
echo -e "${CYAN}Launch coding-helper wizard now?${NC} ${GREEN}[Y/n]${NC}"
>&2 echo -en "\033[0;36m> \033[0m"
read -n 1 -r var < /dev/tty 2>/dev/null || var="Y"
The key changes:
1. Echo the prompt text explicitly before calling read
2. Use >&2 to send to stderr (bypasses pipe)
3. Show visual indicator "> " using stderr
4. read command now just waits for input (no -p flag)
5. Default to "Y" if read fails (makes script usable non-interactively)
Fixed 5 wizard launch prompts:
- Line 652: All components installed case
- Line 668: Partial components case
- Line 697: Already installed case
- Line 724: Normal install success case
- Line 775: Sudo install success case
All now show:
Launch coding-helper wizard now? [Y/n]
>
And wait for user input with visible prompt.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -649,7 +649,11 @@ offer_coding_helper_addons() {
|
||||
if [ "$installed" -eq "$total" ]; then
|
||||
log_success "All coding-helper components are already installed!"
|
||||
echo ""
|
||||
read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper < /dev/tty
|
||||
echo -e "${CYAN}Launch coding-helper wizard now?${NC} ${GREEN}[Y/n]${NC}"
|
||||
>&2 echo -en "\033[0;36m> \033[0m"
|
||||
set +e
|
||||
read -n 1 -r launch_helper < /dev/tty 2>/dev/null || launch_helper="N"
|
||||
set -e
|
||||
echo ""
|
||||
if [[ $launch_helper =~ ^[Yy]$ ]]; then
|
||||
launch_coding_helper
|
||||
@@ -661,7 +665,11 @@ offer_coding_helper_addons() {
|
||||
if [ "$core" = "true" ]; then
|
||||
log_info "coding-helper is installed, but some components may be missing"
|
||||
echo ""
|
||||
read -p "Launch coding-helper wizard to configure missing components? [y/N] " -n 1 -r launch_helper < /dev/tty
|
||||
echo -e "${CYAN}Launch coding-helper wizard to configure missing components?${NC} ${GREEN}[Y/n]${NC}"
|
||||
>&2 echo -en "\033[0;36m> \033[0m"
|
||||
set +e
|
||||
read -n 1 -r launch_helper < /dev/tty 2>/dev/null || launch_helper="N"
|
||||
set -e
|
||||
echo ""
|
||||
if [[ $launch_helper =~ ^[Yy]$ ]]; then
|
||||
launch_coding_helper
|
||||
@@ -693,9 +701,12 @@ install_coding_helper() {
|
||||
if check_coding_helper_installed; then
|
||||
log_info "coding-helper already installed"
|
||||
echo ""
|
||||
# Show prompt explicitly (read -p doesn't work with curl | bash)
|
||||
echo -e "${CYAN}Launch coding-helper wizard now?${NC} ${GREEN}[Y/n]${NC}"
|
||||
>&2 echo -en "\033[0;36m> \033[0m"
|
||||
# Temporarily disable set -e for read command
|
||||
set +e
|
||||
read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper < /dev/tty 2>/dev/null || launch_helper="N"
|
||||
read -n 1 -r launch_helper < /dev/tty 2>/dev/null || launch_helper="N"
|
||||
set -e
|
||||
echo ""
|
||||
if [[ $launch_helper =~ ^[Yy]$ ]]; then
|
||||
@@ -718,8 +729,10 @@ install_coding_helper() {
|
||||
echo ""
|
||||
echo -e "${CYAN}You can now run:${NC} ${YELLOW}npx @z_ai/coding-helper${NC}"
|
||||
echo ""
|
||||
echo -e "${CYAN}Launch coding-helper wizard now?${NC} ${GREEN}[Y/n]${NC}"
|
||||
>&2 echo -en "\033[0;36m> \033[0m"
|
||||
set +e
|
||||
read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper < /dev/tty 2>/dev/null || launch_helper="N"
|
||||
read -n 1 -r launch_helper < /dev/tty 2>/dev/null || launch_helper="N"
|
||||
set -e
|
||||
echo ""
|
||||
if [[ $launch_helper =~ ^[Yy]$ ]]; then
|
||||
@@ -771,11 +784,17 @@ install_coding_helper() {
|
||||
if npm list -g @z_ai/coding-helper &> /dev/null 2>&1; then
|
||||
log_success "coding-helper installed and verified with sudo!"
|
||||
echo ""
|
||||
# Show prompt explicitly (read -p doesn't work with curl | bash)
|
||||
echo -e "${CYAN}Launch coding-helper wizard now?${NC} ${GREEN}[Y/n]${NC}"
|
||||
echo -e "${CYAN}(Press Enter for Yes, or 'n' to skip)${NC}"
|
||||
# Flush output to ensure prompt displays
|
||||
>&2 echo -en "\033[0;36m> \033[0m"
|
||||
set +e
|
||||
read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper < /dev/tty 2>/dev/null || launch_helper="N"
|
||||
read -n 1 -r launch_helper < /dev/tty 2>/dev/null || launch_helper="Y"
|
||||
set -e
|
||||
echo ""
|
||||
if [[ $launch_helper =~ ^[Yy]$ ]]; then
|
||||
echo ""
|
||||
if [[ -z "$launch_helper" ]] || [[ $launch_helper =~ ^[Yy]$ ]]; then
|
||||
launch_coding_helper
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user