Skip to content

Instantly share code, notes, and snippets.

@eggplants
Last active May 10, 2024 14:59
Show Gist options
  • Save eggplants/24e960889d432995fa33c129758b300e to your computer and use it in GitHub Desktop.
Save eggplants/24e960889d432995fa33c129758b300e to your computer and use it in GitHub Desktop.
List of alternative shell-scripting languages (or shells)

Alternative shell-scripting languages (or shells)

  • sorted by repo name [a-z]

amirbawab/BashClass

BashClass is an Object Oriented Programming language that compiles to BASH 4.4

feature data
written C++
statically typed? true
into Bash 4.4
since 2017
active? false
class Square {
    var int side;
    constructor Square(var int side=0) {
        this.side = side;
    }

    function int getArea() {
        return side * side;
    }
}

function void print(var int num) {
    ># echo $1
}

function int main() {
    var Square sq = new Square(10);
    print(sq.getArea());
    return 0;
}

Apache License 2.0

batsh-dev-team/Batsh

A language that compiles to Bash and Windows Batch

feature data
written OCaml
statically typed? false
into Bash/BAT
since 2013
active? true?
call("println", "Println Called");
cmd = "ec" ++ "ho";
call(cmd, "Echo Called");
retval = echo("Value 100%");
println(retval);

MIT License

cotowali/cotowali

A statically typed script language that transpile into POSIX sh

feature data
written V
statically typed? true
into POSIX sh
since 2021
active? true
fn fib(n: int) int {
  if n < 2 {
    return n
  }
  return fib(n - 1) + fib(n - 2)
}

fn int |> twice() int {
   var n = 0
   read(&n)
   return n * 2
}

assert(fib(6) == 8)
assert((fib(6) |> twice()) == 16)

fn ...int |> sum() int {
  var v: int
  var res = 0
  while read(&v) {
    res += v
  }
  return res
}

fn ...int |> twice_each() |> ...int {
  var n: int
  while read(&n) {
    yield n * 2
  }
}

assert((seq(3) |> sum()) == 6)
assert((seq(3) |> twice_each() |> sum()) == 12)

MPL License

ryuichiueda/GlueLang

A programming language that has a strong nature to be a glue of commands.

feature data
written C++
statically typed? false
into syscall
since 2014
active? true
import PATH
 
# not a Haskell code but a glue code
 
# how to write a procedure (function of bash)
proc revten =
	/usr/bin/seq 1 10
	>>= /usr/bin/tail -r
 
# if, else if, else
{
	false
	this.revten
} !> {
	echo 'foo'
} !> {
	echo 'bar'
}
 
# output connection
str s = echo 'foofoo' >> echo 'barbar'
echo s

# tmpfile
file f = seq 1 10 >>= grep 5
cat f

# where
diff local.a local.b
	where file a = seq 1 10
	      file b = seq 1 10

MIT License

konoha-project/konoha[1-3]

Konoha is a scripting language, characterized by:

  • simple
  • static
  • syntax extensible
feature data
written C/C++
statically typed? true
into syscall
since 2012
active? false
import konoha.syntax.ClassDeclaration;
class Klass {
  int a,b;
  String s;
  int add(){
    return this.a + this.b;
  }
  Klass(int a, int b){
    this.a = a;
    this.b = b;
  }
  Klass(){}
}
// 1. check eval (top level)

Klass c = new Klass(1,2);
c.s = "World";

assert(c.s == "World");
assert(c.add() == 3);

// 2. check in function
function test1(){
  Klass c = new Klass(10, 20);
  return c.add();
}

function test2(){
  Klass c = new Klass();
  c.s = "Hello";
  return c.s;
}

assert(test1() == 30);
assert(test2() == "Hello");

BSD 2-Clause "Simplified" License

mweststrate/nscript

Write shell scripts like a bearded guru by unleashing your javascript skills!

feature data
written NodeJS
statically typed? false
into NodeJS
since 2014
active? false
#!/usr/bin/nscript
module.exports = function(shell, echo, $beard) {
  if ($beard)
    echo("Awesome, you invoked this script with --beard. You probably are an unixian.");
  else if (shell.prompt("Do you have a mustache at least?","y") === "y")
    echo("Welcome, oh hairy ", shell.env.USER);
  else
    shell.exit(1, "Epic fail.");
};

MIT License

oilshell/oil

Oil is a new Unix shell. It's our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!

feature data
written Python
statically typed? false
into C++
since 2016
active? true
# Test Oil expressions

#### command sub $(echo hi)
var x = $(echo hi)
var y = $(echo '')
# Make sure we can operate on these values
echo x=${x:-default} y=${y:-default}
## STDOUT:
x=hi y=default
## END

#### shell array %(a 'b c')
shopt -s parse_at
var x = %(a 'b c')
var empty = %()
argv.py / @x @empty /

## STDOUT:
['/', 'a', 'b c', '/']
## END

Apache License 2.0

coderofsalvation/powscript

transpiler written in bash: painless shellscript, indentbased, coffee for the shell with hipster-sparkles v1 BETA LANDED tadatadatadatada thanks fcard!

feature data
written Bash
statically typed? false
into Bash/POSIX sh
since 2016
active? false
#!/usr/bin/env powscript
require_cmd 'echo'
require_env 'TERM'

error(msg exitcode)
  echo "error: $msg"
  if set? $exitcode
    exit $exitcode

run(@args -- foo)
  if empty? foo
    error "please pass --foo <string>" 1
  echo $args[@] "$foo universe!!"
  echo "HOME=$HOME"

run $@

License

Luavis/sherlock.py

Sherlock is transpiler that translate python to shell script language.

feature data
written Python
statically typed? false
into POSIX sh
since 2016
active? false
def main():
    git('add', '-A')
    git('commit', '-m', 'Git commit: fire')
    git('push', 'origin', 'master')

main()

MIT License

sekiguchi-nagisa/ydsh

A statically typed scripting language with shell-like features

feature data
written C++
statically typed? true
into syscall
since 2014
active? true
#!/usr/bin/env ydsh
assert $OSTYPE =~ $/darwin/i

var w = "$(date +%w)".toInt()!
if $w < 1 || $w > 5 {
    echo today is holiday!!
    exit 1
}

var begin = "$(date -v -${$w - 1}d +'%Y%m%d')"
var end = "$(date -v +${5 - $w}d +'%Y%m%d')"

var name = "$begin-$end.md"

test -e $name && { echo $name already exists!!; exit 1; }

touch $name 

Apache License 2.0

google/zx

A tool for writing better scripts

feature data
written NodeJS
statically typed? false
into syscall
since 2021
active? true
#!/usr/bin/env zx

// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

let serve = $`npx serve`

for await (let chunk of serve.stdout) {
  if (chunk.includes('Accepting connections')) break
}

await $`curl http://localhost:5000`

serve.kill('SIGINT')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment