Why Sponsor Oils? | source | all docs for version 0.22.0 | all versions | oilshell.org
Here are some recommendations on coding style.
proc kebab-case() {
echo hi
}
func camelCase() {
echo hi
}
Local variables:
var snake_case = 42
Hungarian for global "constants":
var kMyConst = 42 # immutable
var gMyGlobal = {} # mutable
For consistency, this style is also OK:
var MY_CONST = 42
Env vars use CAP_WORDS
:
var maxProcs = ENV.MAX_PROCS
my-script.sh # runs with /bin/sh and OSH
my-script.bash # runs with bash and OSH
my-script.osh # runs with OSH
my-script.ysh # runs with YSH
Capital Letters are used for types:
Null Bool Int Float Str
List Dict
Proc Func
Special shell variables:
PATH IFS
Global variables that are silently mutated by the interpreter start with
_
:
_error _pipeline_status _reply
As do functions to access such mutable vars:
_group() _start() _end()
Example:
try {
false
}
if (_error.code !== 0) {
echo 'failed'
}