Giter VIP home page Giter VIP logo

Comments (8)

kareman avatar kareman commented on May 24, 2024

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.

fabiomassimo avatar fabiomassimo commented on May 24, 2024

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.

kareman avatar kareman commented on May 24, 2024

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.

kareman avatar kareman commented on May 24, 2024

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.

kareman avatar kareman commented on May 24, 2024

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.

yonaskolb avatar yonaskolb commented on May 24, 2024

Are there any updates on this? I also need this for Mint yonaskolb/Mint#37

from swiftshell.

toshi0383 avatar toshi0383 commented on May 24, 2024

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.

kareman avatar kareman commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.