1 |
# This syntax is available with OSH too |
2 |
|
3 |
#### ... with simple command |
4 |
... echo # comment |
5 |
hi # comment |
6 |
there |
7 |
; |
8 |
## STDOUT: |
9 |
hi there |
10 |
## END |
11 |
|
12 |
#### ... with pipeline |
13 |
... { echo one; echo two; } |
14 |
| sort |
15 |
| wc -l |
16 |
; |
17 |
## STDOUT: |
18 |
2 |
19 |
## END |
20 |
|
21 |
#### ... with comment sub |
22 |
|
23 |
# newlines mean the normal thing |
24 |
echo $(echo one |
25 |
echo two) |
26 |
|
27 |
... echo |
28 |
$(echo 3 |
29 |
echo 4) # is this right? |
30 |
| wc -l |
31 |
; |
32 |
## STDOUT: |
33 |
2 |
34 |
## END |
35 |
|
36 |
#### ... with && and [[ |
37 |
echo 1 && false || echo end |
38 |
|
39 |
... echo one |
40 |
&& [[ 0 -eq 0 ]] |
41 |
&& echo two |
42 |
&& false |
43 |
|| echo end |
44 |
|
45 |
## STDOUT: |
46 |
one |
47 |
two |
48 |
## END |
49 |
|
50 |
# Notes: |
51 |
# - MakeParserForCommandSub() instantiates a new WordParser, so we can safetly |
52 |
# change state in the top-level one only |
53 |
# - BoolParser is called for [[ ]] and uses the same self.w_parser. I think |
54 |
# that's OK? |
55 |
|
56 |
# So I think we can change state in WordParser. (Also possible in |
57 |
# CommandParser but meh). |
58 |
# |
59 |
# self.is_multiline = False |
60 |
# |
61 |
# When this is flag is on, then we |
62 |
# |
63 |
# Id.Op_Newline -> Id.WS_Space or Id.Ignored_LineCont |
64 |
# - and then that is NOT passed to the command parser? |
65 |
# - Or you can make it Id.Ignored_Newline |
66 |
# |
67 |
# BUT if you get 2 of them in a row without a comment, you can change it to: |
68 |
# - Id.Op_Newline? |
69 |
# |
70 |
# Actually this is very simple rule and maybe can be done without much |
71 |
# disturbance to the code. |
72 |
# |
73 |
# cursor_was_newline might need more state? |
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|