OILS / demo / home-page.ysh View on Github | oils.pub

34 lines, 23 significant
1#!bin/ysh
2
3proc precise {
4 ls | grep + | wc -l
5}
6
7proc errors {
8 var x = $(date %D)
9 echo hi
10}
11
12proc no-word-split {
13 var mystr = 'a string with spaces'
14 var myarray = :| and an array |
15 write -- $mystr @myarray @ARGV
16
17 echo
18 shopt --unset simple_word_eval
19 for s in $mystr @myarray @ARGV; do
20 echo $s
21 done
22}
23
24proc safe {
25 #var tricky = u'hi\nthere.txt'
26 #var tricky = $(find build/testdata -type f -a -print0)
27 #var tricky = $(head --bytes 10 $(which cat))
28
29 var tricky = $(printf '\x00 \n \xff')
30 json8 write (tricky) | json8 read (&round_tripped)
31 assert [round_tripped === tricky]
32}
33
34@ARGV