Skip to content

shellgei/rusty_bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5,634 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sushi shell (a.k.a. 🍣 Sush): a Bash clone shell implemented in Rust

former name: Rusty Bash

ubuntu-latest macos-latest

NEWS

Bash-completion starts working on our shell! (how to use)

completion

What's this?

A clone of Bash, which is developed as a hobby of our group and for monthly articles on SoftwareDesign magazine published by Gijutsu-Hyohron Co., Ltd.

Quick Start

$ git clone https://github.com/shellgei/rusty_bash.git
$ cd rusty_bash
$ cargo run
・・・
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/sush`
ueda@uedaP1g6:main🌵~/GIT/rusty_bash(debug)🍣

Install

$ git clone https://github.com/shellgei/rusty_bash.git
$ cd rusty_bash
$ cargo build --release
### ↓  Change /bin/ to /usr/local/bin/ or another path in $PATH if you are using Mac or BSD ###
$ sudo cp target/release/sush /bin/
$ cp .sushrc ~/.sushrc # edit if some errors occur
$ sush
ueda@uedaP1g6:main🌵~/GIT/rusty_bash🍣

Comparison with Bash 5.2

This graph shows the test result with the script in ./sush_test/bash_genuine_test of this test repository. Currently, the binary built from alpha repo has passed 27 of 84 test scripts.

Bash behavior that we don't follow

The following behavior of Bash will not be imitated by sush. So we alter the right output file (e.g globstar.right) for comparision.

  • the output order of associative array
  • output duplication of globstar
    • Bash outputs the same path repeatedly in some situations of globstar. It may be for compatibility of ksh.
  • overflow at calculations
    • Bash outputs overflow calculation results at the border of 64 bit intergers and arith5.sub tells that this behavior should be reproduced. But we don't follow it.
    ### Bash example ###
    $ echo $(( -9223372036854775808 * -1 )) 
    -9223372036854775808                    #IT'S WRONG. 
    $ echo $(( -9223372036854775807 * -1 )) #IT'S OK.
    9223372036854775807
    ### Sushi shell ###
    🍣 echo $(( -9223372036854775808 * -1 ))
    9223372036854775808
    🍣 echo $(( -9223372036854775807 * -1 ))
    9223372036854775807
  • spaces of error log
    • Bash adds spaces to each token and displays them in error messages. These spaces are elliminated in our shell.
    ### Bash ###
    $ (( 1++     ))
    bash: ((: 1++     : syntax error: operand expected (error token is "+     ")
    ### Sush ###
    🍣 (( 1++     ))
    sush: ((: 1++     : syntax error: operand expected (error token is "+")
  • error messages of readonly
    • We added readonly: to the messages in attr.right.
      • e.g.: ./attr.tests: line 17: a: readonly variable -> ./attr.tests: line 17: readonly: a: readonly variable

Contribution

Because the shell in this repository can be a standard one in the next generation, it may a good idea to leave your name as a contributor. Give us pull requests with what you think as contribution. As our community is not big, rules have not been fixed yet.

Followings are not difficult but very important tasks.

  • To fix the code based on Clippy. (There are many warnings by Clippy in the current codes. )
  • To develop builtin commands. (Especially echo may be easy. )
  • To add test cases.
  • To fix the test methodology, especially for the parts related to human input.

Important branch

  • alpha: checkout this branch if you want to develop.
  • beta: we are using the head version of this branch on a day-to-day basis.
  • main: the beta version is merged to this branch if fatal problems are not found for a week.

List of Features

  • ✔️ :available
  • 🚧 :partially available (or having known bugs)
  • 🙅 : not implemented

compound commands

features status features status features status
if ✔️ while ✔️ () ✔️
{} ✔️ case ✔️ until 🙅
for ✔️ [[ ]] ✔️

special parameters

features status features status features status
$ ✔️ ? ✔️ * ✔️
@ ✔️ # ✔️ - ✔️
! 🙅 _ ✔️

builtin commands

features status features status features status
cd ✔️ pwd ✔️ read 🚧
exit ✔️ source ✔️ set 🚧
shopt 🚧 : ✔️ . ✔️
alias ✔️ bg 🚧 bind 🙅
break ✔️ builtin ✔️ caller :under_construction:
command ✔️ compgen 🚧 complete 🚧
compopt 🙅 continue ✔️ declare 🙅
dirs 🙅 disown ✔️ echo 🙅
enable 🙅 eval ✔️ exec 🙅
fc 🙅 fg 🚧 getopts 🚧
hash 🙅 help 🙅 history 🚧
jobs 🚧 kill :under_construction: let 🙅
local ✔️ logout 🙅 mapfile 🙅
popd 🙅 printf ✔️ pushd 🙅
readonly 🙅 return ✔️ false ✔️
shift ✔️ suspend 🙅 test ✔️
times 🙅 trap 🙅 true ✔️
type 🙅 typeset 🙅 ulimit ✔️
umask 🙅 unalias ✔️ unset 🚧
wait 🚧 export ✔️

options

features status features status features status
-c ✔️ -i ✔️ -l, --login 🙅
-r 🙅 -s 🙅 -D 🙅
[-+]O 🙅 -- 🙅 --debugger 🙅
--dimp-po-strings 🙅 --help ✔️ --init-file 🙅
--rcfile 🙅 --noediting 🙅 --noprofile 🙅
--norc 🙅 --posix :under_construction: --restricted ✔️
-v, --verbose 🙅 --version ✔️ -e ✔️
--pipefail ✔️ -B ✔️

shopt

features status features status features status
autocd 🙅 cdable_vars 🙅 cdspell 🙅
checkhash 🙅 checkjobs 🙅 checkwinsize 🙅
cmdhist 🙅 compat31 🙅 compat32 🙅
compat40 🙅 compat41 🙅 dirspell 🙅
dotglob ✔️ execfail 🙅 expand_aliases 🙅
extdebug 🙅 extglob ✔️ extquote 🙅
failglob 🙅 force_fignore 🙅 globstar ✔️
gnu_errfmt 🙅 histappend 🙅 histreedit 🙅
histverify 🙅 hostcomplete 🙅 huponexit 🙅
interactive_comments 🙅 lastpipe 🙅 lithist 🙅
login_shell 🙅 mailwarn 🙅 no_empty_cmd_completion 🙅
nocaseglob 🙅 nocasematch 🙅 nullglob ✔️
progcomp ✔️ promptvars 🙅 restricted_shell ✔️
shift_verbose 🙅 sourcepath 🙅 xpg_echo 🙅

variables

Born Shell Variables

features status features status features status
CDPATH 🙅 HOME ✔️ IFS ✔️
MAIL 🙅 MAILPATH 🙅 OPTARG ✔️
OPTIND ✔️ PATH ✔️ PS1 ✔️
PS2 ✔️

Bash Variables

features status features status features status
_ ✔️ BASH 🙅 BASHOPTS 🙅
BASHPID ✔️ BASH_ALIASES 🙅 BASH_ARGC 🙅
BASH_ARGV 🙅 BASH_ARGV0 🙅 BASH_CMDS 🙅
BASH_COMMAND 🙅 BASH_COMPAT 🙅 BASH_ENV 🙅
BASH_EXECUTION_STRING 🙅 BASH_LINENO 🙅 BASH_LOADABLES_PATH 🙅
BASH_REMATCH ✔️ BASH_SOURCE 🙅 BASH_SUBSHELL ✔️
BASH_VERSINFO ✔️ BASH_VERSION ✔️ BASH_XTRACEFD 🙅
CHILD_MAX 🙅 COLUMNS 🙅 COMP_CWORD 🙅
COMP_LINE 🙅 COMP_POINT 🙅 COMP_TYPE 🙅
COMP_KEY 🙅 COMP_WORDBREAKS 🙅 COMP_WORDS 🙅
COMPREPLY 🙅 COPROC 🙅 DIRSTACK 🙅
EMACS 🙅 ENV 🙅 EPOCHREALTIME ✔️
EPOCHSECONDS ✔️ EUID 🙅 EXECIGNORE 🙅
FCEDIT 🙅 FIGNORE 🙅 FUNCNAME ✔️
FUNCNEST 🙅 GLOBIGNORE 🙅 GROUPS 🙅
histchars 🙅 HISTCMD 🙅 HISTCONTROL 🙅
HISTFILE ✔️ HISTFILESIZE ✔️ HISTIGNORE 🙅
HISTSIZE 🙅 HISTTIMEFORMAT 🙅 HOSTFILE 🙅
HOSTNAME 🙅 HOSTTYPE ✔️ IGNOREEOF 🙅
INPUTRC 🙅 INSIDE_EMACS 🙅 LANG ✔️
LC_ALL 🙅 LC_COLLATE 🙅 LC_CTYPE 🙅
LC_MESSAGES 🙅 LC_NUMERIC 🙅 LC_TIME 🙅
LINENO ✔️ LINES 🙅 MACHTYPE ✔️
MAILCHECK 🙅 MAPFILE 🙅 OLDPWD ✔️
OPTERR 🙅 OSTYPE ✔️ PIPESTATUS ✔️
POSIXLY_CORRECT 🙅 PPID 🙅 PROMPT_COMMAND 🙅
PROMPT_DIRTRIM 🙅 PS0 🙅 PS3 🙅
PS4 ✔️ PWD ✔️ RANDOM ✔️
READLINE_ARGUMENT 🙅 READLINE_LINE 🙅 READLINE_MARK 🙅
READLINE_POINT 🙅 REPLY 🙅 SECONDS ✔️
SHELL ✔️ SHELLOPTS 🙅 SHLVL ✔️
SRANDOM ✔️ TIMEFORMAT 🙅 TMOUT 🙅
TMPDIR 🙅 UID 🙅

beyond Bash

features status
repeat command ✔️
branch display in prompt ✔️

Thanks to

Partially in Japanese.

Attempts by other groups

Copyright

© 2022-2025 shellgei group

About

bash written with Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6