Skip to content

Edd12321/zrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is the new, better and REWRITTEN version of Zrc (master branch)! It has way less bugs, a better codebase, nicer syntax, etc.

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

Note: The shell is experimental and behvaiour may change often between releases. The codebase is also intentionally written in C++11 without any compiler extensions, for compatibility reasons.

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)
  • Getopts
  • Login/Logout file sourcing
  • Procedures/functions
    • Function arguments
      • ${argv "..."} or just $0, $1, ...
      • $argc
    • Introspection (via help)
  • Globbing (via glob)
    • Tilde expansion (on GNU systems)
    • Wildcards
  • Signal trapping (via trap)
  • 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
      • String concatenation
    • Command substitution
      • Output (`{...})
      • Process (<{...})
      • Return value ([...])
  • Built-in commands (like expr, etc. but there are too many to list. View dispatch.hpp)
  • Tcl-style unknown (ex: fn unknown { expr [arr argv vals] })
  • Stack trace (via caller)
  • Conditional logic/flow control with full C arithmetic operator set
    • If/else
    • Unless
    • Do
    • While
    • Repeat
    • Foreach
    • For
    • Switch
    • Select
    • Try/catch, throw
    • Subshell (@ {...})
    • Lexial scoping (let)
    • Until
    • Eval
    • Return
    • Continue
    • Break
    • Fallthrough
  • Customisable $prompt1 and $prompt2
  • FP paradigm (list map|filter|reduce, apply)
  • Full job control
    • Job table support
    • Job listing command
    • Job manipulation
    • Background and foreground processes with &
    • Disowning jobs
  • Usable regular expressions
    • Basic built-in regex support (regexp)
    • More commandline options
    • regcomp
  • Pleasant interactive shell
    • History file
      • Command fixing
    • Login shell session
    • Line editor
    • Tab completion (need to re-implement)
    • Syntax highlighting
    • Keybindings

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

Inspirations: