diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index eb0540480..8043a7a03 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -113,7 +113,7 @@ jobs: echo "uutils WASM build: ${commit_short} (${commit_date})" - name: Upload uutils WASM artifact - uses: actions/upload-artifact@v8 + uses: actions/upload-artifact@v7 with: name: wasm-coreutils path: wasm-out @@ -214,7 +214,7 @@ jobs: echo "${{ matrix.name }} WASM build: ${s} (${d})" - name: Upload ${{ matrix.name }} WASM artifact - uses: actions/upload-artifact@v8 + uses: actions/upload-artifact@v7 with: name: wasm-${{ matrix.name }} path: wasm-out @@ -389,7 +389,7 @@ jobs: run: rm -f public/js/wasm-terminal.test.html - name: Upload artifact for checking the output - uses: actions/upload-artifact@v8 + uses: actions/upload-artifact@v7 with: path: ./public diff --git a/static/js/wasm-terminal.js b/static/js/wasm-terminal.js index fd5b9afb7..1f79bbeb2 100644 --- a/static/js/wasm-terminal.js +++ b/static/js/wasm-terminal.js @@ -638,10 +638,30 @@ async function executeCommandLine(line) { } try { + // sed's script argument is a program, not a path — it must NOT go through + // resolvePath, which normalizes path segments and would strip a trailing + // delimiter (e.g. `s/world/there/` -> `s/world/there`, breaking the `s` + // command). Collect the indices of any sed script arguments to skip. + const sedScriptIndices = new Set(); + if (cmd === "sed") { + let scriptFromFlag = false; + for (let i = 1; i < args.length; i++) { + const a = args[i]; + if (a === "-e" || a === "-f") { sedScriptIndices.add(i + 1); scriptFromFlag = true; i++; continue; } + if (a.startsWith("-e") || a.startsWith("-f")) { scriptFromFlag = true; } // combined form, e.g. -e's/a/b/' + } + // Without -e/-f, the script is the first non-option argument. + if (!scriptFromFlag) { + for (let i = 1; i < args.length; i++) { + if (!args[i].startsWith("-")) { sedScriptIndices.add(i); break; } + } + } + } // Resolve relative paths using the virtual cwd const resolvedArgs = args.map((arg, i) => { if (i === 0) return arg; // command name if (arg.startsWith("-")) return arg; // flag + if (sedScriptIndices.has(i)) return arg; // sed script, not a path return resolvePath(arg); }); // If the command takes a default path (like ls) and no path args