rash-coreutils
1 Commands
2 Racket procedures
coreutils-pwd
coreutils-ls
coreutils-mkdir
coreutils-rmdir
coreutils-rm
coreutils-cp
coreutils-mv
coreutils-cat
coreutils-touch
coreutils-echo
coreutils-which
coreutils-head
coreutils-tail
coreutils-wc
coreutils-sort
coreutils-uniq
coreutils-cut
coreutils-tee
coreutils-tr
coreutils-basename
coreutils-dirname
coreutils-realpath
coreutils-readlink
coreutils-stat
coreutils-du
coreutils-df
coreutils-mktemp
coreutils-printenv
coreutils-env
coreutils-date
raco
coreutils-raco
3 Path selection
4 Windows paths
5 Help
6 Capturing and redirecting output
7 Compatibility scope
9.3

rash-coreutils🔗ℹ

Hans Dijkema / hans@dijkewijk.nl

 (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?

Writes the current directory.

procedure

(coreutils-ls arg ...)  void?

  arg : any/c
Lists paths. Supports -a, -l, and their long forms.

procedure

(coreutils-mkdir arg ...)  void?

  arg : any/c
Creates directories. Supports -p.

procedure

(coreutils-rmdir arg ...)  void?

  arg : any/c
Removes empty directories.

procedure

(coreutils-rm arg ...)  void?

  arg : any/c
Removes paths. Supports recursive and force options.

procedure

(coreutils-cp arg ...)  void?

  arg : any/c
Copies a source to a destination. Directory copies require -r.

procedure

(coreutils-mv source destination)  void?

  source : any/c
  destination : any/c
Moves or renames a path.

procedure

(coreutils-cat arg ...)  void?

  arg : any/c
Copies files, or standard input, to standard output.

procedure

(coreutils-touch arg ...)  void?

  arg : any/c
Updates modification times or creates empty files.

procedure

(coreutils-echo arg ...)  void?

  arg : any/c
Writes arguments separated by spaces.

procedure

(coreutils-which arg ...)  void?

  arg : any/c
Finds executables using Racket’s executable search.

procedure

(coreutils-head arg ...)  void?

  arg : any/c
Writes the first lines of input. Supports -n.

procedure

(coreutils-tail arg ...)  void?

  arg : any/c
Writes the last lines of input. Supports -n.

procedure

(coreutils-wc arg ...)  void?

  arg : any/c
Counts lines, words, and bytes. Supports -l, -w, and -c.

procedure

(coreutils-sort arg ...)  void?

  arg : any/c
Sorts lines. Supports -r and -n.

procedure

(coreutils-uniq arg ...)  void?

  arg : any/c
Collapses adjacent duplicate lines. Supports -c.

procedure

(coreutils-cut arg ...)  void?

  arg : any/c
Selects one delimited field with -d and -f.

procedure

(coreutils-tee arg ...)  void?

  arg : any/c
Copies standard input to standard output and files. Supports -a.

procedure

(coreutils-tr arg ...)  void?

  arg : any/c
Translates characters from standard input. Character ranges such as a-z, A-Z, and 0-9 are expanded. -d deletes characters and -s squeezes repeated characters.

procedure

(coreutils-basename path)  void?

  path : any/c
Writes the final path component.

procedure

(coreutils-dirname path)  void?

  path : any/c
Writes the directory portion of a path.

procedure

(coreutils-realpath path)  void?

  path : any/c
Writes a complete simplified path.

procedure

(coreutils-readlink path)  void?

  path : any/c
Resolves a symbolic link.

procedure

(coreutils-stat path ...)  void?

  path : any/c
Writes basic portable path metadata.

procedure

(coreutils-du arg ...)  void?

  arg : any/c
Calculates recursive file size. Supports -h.

procedure

(coreutils-df)  void?

Lists filesystem roots. Racket has no portable API for total and free filesystem capacity, so this initial implementation deliberately does not invent platform-specific subprocess fallbacks.

procedure

(coreutils-mktemp arg ...)  void?

  arg : any/c
Creates a temporary file, or a directory with -d, and writes its path.

procedure

(coreutils-printenv name ...)  void?

  name : any/c
Writes environment variables.

procedure

(coreutils-env arg ...)  void?

  arg : any/c
Creates a copied environment, applies leading NAME=value assignments, and either writes that environment or runs the remaining command in it. Racket values are converted to environment strings.

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
Writes the current date and time using Gregor. Supports -u/utc, -I/iso, tz ZONE, and format CLDR-PATTERN. The format pattern follows Gregor’s CLDR syntax rather than pretending to implement every GNU date format escape.

date

date --iso

date --utc --iso

date --tz Europe/Amsterdam --format "yyyy-MM-dd HH:mm:ss"

procedure

(raco arg ...)  void?

  arg : any/c
Runs raco from the current Racket installation. The executable is resolved from the active Racket installation before PATH is considered, so it also works on Windows when raco.exe is not on PATH. Arguments may be strings, symbols, paths, numbers, or nested lists. With no arguments, the underlying raco program is invoked without a subcommand.

procedure

(coreutils-raco arg ...)  void?

  arg : any/c
Explicit implementation name for raco.

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.