mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-02-07 12:19:31 +00:00
47 lines
1.5 KiB
Org Mode
47 lines
1.5 KiB
Org Mode
|
#+title: Oil shell
|
||
|
#+date: "2021-05-09 16:40:50 +08:00"
|
||
|
#+date_modified: "2021-05-09 17:15:03 +08:00"
|
||
|
#+language: en
|
||
|
|
||
|
|
||
|
For future references:
|
||
|
|
||
|
#+begin_src sh :results output
|
||
|
oil --version
|
||
|
#+end_src
|
||
|
|
||
|
#+RESULTS:
|
||
|
: Oil version 0.8.7
|
||
|
: Release Date: 2021-01-23 07:35:11+00:00
|
||
|
: Arch: x86_64
|
||
|
: OS: Linux
|
||
|
: Platform: #13~1617215757~20.10~97a8d1a-Ubuntu SMP Thu Apr 1 21:09:17 UTC 2
|
||
|
: Compiler: GCC 10.2.0
|
||
|
: Interpreter: OVM
|
||
|
: Interpreter version: 2.7.13
|
||
|
: Bytecode: bytecode-opy.zip
|
||
|
|
||
|
This version contains incomplete implementation and documentation which is why I'm noting it here.
|
||
|
|
||
|
- You can make an array so far with ~var x = %()~.
|
||
|
|
||
|
- To push for an array, use ~push :ARRAY_VAR $ITEMS...~.
|
||
|
|
||
|
- Oil has two main syntactic modes: command and expression mode.
|
||
|
Command mode is more like Bash while expression mode is more like Python.
|
||
|
This is how Oil can make a rich and expressive scripting that is closer to the shell.
|
||
|
|
||
|
- Oil will go into expression mode in few places:
|
||
|
+ In RHS of an assignment expression.
|
||
|
+ In ~if~ statements (e.g., ~if ($EXPR) { echo "WHOA" }~).
|
||
|
+ Interpolated Oil expressions with ~$[]~ (e.g., ~$[true]~, ~$[len(ARGV)~).
|
||
|
|
||
|
- Oil can parse different modes, making it possible to create DSLs and to deal with the complex syntax of the shell.
|
||
|
|
||
|
- You can also create an array with ~[]~.
|
||
|
The ~%()~ is more like for an array of objects.
|
||
|
|
||
|
- You can enter into expression mode with ~_~.
|
||
|
Although, this simply ignores the expression and will not be printed.
|
||
|
Still pretty useful.
|