Comments (8)
Hi, good question. I will take a look when I get back in 2 days. Just a couple of questions:
- are you using SwiftShell from a command-line application/script or a GUI application?
- which version of macOS or Linux?
- is the external script launched using bash?
from swiftshell.
are you using SwiftShell from a command-line application/script or a GUI application?
I'm using it as part of a WebSocket API I'm building. The user triggers the action and the result, or pending input, are sent back on the socket.
which version of macOS or Linux?
I'm planning to run my application on macOS 10.11.6
is the external script launched using bash?
It can be multiple tasks. In scope there is git
command and some ruby executable applications. Does this answer your question?
If you have any input I could investigate to help you with this, let me know :)
from swiftshell.
This is something like what I had in mind. The problem is the closure you assign to onInput
will be called many many times, even if the script/command you are running is not asking for input (that is, not pulling its standard input). Se the aptly named testFoundationWriteabilityHandlerBeingCalledWhenNoInputIsAskedFor
unit test.
from swiftshell.
You will in any case also have to check the stdout of the command to see what input the script is asking for. Also I think many commands will wisely not ask for input if its stdin is not a terminal session. So we will have to trick them into thinking our filehandle actually belongs to a terminal.
from swiftshell.
I don't know how to be notified only when and if a command asks for input. I'm leaving this open in case someone else does.
from swiftshell.
Are there any updates on this? I also need this for Mint yonaskolb/Mint#37
from swiftshell.
I implemented stdin in cmdshelf.
You might be interested to the implementation, so FYI.👋
https://github.com/toshi0383/cmdshelf/blob/master/Sources/cmdshelf/Functions.swift#L10
The function name is "shellOut", but not using JohnSundell/ShellOut.
from swiftshell.
I don’t know any more about this than I did 1 year ago I’m afraid. FileHandle’s writeabilityHandler seems like the right tool for the job but I couldn’t get it to work properly. You can see my attempt here: https://github.com/kareman/SwiftShell/compare/writeablestream-oninput
from swiftshell.
Related Issues (20)
- runAsync(bash"") cannot write nothing on onStringOutput on mac osx app standalone HOT 2
- `waitUntilExit` cause slow execution HOT 1
- How to execute rm -rf /xxx/* HOT 3
- Could not find module 'SwiftShell' for target 'arm64-apple-macos'; found: x86_64, x86_64-apple-macos
- How to execute an ncurses-based command? HOT 2
- run shell empty output HOT 4
- PID of the command launched using SwiftShell
- The interactive command is suspended at the terminal
- Im trying to find a way to make a run cancellable
- Not support `Pod` command HOT 5
- New syntax? HOT 2
- Xcode 12 beta / Swift 5.3 not building HOT 5
- Tupling issue? HOT 1
- Request for an API that do not exit when executable to run is not found HOT 2
- Final released Swift 5.3 crashes on compile HOT 10
- Using ubuntu-latest for GHAction Test HOT 4
- Make run and throwable HOT 1
- onStringOutput returning nothing.
- Allow `run` to take an array HOT 1
- How to pipe with different contexts?
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 swiftshell.