OILS / doc / ref / chap-word-lang.md View on Github | oilshell.org

112 lines, 65 significant
1---
2in_progress: yes
3body_css_class: width40 help-body
4default_highlighter: oils-sh
5preserve_anchor_case: yes
6---
7
8Word Language
9===
10
11This chapter in the [Oils Reference](index.html) describes the word language
12for OSH and YSH.
13
14<div id="toc">
15</div>
16
17<h2 id="expression">Expressions to Words</h2>
18
19### expr-sub
20
21### expr-splice
22
23### var-splice
24
25<h2 id="formatting">Formatting Typed Data as Strings</h2>
26
27### ysh-printf
28
29### ysh-format
30
31
32## Quotes
33
34### osh-string
35
36- Single quotes
37- Double Quotes
38- C-style strings: `$'\n'`
39
40TODO: elaborate
41
42### ysh-string
43
44YSH strings in the word language are the same as in the expression language.
45
46See [ysh-string in chap-expr-lang](chap-expr-lang.html#ysh-string).
47
48### triple-quoted
49
50Triple-quoted in the word language are the same as in the expression language.
51
52See [triple-quoted in chap-expr-lang](chap-expr-lang.html#triple-quoted).
53
54### tagged-str
55
56Not done.
57
58## Substitutions
59
60### com-sub
61
62Evaluates to the stdout of a command. If a trailing newline is returned, it's
63stripped:
64
65 $ hostname
66 example.com
67
68 $ x=$(hostname)
69 $ echo $x
70 example.com
71
72### var-sub
73
74Evaluates to the value of a variable:
75
76 $ x=X
77 $ echo $x ${x}
78 X X
79
80### arith-sub
81
82Shell has C-style arithmetic:
83
84 $ echo $(( 1 + 2*3 ))
85 7
86
87### tilde-sub
88
89Used as a shortcut for a user's home directory:
90
91 ~/src # my home dir
92 ~bob/src # user bob's home dir
93
94## Var Ops
95
96### op-test
97
98### op-strip
99
100### op-replace
101
102### op-index
103
104 ${a[i+1]}
105
106### op-slice
107
108### op-format
109
110${x@P} evaluates x as a prompt string, e.g. the string that would be printed if
111PS1=$x.
112