Problem
In skills/runtime-switch/scripts/switch.js, the writeTokenCmd is constructed by joining shell command fragments with '; ':
```js
const writeTokenCmd = [
"source ~/.nvm/nvm.sh",
`if grep -q '^CLAUDE_CODE_OAUTH_TOKEN=' ~/zylos/.env 2>/dev/null; then`,
` sed -i 's|^CLAUDE_CODE_OAUTH_TOKEN=.*|CLAUDE_CODE_OAUTH_TOKEN=${token}|' ~/zylos/.env`,
`else`,
` echo 'CLAUDE_CODE_OAUTH_TOKEN=${token}' >> ~/zylos/.env`,
`fi`,
"echo 'token_written'"
].join('; ');
```
When joined with '; ', the resulting string becomes:
```bash
source ~/.nvm/nvm.sh; if grep -q ...; then; sed -i ...; else; echo ...; fi; echo 'token_written'
```
The then; (semicolon immediately after then) is invalid bash syntax. In bash, then cannot be followed by a semicolon — it must be followed by a newline or a command directly.
Expected Behavior
The command should execute without a shell syntax error. The if/then/else block should be correctly formed.
Fix
Join with '\n' instead of '; ' for multi-line shell constructs, or restructure to a single-line form:
```js
// Option A: join with newline
].join('\n');
// Option B: single-line if
`if grep -q '^CLAUDE_CODE_OAUTH_TOKEN=' ~/zylos/.env 2>/dev/null; then sed -i ...; else echo ...; fi`
```
Impact
All Claude runtime switches via switch.js fail at step 2.1 (writing CLAUDE_CODE_OAUTH_TOKEN to .env) on VMs where the token does NOT already exist in .env. Manual SSH workaround is currently in use.
Related
- Discovered during zylos310 / avere / melody runtime switches on 2026-04-02
Problem
In
skills/runtime-switch/scripts/switch.js, thewriteTokenCmdis constructed by joining shell command fragments with'; ':```js
const writeTokenCmd = [
"source ~/.nvm/nvm.sh",
`if grep -q '^CLAUDE_CODE_OAUTH_TOKEN=' ~/zylos/.env 2>/dev/null; then`,
` sed -i 's|^CLAUDE_CODE_OAUTH_TOKEN=.*|CLAUDE_CODE_OAUTH_TOKEN=${token}|' ~/zylos/.env`,
`else`,
` echo 'CLAUDE_CODE_OAUTH_TOKEN=${token}' >> ~/zylos/.env`,
`fi`,
"echo 'token_written'"
].join('; ');
```
When joined with
'; ', the resulting string becomes:```bash
source ~/.nvm/nvm.sh; if grep -q ...; then; sed -i ...; else; echo ...; fi; echo 'token_written'
```
The
then;(semicolon immediately afterthen) is invalid bash syntax. In bash,thencannot be followed by a semicolon — it must be followed by a newline or a command directly.Expected Behavior
The command should execute without a shell syntax error. The if/then/else block should be correctly formed.
Fix
Join with
'\n'instead of'; 'for multi-line shell constructs, or restructure to a single-line form:```js
// Option A: join with newline
].join('\n');
// Option B: single-line if
`if grep -q '^CLAUDE_CODE_OAUTH_TOKEN=' ~/zylos/.env 2>/dev/null; then sed -i ...; else echo ...; fi`
```
Impact
All Claude runtime switches via
switch.jsfail at step 2.1 (writing CLAUDE_CODE_OAUTH_TOKEN to .env) on VMs where the token does NOT already exist in .env. Manual SSH workaround is currently in use.Related