dsherret / dax

Cross-platform shell tools for Deno and Node.js inspired by zx.
MIT License
969 stars 33 forks source link

Keep new lines in commands? #153

Closed sigmaSd closed 1 year ago

sigmaSd commented 1 year ago

Currently commands seems to not keep new lines in string literals, the workaround is to use quotes inside, is this by design ?

import { $ } from "./mod.ts";

await $`echo hello
world`; // the new line here becomes a space
console.log("------------------------------");
await $`echo "hello\nworld"`;

result

hello world
------------------------------
hello
world
dsherret commented 1 year ago

Yeah, that's by design. The first command is passing two arguments (["hello", "world"]) and the second is passing one (["hello\world"]). I think it's similar to how echo hello world outputs hello world.