Skip to content

shellgei/rusty_bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Rusty Bash (a.k.a. sushi ๐Ÿฃ shell)

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 15 of 84 test scripts.

strange behavior of Bash that we don't want to 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.

  • Bash outputs the same path repeatedly in some situations of globstar. It may be for compatibility of ksh.
  • 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
    ### Rusty Bash ###
    ๐Ÿฃ echo $(( -9223372036854775808 * -1 ))
    9223372036854775808
    ๐Ÿฃ echo $(( -9223372036854775807 * -1 ))
    9223372036854775807

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 ๐Ÿ™…
command โœ”๏ธ compgen ๐Ÿšง complete ๐Ÿšง
compopt ๐Ÿ™… continue โœ”๏ธ declare ๐Ÿ™…
dirs ๐Ÿ™… disown ๐Ÿ™… echo ๐Ÿ™…
enable ๐Ÿ™… eval โœ”๏ธ exec ๐Ÿ™…
fc ๐Ÿ™… fg ๐Ÿšง getopts ๐Ÿšง
hash ๐Ÿ™… help ๐Ÿ™… history ๐Ÿšง
jobs ๐Ÿšง kill ๐Ÿ™… 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 ๐Ÿ™… --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
branch display in prompt โœ”๏ธ

Thanks to

Partially in Japanese.

Copyright

ยฉ 2022-2025 shellgei group