tdenniston / bish

Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.
MIT License
1.48k stars 36 forks source link

biah interpreter #7

Closed reklis closed 9 years ago

reklis commented 9 years ago

Perhaps there is some way to have a single step compile / source so that we could make .bish files executable and put a shabang at the top?

Something like :

!/usr/bin/env bish

...

And then that automatically does this when you run it:

bish < myscript.bish | bash

Or something to that effect?

Having to compile it seems like a lot of friction for quick and dirty. But it is great for deploying when you want to drop something on a server and not have to install anything (namely bish)

hawkw commented 9 years ago

:+1: This would also open up the possibility of a REPL, which is always nice.

Inndy commented 9 years ago
#!/bin/bash
bish $1 | bash
ghost commented 9 years ago

Why don't you write a program that accepts the filename of .bish as the last argument, redirects the stdout to an output file and finally executes bish to compile .bish?

Accepting a filename as the last argument makes the program possible to be "called" from shebang, and the name of the file, where the shebang is, is the last argument.

Upd: yeah, it's my fault, s/to an output file/to bash.

eridal commented 9 years ago

being able to #!/usr/bin/env bish would be nice

tdenniston commented 9 years ago

I do like this idea. It shouldn't be too difficult to write a bish to bash pipeline usable from the shebang. Something like ExeTwezz's idea, only instead of redirecting to an actual output file, connect bish stdout to bash stdin. With large programs, however, this might result in noticeable delay as the parser and code generator would be run before every execution.

tdenniston commented 9 years ago

Thanks to @noahmorrison for implementing this.