q shell
$ go get github.com/lufia/qsh
# comment
Simple declaration.
a=1 # scalar; same as a=(1)
a=(1 2) # array
echo $a
# Output:
# 1 2
if variable name all are capital letter, it handles as environment variables.
RESULT_CODE=1
bash -c 'echo $RESULT_CODE'
# Output: 1
Indirect reference
arch=lib_amd64
lib_amd64=lib64
lib_x86=lib
echo $$arch
# Output:
# lib64
if { true } {
echo ok
}
# Output:
# ok
for i in 1 2 3 {
echo $i
}
# Output:
# 1
# 2
# 3
first, write your code in Go.
package main
var SampleModule = map[string]string{
"hello": "Hello",
}
func Hello(args []string) ([]string, error) {
a := make([]string, 0, len(args)+1)
a = append(a, "hello")
return append(a, args...), nil
}
build it as plugin.
go build -buildmode=plugin sample.go
then load with load stamtement.
load sample # plugin filepath without .so
echo ${hello a ${hello b}}
# Output: hello a hello b
true && echo true
false || echo false
# output
echo hello >out
# append
echo hello >>out
# input
echo hello <in
# pipe
echo hello | wc
- Basic
- comments
- command execution
- background execution
- inline execution
- glob
- Variable
- assign
- indexing
- concat
- environment
- Redirection
- read
- write
- append
- error
- pipe
- dup
- Statements
- if
- if-else
- for
- switch
- load
- Expression
-
&&
-
||
-