Skip to content

Commit f9b837e

Browse files
committed
Fix installer pipe execution - wrap in block and re-download when piped
The previous cat > temp approach failed because bash reads stdin in buffered blocks, consuming most of the pipe content before the guard code executes. Wrap entire installer in { } block to force bash to read everything first, and re-download from GitHub when piped instead of trying to save stdin.
1 parent 0f4a200 commit f9b837e

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

build-dist.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,27 @@ echo -e "${BLUE}→${NC} Creating self-extracting installer..."
5656

5757
cat > "$DIST_DIR/$INSTALLER_NAME" << 'EOF'
5858
#!/usr/bin/env bash
59-
59+
{
6060
set -e
6161
62-
# Detect pipe execution and save to temp file
62+
# Detect pipe execution and re-download to temp file
6363
if [ ! -f "$0" ] || [ "$(basename "$0")" = "bash" ] || [ "$(basename "$0")" = "sh" ]; then
64-
SELF_TEMP=$(mktemp)
65-
cat > "$SELF_TEMP"
64+
SELF_TEMP=$(mktemp /tmp/shipnode-installer.XXXXXX)
65+
DOWNLOAD_URL="https://github.com/devalade/shipnode/releases/latest/download/shipnode-installer.sh"
66+
67+
# Colors for download message
68+
BLUE='\033[0;34m'
69+
NC='\033[0m'
70+
RED='\033[0;31m'
71+
72+
echo -e "${BLUE}→${NC} Downloading installer..."
73+
74+
if ! curl -fsSL "$DOWNLOAD_URL" -o "$SELF_TEMP"; then
75+
echo -e "${RED}Error: Failed to download installer${NC}"
76+
rm -f "$SELF_TEMP"
77+
exit 1
78+
fi
79+
6680
bash "$SELF_TEMP" "$@"
6781
EXIT_CODE=$?
6882
rm -f "$SELF_TEMP"
@@ -301,7 +315,7 @@ echo "Documentation: https://github.com/devalade/shipnode"
301315
echo
302316
303317
exit 0
304-
318+
}
305319
__ARCHIVE_BELOW__
306320
EOF
307321

0 commit comments

Comments
 (0)