Shell/Dreams: различия между версиями

Материал из Etersoft wiki
Перейти к навигацииПерейти к поиску
(Новая страница: « = Dreams about new generation Bash syntax = 1. Compatible with bash code == Features == * indentbased, memorizable, coffeescript-inspired syntax * removes se…»)
 
Строка 16: Строка 16:
* written/generated for bash >= 4.x, 'zero'-dependency solution
* written/generated for bash >= 4.x, 'zero'-dependency solution
* hasslefree: easy installation without gcc compilation/3rd party software-->
* hasslefree: easy installation without gcc compilation/3rd party software-->
https://github.com/coderofsalvation/powscript


=== Use vars without quotes ===
=== Use vars without quotes ===

Версия 13:14, 25 ноября 2017

Dreams about new generation Bash syntax

1. Compatible with bash code


Features

  • indentbased, memorizable, coffeescript-inspired syntax
  • removes semantic noise like { ! @ || ~=
  • safetynets: automatic quoting, halt on error or missing dependency (require_cmd)
  • comfort: json, easy arrays, easy async, functional programming, named variables instead of positionals
  • Modules / bundling

https://github.com/coderofsalvation/powscript

Use vars without quotes

Drop any qoute hell: make qoute arg optionally.

if [ $1 = "Hello" ]

always correct, ever when $1 is empty


Function arguments

[function] funcname(arg1, arg2) {
    echo "First arg: $arg1, Secord arg: $arg2"
}

funcname "Hello" "second!"

Global and local variables

All vars are local by default.

use global [readonly] varname for define global var;


Function return value

funcname(arg1) {
    return "text: $arg1"
}

$str = $(funcname Hello)


funcname(arg1) {
    [ "$arg1" = "Hello" ]
}

funcname Hello || echo Bye

if

Use usual

if ($a > $b)
if ($a == $b)

arithmetics