GithubHelp home page GithubHelp logo

Comments (8)

shirok avatar shirok commented on August 20, 2024

scsh-type shell control has long been on my todo list. One problem I see in scsh approach is that it introduces sort of mini-language but with confusing syntax (i.e. comnand arg list and redirections are both represented by lists. For example, (ls -l) and ((ls -l) (> 1 "abc")) both represent a process, but in the first one the outer list represents command and its args, while the second one the outer list have different meaning.

I feel we need either (1) an DSL a lot more tuned for shell programming, or (2) more compositional approach, e.g. each process form becomes a first-class object and we combine them much like function composition.

I vaguely remember there was a discussion among uses several years back. I'll dig it up if I can find it.

from gauche.

pclouds avatar pclouds commented on August 20, 2024

Thanks. I will also look at Haskell and see how they deal with this. A quick search shows that they do have shell-like functions.

from gauche.

xificurC avatar xificurC commented on August 20, 2024

Looking at some examples I don't see how yours would work @shirok . From what I can see each process in scsh notation is a non-nested list, although I admit I haven't checked all the procedures. When trying your example in chicken-scheme's implementation I get an error. The correct syntax would be (run (ls -l)) in the first case which was correct and (run (ls -l) (> "abc")) in the second.

I understand the opinions can vary on the process notation though. Personally I found it takes a while to get it right but is composable and to the point. Either way getting a mini-DSL or a more powerful API to handle processes would be greatly welcomed by me as I could drop writing bash scripts to glue external commands together. The chicken implementation of scsh-process hits in 400 loc and could probably be easily ported to gauche, but I'm not going to as far as looking into it if you have a different solution in mind :)

from gauche.

pclouds avatar pclouds commented on August 20, 2024

Just a bit of update from my side if anyone is wondering. I'm so busy with stuff that I still have not investigated any further :(

from gauche.

shirok avatar shirok commented on August 20, 2024

@xificurC, in the development HEAD I've added do-process and do-process-pipeline in gauche.process. These wrap the counterparts of run-* version for the typical case that you run process synchronously and only care about its exit status. With them, typical process operations (shell's && and || and conditionals) can be written as mere Scheme expressions. Document is half-done and sitting in my local branch, though.

The advantage is that users don't need to remember yet another DSL to handle all possible options and various ways to combine processes. The disadvantage is it's more verbose than process forms. Some of verbosity can be addressed by tuning the API, I think.

from gauche.

xificurC avatar xificurC commented on August 20, 2024

@shirok I remember you adding those, it actually stemmed from a mail question I had, thanks :)

Maybe if there was an API with a bit higher-level coverage that would allow all of redirection and pipelining options it would suffice. If not it would be a good base for someone to wrap that in another scsh (or something alike) DSL for his/her own needs. I understand you're not keen on building DSLs out of everything, but when one wants to use something extensively it really pays off.

from gauche.

pclouds avatar pclouds commented on August 20, 2024

There is 7424fd7 (Introduce do-pipeline/run-pipeline - 2017-01-10). Together with do-process, process-output->... I think we have covered pretty much all common cases (the other two are maybe string->process-input and something that does (cat port) | command | (port->string-list) or something along that line, where the port is not a file.

Anyway I think I'm closing this ticket since it's good enough, and I did not make any progress at all about the DSL front. It'll come up when it comes up.

from gauche.

shirok avatar shirok commented on August 20, 2024

Thanks. For the uncovered cases, feel free to open issues if you can identify a specific common pattern you want to support.

from gauche.

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.