1 | # TODO-deprecate: Code we want to get rid of!
|
2 |
|
3 |
|
4 | #### oil:upgrade as alias for ysh:upgrade
|
5 |
|
6 | shopt -p | grep simple_word
|
7 | shopt --set oil:upgrade
|
8 | shopt -p | grep simple_word
|
9 |
|
10 | shopt --unset ysh:upgrade
|
11 | shopt -p | grep simple_word
|
12 |
|
13 | ## STDOUT:
|
14 | shopt -u simple_word_eval
|
15 | shopt -s simple_word_eval
|
16 | shopt -u simple_word_eval
|
17 | ## END
|
18 |
|
19 |
|
20 | #### %() array literal
|
21 |
|
22 | shopt --set parse_at
|
23 |
|
24 | var x = %(one two)
|
25 | echo @x
|
26 |
|
27 | ## STDOUT:
|
28 | one two
|
29 | ## END
|
30 |
|
31 | #### _match() instead of _group()
|
32 |
|
33 | shopt --set ysh:upgrade
|
34 |
|
35 | if ('foo42' ~ / <capture d+> /) {
|
36 | echo $[_match(0)]
|
37 | echo $[_group(0)]
|
38 | }
|
39 |
|
40 | ## STDOUT:
|
41 | 42
|
42 | 42
|
43 | ## END
|
44 |
|
45 | #### _status instead of _error.code
|
46 |
|
47 | shopt --set ysh:upgrade
|
48 |
|
49 | f() {
|
50 | return 42
|
51 | }
|
52 |
|
53 | try {
|
54 | f
|
55 | }
|
56 | echo status=$_status
|
57 |
|
58 | ## STDOUT:
|
59 | status=42
|
60 | ## END
|
61 |
|
62 |
|
63 | #### source ///osh/two.sh rather than source --builtin osh/two.sh
|
64 |
|
65 | source --builtin osh/two.sh
|
66 | echo status=$?
|
67 |
|
68 | ## STDOUT:
|
69 | status=0
|
70 | ## END
|
71 |
|
72 | #### OILS_VERSION, not OIL_VERSION
|
73 |
|
74 | if test -n "$OIL_VERSION"; then
|
75 | echo OIL
|
76 | fi
|
77 |
|
78 | ## STDOUT:
|
79 | OIL
|
80 | ## END
|
81 |
|
82 | #### s.upper(), not s => upper() (might keep this)
|
83 |
|
84 | echo $['foo' => upper()]
|
85 |
|
86 | ## STDOUT:
|
87 | FOO
|
88 | ## END
|
89 |
|
90 | #### fopen can be spelled redir
|
91 | shopt --set ysh:upgrade
|
92 |
|
93 | fopen >out {
|
94 | echo 1
|
95 | echo 2
|
96 | }
|
97 |
|
98 | tac out
|
99 |
|
100 | ## STDOUT:
|
101 | 2
|
102 | 1
|
103 | ## END
|
104 |
|
105 |
|
106 | #### Dict => keys()
|
107 | var en2fr = {}
|
108 | setvar en2fr["hello"] = "bonjour"
|
109 | setvar en2fr["friend"] = "ami"
|
110 | setvar en2fr["cat"] = "chat"
|
111 | pp test_ (en2fr => keys())
|
112 | ## status: 0
|
113 | ## STDOUT:
|
114 | (List) ["hello","friend","cat"]
|
115 | ## END
|
116 |
|
117 |
|
118 | #### Obj API
|
119 | shopt --set ysh:upgrade
|
120 |
|
121 | try {
|
122 | var obj = Object(null, {x: 4})
|
123 | pp test_ (obj)
|
124 | }
|
125 | echo $[_error.code]
|
126 |
|
127 | try {
|
128 | pp test_ (propView(obj))
|
129 | }
|
130 | echo $[_error.code]
|
131 |
|
132 | try {
|
133 | pp test_ (prototype(obj))
|
134 | }
|
135 | echo $[_error.code]
|
136 |
|
137 | ## STDOUT:
|
138 | (Obj) ("x":4)
|
139 | 0
|
140 | (Dict) {"x":4}
|
141 | 0
|
142 | (Null) null
|
143 | 0
|
144 | ## END
|