Yet Another shell can run anwhere Pthon eists.

PySh

Another shell can run anywhere Python exists.

Why another shell

Because it's fun.

Supported shell feature

Common shell features can be found here. Pysh already have:

  1. |, Pipe output

  2. $var, Use value for variable

  3. " ", double quote (allows variable and command expansion)

Usage

git clone https://github.com/jiacai2050/pysh.gitcd pyshpython -m pysh.shell## Demo> ls.git.gitignore.pre-commit-config.yamlassetspyshREADME.md> echo $HOME/Users/liujiacai> echo ${JAVA_HOME}/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home> pwd/Users/liujiacai/codes/python/pysh> cd ../Users/liujiacai/codes/python> pwd/Users/liujiacai/codes/python> cat /etc/hosts | grep 127.0.0.1127.0.0.1       localhost> grep 127.0.0.1 /etc/hosts127.0.0.1       localhost

Supported commands can be found here.

More commands are on the way. PR welcomed !

Have fun :smile:

How PySh work

A shell in unix box is a bridge bewteen user and the kernel through system call.

As we can see from above picture (taken from here), some commands (eg ls, cat) are passed to other programs, while built-in commands (eg cd, exit) are executed inside shell. This way can keep shell small in size and strong in function.

In order to let PySh run anywhere (hi, Windows, I mean you), PySh implmented all commands in its core, so there is no differences bewteen builtins and one that is not, also you can say all commands are builtins.

One thing I should mention here is:

Pipelines between different commands are supported by generator in Python.

So, every command should yield something, this is like s-expression in Lisp world, where every s-expression should return a value.

How to contribute

PySh use pre-commit to ensure code quality, so you should install it before contribute.

Fork and PR :beer:

关键字:Python, shell, hacker


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部