Problem
Running ./setup.sh --build on Linux can fail during local Whisper setup after openai-whisper is installed:
Unknown regexp modifier "/b" at -e line 1, at end of line
Execution of -e aborted due to compilation errors.
Reproduction
On Linux, run:
The script configures local Whisper and attempts to write this value into .env:
WHISPER_COMMAND=.venv-whisper/bin/whisper
Root cause
setup.sh currently updates existing .env keys with this Perl substitution:
perl -0pi -e "s/^${key}=.*\$/${key}=${value}/m" .env
When value contains /, such as .venv-whisper/bin/whisper, the slash is interpreted as the Perl substitution delimiter. The /b in /bin is then parsed as an invalid regexp modifier, causing the setup script to abort.
This is not machine-specific; any value containing unescaped / can trigger it.
Suggested fix
Avoid embedding unescaped values directly into a Perl substitution. For example, replace the existing-key path in upsert_env with a delimiter-safe/plain-text update using awk:
upsert_env() {
local key="$1"
local value="$2"
local tmp_file
if grep -q "^${key}=" .env 2>/dev/null; then
tmp_file=$(mktemp ".env.tmp.XXXXXX")
awk -v key="$key" -v value="$value" '
$0 ~ "^" key "=" {
print key "=" value
next
}
{ print }
' .env > "$tmp_file"
mv "$tmp_file" .env
else
printf "%s=%s\n" "$key" "$value" >> .env
fi
}
I verified the original failure with a minimal reproduction using WHISPER_COMMAND=.venv-whisper/bin/whisper, and the awk approach writes the expected line without the Perl parsing error.
Problem
Running
./setup.sh --buildon Linux can fail during local Whisper setup afteropenai-whisperis installed:Reproduction
On Linux, run:
The script configures local Whisper and attempts to write this value into
.env:Root cause
setup.shcurrently updates existing.envkeys with this Perl substitution:perl -0pi -e "s/^${key}=.*\$/${key}=${value}/m" .envWhen
valuecontains/, such as.venv-whisper/bin/whisper, the slash is interpreted as the Perl substitution delimiter. The/bin/binis then parsed as an invalid regexp modifier, causing the setup script to abort.This is not machine-specific; any value containing unescaped
/can trigger it.Suggested fix
Avoid embedding unescaped values directly into a Perl substitution. For example, replace the existing-key path in
upsert_envwith a delimiter-safe/plain-text update usingawk:I verified the original failure with a minimal reproduction using
WHISPER_COMMAND=.venv-whisper/bin/whisper, and theawkapproach writes the expected line without the Perl parsing error.