Comments (6)
Ouch, we have our first bug :). This used to work on previous development versions, but I had to rework the capture code to solve a bug related to redirections, and accidentally introduced this bug while doing so. The issue is that we're reading the pipe after waiting the command to finish, but the command is waiting because the pipe is full. I already have a fix in mind, and will try to implement it until the weekend. Thanks for reporting!
from hush.
Interesting cause... makes me think about my comment in another issue about being able to read stdout from async capture before joining.
I'd imagine hush will need to support streaming input as bash supports streaming output.
from hush.
Talking about that, if I recall correctly, to stream output using bash one would use a named fifo (mkfifo) and then use standard redirection operations to route the data. Something like:
#!/usr/bin/env bash
mkfifo /tmp/webserver.log
webserver --start > /tmp/webserver.log &
while read data < /tmp/webserver.log; do
# use $data
end
Considering this approach, it makes sense to have the capture block produce a single string instead of streaming the output. What do you think?
from hush.
Fixed by 335d5b7, released on v0.1.3-alpha
from hush.
When you pipe in bash I believe it also streams. i.e. I believe that each line of output is sent to the next command in the pipe immediately, it doesn't batch multiple lines.
I think Hush will need to support this or miss out on some common use cases. For example, if I want to tail live server logs and filter lines to print only the ones with errors I can do something like aws logs | grep 'ERROR'
. I don't think that currently I can do this in hush with an async capture around the aws logs
since the command would never finish on its own.
from hush.
But those are two separate features, and both work the same way in Hush and Bash. Capture is synchronous, so it will hang until the command finishes.
#!/usr/bin/env bash
$(mycommand)
#!/usr/bin/env hush
${ mycommand }
Pipes on the other hand are asynchronous, and will allow data streaming.
mycommand | tee file.log | grep Error
{ mycommand | tee file.log | grep Error }
Hush implements the exact same behavior as Bash in both cases.
from hush.
Related Issues (20)
- Filesystem queries HOT 6
- Publish vscode extension to open-vsx HOT 2
- Feature: Add print() function with no newline HOT 3
- Parse error when std.import'ed script contains executable statements HOT 3
- Feature: Add symbols for interpreter, program, and script HOT 3
- Feature: Add 'File' support that can cross the curly-block barrier HOT 1
- Feature: Add support for multi-way conditional(s) HOT 1
- Question: std.catch with parameters HOT 4
- Running script has no output unless run inside another program HOT 7
- Test using `capture.hsh` fails HOT 7
- Feature: Potential for bash transpilation? HOT 1
- External: Neovim syntax highlighting and static checks HOT 1
- Regex doesn't work due to UTF-8 HOT 2
- [Suggestion] Add global prelude HOT 5
- The command block commands require extra escape HOT 1
- Tests HOT 2
- Async not working HOT 2
- Feature Request: Include and import HOT 3
- Syntax sugar for function containing shell commands HOT 2
- Can't use `elseif` and `else if` with one `end` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hush.