aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cli/run_command.zig18
-rw-r--r--test/cli/run/run-quote.test.ts15
-rw-r--r--test/harness.ts2
3 files changed, 34 insertions, 1 deletions
diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig
index 24304f169..0c9145db1 100644
--- a/src/cli/run_command.zig
+++ b/src/cli/run_command.zig
@@ -192,6 +192,24 @@ pub const RunCommand = struct {
delimiter = 0;
},
+ // TODO: handle escape sequences properly
+ // https://github.com/oven-sh/bun/issues/53
+ '\\' => {
+ delimiter = 0;
+
+ if (entry_i + 1 < script.len) {
+ switch (script[entry_i + 1]) {
+ '"', '\'' => {
+ entry_i += 1;
+ continue;
+ },
+ '\\' => {
+ entry_i += 1;
+ },
+ else => {},
+ }
+ }
+ },
else => {
delimiter = 0;
},
diff --git a/test/cli/run/run-quote.test.ts b/test/cli/run/run-quote.test.ts
new file mode 100644
index 000000000..a6dffbd6a
--- /dev/null
+++ b/test/cli/run/run-quote.test.ts
@@ -0,0 +1,15 @@
+import { expect, it } from "bun:test";
+import { bunRunAsScript, tempDirWithFiles } from "harness";
+
+it("should handle quote escapes", () => {
+ const package_json = JSON.stringify({
+ scripts: {
+ test: `echo "test\\\\$(pwd)"`,
+ },
+ });
+ expect(package_json).toContain('\\"');
+ expect(package_json).toContain("\\\\");
+ const dir = tempDirWithFiles("run-quote", { "package.json": package_json });
+ const { stdout } = bunRunAsScript(dir, "test");
+ expect(stdout).toBe(`test\\${dir}`);
+});
diff --git a/test/harness.ts b/test/harness.ts
index bfd159b18..b0cedba74 100644
--- a/test/harness.ts
+++ b/test/harness.ts
@@ -81,7 +81,7 @@ export function hideFromStackTrace(block: CallableFunction) {
}
export function tempDirWithFiles(basename: string, files: Record<string, string>) {
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), basename + "_"));
+ const dir = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), basename + "_"));
for (const [name, contents] of Object.entries(files)) {
fs.writeFileSync(path.join(dir, name), contents);
}