Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.

Word Language

This chapter in the Oils Reference describes the word language for OSH and YSH.

Table of Contents
String Literals
multi-str
j8-str
Expressions to Words
expr-sub
expr-splice
var-splice
Formatting Typed Data as Strings
ysh-printf
ysh-format
Quotes
quotes
Substitutions
com-sub
var-sub
arith-sub
tilde-sub
Var Ops
op-test
op-strip
op-replace
op-index
op-slice
op-format

String Literals

multi-str

j8-str

Expressions to Words

expr-sub

expr-splice

var-splice

Formatting Typed Data as Strings

ysh-printf

ysh-format

Quotes

quotes

Also see oil-string.

Substitutions

com-sub

Evaluates to the stdout of a command. If a trailing newline is returned, it's stripped:

$ hostname
example.com

$ x=$(hostname)
$ echo $x
example.com

var-sub

Evaluates to the value of a variable:

$ x=X
$ echo $x ${x}
X X

arith-sub

Shell has C-style arithmetic:

$ echo $(( 1 + 2*3 ))
7

tilde-sub

Used as a shortcut for a user's home directory:

~/src     # my home dir
~bob/src  # user bob's home dir

Var Ops

op-test

op-strip

op-replace

op-index

${a[i+1]}

op-slice

op-format

${x@P} evaluates x as a prompt string, e.g. the string that would be printed if PS1=$x.


Generated on Sun, 04 Feb 2024 00:32:22 -0500