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

Accept a script through standard input, not only a file argument #38

Closed roryokane closed 9 years ago

roryokane commented 9 years ago

Currently, the only way to compile a script is passing an existing file as an argument:

./bish input.bish > output.bash

I think bish should be able to read a script from standard input, too:

cat input.bish | ./bish > output.bash

Why does this feature need to be added? Well, it would make bish adhere more closely to UNIX principles, making it easier to use in various scripts. But the specific reason I care is that it makes experimentation easier. After I compiled bish, the first thing I tried was this:

echo "export x=3" | ./bish

I wanted to see what kind of boilerplate bish adds to its output. I was disappointed that the command failed. I see no downside to changing bish so that it works.

tdenniston commented 9 years ago

Should be pretty easy to add. I'll hopefully have a few minutes tonight to get that in.

As a side note, export x=3 is a bash command, not a bish statement. So for your experiment you'd want to do something like echo "x=3;" | bish.

tdenniston commented 9 years ago

This is now implemented. If you specify '-' as the input file, it will read from stdin. You can now do things like this:

echo 'println("hello");' | bish - | bash