fix(install): make install.sh run under any /bin/sh - #1037
Merged
Conversation
`curl -fsSL agents.railway.com | sh` fails on Debian/Ubuntu, where /bin/sh is dash: `sh: 146: Bad substitution` (#990, also #319). agents.sh pipes install.sh to `sh`, but install.sh used bash-only `${var//needle/repl}`. Made the script POSIX rather than switching the wrapper to bash, so the published one-liner keeps working verbatim and no bash is needed: - Replace the three `${var//…}` expansions with a `replace_all` helper. - Drop the `$RANDOM` fallback. Under dash + `set -u` it aborts with "RANDOM: parameter not set" whenever the /dev/urandom path yields empty. - Fix `unpack()`: `flags=$(test -n)` always expanded to an empty *quoted* argument. GNU tar ignores it; busybox tar reads it as a member name and fails with "tar: : not found in archive". Also makes `-V` verbose extraction work. This makes Alpine work too, which was blocked by both bugs independently. Also stop `setup agent` failures aborting bare under `set -e` — the silent "exit 1" half of #990. A crash, or an older CLI with no `setup` subcommand (v4.5.3 exits 2), now reports the real status instead of dying with no message. Verified: the quoting helpers are byte-identical to the bash originals across quote, backslash, glob and empty inputs under dash, bash and busybox ash; full installs pass on ubuntu/debian × sh,dash,bash and alpine × sh,ash. New CI job lints both scripts as dash and runs a real install under dash and under ash. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
An empty needle matches at every position, so the substitution loop would never advance and the installer would hang with no output. No current caller passes one; guard rather than leave the trap for a future one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The published one-liner
curl -fsSL agents.railway.com | shfails on every Debian/Ubuntu host, where/bin/shis dash:Fixes #990 (bug 3). Same class as #319.
Why POSIX, not
| bash— only 3 constructs were bash-only. Going POSIX keeps the published command unchanged, drops the bash dependency entirely, and fixes Alpine. Switching the wrapper to bash leaves every already-published copy of| shbroken.Changes
shell_quote/fish_quote: 3 ×${var//…}→replace_allhelper$RANDOMfallback aborts under dash +set -u→$$unpack():flags=$(test -n)passed an empty quoted arg to tar. GNU tar ignores it; busybox tar reads it as a member name →tar: : not found in archive. Also makes-Vverbose work for the first time.setup agentfailures no longer abort bare underset -e— the silent "exit 1" half ofagents.railway.cominstall fails silently in several common cases (segfault,set -e+whoami,shvsbash) #990. Reachable in practice: v4.5.3 exits 2 onsetup agent, and the brew/sandbox branches deliberately continue with an old CLI.The shell and tar bugs blocked Alpine independently; both fixed, so Alpine works now.
Verification
sh/dash/bash; alpine:3.20 ×sh/ash🤖 Generated with Claude Code