Giter Club home page Giter Club logo

meshell's Introduction

Meshell

How hard is it to write your own shell? I'm trying to find out!

Installing

Not sure you want to do that :) Anyway:

go install github.com/arnodel/meshell

Running

$ meshell gives you a repl

$ meshell script.sh runs a shell script. You can also do $ meshell <script.sh.

Features

  • cd builtin
  • exit builtin
  • shift builtin
  • simple commands (ls -a)
  • pipelines (ls | grep foo)
  • and, or lists (touch foo || echo ouch)
  • command lists (sleep 10; echo "Wake up!")
  • redirects to files (ls >my-files, echo onions >>shopping.txt, go build . 2> build_errors)
  • redirect stdin (cat <foo >bar)
  • redirect to fd (./myscript.sh 2>&1 >script_output.txt)
  • command groups ({echo "my files"; ls})
  • subshells ((a=12; echo $a))
  • env variable substitutions (echo $PATH)
  • tilde expansion (PATH=$PATH:~/bin) - hard to know what the rule is! (use $HOME for now)
  • simple parameter substitution (echo ${var})
  • general parameter expansion (echo ${PATH:stuff}) - that's a rabbit hole
  • command substitution (ls $(go env GOROOT))
  • shell variables (a=hello; echo "$a, $a!")
  • functions with return (function foo() {echo $2; return; echo $1}; foo hello there )
  • local variables
  • if then else if cond; then echo foo; elif cond2; then echo bar; else exit; fi
  • while loops while [ $# -gt 0 ]; do echo $1; shift; done
  • for loops
  • export (export a=10)
  • arguments (echo $1 ${2})
  • arg list (echo $@ ${@})
  • arg count (echo $# ${#})
  • status code (mycommand; echo $?)
  • PID (echo $$)
  • expressions [[ x = y ]]
  • arithmetic (( x = y+1 ))
  • comments echo no comment # Print "no comment"
  • add more to the list

meshell's People

Contributors

arnodel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.