Comments (8)
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.
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.
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.
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.
@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.
@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.
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.
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)
- `#<undef> is used in boolean context` when interpolating module name in REPL
- configure - Program text - Stree or list of lines?
- Return value of `process-output->string` when the subprocess exits abnormally
- configure - Wrong substitution of `@srcdir@` HOT 1
- shell-compatible `case`
- Initialization fails if descriptive type instance is precompiled
- cf-output needs better escaping HOT 3
- Tiny issue: gosh precomp usage HOT 1
- Printing content of hashtables/treemaps
- Revise uuid API
- Better genconfig
- write-uvector doesn't understand 'big endianness HOT 2
- Detangle `ScmEscapePoint` HOT 1
- generic ref for <box> HOT 2
- gauche.collection breaks repl completion? HOT 3
- Rewrite `let-args` to object-centric model
- Efficient parameterizaton of ScmNumberFormat through ScmWriteControls
- Hide sensitive info from `-V` output HOT 3
- Security implication of `COMPILE_R7RS` HOT 3
- ffitest error on Fedora 40
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 gauche.