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

Материал из Etersoft wiki
Перейти к навигацииПерейти к поиску
(Новая страница: « = Dreams about new generation Bash syntax = 1. Compatible with bash code == Features == * indentbased, memorizable, coffeescript-inspired syntax * removes se…»)
 
 
(не показаны 2 промежуточные версии этого же участника)
Строка 2: Строка 2:
= Dreams about new generation Bash syntax =
= Dreams about new generation Bash syntax =


1. Compatible with bash code
# Backward compatible with bash code (like C++ compilers supports C)
# Use static analizer like shellcheck by default
# Use shellcheck extension for VS Code
# Use shell formatter shfmt (https://github.com/mvdan/sh)
# Use transpiler
# Modules support


Исследование, что имеется: [[Shell/Reload]].


== Features ==
== Features ==
Строка 16: Строка 22:
* 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:26, 25 ноября 2017

Dreams about new generation Bash syntax

  1. Backward compatible with bash code (like C++ compilers supports C)
  2. Use static analizer like shellcheck by default
  3. Use shellcheck extension for VS Code
  4. Use shell formatter shfmt (https://github.com/mvdan/sh)
  5. Use transpiler
  6. Modules support

Исследование, что имеется: Shell/Reload.

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