Comments (12)
This might be a useful option - I stumbled into this when realizing exit
didn't work, and I had to do (exit)
.
from racket-rash.
That's how I thought of it too. A kind of workaround you can do for exit is make a line macro called quit or something, I'm not sure if there's a way to name it exit due to circular deffinitions. You can also do |> exit
, but that's not very easy to type.
from racket-rash.
So you can do this with a different pipeline operator, and you can set the default to be different ones. The way to set the top-level default in the repl is with a jenky set! command, but I hope to improve that at some point. In general it is a syntax parameter. Check out the =obj-if-def/unix-if-undef=
operator in the shell-pipeline/demo/more-pipeline-operators.rkt
file.
Perhaps something like that should be the default, but I'm somewhat hesitant to do that.
from racket-rash.
(I always use the C-d
keystroke instead of (exit)
...)
from racket-rash.
Stupid question, but how would I go about setting the top level as you mention? I tried:
(set! #%top =obj-if-def/unix-if-undef=)
; and
(set! default-pipeline-starter =obj-if-def/unix-if-undef=)
but it says bad syntax.
from racket-rash.
sigh Sorry I wasted your time with that -- somehow I thought it was documented, and I was sleepy. The form is (set-default-pipeline-starter! new-starter)
.
from racket-rash.
I have various thoughts about different ways I might do it going forward, but they are still a little nebulous and I put that one in just to have something available.
from racket-rash.
Something I noticed when using =obj-if-def/unix-if-undef=
is that aliases are counted as identifiers, so it tries to run them using =object-pipe=
which doesn't support macros as the first arg. Maybe something like =unix-if-supported/otherwise-racket=
would be a good default, although I'm not sure how that would be implemented nicely, and not something like: try to run it with unix and if it fails, try to run it in racket.
from racket-rash.
I think it should prefer the executable over an identically named racket function, at least in the repl, since it's easier and more Intuitive to type (racket-function)
that it is to type =unix-pipe= external-command
from racket-rash.
As I said about stuff in the demo directories -- half baked. But it wouldn't be too hard to get it to recognize aliases.
But the question of when to prefer what is one of the things keeping me from wanting it as a default. If you let any bound Racket identifier defer to =object-pipe=
but you've imported something that happens to conflict with a command name that's annoying. But I think it would be even worse to check first if a program of the right name exists -- if you add a program to your path that happens to have the same name as a function you are using in a script, suddenly your script breaks.
from racket-rash.
That's also one of the reasons aliases exist (because frankly you could define aliases as pipeline operators instead) is to be able to define a set of Racket functions that you want to use without specifying a different pipeline operator without having the wonky behavior of an operator that checks if a program exists.
from racket-rash.
Yeah, the more I think about it, merging external programs and racket functions sounds like a bad idea. It's easy enough to make a line macro that can run racket functions.
from racket-rash.
Related Issues (20)
- Save history between sessions? HOT 1
- SIGPIPE issue
- Ctrl-C handling HOT 4
- testing maubot integration
- Relicensing Rash HOT 8
- Allow comment with # in repl HOT 1
- terminal title with current directory HOT 2
- Tab completion does not quote
- ls causes issues with history-delete HOT 18
- Can't exit shell on Mac OS X HOT 2
- Behavior of Control-c (C-c, ^C, SIGINT) when no process is active HOT 3
- How to build documentation? HOT 2
- contract violation on 8.2[cs]? HOT 6
- Resizing terminal emulator
- Rash in Jupyter (with iracket) HOT 5
- multi-line readline prompt with ansi-escapes HOT 3
- Get the exit code of the last command HOT 2
- Tab completion doesn't escape `]`
- Nix flake / nixpkgs package HOT 2
- invalid memory reference HOT 4
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 racket-rash.