diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-14 06:29:38 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-14 06:29:38 +0000 |
commit | 395ae452165a607c6b5bc4623225516044619616 (patch) | |
tree | 00ceff4dcd3fc4604d9252003cf45dfb6cfbedc1 /shell/hush_doc.txt | |
parent | 17f02e79f407ff2311255981c191a1bf8b3a7ae0 (diff) | |
download | busybox-w32-395ae452165a607c6b5bc4623225516044619616.tar.gz busybox-w32-395ae452165a607c6b5bc4623225516044619616.tar.bz2 busybox-w32-395ae452165a607c6b5bc4623225516044619616.zip |
hush: delete unused field in struct child.
reinstate needed check for invalid syntax.
document command parsing in hush_doc.txt.
Diffstat (limited to 'shell/hush_doc.txt')
-rw-r--r-- | shell/hush_doc.txt | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/shell/hush_doc.txt b/shell/hush_doc.txt index 973fe44c5..ec5dd00f2 100644 --- a/shell/hush_doc.txt +++ b/shell/hush_doc.txt | |||
@@ -1,3 +1,80 @@ | |||
1 | 2008-07-14 | ||
2 | |||
3 | Command parsing | ||
4 | |||
5 | Command parsing results in "pipe" structures. "Pipe" structure | ||
6 | does not always correspond to what sh language calls "pipe", | ||
7 | it also controls execution of if, while, etc statements. | ||
8 | |||
9 | struct pipe fields: | ||
10 | smallint res_word - "none" for normal commands, | ||
11 | "if" for if condition etc | ||
12 | struct child_prog progs[] - array of commands in pipe | ||
13 | smallint followup - how this pipe is related to next: is it | ||
14 | "pipe; pipe", "pipe & pipe" "pipe && pipe", | ||
15 | "pipe || pipe"? | ||
16 | |||
17 | Blocks of commands { pipe; pipe; } and (pipe; pipe) are represented | ||
18 | as one pipe struct with one progs[0] element which is a "group" - | ||
19 | struct child_prog can contain a list of pipes. Sometimes these | ||
20 | "groups" are created implicitly, e.g. every control | ||
21 | statement (if, while, etc) sits inside its own "pipe" struct). | ||
22 | |||
23 | res_word controls statement execution. Examples: | ||
24 | |||
25 | "echo Hello" - | ||
26 | pipe 0 res_word=NONE followup=SEQ prog[0] 'echo' 'Hello' | ||
27 | pipe 1 res_word=NONE followup=1 SEQ | ||
28 | |||
29 | "echo foo || echo bar" - | ||
30 | pipe 0 res_word=NONE followup=OR prog[0] 'echo' 'foo' | ||
31 | pipe 1 res_word=NONE followup=SEQ prog[0] 'echo' 'bar' | ||
32 | pipe 2 res_word=NONE followup=SEQ | ||
33 | |||
34 | "if true; then echo Hello; true; fi" - | ||
35 | res_word=NONE followup=SEQ | ||
36 | prog 0 group {}: | ||
37 | pipe 0 res_word=IF followup=SEQ prog[0] 'true' | ||
38 | pipe 1 res_word=THEN followup=SEQ prog[0] 'echo' 'Hello' | ||
39 | pipe 2 res_word=THEN followup=SEQ prog[0] 'true' | ||
40 | pipe 3 res_word=FI followup=SEQ | ||
41 | pipe 4 res_word=NONE followup=(null) | ||
42 | pipe 1 res_word=NONE followup=SEQ | ||
43 | |||
44 | "if true; then { echo Hello; true; }; fi" - | ||
45 | pipe 0 res_word=NONE followup=SEQ | ||
46 | prog 0 group {}: | ||
47 | pipe 0 res_word=IF followup=SEQ prog[0] 'true' | ||
48 | pipe 1 res_word=THEN followup=SEQ | ||
49 | prog 0 group {}: | ||
50 | pipe 0 res_word=NONE followup=SEQ prog[0] 'echo' 'Hello' | ||
51 | pipe 1 res_word=NONE followup=SEQ prog[0] 'true' | ||
52 | pipe 2 res_word=NONE followup=SEQ | ||
53 | pipe 2 res_word=NONE followup=(null) | ||
54 | pipe 1 res_word=NONE followup=1 SEQ | ||
55 | |||
56 | "for v in a b; do echo $v; true; done" - | ||
57 | pipe 0 res_word=NONE followup=SEQ | ||
58 | prog 0 group {}: | ||
59 | pipe 0 res_word=FOR followup=SEQ prog[0] 'v' | ||
60 | pipe 1 res_word=IN followup=SEQ prog[0] 'a' 'b' | ||
61 | pipe 2 res_word=DO followup=SEQ prog[0] 'echo' '$v' | ||
62 | pipe 3 res_word=DO followup=SEQ prog[0] 'true' | ||
63 | pipe 4 res_word=DONE followup=SEQ | ||
64 | pipe 5 res_word=NONE followup=(null) | ||
65 | pipe 1 res_word=NONE followup=SEQ | ||
66 | |||
67 | Note how "THEN" and "DO" does not just mark the first pipe, | ||
68 | it "sticks" to all pipes in the body. This is used when | ||
69 | hush executes parsed pipes. | ||
70 | |||
71 | Dummy trailing pipes with no commands are artifacts of imperfect | ||
72 | parsing algorithm - done_pipe() appends new pipe struct beforehand | ||
73 | and last one ends up empty and unused. | ||
74 | |||
75 | |||
76 | 2008-01 | ||
77 | |||
1 | This is how hush runs commands: | 78 | This is how hush runs commands: |
2 | 79 | ||
3 | /* callsite: process_command_subs */ | 80 | /* callsite: process_command_subs */ |