rash-coreutils
| (require rash-coreutils) | package: rash-coreutils |
rash-coreutils provides platform-independent Unix-style shell commands for Rash. The commands are implemented in Racket, so common shell utilities do not depend on cmd.exe, PowerShell, or Unix executables being installed.
Rash remains responsible for shell syntax such as pipelines, globbing, tilde expansion, variable expansion, and redirection. rash-coreutils supplies the commands themselves plus Racket-specific additions such as regular-expression path selectors.
1 Commands
The package provides pwd, ls, mkdir, rmdir, rm, cp, mv, cat, touch, echo, which, head, tail, wc, sort, uniq, cut, tee, tr, basename, dirname, realpath, readlink, stat, du, df, mktemp, printenv, env, date, raco, and help.
The option set is deliberately smaller than GNU coreutils. Unsupported options raise an error instead of silently approximating another command’s behavior.
2 Racket procedures
Each shell command has an explicitly named Racket procedure. All procedures write to the normal current ports so Rash pipeline and redirection semantics continue to work.
procedure
(coreutils-pwd) → void?
procedure
(coreutils-ls arg ...) → void?
arg : any/c
procedure
(coreutils-mkdir arg ...) → void?
arg : any/c
procedure
(coreutils-rmdir arg ...) → void?
arg : any/c
procedure
(coreutils-rm arg ...) → void?
arg : any/c
procedure
(coreutils-cp arg ...) → void?
arg : any/c
procedure
(coreutils-mv source destination) → void?
source : any/c destination : any/c
procedure
(coreutils-cat arg ...) → void?
arg : any/c
procedure
(coreutils-touch arg ...) → void?
arg : any/c
procedure
(coreutils-echo arg ...) → void?
arg : any/c
procedure
(coreutils-which arg ...) → void?
arg : any/c
procedure
(coreutils-head arg ...) → void?
arg : any/c
procedure
(coreutils-tail arg ...) → void?
arg : any/c
procedure
(coreutils-wc arg ...) → void?
arg : any/c
procedure
(coreutils-sort arg ...) → void?
arg : any/c
procedure
(coreutils-uniq arg ...) → void?
arg : any/c
procedure
(coreutils-cut arg ...) → void?
arg : any/c
procedure
(coreutils-tee arg ...) → void?
arg : any/c
procedure
(coreutils-tr arg ...) → void?
arg : any/c
procedure
(coreutils-basename path) → void?
path : any/c
procedure
(coreutils-dirname path) → void?
path : any/c
procedure
(coreutils-realpath path) → void?
path : any/c
procedure
(coreutils-readlink path) → void?
path : any/c
procedure
(coreutils-stat path ...) → void?
path : any/c
procedure
(coreutils-du arg ...) → void?
arg : any/c
procedure
(coreutils-df) → void?
procedure
(coreutils-mktemp arg ...) → void?
arg : any/c
procedure
(coreutils-printenv name ...) → void?
name : any/c
procedure
(coreutils-env arg ...) → void?
arg : any/c
The Rash form can mix shell-style assignment names with Racket expressions:
(define x 42) |
env ANSWER=(values x) printenv ANSWER |
A parenthesized expression in Rash line mode is ordinary Racket code. Therefore the value after an empty NAME= token can be a number, symbol, path, string, or another printable Racket value.
procedure
(coreutils-date arg ...) → void?
arg : any/c
date |
date --iso |
date --utc --iso |
date --tz Europe/Amsterdam --format "yyyy-MM-dd HH:mm:ss" |
procedure
(coreutils-raco arg ...) → void?
arg : any/c
raco setup rash-coreutils |
raco pkg show |
The same raco binding is a normal Racket procedure, so expression-mode code can use (raco '(setup rash-coreutils)). The explicit implementation name coreutils-raco is also exported.
3 Path selection
Shell-style argument expansion remains Rash’s responsibility. The aliases expand back into Rash’s =unix-pipe= operator, preserving Rash globbing, tilde expansion, and $ expansion.
ls *.rkt |
ls -l info* |
cat info* |
Regular-expression values are an additional rash-coreutils selector. A #rx"" or #px"" value is matched against entry names in the current directory.
ls #px"^info[0-9]+[.]rkt$" |
4 Windows paths
On Windows, commands that write path names use forward slashes in their textual output. Rash treats backslashes as escape characters in line mode, so a printed path such as C:/Users/name/AppData/Local/Temp/file can be copied directly into another Rash command. Racket path values themselves remain native and can be passed directly to a command through a Racket expression.
5 Help
help uses Racket’s documentation search through raco docs. Registered commands use package-specific index terms such as rash-coreutils-ls.
help |
help ls |
ls --help |
help directory-list |
6 Capturing and redirecting output
Commands use normal ports. Rash can therefore capture or redirect them without special support in this package.
(define git-path { which git |> read-line }) |
ls &> listing.txt |
cat info.rkt &>! copy.rkt |
7 Compatibility scope
The command names and common options follow Unix conventions, but this package does not claim complete GNU coreutils compatibility. Platform-independent behavior, predictable Rash scripting, and useful integration with Racket values are the primary goals.