Hacker News new | ask | show | jobs
by _carl_jung 2161 days ago
Sorry for the late response.

> execute relatively small snippets of shell code/one-liners as part of an asset management pipeline without having to "shell-out" and invoke an external process

This is indeed a small part of the value of my shell, though I wouldn't view it as the primary reason. I'm trying to make a nice experience for an interactive command line shell first, then will think about scripting use cases.

Blurring that line between shell + scripting is my intention, so it would be good to capture your case here at some point.

> Requirements for shell control constructs are modest, but piping and redirection should work, as well as limited shell var/macros expansion, and maybe if/then.

I'm struggling to understand one detail of your use case here. Is this a script (stored as some e.g. .js file), or something you'd be executing interactively? If the former, my shell does have as part of its library a suite of tools for executing shell commands (including piping + redirect) from within the Deno runtime. That would make something like the following possible:

const jsFilesInDirectory = await exec('ls | grep .js');

if (jsFilesInDirectory.includes('index.js') {

  // some logic
}

The above is also strikingly similar to shelljs, but my solution differs in a key way: where shelljs is re-implementing many commands, I've developed logic for parsing and evaluating any shell-like "pipe-separated" commands.

In any case, the primary intention of my project is to create an interactive shell, not a scripting language. That said, it would be possible to tease out and reproduce my logic to parse and execute piped commands in Node.js, to allow for a slightly more capable "shelljs" clone.

Hope that helps.

1 comments

Yes, as I looked into your code, I was even tempted (in thought only, eg subconsciously feasability-checking) to fork/rip your shell syntax parser and plug it into shelljs to replace theirs ;)

To clarify, in my use case, the native asset meta-format for declaring assets and their relationships has a "field" where you can put in an external command to prepare the asset (such as minifying, sass compilation). Like in a Makefile.