Skip to content

Latest commit

 

History

History
98 lines (90 loc) · 3.93 KB

README.md

File metadata and controls

98 lines (90 loc) · 3.93 KB

This is the new, better and REWRITTEN version of Zrc (master branch)! It has way less bugs, a better codebase, nicer syntax, etc. It also no longer has regex and a bunch of other stuff. I plan to add it again.

Zrc is a small scripting language for Linux, BSD, etc. written in C++ (core interpreter in a very small ~2000SLOC). It is a shell with syntax similar to Tcl/TK (EIAS). The code is quite small, but minimalism is not the main focus of Zrc (which is why it has way more "luxury features" compared to usual shells). Instead, the idea is to be a better alternative to tclsh that extends its syntax and adds features like job control, a custom line editor and more, while still almost keeping Tcl's "pure syntax".

It was created because the old shell languages that I used weren't "programmable" like Tcl or Lisp, didn't have a builtin expression evaluator, and were very basic. It is hard to write simple scripts in these usual shells because of the compilcated grammar rules. Zrc makes it easy to write even small programs, being a full programming language.

Zrc is just ~600KB in size because its implementation is to the point and simple. The language doesn't even need a Backus -- Naur form (BNF). You can compile with -Os to make it even smaller, at the expense of performance!

To use the classic version, issue the following command:

git checkout legacy

Features left to implement:

  • Path hashing/caching
  • Cdpath support
  • Home directory config file (~/.zrc)
  • Aliases
  • Rich return values (not just 0-255, but any string)
  • Complex I/O handling (control flow, functions, built-ins and commands can be seamlessly piped together)
  • Procedures/functions
    • Function arguments
      • ${argv "..."}
      • $argc
  • Globbing (via glob)
    • Tilde expansion (on GNU systems)
    • Wildcards
  • Signal trapping (via fn)
  • Directory stack
  • Pipelines
  • Full redirection
    • Basic redirection (^, ^?, ^^, >>, >, >?, <)
    • File descriptors (> x, >> x, >&- x, >& x y or >? x)
  • Non-I/O shell operators
    • &&
    • ||
    • !
  • Word splitting via {*}
  • Quoting
    • Brace quoting ({})
    • Regular quoting (', ")
  • Escape sequences
    • Basic support (every other esc. code)
    • \e, \cx
    • Full support (\uhhh, \xhh)
  • Word substitution
    • Variable expansion
      • Scalars, arrays/hashes ($, ${...})
      • Environment scalars, exporting
    • Command substitution
      • Output (`{...})
      • Process (<{...})
      • Return value ([...])
  • Built-in commands (like expr, etc. but there are too many to list. View dispatch.hpp)
  • Conditional logic/flow control with full C arithmetic operator set
    • If/else
    • Unless
    • Do
    • While
    • Foreach
    • For
    • Switch (currently does nothing)
    • Subshell (@ {...})
    • Lexial scoping (let)
    • Until
    • Eval
    • Return
    • Continue
    • Break
    • Fallthrough
  • Full job control
    • Job table support
    • Job listing command
    • Job manipulation
    • Background and foreground processes with &
  • Usable regular expressions
    • Basic built-in regex support (regexp)
    • More commandline options
    • regcomp
  • Pleasant interactive shell
    • History file
    • Line editor
    • Tab completion (need to re-implement)
    • Syntax highlighting
    • Keybindings

As mentioned on the Oil wiki's Alternative Shells list.

Inspirations: