Skip to content

Edd12321/zrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zrc is a small scripting language for Linux, BSD, etc. written in C++ (core interpreter in a very small ~3000SLOC). 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!

Features left to implement:

  • Full standard library
    • Finish corebuf
    • Finish zrclib
      • List implementation
      • Basic utility library
      • Math.h equivalent
      • Formatted I/O
      • Classes/objects, structs
      • More?
  • 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
    • Tilde expansion
    • Wildcards
  • Signal trapping (via fn, nf)
  • Directory stack
  • Pipelines
  • Full redirection
    • Basic redirection (^, ^?, ^^, >>, >, >?, <)
    • Here(documents/strings) (<<< STR, << EOF[...]EOF)
    • File descriptors (x>, x>>, x> &-, x> &y or x>? y)
  • 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 ($, ${...})
      • Separate envvar array ($env(...))
    • Command substitution
      • Output (`{...})
      • Process (<{...})
      • Return value ([...])
  • Built-in commands (like expr, jobs, 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
    • Subshell (@ {...})
    • Lexial scoping (let)
    • Until
    • Eval
    • Return
    • Continue
    • Break
  • Full job control
    • Job table support
    • Job listing command
    • Job manipulation
    • Don't separate jobs by pipe
    • 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
    • Syntax highlighting
    • Keybindings

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

Inspirations: