Code Monkey home page Code Monkey logo

racket-rash's Introduction

Rash: The Reckless Racket Shell

Scribble Docs

Rash is a shell language, library, and REPL for Racket.

Use as a repl that is as convenient for pipelining programs as Bash is, but has all the power of Racket. Use as a scripting language with #lang rash. Embed in normal Racket files with (require rash), and mix freely with any other Racket language or library.

Rash is in active development, but it is largely stable (and the parts that aren't are marked as such). I use it as my default interactive shell on my laptop. It currently lacks the interactive polish of Zsh or Fish, but it is so much better as a language. Every script I've ported from a Bourne-related shell to Rash is more robust, simpler, easier to maintain, easier to expand, and much more fun.

Getting started

Prerequisites

Rash does work on windows, but it works better and is more useful on unix based systems.

To install, you will need a working installation of racket v6.12 or later.

Installation

You can either install with racket's built in package manager, raco, or install directly from github. If you have DrRacket installed, you can install rash with File -> Install Package.

via raco:

raco pkg install rash

git version:

git clone https://github.com/willghatch/racket-rash rash && cd rash/linea && raco pkg install && cd ../shell-pipeline && raco pkg install && cd ../rash && raco pkg install

OR

use raco pkg install --clone rash

Readline

The Rash REPL currently relies on Racket's Readline FFI wrapper. However, by default Racket uses libedit instead of libreadline for licensing reasons. Libedit does not support unicode, so typing non-ASCII characters will result in sadness. To use libreadline instead, run raco pkg install readline-gpl. Note that the readline-gpl Racket package needs a libreadline shared library to be installed on your system, so you may need to install a libreadline package using your system package manager. For example, on Debian-based distributions you can install by running sudo apt install --yes libreadline-dev.

Usage

Run with racket -l rash/repl --, or with rash-repl if you have Racket's package bin/ directory on your path.

Online documentation is here. After installation, local documentation can be accessed with raco docs rash.

The project web site has a quick demo video of Rash in action.

I published a paper about Rash in GPCE 2018.

This repo also contains the shell-pipeline and linea packages. They mostly support Rash itself, so they live in the same repo.

Talk

Feel free to ask questions in issues, to join the matrix room, to email me, etc.

racket-rash's People

Contributors

alexknauth avatar bennn avatar bostx avatar colelyman avatar jasperpilgrim avatar jgarte avatar lexi-lambda avatar lordmzte avatar octplane avatar rfindler avatar willghatch avatar zlee-personal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

racket-rash's Issues

rash vs rash/out

Not sure if you've noticed this yet, but rash will error out on any command (rash/out works just fine).

~> racket
Welcome to Racket v6.7.
> (require rash)
> (rash/out "ls | wc -l")
"15\n"
> (rash "ls | wc -l")
15
#<pipeline:success=#t,return=0>

> ; error writing to stream port
;   system error: Broken pipe; errno=32
; [,bt for context]
,bt
; error writing to stream port
;   system error: Broken pipe; errno=32
;   context...:
;    /usr/share/racket/collects/racket/private/port.rkt:129:15: loop
;    /usr/share/racket/collects/racket/private/port.rkt:123:4: loop
;    /home/lehi/.racket/6.7/pkgs/shell-pipeline/shell/pipeline.rkt:512:31
>

startup hints

I added a startup hint feature meant to be reminiscent of video games that give a hint on startup or in a loading screen. I feel that such a feature could improve discoverability of shell features for new users. However, right now the hints I added are pretty useless.

Does anyone have ideas for good hints/tips to give users? Or should I scrap this feature?

Recording link on README is broken

The video page ends up with this message

All unclaimed recordings (the ones not linked to any user account) are automatically archived 7 days after upload. 

objects in pipelines

To have a useful suite of system administration commands in Racket, I think Rash needs a convention of object types for commands to pass around. While Rash can pass arbitrary Racket objects (and by objects I mean values, not necessarily instances of classes) between pipeline stages, I think many commands would be useful if they provided something with a shared interface. One thing that is nice about powershell's objects is that they can be enriched with extra methods or fields by intermediate pipeline stages. Eg. a user can list files, send them to a stage that annotates each file object with extra data in some field, and then a final stage processes the files using that extra annotation to determine how each file should be handled -- eg. to be displayed differently, updated in different ways, etc. Javascript objects and Lua tables fit this model well -- they are essentially dictionaries that can be extended arbitrarily while still adhering to various interfaces.

I think I want this type of object to be available for Rash commands to use. I imagine it as a struct that includes a dictionary and supports gen:dict for arbitrary updates, but that can also be extended to support various generic interfaces or struct type properties. One problem here is that struct type properties are on struct types and not struct instances. I've played with various ways of getting around this. For example, I toyed with a protocol for struct type properties to look for instance properties as well, but this would only work for properties that are created with this behavior in mind, and therefore would not be able to fulfill most interfaces. Creating a new struct type that adds new properties could work, but this has problems with things like struct-copy and generic interface implementations that do similar things when functionally updating a struct. I've been advised to check out chaperones to get this kind of behavior, but I haven't looked into it yet.

Anyway, I thought I would add this to an issue for the record, rather than having all of this just in my head.

When typing non latin chars in REPL - get "¼Ð³Ð¼Ð¾ÑÐ"

When typing non latin chars in REPL - get "¼Ð³Ð¼Ð¾ÑÐ"
Steps to reproduce:

  1. Install Dr. Racket
  2. raco pkg install rash
  3. run in terminal emulator racket -l rash/repl
  4. try to type non latin chars

Tested on Manjaro Linux and FreeBSD in xterm qterminal and xfce terminal

commenting code

Are you okay with comments above functions in the code that describe what they do for more complex functions? I was reading over the code and was wondering if I could write some in to understand how the code works better. But some people find that it clutters the code so I wanted to make sure.

cd: collection not found

I updated to the latest planet rash and ran the setup on my project, which depends on rash and got:

/home/pmatos/.racket/6.11/pkgs/rash/rash/private/cd.rkt:11:1: collection not found
  for module path: shell/utils/bourne-expansion-utils
  collection: "shell/utils"
  in collection directories:
   /home/pmatos/.racket/6.11/collects
   /home/pmatos/installs/racket-6.11/collects
   ... [167 additional linked and package directories]
  compilation context...:
   /home/pmatos/.racket/6.11/pkgs/rash/rash/private/cd.rkt
   /home/pmatos/.racket/6.11/pkgs/rash/rash/private/lang-funcs.rkt
   /home/pmatos/.racket/6.11/pkgs/rash/rash/main.rkt
   /home/pmatos/Projects/linkithumb/scripts/extract-random-programs.rkt
  context...:
   show-collection-err
   standard-module-name-resolver
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:363:0: compile-zo*
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:572:26
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:564:42
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:635:0: compile-root
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:782:4: compilation-manager-load-handler
   standard-module-name-resolver
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:363:0: compile-zo*
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:572:26
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:564:42
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:635:0: compile-root
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:782:4: compilation-manager-load-handler
   standard-module-name-resolver
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:363:0: compile-zo*
   /home/pmatos/installs/racket-6.11/collects/compiler/cm.rkt:572:26

require tries to require from pkgs/rash/private

If I have "test.rkt" in my home dir and I try to require it, I get:

#(struct:exn:fail:syntax:missing-module readline-input:16:9: cannot open module file
  module path: #<path:/home/vityou/.racket/6.12/pkgs/rash/private/test.rkt>
  path: /home/vityou/.racket/6.12/pkgs/rash/private/test.rkt
  system error: No such file or directory; errno=2 #<continuation-mark-set> (#<syntax:16:9 #<path:/home/vityou/.racket/6.1...>) /home/vityou/.racket/6.12/pkgs/rash/private/test.rkt)

I think it's because it evaluates require forms in the context of the rash/private/repl-namespace file.

Capture failed pipeline

I am starting to have more and more scripts using rash but they are quite flaky in general.
One thing I still haven't figured out the best way to achieve is grab a pipeline failure with the failing exit code. For example:

#lang rash
(define (my-false)
  {true
   echo "1"
   false
   echo "42"})

I get:

> (my-false)
1
; run-pipeline: unix pipeline-segment (#<path:/usr/bin/false>) terminated with code 1
; 
; Context:
;  /home/pmatos/.racket/7.3/pkgs/shell-pipeline/private/mixed-pipeline.rkt:161:6 for-loop
;  /home/pmatos/.racket/7.3/pkgs/shell-pipeline/private/mixed-pipeline.rkt:257:0 unpack21
;  /home/pmatos/Projects/igalia/jsc-utils/webkit.rkt:23:0 my-false
;  /home/pmatos/installs/racket-7.3/collects/racket/repl.rkt:11:26

I see the error call that terminates this in the rash source (https://github.com/willghatch/racket-rash/blob/master/shell-pipeline/private/mixed-pipeline.rkt) however this error call is less than ideal if I want to grab the error and the exit code. I could in principle catch the exception thrown by error (exn:fail) and parse the string, however this is less than ideal. Is there a good way to actually do this at the moment?

Question: Executing commands inside strings

When you run docker-machine to create a machine you need to change your environment so that you can control the machine using docker. docker-machine provides the information you need to change the environment.

So, after you create a machine you usually run eval $(docker-machine env my-machine).
I want to do this in rash, but eval doesn't exist and $(...) gets me into racket and rash complains docker-machine in this case is an undefined identifier.

Now, I can do this:

(define machine-name "my-machine")
(define lines (string-split #{docker-machine env $machine-name} #\newline))
(for ([l (in-list lines)])
  ...)

For reference, the output of docker-machine env ... looks like:

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://18.185.184.7:2376"
export DOCKER_CERT_PATH="/home/pmatos/.docker/machine/machines/test-machine"
export DOCKER_MACHINE_NAME="test-machine"
# Run this command to configure your shell: 
# eval $(/usr/bin/docker-machine env test-machine)

So in the loop above l will take the value of each of these lines. I would like to run them but I can't figure out how to do that. Any help on how to achieve this would be great.

multiple value return error when using pipe operators

I was just playing with rash and noticed the following:

> ls |> (lambda (s) (values 1 2))
Result 46:
result arity mismatch;
 expected number of values not received
  expected: 1
  received: 2
  values...:
   1
   2

It fails similarly when using |>> as well.

prompt info

I want to collect ideas for what kinds of information would be useful in prompts. I want to have a library of useful functions for making prompts, but also I want a good default prompt.

Here are some ideas I have:

  • Version control info -- the default already has git info, but info for other version control systems would be good too.
  • User/host info -- most shells show this info by default, but I find I want it only conditionally -- I want the username to show when I'm logged in with a different username than I usually am, and I want the host name when I am logged into something remotely. Perhaps the default should show both, but should also provide a parameter to set for each, so a user can include a quick snippet of code in their RC file to check for such conditions without having to set a custom prompt to customize that info.
  • Battery state
  • Time
  • Eventually, after getting a better line editor, I would like more dynamic functionality for the prompt -- eg. let the prompt re-draw itself at any moment with updated info. This can include editor state for the enlightened typists who use modal editing, the current time now rather than the time when the last command ended, etc. Also, such a system could allow the "I'm writing my new command now" prompt to be replaced in the history with a "historical prompt", which removes information like editor mode and anything uninteresting for history while adding information useful for history but not necessarily interesting while typing the next command -- command start time and date, expected run-time based on previous uses of the same or similar command, etc
  • Current directory shortening -- shells usually use ~/ when a path is a subdirectory of your home. It would also be nice to allow other well-known paths set by the user to have a shorthand -- eg. $dev/rash-repo for /path/to/development/environment/rash-repo. Additionally, it would be nice to be able to set a maximum width for the path or the entire prompt and optionally compress the path like /p/t/d/e/rash-repo.
  • Current directory path extra info -- I the path to be more useful than in most shells. For example, I made a custom zsh prompt that uses colors on path elements to show ownership and read/write info. I like that, but I would like even more info. Information can be shown with color and with style bits like bold, underline, and italic. Each of these can be applied separately to the directory name and the slash following it (except for the root directory, but I'm ok with showing less info for that). Information I would like to see includes ownership and permissions info, whether a path element is a symlink, whether a path element crosses a file system boundary, what kind of file system a directory is in (eg. is it a normal fs, a ramfs, a remote fs a la NFS or sshfs, etc), whether a path element is the root of a version control repo... Extra info could also be shown inline with the path, eg. ~/dev/rash{master, other git info}/linea/.... However, both path shortening and inline extra data that is not encoded in the style make it impossible to copy/paste a path and use it. So I'm somewhat wary of both of those options.

The path styling could be something like this:

  • read-only = underline for name
  • ownership = color for name
  • symlink = bold for name
  • fs type = color for slash
  • repo root = bold for slash
  • cross FS boundary = underline for slash

Would people like this or simply find it annoying? Is there other information you would want in a prompt?

I feel I would rather err on having too much info in the default prompt rather than having a bland and useless prompt like most shells come with by default.

maybe confusing behavior with line-macro syntax class

I'm defining a line macro called slm with the goal being to have an easy way to create line macros:

; stands for "simple line macro"
(define-line-macro slm
  (syntax-parser
    ; if lm is defined in the form `slm name = (blah x y)`
    [(_ name:id (~datum =) (~and value:expr (~not line-macro)))
     #'(define-line-macro name
         (syntax-parser
           [(_) #'value]))]
    ; if lm is defined with multiple things after `=` ex: `slm name = blah x y`
    ; it just wraps them in parentheses so it would become `(blah x y)`
    [(_ name:id (~datum =) first-thing ...)
     #'(define-line-macro name
         (syntax-parser
           [(_) #'(first-thing ...)]))]))

The idea is to minimize parentheses, so I'm trying to make it so that line macros that look like expressions, like cd with no arguments fall through to the second clause, and normal expressions like (display "hi") are handled by the first clause. This works pretty well, until it encounters a line macro wrapped in parentheses, like (cd) or (cd ..). Apparently it recognizes them as line macros so they fall through to the second clause and are wrapped in too many parentheses. I would have thought that they would be recognized as expressions and not line macros since they aren't straight like macros and are wrapped in parentheses.

I would like to avoid having to force the user to only provide s-expressions as values for their macros if possible.

How to define an alias

For example if I wanted to make ls run ls --color=auto, or make la run ls -a, how would I do that? Also, how do you define or edit environment variables like PATH? Thanks for any help.

Add a secondary Posix-compatible mode

Personally, I don't care much about trying to run existing scripts in Rash, but I definitely want to be able to source /etc/profile with it!

This is especially a problem on eg. NixOS, because without sourcing /etc/profile (or copying the relevant bits into a rashrc), Rash inherits Racket's limited environment instead of getting a useful environment... This has been a pain since I switched to NixOS.

Ultimately, though, supporting /etc/profile eventually means there should be a mode that is basically Posix shell support in Racket. Then I guess we could make a mode that is Posix compatible but extended to allow Rash-like things as well.

[Windows] path

run-pipeline: unix pipeline-segment (#<path:C:/Users/libre/scoop/apps/yarn/current/Yarn/bin\yarn>) terminated with code -1

Is there a pipeline operator that can run forms

For example, something like:

=pipeline-name= cd ..
or
=pipeline-name= (cd ..)

I am trying to create a line macro that can define aliases that can run arbitrary racket code, so I can create aliases like ../.. that turn into (cd ../..).

Interaction with plot library

I noticed something that looks like a bug (might be known):

  1. I am using Racket 7.3 on Ubuntu 16.04 using Unity
  2. I open rash using racket -l 'rash/repl' on the cmd line
  3. I attempt to use the plot library using the following commands:

(require racket/math)
(require plot)
(plot-new-window? #t)
(plot (function sin (- pi) pi #:label "y = sin(x)"))

I find that I cannot open a plot window successfully; instead I get a window that looks like it contains portions of my shell text and which I cannot close by clicking the "x" in the upper left hand corner of the window.

If I use the same commands using racket (without rash) on the cmd line then it works.

want to say rash is great btw!

error running any command in rash on racket 6.12

I have installed racket 6.12 from the PPA on ubuntu 18.04.
I have also installed rash from raco
When I attempt to use rash, I get the following issue:


$ raco pkg show rash
Installation-wide:
 [none]
User-specific for installation "6.12":
 Package  Checksum                Source
 rash     8c75faf666c6376d965...  catalog...it?path=rash
$ racket --version
Welcome to Racket v6.12.


$ dpkg -l | grep racket
ii  racket                                6.12+ppa1-1~bionic2                  amd64        extensible programming language in the Scheme family
ii  racket-common                         6.12+ppa1-1~bionic2                  all          extensible programming language in the Scheme family (shared files)
ii  racket-doc                            6.12+ppa1-1~bionic2                  all          extensible programming language in the Scheme family (documentation)
$ racket -I rash
Welcome to Racket v6.12.
> ls
; readline-input:1:0: #%top-interaction: unbound identifier;
;  also, no #%app syntax transformer is bound
;   at: #%top-interaction
;   in: (#%top-interaction . ls)
; [,bt for context]
>

I saw some similar issues, and they seemed to say update the readline-lib package. I am however already on 6.12 and when I try to update readline-lib, I have the following issues:

$ raco pkg update --clone readline-lib
Inferred package name from given `--clone' path
  package: readline-lib
  given path: readline-lib
Inferred package scope: installation
open-output-file: cannot open output file
  path: /usr/share/racket/pkgs/.LOCKpkgs.rktd
  system error: Permission denied; errno=13
  context...:
   /usr/share/racket/collects/racket/private/kw-file.rkt:116:2: call-with-output-file*70
   /usr/share/racket/collects/racket/file.rkt:334:2: loop
   /usr/share/racket/collects/pkg/main.rkt:305:16
   (submod /usr/share/racket/collects/pkg/main.rkt main): [running body]
   /usr/share/racket/collects/pkg/raco.rkt: [traversing imports]
   /usr/share/racket/collects/raco/raco.rkt: [running body]
   /usr/share/racket/collects/raco/main.rkt: [running body]
#  raco pkg update --clone readline-
Inferred package name from given `--clone' path
  package: readline-lib
  given path: readline-lib
Inferred package scope: installation
raco pkg update: package is not currently installed from a repository
  package: readline-lib
  current installation: (catalog readline-lib)

I am a racket beginner, so please forgive me if I am missing something obvious.

rash-lang.org

I'll just put this up here as a future plan. I could maybe start making a rudimentary homepage for rash-lang.org, perhaps with pollen or something like that. GitHub lets you host a static website under a gh-pages branch, I believe.

At-Exprs

Rash feels like its screeming out for at-expression support. It would make for a very natural way to type some of those delimiters you have.

@rash{cat @rash{which file.rkt}}

Is there a way to set the default line macro?

There's set-default-pipeline-starter! for the run-pipeline macro, but is there any way to set the default line macro? In racket you can re-define-syntax #%app, but I haven't been able to redefine #%linea-default-line-macro.

remove --color=auto ls alias from default demo/setup?

On OS X, 'ls' does not support a '--color=auto' switch. This means that importing demo/setup (or shell/demo/more-pipeline-operators) makes 'ls' stop working. One easy hack is just to remove the alias for 'ls' in a fork, but this seems likely to bite any Mac users that try to use the code. Ultimately, of course, things like 'in-dir' and '=filter=' should be moved out of the demo, but in the short term, would it make sense to comment this alias out?

I'd be happy to make this as a pull request, but I don't want to bother if it doesn't make sense to others.

What is the language of the rashrc file

I was playing around with the .config/rash/rashrc file, and noticed that it wasn't normal racket syntax. When I added cd /, that action was performed, but when I added ls /, I got an error:

error in rc file /home/vityou/.config/rash/rashrc: .racket/6.12/pkgs/shell-pipeline/private/pipeline-operator-transform.rkt:14:60: erroring-default-pipeline-starter: No explicit pipeline starter given in a context with no default set.
  in: (default-pipeline-starter-macro ls /)
  context...:
   dots-loop
   /home/vityou/.racket/6.12/pkgs/rash/repl.rkt:134:2: for-loop
   /home/vityou/.racket/6.12/pkgs/rash/repl.rkt:116:0: main
   /home/vityou/.racket/6.12/pkgs/rash/repl.rkt: [running body]

I'm not really sure what exactly it means, but allowing cd / and not other things doesn't seem like intended behavior. I think it has something to do with cd being part of the shell and ls being external.

rash build result varies from parallelism

While working on reproducible builds for openSUSE, I found that
our rash package varies when comparing builds from 1-core-VM and a 4-core-VM.

Two builds from 1-core-VMs are identical though, so there is some race going on during the build.

Here is an extract from the lengthy total diff:

/usr/share/racket/pkgs/shell-pipeline/shell/demo/compiled/more-pipeline-operators_rkt.zo differs at offset '41' (data)
--- a 2019-04-08 20:45:02.853104872 +0000
+++ b 2019-04-08 20:45:02.853104872 +0000
@@ -1,33 +1,33 @@
 00000000  23 7e 03 37 2e 32 06 72  61 63 6b 65 74 44 02 00  |#~.7.2.racketD..|
 00000010  00 00 12 00 00 00 11 63  6f 6e 66 69 67 75 72 65  |.......configure|
-00000020  2d 72 75 6e 74 69 6d 65  0f 89 00 00 9a 02 00 00  |-runtime........|
+00000020  2d 72 75 6e 74 69 6d 65  27 89 00 00 9a 02 00 00  |-runtime'.......|
 00000030  38 00 00 00 00 00 00 00  00 00 00 00 4c 00 00 00  |8...........L...|
-00000040  c3 88 00 00 00 00 00 00  00 00 00 00 23 7e 03 37  |............#~.7|
-00000050  2e 32 06 72 61 63 6b 65  74 42 ae 89 99 2b 9f 9c  |.2.racketB...+..|
-00000060  e5 3a 9d 55 7d ed 50 8a  32 5e 75 4f da 18 f2 00  |.:.U}.P.2^uO....|
+00000040  db 88 00 00 00 00 00 00  00 00 00 00 23 7e 03 37  |............#~.7|
+00000050  2e 32 06 72 61 63 6b 65  74 42 6a 31 80 57 72 da  |.2.racketBj1.Wr.|
+00000060  ae 16 e0 34 bc 8e f6 ef  f9 08 48 78 7f 33 f2 00  |...4......Hx.3..|
 00000070  00 00 01 00 00 07 00 17  00 37 00 3c 00 42 00 4f  |.........7.<.B.O|
...

/usr/share/racket/pkgs/rash/rash/demo/compiled/rc17-demo-modbeg_rkt.zo differs at offset '41' (data)
@@ -1,33 +1,33 @@
 00000000  23 7e 03 37 2e 32 06 72  61 63 6b 65 74 44 02 00  |#~.7.2.racketD..|
 00000010  00 00 12 00 00 00 11 63  6f 6e 66 69 67 75 72 65  |.......configure|
-00000020  2d 72 75 6e 74 69 6d 65  08 20 03 00 8b 02 00 00  |-runtime. ......|
+00000020  2d 72 75 6e 74 69 6d 65  0a 20 03 00 8b 02 00 00  |-runtime. ......|
 00000030  38 00 00 00 00 00 00 00  00 00 00 00 4c 00 00 00  |8...........L...|
-00000040  bc 1f 03 00 00 00 00 00  00 00 00 00 23 7e 03 37  |............#~.7|
-00000050  2e 32 06 72 61 63 6b 65  74 42 22 58 4a f2 09 a4  |.2.racketB"XJ...|
-00000060  40 6f 08 3e ee 1d aa ae  dd d0 52 72 b7 24 a5 07  |@o.>......Rr.$..|
-00000070  00 00 01 00 00 07 00 27  00 40 00 4e 00 51 00 55  |.......'[email protected]|
-00000080  00 6e 00 72 00 76 00 8c  00 a8 00 c0 00 c9 00 d1  |.n.r.v..........|
-00000090  00 df 00 e3 00 ed 00 f2  00 f8 00 04 01 11 01 26  |...............&|
-000000a0  01 34 01 43 01 48 01 4f  01 5e 01 67 01 77 01 82  |.4.C.H.O.^.g.w..|
-000000b0  01 8e 01 99 01 ba 01 da  01 f4 01 ff 01 0b 02 10  |................|
-000000c0  02 16 02 1b 02 24 02 2c  02 32 02 3c 02 4c 02 54  |.....$.,.2.<.L.T|
-000000d0  02 5c 02 73 02 7d 02 8a  02 98 02 b3 02 b9 02 c6  |.\.s.}..........|
-000000e0  02 d4 02 e6 02 f1 02 00  03 0c 03 1b 03 22 03 38  |.............".8|
-000000f0  03 51 03 5e 03 68 03 72  03 84 03 8a 03 9c 03 ae  |.Q.^.h.r........|
-00000100  03 c4 03 c7 03 d3 03 d6  03 d9 03 dd 03 e1 03 e5  |................|
-00000110  03 ea 03 ef 03 f3 03 f9  03 07 04 0c 04 18 04 26  |...............&|
-00000120  04 2e 04 30 04 32 04 34  04 38 04 3a 04 41 04 43  |...0.2.4.8.:.A.C|
-00000130  04 46 04 48 04 4b 04 6b  04 85 04 9a 04 ac 04 bd  |.F.H.K.k........|
-00000140  04 c6 04 db 04 f2 04 fd  04 0a 05 11 05 2d 05 31  |.............-.1|
-00000150  05 3f 05 64 05 80 05 9a  05 ae 05 b3 05 b8 05 cc  |.?.d............|
-00000160  05 e7 05 eb 05 f7 05 13  06 15 06 18 06 1a 06 35  |...............5|
-00000170  06 37 06 53 06 57 06 66  06 6b 06 70 06 7a 06 8a  |.7.S.W.f.k.p.z..|
-00000180  06 97 06 a2 06 a6 06 ad  06 b5 06 bb 06 c2 06 c8  |................|
-00000190  06 d2 06 e3 06 f2 06 08  07 18 07 28 07 30 07 35  |...........(.0.5|
-000001a0  07 3a 07 40 07 45 07 4a  07 4f 07 56 07 67 07 6e  |.:[email protected]|
-000001b0  07 7a 07 8c 07 9d 07 a9  07 b5 07 c1 07 ca 07 de  |.z..............|
-000001c0  07 e2 07 eb 07 f9 07 fe  07 0c 08 25 08 33 08 40  |...........%.3.@|
-000001d0  08 4b 08 56 08 72 08 7f  08 8c 08 99 08 a7 08 b3  |.K.V.r..........|
-000001e0  08 bf 08 cc 08 d2 08 d8  08 f0 08 fc 08 08 09 1d  |................|
-000001f0  09 34 09 4a 09 5f 09 6c  09 83 09 91 09 a3 09 b4  |.4.J._.l........|
+00000040  be 1f 03 00 00 00 00 00  00 00 00 00 23 7e 03 37  |............#~.7|
+00000050  2e 32 06 72 61 63 6b 65  74 42 52 c2 82 78 e7 99  |.2.racketBR..x..|
+00000060  f6 f6 7f e2 4e ea 55 9d  34 88 49 0f ce a6 a5 07  |....N.U.4.I.....|
+00000070  00 00 01 00 00 07 00 28  00 41 00 4f 00 52 00 56  |.......(.A.O.R.V|
+00000080  00 6f 00 73 00 77 00 8d  00 a9 00 c1 00 ca 00 d2  |.o.s.w..........|
+00000090  00 e0 00 e4 00 ee 00 f3  00 f9 00 05 01 12 01 27  |...............'|
+000000a0  01 35 01 44 01 49 01 50  01 5f 01 68 01 78 01 83  |.5.D.I.P._.h.x..|
+000000b0  01 8f 01 9a 01 bb 01 db  01 f5 01 00 02 0c 02 11  |................|
+000000c0  02 17 02 1c 02 25 02 2d  02 33 02 3d 02 4d 02 55  |.....%.-.3.=.M.U|
+000000d0  02 5d 02 74 02 7e 02 8b  02 99 02 b4 02 ba 02 c7  |.].t.~..........|
+000000e0  02 d5 02 e7 02 f2 02 01  03 0d 03 1c 03 23 03 39  |.............#.9|
+000000f0  03 52 03 5f 03 69 03 73  03 85 03 8b 03 9d 03 af  |.R._.i.s........|
+00000100  03 c5 03 c8 03 d4 03 d7  03 da 03 de 03 e2 03 e6  |................|
+00000110  03 eb 03 f0 03 f4 03 fa  03 08 04 0d 04 19 04 27  |...............'|
+00000120  04 2f 04 31 04 33 04 35  04 39 04 3b 04 42 04 44  |./.1.3.5.9.;.B.D|
+00000130  04 47 04 49 04 4c 04 6c  04 86 04 9b 04 ad 04 be  |.G.I.L.l........|
+00000140  04 c7 04 dc 04 f3 04 fe  04 0b 05 12 05 2e 05 32  |...............2|
+00000150  05 40 05 65 05 81 05 9b  05 af 05 b4 05 b9 05 cd  |[email protected]............|
+00000160  05 e8 05 ec 05 f8 05 14  06 16 06 19 06 1b 06 36  |...............6|
+00000170  06 38 06 54 06 58 06 67  06 6c 06 71 06 7b 06 8b  |.8.T.X.g.l.q.{..|
+00000180  06 98 06 a3 06 a7 06 ae  06 b6 06 bc 06 c3 06 c9  |................|
+00000190  06 d3 06 e4 06 f3 06 09  07 19 07 29 07 31 07 36  |...........).1.6|
+000001a0  07 3b 07 41 07 46 07 4b  07 50 07 57 07 68 07 6f  |.;.A.F.K.P.W.h.o|
+000001b0  07 7b 07 8d 07 9e 07 aa  07 b6 07 c2 07 cb 07 df  |.{..............|
+000001c0  07 e3 07 ec 07 fa 07 ff  07 0d 08 26 08 34 08 41  |...........&.4.A|
+000001d0  08 4c 08 57 08 73 08 80  08 8d 08 9a 08 a8 08 b4  |.L.W.s..........|
+000001e0  08 c0 08 cd 08 d3 08 d9  08 f1 08 fd 08 09 09 1e  |................|
+000001f0  09 35 09 4b 09 60 09 6d  09 84 09 92 09 a4 09 b5  |.5.K.`.m........|
 00000200

+++ new//usr/share/racket/pkgs/rash/rash/demo/compiled/rc17_rkt.dep     2019-04-05 12:00:00.000000000 +0000
@@ -1 +1 @@
-("7.2" racket ("efe0dc5499c61488b11498a84f78962ffa64b116" . "408d55c1c3a6e91ef58aa3821ba4cc2704944c0e") (collects #"linea" #"read.rkt") (collects #"racket" #"base.rkt") (collects #"racket" #"runtime-config.rkt") (collects #"rash" #"private" #"lang-funcs.rkt") (collects #"syntax" #"module-reader.rkt"))
+("7.2" racket ("efe0dc5499c61488b11498a84f78962ffa64b116" . "b86f4cd74942f160d7cdb7d9b2fc87f18423b045") (collects #"linea" #"read.rkt") (collects #"racket" #"base.rkt") (collects #"racket" #"runtime-config.rkt") (collects #"rash" #"private" #"lang-funcs.rkt") (collects #"syntax" #"module-reader.rkt"))
/usr/share/racket/pkgs/rash/rash/demo/compiled/setup_rkt.dep differs (ASCII text, with very long lines)

Unfortunately I know too little about racket or rash to debug this without some help.

Extremely cool idea! Some questions

First of all, I love this - it's like emacs' eshell but for a real terminal, and more scheme-y, which is great. I just had some general thoughts - I understand this is unstable and feature requests are the last thing on your mind, but I just wanted to pick your brain on a couple things:

More immediate:

  • Do you plan to define some standard interface to addons/goodies? (something like rash/infix would feel neater than rash/demo/infix)
  • Would bee cool to expose the currently implemented prompts/git stuff as an addon module (unless there's already a way to do this and I'm just blind)

Way lower priority:

  • Is it possible to get bracket auto-insertion so that when ( is typed, ) is inserted, with the cursor remaining between the two? In general, a hackable prompt would be neat (text substitution and snippets, autoinsertion, autosuggestions, but I understand this might be a limitation of the readline library? unsure).
  • Key bindings?
  • Would it be possible to get fish/zsh-like completion, where completions appear as a sort of 'pop-up' in which you can cycle through completions, and completion doesn't emit a new prompt?

I mostly have experience with chicken scheme, and only just recently started diving into racket, but I'd love to help your project however I can.

Error during setup

While trying to setup rash on 6.10.1 with raco pkg install rash I get:

pre-readline-input-port: unbound identifier in module

while compiling repl.rkt

Feature: Docker integration

This is an idea I have been thinking about but I am still not sure if should be part of Rash or a sort of plugin to rash. However, the idea is to integrate docker into Rash so that pipelines can be run inside a container.

I can imagine something like:

(with-pipeline-in-docker 'ubuntu:latest
  { sudo apt-get update
    sudo apt-get upgrade -y  })

There are problem lots of issues to solve here but something like this would be awesome. If you don't get to it, probably I will. However, if would be interesting, given you know the internals of Rash, if this is feasible at the moment.

Question mark '?' char in a string

IMO the special meaning of the question mark character '?' in racket should be ignored if it occurs in a string:

> echo "hello ? where are you?"

16:19 /home/bost/
> echo hello '? where are you'?
hello ? where are you ?
16:19 /home/bost/
> echo "hello '? where are you'?"

16:19 /home/bost/
> echo '"hello '? where are you'?"
hello '? where are you'?
16:20 /home/bost/
> echo '"hello ? where are you?"
hello ? where are you?
16:20 /home/bost/
> 

And also there should be no blanks inserted between the question marks:

> echo hey '?'?'?
hey ? ? ?
16:22 /home/bost/
> 

And at last but not least:

> echo ???
/home/bost/bin /home/bost/dec /home/bost/dev /home/bost/env /home/bost/foo /home/bost/txt
16:24 /home/bost/
>

Thanx.

job control

I've been meaning to add job control for a long time, but haven't gotten around to it. I'll probably add it soon (for some value of "soon"). Problems arising due to lack of job control include TUI programs not resizing properly or having other issues because they are connected weirdly to their controlling terminal, and obviously issues with killing processes with C-c or trying to background them with C-z.

Racket's subprocess form has supported job control for a couple releases now, so adding job control to the run-subprocess-pipeline function will be easy. It will be harder to add sensible job control support for mixed pipelines of subprocesses and functions, which is what is needed for job control to be actually useful in Rash.

Support or document glob expansion suppression

I can't find a convenient way to suppress glob expansion. If I want to run find, for example:

find /usr/include -iname *.h

It seems I have to escape to Racket in order to prevent the *.h from being expanded:

find /usr/include -iname (values "*.h")

In other shells, I would just use single quotes. This seems like a common thing to want to do, even with programs besides find.

Ideas from ion shell?

Apologies for the most useless issue raised ever, been following this project a while and eager to set how racket and it's projects evolve in the next year or three,
recently came across this https://doc.redox-os.org/ion-manual/html/ from the super integrating redox project, thought I would share it here, without comment/suggestions/issue (hence most useless issue raised ever) and see if there was anything to be learned from this other rethink of a shell implementation for rash, (though I'm sure you are already aware of it...)

Line macro not being applied to included file

Sorry if this isn't the right place to ask. I created a line macro for aliases like this:

(define-line-macro alias
  (syntax-parser
    [(_ i (~datum =) value ...) #'(define-simple-pipeline-alias i value ...)]))

I decided to separate my aliases into a file called aliases.rash, and I defined the line macro in the rashrc file, and used include to run the alias file. However, I get an error saying bad syntax in alias. This didn't happen when I defined the macro in the aliases.rash file. I suspect it may have something to do with syntax, or I'm just using include wrong.

rash logo

Well, instead of looking at the code, I decided to try and make a logo for rash. Tell me if you wan't me to change anything or if you don't want to use it that's fine.

with-rash-config name change

The with-rash-parameters form has existed for a little while (maybe a few weeks), but I've realized that the name is wrong in a deceptive way, so I've changed it to with-rash-config. Since Rash advertises its instability and the form has only existed (or at least been documented) a little while, I'm expecting that there will be no pain with this change. But I'm sorry if this breaks something.

Feature request: disable error context

If it's possible it would be nice. Whenever a program fails, rash always displays:

  context...:
   /home/vityou/.racket/6.12/pkgs/shell-pipeline/private/mixed-pipeline.rkt:148:6: for-loop
   /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt:388:18
   /home/vityou/.racket/6.12/pkgs/rash/private/top-level-print.rkt:12:0: default-rash-formatter
   /home/vityou/.racket/6.12/pkgs/rash/private/rashrc-lib.rkt:141:0
   /home/vityou/.racket/6.12/pkgs/rash/repl.rkt:50:0: rash-repl
   /home/vityou/.racket/6.12/pkgs/rash/repl.rkt:111:0: main
   /home/vityou/.racket/6.12/pkgs/rash/repl.rkt: [running body]

string colorizer for prompts

I noticed you said it would be nice to have a suite of functions to design prompts, so I made a function that can add color (and other things) to a string in the form of ANSI escape sequences. It supports 4 bit, 8 bit, and 24 bit colors. It has other common style options like bold and underline. And you can also add your own commands and it appends them. Currently no hexadecimal support (only r,g,b form) but that would be easy to add. Here is the function: https://github.com/vityou/rash-files/blob/master/prompt-helpers/string-color.rkt Let me know if you'd like to use it or if theres anything I could change/add.

Request: rash arguments

In rash, it seems I cannot do (define foo "ls -l") (rash foo). Is there another way of achieving this?

Error about importing #%linea-default-line-macro

I get this after updating rash:

error in rc file /home/vityou/.config/rash/rashrc.rkt: .config/rash/rashrc.rkt:9:11: module: identifier already imported from: rash/private/basic-module-begin
  at: #%linea-default-line-macro
  in: "aliases.rkt"
  location...:
   .config/rash/rashrc.rkt:9:11
   .config/rash/rashrc.rkt:1:6
  context...:
   standard-module-name-resolver
   /home/vityou/.racket/6.12/pkgs/rash/repl.rkt:126:2: for-loop
   /home/vityou/.racket/6.12/pkgs/rash/repl.rkt:113:0: main
   /home/vityou/.racket/6.12/pkgs/rash/repl.rkt: [running body]

I don't define a #%linea-default-line-macro in my aliases.rkt file:

#lang rash

(require linea/defaults linea/line-macro
         (for-syntax racket/base syntax/parse))

(provide (all-defined-out))


; allows defining aliases in the form:
; alias x = y
; or:
; alias x y

(define-line-macro alias
  (syntax-parser
    [(_ i (~datum =) value ...) #'(define-simple-pipeline-alias i value ...)]
    [(_ i value ...) #'(define-simple-pipeline-alias i value ...)]))


; ls aliases
alias ls = 'ls_extended
alias la = ls -a
alias ll = ls -la
alias l = ls -l


(define-line-macro quit
  (syntax-parser
    [(_) #'(exit)]))

Changes

FYI, to anybody watching this repo, I've got some fairly major changes coming. I did say it was unstable.

  • |> will no longer turn ports to strings, instead |>> will do that.
  • String reading at expansion time is cool, but it is not really necessary, and is mostly a holdout from earlier designs with poor separation between macros and reading. Also, I've given in to having more normal ascii delimiters available. So now {} will switch the reader to line-mode, and it will happen as a part of the original read phase, not mixed with expansion. However, the rash macro will still allow strings. So you can do it either way. {} will not wrap the line-mode code with any configuration, so eg. if you are at the top level and the default output for processes is current-output-port, it will still be inside {}. #{} wraps it with the default rash macro settings, IE an empty input port, output converted to a string, etc.

So basically, you might have to change some pipelines that use |>. Basically this makes things more consistent when you want to eg. read process output as something other than a string.

Those are the big changes that I think people following the repo might want to know about. I haven't merged the changes into master yet, but I will in the next couple days. Probably when I write some documentation to go with the changes.

RPM packaging

@bitstreamout in scheme/scsh#41 (comment) mentions:

Nice but it seems not to be possible to get the install tool raco to
install without trying to connect download.racket-lang.org which is
never allowed within a chroot/container build system. Also it requires
root permissions to get installed as system package ... currently I've
not found a way with raco to do this a build user below DESTDIR nor a
way to refresh /usr/share/racket/info-cache.rktd and
/usr/share/racket/pkgs/pkgs.rktd within a %post and %preun rpm scriplet
to get the informations below /usr/share/racket/ uptodate if the rpm
becomes installed.

Regexes in grep

Hi, I have a problem using regexes in grep. Following examples don't terminate when started from rash-repl:

grep -i "computer.*store"  purchases.csv
grep -i "computer.*?store" purchases.csv
grep -i "computer.+?store" purchases.csv

My purchases.csv contains:

"amount","where"
"100"   ,"supermarket"
"200"   ,"computer store X"
"300"   ,"petrol station"
"400"   ,"computer store Y"
"500"   ,"retail store"

I tried to look at the source code, but I'm not sure:

  • Is there a bug in the current run-pipeline implementation (or somewhere else)?
  • Or is there anything, some expansions which are not implemented yet?

Could you shed some light on this spot please? Thanks

Outputting to stdout

Hi,

i have some simple rash script to build some software that look like:

(define (main prefix [makej 1])
  (cd solvers/z3)
  #{python scripts/mk_make.py --prefix=$prefix}
  (cd build)
  #{make VERBOSE=1 -j $makej}
  #{make VERBOSE=1 -j $makej install})

The downside of this is that there's no output on stdout, is there a way to force the output of these command to stdout while they are being run? I assume I could (printf #{echo foo}) but it would be better if the bytes are printed as they come.

is there a way to make line macros separate from normal macros?

define-line-macro defines both a line macro and a normal macro, which is usually ok. But I would like to define a line macro called exit that just runs (exit). When I try to do that I get an infinite loop because the definition refers to itself. I may be overlooking a simple way to accomplish this.

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.