aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-07-19 01:09:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-07-19 01:09:42 +0200
commit252ccba948eb9f6372de0ddf6d61654df91ab360 (patch)
tree947104d184708fd3a04fe0cc73871ce0db0423a1
parente414896f38860abc5d51c8a1eda023db3757501a (diff)
downloadbusybox-w32-252ccba948eb9f6372de0ddf6d61654df91ab360.tar.gz
busybox-w32-252ccba948eb9f6372de0ddf6d61654df91ab360.tar.bz2
busybox-w32-252ccba948eb9f6372de0ddf6d61654df91ab360.zip
remove msh_function.patch. msh is deprecated
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--docs/posix_conformance.txt732
-rw-r--r--shell/msh_function.patch350
2 files changed, 366 insertions, 716 deletions
diff --git a/docs/posix_conformance.txt b/docs/posix_conformance.txt
index 5451a322d..474465efc 100644
--- a/docs/posix_conformance.txt
+++ b/docs/posix_conformance.txt
@@ -6,70 +6,70 @@ http://www.opengroup.org/onlinepubs/9699919799/
6And the complete list of all utilities that POSIX covers: 6And the complete list of all utilities that POSIX covers:
7http://www.opengroup.org/onlinepubs/9699919799/idx/utilities.html 7http://www.opengroup.org/onlinepubs/9699919799/idx/utilities.html
8 8
9This listing is a work in progress, and currently only covers 9This listing is a work in progress, and currently only covers
10tool options (not operands, enviroment variables, return codes, etc..). 10tool options (not operands, enviroment variables, return codes, etc..).
11For each option it is set if it (a) exists and (b) compliant to POSIX 2008. 11For each option it is set if it (a) exists and (b) compliant to POSIX 2008.
12Some options exist but there is no value in the 'compliant' column: that 12Some options exist but there is no value in the 'compliant' column: that
13means no one has yet bothered to make sure that the option does what it is 13means no one has yet bothered to make sure that the option does what it is
14required to do. 14required to do.
15 15
16----------------------------------------------- 16-----------------------------------------------
17 17
18POSIX Tools supported only as shell built-ins (ash shell): 18POSIX Tools supported only as shell built-ins (ash shell):
19 alias, bg, cd, fg, getopts, hash, jobs, read, type, umask, ulimit, 19 alias, bg, cd, fg, getopts, hash, jobs, read, type, umask, ulimit,
20 unalias, wait, write 20 unalias, wait, write
21 21
22POSIX Tools not supported: 22POSIX Tools not supported:
23 asa, at, batch, bc, c99, command, compress, csplit, ex, fc, file, 23 asa, at, batch, bc, c99, command, compress, csplit, ex, fc, file,
24 gencat, getconf, iconv, join, link, locale, localedef, lp, m4, 24 gencat, getconf, iconv, join, link, locale, localedef, lp, m4,
25 mailx, newgrp, nl, paste, pathchk, pax, pr, qalter, qdel, qhold, qmove, 25 mailx, newgrp, nl, paste, pathchk, pax, pr, qalter, qdel, qhold, qmove,
26 qmsg, qrerun, qrls, qselect, qsig, qstat, qsub, tabs, talk, tput, 26 qmsg, qrerun, qrls, qselect, qsig, qstat, qsub, tabs, talk, tput,
27 tsort, unlink, uucp, uustat, uux 27 tsort, unlink, uucp, uustat, uux
28 28
29POSIX Tools not supported (DEVELOPMENT): 29POSIX Tools not supported (DEVELOPMENT):
30 admin, cflow, ctags, cxref, delta, fort77, get, lex, make, nm, prs, rmdel, 30 admin, cflow, ctags, cxref, delta, fort77, get, lex, make, nm, prs, rmdel,
31 sact, sccs, strip, unget, val, what, yacc 31 sact, sccs, strip, unget, val, what, yacc
32 32
33 33
34POSIX Tools supported: 34POSIX Tools supported:
35 35
36Note: echo, printf, kill, pwd documented here as stand-alone applets, 36Note: echo, printf, kill, pwd documented here as stand-alone applets,
37 not as ash built-ins. 37 not as ash built-ins.
38 38
39 39
40ar POSIX options ********************* Failed to recognize zip & tar (did not compare to regular ar) 40ar POSIX options ********************* Failed to recognize zip & tar (did not compare to regular ar)
41 option | exists | compliant | remarks 41 option | exists | compliant | remarks
42 -C | no | no | 42 -C | no | no |
43 -T | no | no | 43 -T | no | no |
44 -a | no | no | 44 -a | no | no |
45 -b | no | no | 45 -b | no | no |
46 -c | no | no | 46 -c | no | no |
47 -d | no | no | 47 -d | no | no |
48 -i | no | no | 48 -i | no | no |
49 -m | no | no | 49 -m | no | no |
50 -p | yes | | 50 -p | yes | |
51 -q | no | no | 51 -q | no | no |
52 -r | no | no | 52 -r | no | no |
53 -s | no | no | 53 -s | no | no |
54 -t | yes | | 54 -t | yes | |
55 -u | no | no | 55 -u | no | no |
56 -v | yes | | 56 -v | yes | |
57 -x | yes | | 57 -x | yes | |
58ar Busybox specific options: 58ar Busybox specific options:
59 -o 59 -o
60 60
61awk POSIX options 61awk POSIX options
62 option | exists | compliant | remarks 62 option | exists | compliant | remarks
63 -F ERE | yes | | 63 -F ERE | yes | |
64 -f progfile | yes | | 64 -f progfile | yes | |
65 -v assignment | yes | | 65 -v assignment | yes | |
66awk Busybox specific options: None 66awk Busybox specific options: None
67 67
68basename POSIX options: None 68basename POSIX options: None
69basename Busybox specific options: None 69basename Busybox specific options: None
70 70
71cal POSIX options: None 71cal POSIX options: None
72cal Busybox specific options: 72cal Busybox specific options:
73 -y, -j 73 -y, -j
74 74
75cat POSIX options 75cat POSIX options
@@ -79,28 +79,28 @@ cat Busybox specific options: None
79 79
80chgrp POSIX options 80chgrp POSIX options
81 option | exists | compliant | remarks 81 option | exists | compliant | remarks
82 -H | yes | | 82 -H | yes | |
83 -L | yes | | 83 -L | yes | |
84 -P | yes | | 84 -P | yes | |
85 -R | yes | | 85 -R | yes | |
86 -h | yes | | 86 -h | yes | |
87chgrp Busybox specific options: 87chgrp Busybox specific options:
88 -f, -c, -v 88 -f, -c, -v
89 89
90chmod POSIX options 90chmod POSIX options
91 option | exists | compliant | remarks 91 option | exists | compliant | remarks
92 -R | yes | yes | 92 -R | yes | yes |
93chmod Busybox specific options: 93chmod Busybox specific options:
94 -f, -v, -c 94 -f, -v, -c
95 95
96chown POSIX options ********************************************* 96chown POSIX options *********************************************
97 option | exists | compliant | remarks 97 option | exists | compliant | remarks
98 -H | yes | | It seems like all flags are supported (according to printout), but 98 -H | yes | | It seems like all flags are supported (according to printout), but
99 -L | yes | | it fails to work on my machine 99 -L | yes | | it fails to work on my machine
100 -P | yes | | 100 -P | yes | |
101 -R | yes | | 101 -R | yes | |
102 -h | yes | | 102 -h | yes | |
103chown Busybox specific options: 103chown Busybox specific options:
104 -f, -c, -v 104 -f, -c, -v
105 105
106cksum POSIX options: None 106cksum POSIX options: None
@@ -108,52 +108,52 @@ cksum Busybox specific options: None
108 108
109cmp POSIX options 109cmp POSIX options
110 option | exists | compliant | remarks 110 option | exists | compliant | remarks
111 -l | yes | yes | 111 -l | yes | yes |
112 -s | yes | yes | 112 -s | yes | yes |
113cmp Busybox specific options: 113cmp Busybox specific options:
114 114
115 115
116comm POSIX options 116comm POSIX options
117 option | exists | compliant | remarks 117 option | exists | compliant | remarks
118 -1 | yes | yes | 118 -1 | yes | yes |
119 -2 | yes | yes | 119 -2 | yes | yes |
120 -3 | yes | yes | 120 -3 | yes | yes |
121comm Busybox specific options: None 121comm Busybox specific options: None
122 122
123cp POSIX options 123cp POSIX options
124 option | exists | compliant | remarks 124 option | exists | compliant | remarks
125 -H | yes | yes | 125 -H | yes | yes |
126 -L | yes | yes | 126 -L | yes | yes |
127 -P | yes | yes | 127 -P | yes | yes |
128 -R | yes | yes | 128 -R | yes | yes |
129 -f | yes | yes | 129 -f | yes | yes |
130 -i | yes | yes | 130 -i | yes | yes |
131 -p | yes | yes | 131 -p | yes | yes |
132cp Busybox specific options: 132cp Busybox specific options:
133 -d, -a, -s, -c, -r, -l 133 -d, -a, -s, -c, -r, -l
134 134
135crontab POSIX options 135crontab POSIX options
136 option | exists | compliant | remarks 136 option | exists | compliant | remarks
137 -e | yes | | 137 -e | yes | |
138 -l | yes | | 138 -l | yes | |
139 -r | yes | | 139 -r | yes | |
140crontab Busybox specific options: 140crontab Busybox specific options:
141 -u, -c 141 -u, -c
142 142
143cut POSIX options 143cut POSIX options
144 option | exists | compliant | remarks 144 option | exists | compliant | remarks
145 -b list | yes | yes | 145 -b list | yes | yes |
146 -c list | yes | yes | 146 -c list | yes | yes |
147 -d delim | yes | yes | 147 -d delim | yes | yes |
148 -f list | yes | yes | 148 -f list | yes | yes |
149 -n | yes | yes | 149 -n | yes | yes |
150 -s | yes | yes | 150 -s | yes | yes |
151cut Busybox specific options: None 151cut Busybox specific options: None
152 152
153date POSIX options 153date POSIX options
154 option | exists | compliant | remarks 154 option | exists | compliant | remarks
155 -u | yes | yes | 155 -u | yes | yes |
156date Busybox specific options: 156date Busybox specific options:
157 -I[SPEC], -d TIME, -r FILE, -R, -D FMT 157 -I[SPEC], -d TIME, -r FILE, -R, -D FMT
158 158
159dd POSIX options: 159dd POSIX options:
@@ -167,7 +167,7 @@ dd POSIX options:
167 skip | yes | | 167 skip | yes | |
168 seek | yes | | 168 seek | yes | |
169 count | yes | | 169 count | yes | |
170 conv=ascii | no | no | 170 conv=ascii | no | no |
171 conv=ebcdic | no | no | 171 conv=ebcdic | no | no |
172 conv=ibm | no | no | 172 conv=ibm | no | no |
173 conv=block | no | no | 173 conv=block | no | no |
@@ -178,30 +178,30 @@ dd POSIX options:
178 conv=noerror | yes | | 178 conv=noerror | yes | |
179 conv=notrunc | yes | | 179 conv=notrunc | yes | |
180 conv=sync | yes | | 180 conv=sync | yes | |
181dd Busybox specific options: 181dd Busybox specific options:
182 conv=fsync 182 conv=fsync
183 183
184df POSIX options 184df POSIX options
185 option | exists | compliant | remarks 185 option | exists | compliant | remarks
186 -P | yes | yes | 186 -P | yes | yes |
187 -k | yes | yes | 187 -k | yes | yes |
188 -t | no | no | 188 -t | no | no |
189df Busybox specific options: 189df Busybox specific options:
190 -a, -m, -B SIZE, -i, -h 190 -a, -m, -B SIZE, -i, -h
191Remark: 191Remark:
192- It seems that GNU df does not round percents up in its output (thus its results are a bit different) 192- It seems that GNU df does not round percents up in its output (thus its results are a bit different)
193 193
194diff POSIX options 194diff POSIX options
195 option | exists | compliant | remarks 195 option | exists | compliant | remarks
196 -C n | no | no | 196 -C n | no | no |
197 -U n | yes | | 197 -U n | yes | |
198 -b | yes | | 198 -b | yes | |
199 -c | no | no | 199 -c | no | no |
200 -e | no | no | 200 -e | no | no |
201 -f | no | no | 201 -f | no | no |
202 -r | yes | | 202 -r | yes | |
203 -u | no | no | 203 -u | no | no |
204diff Busybox specific options: 204diff Busybox specific options:
205 -d, -a, -s, -t, -L, -N, -i, -T, -w, -q, -S 205 -d, -a, -s, -t, -L, -N, -i, -T, -w, -q, -S
206 206
207dirname POSIX options: None 207dirname POSIX options: None
@@ -209,60 +209,60 @@ dirname Busybox specific options: None
209 209
210du POSIX options 210du POSIX options
211 option | exists | compliant | remarks 211 option | exists | compliant | remarks
212 -H | yes | | 212 -H | yes | |
213 -L | yes | | 213 -L | yes | |
214 -a | yes | | 214 -a | yes | |
215 -k | yes | | 215 -k | yes | |
216 -s | yes | | 216 -s | yes | |
217 -x | yes | | 217 -x | yes | |
218du Busybox specific options: 218du Busybox specific options:
219 -c, -m, -h, -d N, -l 219 -c, -m, -h, -d N, -l
220 220
221 221
222echo POSIX options: None 222echo POSIX options: None
223 option | exists | compliant | remarks 223 option | exists | compliant | remarks
224 -n | yes | yes | The result of -n is "implementation-defined" 224 -n | yes | yes | The result of -n is "implementation-defined"
225echo Busybox specific options: 225echo Busybox specific options:
226 -e, -E 226 -e, -E
227 227
228ed POSIX options 228ed POSIX options
229 option | exists | compliant | remarks 229 option | exists | compliant | remarks
230 -p string | no | no | 230 -p string | no | no |
231 -s | no | no | 231 -s | no | no |
232ed Busybox specific options: None 232ed Busybox specific options: None
233 233
234env POSIX options 234env POSIX options
235 option | exists | compliant | remarks 235 option | exists | compliant | remarks
236 -i | no | no | 236 -i | no | no |
237env Busybox specific options: 237env Busybox specific options:
238 -u, -, -i 238 -u, -, -i
239 239
240expand POSIX options 240expand POSIX options
241 option | exists | compliant | remarks 241 option | exists | compliant | remarks
242 -t tablist | yes | yes | 242 -t tablist | yes | yes |
243expand Busybox specific options: 243expand Busybox specific options:
244 --tabs=N, -i, --initial 244 --tabs=N, -i, --initial
245 245
246expr POSIX operations: 246expr POSIX operations:
247 option | exists | compliant | remarks 247 option | exists | compliant | remarks
248 | | yes | yes | 248 | | yes | yes |
249 & | yes | yes | 249 & | yes | yes |
250 = | yes | yes | 250 = | yes | yes |
251 > | yes | yes | 251 > | yes | yes |
252 >= | yes | yes | 252 >= | yes | yes |
253 <= | yes | yes | 253 <= | yes | yes |
254 < | yes | yes | 254 < | yes | yes |
255 != | yes | yes | 255 != | yes | yes |
256 + | yes | yes | 256 + | yes | yes |
257 - | yes | yes | 257 - | yes | yes |
258 * | yes | yes | 258 * | yes | yes |
259 / | yes | yes | 259 / | yes | yes |
260 % | yes | yes | 260 % | yes | yes |
261 : | yes | yes | 261 : | yes | yes |
262 (expr) | yes | yes | 262 (expr) | yes | yes |
263 integer | yes | yes | 263 integer | yes | yes |
264 string | yes | yes | 264 string | yes | yes |
265expr Busybox specific operations: 265expr Busybox specific operations:
266 match, substr, index, length, quote 266 match, substr, index, length, quote
267 267
268false POSIX options: None 268false POSIX options: None
@@ -270,104 +270,104 @@ false Busybox specific options: None
270 270
271find POSIX options 271find POSIX options
272 option | exists | compliant | remarks 272 option | exists | compliant | remarks
273 -H | no | no | 273 -H | no | no |
274 -L | no | no | 274 -L | no | no |
275find Busybox specific options: 275find Busybox specific options:
276 -group NAME, -mtime DAYS, -print, -maxdepth N, -exec CMD ARG ;, -newer FILE, -context, -iname PATTERN, -follow, -depth, -xdev, -inum N, -type X, -print0, -mindepth N, -mmin MINS, -regex PATTERN, -prune, -path PATTERN, -user NAME, -delete, -perm NNN, -name PATTERN, -size N[bck] 276 -group NAME, -mtime DAYS, -print, -maxdepth N, -exec CMD ARG ;, -newer FILE, -context, -iname PATTERN, -follow, -depth, -xdev, -inum N, -type X, -print0, -mindepth N, -mmin MINS, -regex PATTERN, -prune, -path PATTERN, -user NAME, -delete, -perm NNN, -name PATTERN, -size N[bck]
277 277
278fold POSIX options 278fold POSIX options
279 option | exists | compliant | remarks 279 option | exists | compliant | remarks
280 -b | yes | yes | 280 -b | yes | yes |
281 -s | yes | yes | 281 -s | yes | yes |
282 -w width | yes | yes | 282 -w width | yes | yes |
283fold Busybox specific options: None 283fold Busybox specific options: None
284 284
285fuser POSIX options 285fuser POSIX options
286 option | exists | compliant | remarks 286 option | exists | compliant | remarks
287 -c | no | no | 287 -c | no | no |
288 -f | no | no | 288 -f | no | no |
289 -u | no | no | 289 -u | no | no |
290fuser Busybox specific options: 290fuser Busybox specific options:
291 -m, -k, -4, -SIGNAL, -6, -s 291 -m, -k, -4, -SIGNAL, -6, -s
292 292
293grep POSIX options 293grep POSIX options
294 option | exists | compliant | remarks 294 option | exists | compliant | remarks
295 -E | yes | | 295 -E | yes | |
296 -F | yes | | 296 -F | yes | |
297 -c | yes | | 297 -c | yes | |
298 -e pattern_list | yes | | 298 -e pattern_list | yes | |
299 -f pattern_file | yes | | 299 -f pattern_file | yes | |
300 -i | yes | | 300 -i | yes | |
301 -l | yes | | 301 -l | yes | |
302 -n | yes | | 302 -n | yes | |
303 -q | yes | | 303 -q | yes | |
304 -s | yes | | 304 -s | yes | |
305 -v | yes | | 305 -v | yes | |
306 -x | no | no | 306 -x | no | no |
307grep Busybox specific options: 307grep Busybox specific options:
308 -A, -C, -B, -L, -H, -o, -h, -w, -r, -z, -m MAX 308 -A, -C, -B, -L, -H, -o, -h, -w, -r, -z, -m MAX
309 309
310head POSIX options 310head POSIX options
311 option | exists | compliant | remarks 311 option | exists | compliant | remarks
312 -n number | yes | yes | 312 -n number | yes | yes |
313head Busybox specific options: 313head Busybox specific options:
314 -v, -c NUM, -q 314 -v, -c NUM, -q
315 315
316id POSIX options 316id POSIX options
317 option | exists | compliant | remarks 317 option | exists | compliant | remarks
318 -G | yes | yes | 318 -G | yes | yes |
319 -g | yes | yes | 319 -g | yes | yes |
320 -n | yes | yes | 320 -n | yes | yes |
321 -r | yes | yes | 321 -r | yes | yes |
322 -u | yes | yes | 322 -u | yes | yes |
323id Busybox specific options: 323id Busybox specific options:
324 -Z 324 -Z
325 325
326ipcrm POSIX options 326ipcrm POSIX options
327 option | exists | compliant | remarks 327 option | exists | compliant | remarks
328 -M shmkey | no | no | 328 -M shmkey | no | no |
329 -Q msgkey | no | no | 329 -Q msgkey | no | no |
330 -S semkey | no | no | 330 -S semkey | no | no |
331 -m shmid | no | no | 331 -m shmid | no | no |
332 -q msgid | no | no | 332 -q msgid | no | no |
333 -s semid | no | no | 333 -s semid | no | no |
334ipcrm Busybox specific options: 334ipcrm Busybox specific options:
335 -mM, -qQ, -sS 335 -mM, -qQ, -sS
336 336
337ipcs POSIX options 337ipcs POSIX options
338 option | exists | compliant | remarks 338 option | exists | compliant | remarks
339 -a | yes | | 339 -a | yes | |
340 -b | no | no | 340 -b | no | no |
341 -c | yes | | 341 -c | yes | |
342 -m | yes | | 342 -m | yes | |
343 -o | no | no | 343 -o | no | no |
344 -p | yes | | 344 -p | yes | |
345 -q | yes | | 345 -q | yes | |
346 -s | yes | | 346 -s | yes | |
347 -t | yes | | 347 -t | yes | |
348ipcs Busybox specific options: 348ipcs Busybox specific options:
349 -l, -i, -u 349 -l, -i, -u
350 350
351kill POSIX options 351kill POSIX options
352 option | exists | compliant | remarks 352 option | exists | compliant | remarks
353 -l | yes | yes | 353 -l | yes | yes |
354 -s signal_name | yes | yes | 354 -s signal_name | yes | yes |
355 -signal_name | yes | yes | 355 -signal_name | yes | yes |
356 -signal_number | yes | yes | 356 -signal_number | yes | yes |
357kill Busybox specific options: 357kill Busybox specific options:
358 -q, -o 358 -q, -o
359 359
360ln POSIX options 360ln POSIX options
361 option | exists | compliant | remarks 361 option | exists | compliant | remarks
362 -L | no | no | 362 -L | no | no |
363 -P | no | no | 363 -P | no | no |
364 -f | yes | yes | 364 -f | yes | yes |
365 -s | yes | yes | 365 -s | yes | yes |
366ln Busybox specific options: 366ln Busybox specific options:
367 -S suf, -n, -b 367 -S suf, -n, -b
368 368
369logger POSIX options: None 369logger POSIX options: None
370logger Busybox specific options: 370logger Busybox specific options:
371 -p PRIO, -t TAG, -s 371 -p PRIO, -t TAG, -s
372 372
373logname POSIX options: None 373logname POSIX options: None
@@ -375,39 +375,39 @@ logname Busybox specific options: None
375 375
376ls POSIX options 376ls POSIX options
377 option | exists | compliant | remarks 377 option | exists | compliant | remarks
378 -1 | yes | yes | 378 -1 | yes | yes |
379 -A | yes | yes | 379 -A | yes | yes |
380 -C | yes | yes | 380 -C | yes | yes |
381 -F | yes | yes | And more: '=' for sockets (not defined by POSIX) 381 -F | yes | yes | And more: '=' for sockets (not defined by POSIX)
382 -H | no | no | 382 -H | no | no |
383 -L | yes | yes | But coloring may be wrong (at least POSIX does not require correct colors :) ) 383 -L | yes | yes | But coloring may be wrong (at least POSIX does not require correct colors :) )
384 -R | yes | yes | 384 -R | yes | yes |
385 -S | yes | yes | 385 -S | yes | yes |
386 -a | yes | yes | 386 -a | yes | yes |
387 -c | yes | no | Sorts output with '-l' (should only show ctime with '-l', and sort only with '-t') 387 -c | yes | no | Sorts output with '-l' (should only show ctime with '-l', and sort only with '-t')
388 -d | yes | no | When invoked together with '-L' should read symbolic links, and doesn't 388 -d | yes | no | When invoked together with '-L' should read symbolic links, and doesn't
389 -f | no | no | 389 -f | no | no |
390 -g | no | no | 390 -g | no | no |
391 -i | yes | yes | 391 -i | yes | yes |
392 -k | yes | no | Does something completely unrelated! (Lists security context instead of specifying block size) 392 -k | yes | no | Does something completely unrelated! (Lists security context instead of specifying block size)
393 -l | yes | yes | 393 -l | yes | yes |
394 -m | no | no | 394 -m | no | no |
395 -n | yes | no | Works correctly only together with '-l' (but POSIX requires '-l' to be implicitly assumed) 395 -n | yes | no | Works correctly only together with '-l' (but POSIX requires '-l' to be implicitly assumed)
396 -o | no | no | 396 -o | no | no |
397 -p | yes | yes | 397 -p | yes | yes |
398 -q | no | no | 398 -q | no | no |
399 -r | yes | yes | 399 -r | yes | yes |
400 -s | yes | yes | 400 -s | yes | yes |
401 -t | yes | yes | 401 -t | yes | yes |
402 -u | yes | yes | 402 -u | yes | yes |
403 -x | yes | yes | 403 -x | yes | yes |
404ls Busybox specific options: 404ls Busybox specific options:
405 --color, -T NUM, -K, -X, -Z, -e, -h, -v, -w NUM 405 --color, -T NUM, -K, -X, -Z, -e, -h, -v, -w NUM
406 406
407man POSIX options 407man POSIX options
408 option | exists | compliant | remarks 408 option | exists | compliant | remarks
409 -k | no | no | 409 -k | no | no |
410man Busybox specific options: 410man Busybox specific options:
411 -a Display all pages 411 -a Display all pages
412 412
413 413
@@ -416,38 +416,38 @@ mesg Busybox specific options: None
416 416
417mkdir POSIX options 417mkdir POSIX options
418 option | exists | compliant | remarks 418 option | exists | compliant | remarks
419 -m mode | yes | yes | 419 -m mode | yes | yes |
420 -p | yes | yes | 420 -p | yes | yes |
421mkdir Busybox specific options: 421mkdir Busybox specific options:
422 -Z 422 -Z
423 423
424mkfifo POSIX options 424mkfifo POSIX options
425 option | exists | compliant | remarks 425 option | exists | compliant | remarks
426 -m mode | yes | yes | 426 -m mode | yes | yes |
427mkfifo Busybox specific options: 427mkfifo Busybox specific options:
428 -Z 428 -Z
429 429
430more POSIX options 430more POSIX options
431 option | exists | compliant | remarks 431 option | exists | compliant | remarks
432 -c | no | no | 432 -c | no | no |
433 -e | no | no | 433 -e | no | no |
434 -i | no | no | 434 -i | no | no |
435 -n number | no | no | 435 -n number | no | no |
436 -p command | no | no | 436 -p command | no | no |
437 -s | no | no | 437 -s | no | no |
438 -t tagstring | no | no | 438 -t tagstring | no | no |
439 -u | no | no | 439 -u | no | no |
440more Busybox specific options: None 440more Busybox specific options: None
441 441
442mv POSIX options 442mv POSIX options
443 option | exists | compliant | remarks 443 option | exists | compliant | remarks
444 -f | yes | yes | 444 -f | yes | yes |
445 -i | yes | yes | 445 -i | yes | yes |
446mv Busybox specific options: None 446mv Busybox specific options: None
447 447
448nice POSIX options 448nice POSIX options
449 option | exists | compliant | remarks 449 option | exists | compliant | remarks
450 -n increment | yes | yes | 450 -n increment | yes | yes |
451nice Busybox specific options: None 451nice Busybox specific options: None
452 452
453nohup POSIX options: None 453nohup POSIX options: None
@@ -455,35 +455,35 @@ nohup Busybox specific options: None
455 455
456od POSIX options 456od POSIX options
457 option | exists | compliant | remarks 457 option | exists | compliant | remarks
458 -A address_base | no | no | 458 -A address_base | no | no |
459 -N count | no | no | 459 -N count | no | no |
460 -b | no | no | 460 -b | no | no |
461 -c | no | no | 461 -c | no | no |
462 -d | no | no | 462 -d | no | no |
463 -j skip | no | no | 463 -j skip | no | no |
464 -o | no | no | 464 -o | no | no |
465 -s | no | no | 465 -s | no | no |
466 -t type_string | no | no | 466 -t type_string | no | no |
467 -v | no | no | 467 -v | no | no |
468 -x | no | no | 468 -x | no | no |
469od Busybox specific options: None 469od Busybox specific options: None
470 470
471patch POSIX options 471patch POSIX options
472 option | exists | compliant | remarks 472 option | exists | compliant | remarks
473 -D define | no | no | 473 -D define | no | no |
474 -N | no | no | 474 -N | no | no |
475 -R | yes | yes | 475 -R | yes | yes |
476 -b | no | no | 476 -b | no | no |
477 -c | no | no | 477 -c | no | no |
478 -d dir | no | no | 478 -d dir | no | no |
479 -e | no | no | 479 -e | no | no |
480 -i patchfile | yes | yes | 480 -i patchfile | yes | yes |
481 -l | no | no | 481 -l | no | no |
482 -n | no | no | 482 -n | no | no |
483 -o outfile | no | no | 483 -o outfile | no | no |
484 -p num | yes | yes | 484 -p num | yes | yes |
485 -r rejectfile | no | no | 485 -r rejectfile | no | no |
486 -u | no | no | 486 -u | no | no |
487patch Busybox specific options: None 487patch Busybox specific options: None
488 488
489printf POSIX options: None 489printf POSIX options: None
@@ -491,63 +491,63 @@ printf Busybox specific options: None
491 491
492ps POSIX options 492ps POSIX options
493 option | exists | compliant | remarks 493 option | exists | compliant | remarks
494 -A | no | no | 494 -A | no | no |
495 -G grouplist | no | no | 495 -G grouplist | no | no |
496 -U userlist | no | no | 496 -U userlist | no | no |
497 -a | no | no | 497 -a | no | no |
498 -d | no | no | 498 -d | no | no |
499 -e | no | no | 499 -e | no | no |
500 -f | no | no | 500 -f | no | no |
501 -g grouplist | no | no | 501 -g grouplist | no | no |
502 -l | no | no | 502 -l | no | no |
503 -n namelist | no | no | 503 -n namelist | no | no |
504 -o format | yes | no | not supported: ruser, group, rgroup, pcpu 504 -o format | yes | no | not supported: ruser, group, rgroup, pcpu
505 -p proclist | no | no | 505 -p proclist | no | no |
506 -t termlist | no | no | 506 -t termlist | no | no |
507 -u userlist | no | no | 507 -u userlist | no | no |
508ps Busybox specific options: None 508ps Busybox specific options: None
509 509
510pwd POSIX options 510pwd POSIX options
511 option | exists | compliant | remarks 511 option | exists | compliant | remarks
512 -L | no | no | 512 -L | no | no |
513 -P | no | no | 513 -P | no | no |
514pwd Busybox specific options: None 514pwd Busybox specific options: None
515 515
516renice POSIX options 516renice POSIX options
517 option | exists | compliant | remarks 517 option | exists | compliant | remarks
518 -g | yes | yes | 518 -g | yes | yes |
519 -n increment | yes | yes | Note POSIX allows only to run with this option (busybox also allows to run without '-n' and set niceness directly) 519 -n increment | yes | yes | Note POSIX allows only to run with this option (busybox also allows to run without '-n' and set niceness directly)
520 -p | yes | yes | 520 -p | yes | yes |
521 -u | yes | yes | 521 -u | yes | yes |
522renice Busybox specific options: None 522renice Busybox specific options: None
523 523
524rm POSIX options 524rm POSIX options
525 option | exists | compliant | remarks 525 option | exists | compliant | remarks
526 -R | yes | yes | 526 -R | yes | yes |
527 -f | yes | yes | 527 -f | yes | yes |
528 -i | yes | yes | 528 -i | yes | yes |
529 -r | yes | yes | 529 -r | yes | yes |
530rm Busybox specific options: None 530rm Busybox specific options: None
531 531
532rmdir POSIX options 532rmdir POSIX options
533 option | exists | compliant | remarks 533 option | exists | compliant | remarks
534 -p | yes | yes | 534 -p | yes | yes |
535rmdir Busybox specific options: 535rmdir Busybox specific options:
536 --parents 536 --parents
537 537
538sed POSIX options 538sed POSIX options
539 option | exists | compliant | remarks 539 option | exists | compliant | remarks
540 -e script | yes | | 540 -e script | yes | |
541 -f script_file | yes | | 541 -f script_file | yes | |
542 -n | yes | | 542 -n | yes | |
543sed Busybox specific options: 543sed Busybox specific options:
544 -i, -r 544 -i, -r
545 545
546sh POSIX options 546sh POSIX options
547 option | exists | compliant | remarks 547 option | exists | compliant | remarks
548 -c | no | no | 548 -c | no | no |
549 -i | no | no | 549 -i | no | no |
550 -s | no | no | 550 -s | no | no |
551sh Busybox specific options: None 551sh Busybox specific options: None
552 552
553sleep POSIX options: None 553sleep POSIX options: None
@@ -555,58 +555,58 @@ sleep Busybox specific options: None
555 555
556sort POSIX options 556sort POSIX options
557 option | exists | compliant | remarks 557 option | exists | compliant | remarks
558 -C | no | no | 558 -C | no | no |
559 -b | yes | yes | 559 -b | yes | yes |
560 -c | yes | yes | 560 -c | yes | yes |
561 -d | yes | yes | 561 -d | yes | yes |
562 -f | yes | yes | 562 -f | yes | yes |
563 -i | yes | yes | But is not like GNU sort, which isn't! (try to sort 'a\nA\nB\nb' with and without -f) 563 -i | yes | yes | But is not like GNU sort, which isn't! (try to sort 'a\nA\nB\nb' with and without -f)
564 -k keydef | yes | | 564 -k keydef | yes | |
565 -m | no | no | 565 -m | no | no |
566 -n | yes | yes | 566 -n | yes | yes |
567 -o output | yes | yes | 567 -o output | yes | yes |
568 -r | yes | yes | 568 -r | yes | yes |
569 -t char | yes | | 569 -t char | yes | |
570 -u | yes | yes | 570 -u | yes | yes |
571sort Busybox specific options: 571sort Busybox specific options:
572 -mST, -g, -M, -s, -z 572 -mST, -g, -M, -s, -z
573 573
574split POSIX options 574split POSIX options
575 option | exists | compliant | remarks 575 option | exists | compliant | remarks
576 -a suffix_length | yes | yes | 576 -a suffix_length | yes | yes |
577 -b n | yes | yes | 577 -b n | yes | yes |
578 -b nk | yes | yes | 578 -b nk | yes | yes |
579 -b nm | yes | yes | 579 -b nm | yes | yes |
580 -l line_count | yes | yes | 580 -l line_count | yes | yes |
581split Busybox specific options: None 581split Busybox specific options: None
582 582
583strings POSIX options 583strings POSIX options
584 option | exists | compliant | remarks 584 option | exists | compliant | remarks
585 -a | yes | yes | 585 -a | yes | yes |
586 -n number | yes | yes | 586 -n number | yes | yes |
587 -t format | no | no | 587 -t format | no | no |
588strings Busybox specific options: 588strings Busybox specific options:
589 -o, -f 589 -o, -f
590 590
591stty POSIX options 591stty POSIX options
592 option | exists | compliant | remarks 592 option | exists | compliant | remarks
593 -a | yes | yes | 593 -a | yes | yes |
594 -g | yes | yes | 594 -g | yes | yes |
595stty Busybox specific options: 595stty Busybox specific options:
596 -F DEVICE 596 -F DEVICE
597 597
598tail POSIX options 598tail POSIX options
599 option | exists | compliant | remarks 599 option | exists | compliant | remarks
600 -c number | yes | yes | 600 -c number | yes | yes |
601 -f | yes | yes | 601 -f | yes | yes |
602 -n number | yes | yes | 602 -n number | yes | yes |
603tail Busybox specific options: 603tail Busybox specific options:
604 -v, -q, -s SEC 604 -v, -q, -s SEC
605 605
606tee POSIX options 606tee POSIX options
607 option | exists | compliant | remarks 607 option | exists | compliant | remarks
608 -a | yes | yes | 608 -a | yes | yes |
609 -i | yes | yes | 609 -i | yes | yes |
610tee Busybox specific options: None 610tee Busybox specific options: None
611 611
612test POSIX options: None 612test POSIX options: None
@@ -614,127 +614,127 @@ test Busybox specific options: None
614 614
615time POSIX options 615time POSIX options
616 option | exists | compliant | remarks 616 option | exists | compliant | remarks
617 -p | no | no | 617 -p | no | no |
618time Busybox specific options: 618time Busybox specific options:
619 -v 619 -v
620 620
621touch POSIX options 621touch POSIX options
622 option | exists | compliant | remarks 622 option | exists | compliant | remarks
623 -a | no | no | 623 -a | no | no |
624 -c | yes | yes | 624 -c | yes | yes |
625 -d date_time | no | no | 625 -d date_time | no | no |
626 -m | no | no | 626 -m | no | no |
627 -r ref_file | no | no | 627 -r ref_file | no | no |
628 -t time | no | no | 628 -t time | no | no |
629touch Busybox specific options: None 629touch Busybox specific options: None
630 630
631tr POSIX options 631tr POSIX options
632 option | exists | compliant | remarks 632 option | exists | compliant | remarks
633 -C | no | no | 633 -C | no | no |
634 -c | yes | yes | 634 -c | yes | yes |
635 -d | yes | yes | 635 -d | yes | yes |
636 -s | yes | yes | 636 -s | yes | yes |
637tr Busybox specific options: None 637tr Busybox specific options: None
638 638
639true POSIX options: None 639true POSIX options: None
640true Busybox specific options: None 640true Busybox specific options: None
641 641
642tty POSIX options: None 642tty POSIX options: None
643tty Busybox specific options: 643tty Busybox specific options:
644 -s 644 -s
645 645
646uname POSIX options 646uname POSIX options
647 option | exists | compliant | remarks 647 option | exists | compliant | remarks
648 -a | yes | yes | 648 -a | yes | yes |
649 -m | yes | yes | 649 -m | yes | yes |
650 -n | yes | yes | 650 -n | yes | yes |
651 -r | yes | yes | 651 -r | yes | yes |
652 -s | yes | yes | 652 -s | yes | yes |
653 -v | yes | yes | 653 -v | yes | yes |
654uname Busybox specific options: 654uname Busybox specific options:
655 -p 655 -p
656 656
657uncompress POSIX options 657uncompress POSIX options
658 option | exists | compliant | remarks 658 option | exists | compliant | remarks
659 -c | yes | yes | 659 -c | yes | yes |
660 -f | yes | yes | 660 -f | yes | yes |
661 -v | no | no | 661 -v | no | no |
662uncompress Busybox specific options: None 662uncompress Busybox specific options: None
663 663
664unexpand POSIX options 664unexpand POSIX options
665 option | exists | compliant | remarks 665 option | exists | compliant | remarks
666 -a | yes | no | POSIX requires converting two or more spaces to tabs, busybox converts one or more spaces 666 -a | yes | no | POSIX requires converting two or more spaces to tabs, busybox converts one or more spaces
667 -t tablist | yes | yes | 667 -t tablist | yes | yes |
668unexpand Busybox specific options: 668unexpand Busybox specific options:
669 --tabs=N, -f, --first-only, --all 669 --tabs=N, -f, --first-only, --all
670 670
671uniq POSIX options 671uniq POSIX options
672 option | exists | compliant | remarks 672 option | exists | compliant | remarks
673 -c | yes | yes | 673 -c | yes | yes |
674 -d | yes | yes | 674 -d | yes | yes |
675 -f fields | yes | yes | 675 -f fields | yes | yes |
676 -s chars | yes | yes | 676 -s chars | yes | yes |
677 -u | yes | yes | 677 -u | yes | yes |
678uniq Busybox specific options: 678uniq Busybox specific options:
679 -w N 679 -w N
680 680
681uudecode POSIX options 681uudecode POSIX options
682 option | exists | compliant | remarks 682 option | exists | compliant | remarks
683 -o outfile | no | no | 683 -o outfile | no | no |
684uudecode Busybox specific options: None 684uudecode Busybox specific options: None
685 685
686uuencode POSIX options 686uuencode POSIX options
687 option | exists | compliant | remarks 687 option | exists | compliant | remarks
688 -m | yes | yes | 688 -m | yes | yes |
689uuencode Busybox specific options: None 689uuencode Busybox specific options: None
690 690
691vi POSIX options 691vi POSIX options
692 option | exists | compliant | remarks 692 option | exists | compliant | remarks
693 -R | yes | | 693 -R | yes | |
694 -c command | yes | | 694 -c command | yes | |
695 -r | no | no | 695 -r | no | no |
696 -t tagstring | no | no | 696 -t tagstring | no | no |
697 -w size | no | no | 697 -w size | no | no |
698vi Busybox specific options: 698vi Busybox specific options:
699 -H 699 -H
700 700
701wc POSIX options 701wc POSIX options
702 option | exists | compliant | remarks 702 option | exists | compliant | remarks
703 -c | yes | yes | 703 -c | yes | yes |
704 -l | yes | yes | 704 -l | yes | yes |
705 -m | no | no | 705 -m | no | no |
706 -w | yes | yes | 706 -w | yes | yes |
707wc Busybox specific options: 707wc Busybox specific options:
708 -L 708 -L
709 709
710who POSIX options 710who POSIX options
711 option | exists | compliant | remarks 711 option | exists | compliant | remarks
712 -H | no | no | 712 -H | no | no |
713 -T | no | no | 713 -T | no | no |
714 -a | yes | no | just shows all 714 -a | yes | no | just shows all
715 -b | no | no | 715 -b | no | no |
716 -d | no | no | 716 -d | no | no |
717 -l | no | no | 717 -l | no | no |
718 -m | no | no | 718 -m | no | no |
719 -p | no | no | 719 -p | no | no |
720 -q | no | no | 720 -q | no | no |
721 -r | no | no | 721 -r | no | no |
722 -s | no | no | 722 -s | no | no |
723 -t | no | no | 723 -t | no | no |
724 -u | no | no | 724 -u | no | no |
725who Busybox specific options: None 725who Busybox specific options: None
726 726
727xargs POSIX options 727xargs POSIX options
728 option | exists | compliant | remarks 728 option | exists | compliant | remarks
729 -E eofstr | no | no | 729 -E eofstr | no | no |
730 -I replstr | no | no | 730 -I replstr | no | no |
731 -L number | no | no | 731 -L number | no | no |
732 -n number | yes | yes | 732 -n number | yes | yes |
733 -p | yes | yes | 733 -p | yes | yes |
734 -s size | yes | yes | 734 -s size | yes | yes |
735 -t | yes | yes | 735 -t | yes | yes |
736 -x | yes | yes | 736 -x | yes | yes |
737xargs Busybox specific options: 737xargs Busybox specific options:
738 -e[STR], -0, -r 738 -e[STR], -0, -r
739 739
740zcat POSIX options: None 740zcat POSIX options: None
diff --git a/shell/msh_function.patch b/shell/msh_function.patch
deleted file mode 100644
index 270b9eeff..000000000
--- a/shell/msh_function.patch
+++ /dev/null
@@ -1,350 +0,0 @@
1This is a "function" patch for msh which is in use by some busybox
2users. Unfortunately it is far too buggy to be applied, but maybe
3it's a useful starting point for future work.
4
5Function-related code is delimited by comments of the form
6 //funccode:start
7 ...
8 //funccode:end
9for ease of grepping
10
11An example of buggy behavior:
12
13#f() {
14# echo foo
15# echo test`echo bar >&2`
16# echo END f
17#}
18
19function g {
20# echo 2 foo
21# echo 2 test`echo 2 bar >&2`
22# f
23 echo END g
24# echo "1:'$1' 2:'$2'"
25}
26
27# Even this first block fails - it does not even call functions!
28# (replacing "echo END g" above with "echo END" makes it run ok)
29echo DRY RUN
30 echo 2 foo
31 echo 2 test`echo 2 bar >&2`
32 echo END g
33 echo "1:'$1' 2:'$2'"
34 echo foo
35 echo test`echo bar >&2`
36 echo END f
37echo END DRY RUN
38
39exit
40
41# This would fail too
42g "$1-one" "two$2"
43echo DONE
44
45
46
47diff -d -urpN busybox.7/shell/msh.c busybox.8/shell/msh.c
48--- busybox.7/shell/msh.c 2008-06-09 09:34:45.000000000 +0200
49+++ busybox.8/shell/msh.c 2008-06-09 09:38:17.000000000 +0200
50@@ -89,6 +89,14 @@ static char *itoa(int n)
51
52 //#define MSHDEBUG 4
53
54+/* Used only in "function" support code */
55+#ifdef KSDBG //funccode:start
56+ #define KSDBG_PRINT_FUNCNAME fprintf(stderr, "in %s\n", __FUNCTION__)
57+#else
58+ #define KSDBG_PRINT_FUNCNAME ((void)0)
59+#endif
60+//funccode:end
61+
62 #ifdef MSHDEBUG
63 static int mshdbg = MSHDEBUG;
64
65@@ -220,6 +228,9 @@ struct op {
66 #define TASYNC 16 /* c & */
67 /* Added to support "." file expansion */
68 #define TDOT 17
69+#define TFUNC 18 //funccode:start
70+#define TRETURN 19
71+ //funccode:end
72
73 /* Strings for names to make debug easier */
74 #ifdef MSHDEBUG
75@@ -319,6 +330,27 @@ struct region {
76 int area;
77 };
78
79+static int func_finished; //funccode:start
80+struct func {
81+ char* name;
82+ int begin_addr; /* pos in buffer of function */
83+ int end_addr;
84+};
85+#define MAX_FUNCS 100
86+
87+static struct func funcs[MAX_FUNCS];
88+
89+/* the max DEPTH of function call */
90+#define MAX_DEPTH 100
91+static struct _frame_s {
92+ int argc;
93+ char **argv;
94+ int saved_return_addr;
95+} frame[MAX_DEPTH];
96+
97+static void register_func(int begin, int end);
98+static struct func* find_func(char* name);
99+static void exec_func(struct func* f); //funccode:end
100
101 /* -------- grammar stuff -------- */
102 typedef union {
103@@ -347,6 +379,8 @@ typedef union {
104 #define IN 272
105 /* Added for "." file expansion */
106 #define DOT 273
107+#define FUNC 274 //funccode:start
108+#define RETURN 275 //funccode:end
109
110 #define YYERRCODE 300
111
112@@ -1722,6 +1756,40 @@ static struct op *simple(void)
113 (void) synio(0);
114 break;
115
116+ case FUNC: { //funccode:start
117+ int stop_flag;
118+ int number_brace;
119+ int func_begin;
120+ int func_end;
121+ int c;
122+ while ((c = my_getc(0)) == ' ' || c == '\t'|| c == '\n') /* skip whitespace */
123+ continue;
124+ stop_flag = 1;
125+ number_brace = 0;
126+ func_begin = global_env.iobase->argp->afpos;
127+ while (stop_flag) {
128+ if (c == '{')
129+ number_brace++;
130+ if (c == '}')
131+ number_brace--;
132+ if (!number_brace) /* if we reach the brace of most outsite */
133+ stop_flag = 0;
134+ c = my_getc(0);
135+ }
136+ unget(c);
137+ unget(c);
138+ func_end = global_env.iobase->argp->afpos;
139+ register_func(func_begin, func_end);
140+ peeksym = 0;
141+ t = NULL;
142+ return t;
143+ }
144+ case RETURN:
145+ func_finished = 1;
146+ peeksym = 0;
147+ t = NULL;
148+ return t; //funccode:end
149+
150 case WORD:
151 if (t == NULL) {
152 t = newtp();
153@@ -2265,6 +2333,13 @@ static int yylex(int cf)
154 case ')':
155 startl = 1;
156 return c;
157+ case '{': //funccode:start
158+ c = collect(c, '}');
159+ if (c != '\0')
160+ return c;
161+ break;
162+ case '}':
163+ return RETURN; //funccode:end
164 }
165
166 unget(c);
167@@ -2293,9 +2368,172 @@ static int yylex(int cf)
168 }
169
170 yylval.cp = strsave(line, areanum);
171+ /* To identify a subroutine */ //funccode:start
172+ c = my_getc(0);
173+ if (c && any(c, "(")) {
174+ c = my_getc(0);
175+ if (c && any(c, ")"))
176+ return FUNC;
177+ zzerr();
178+ } else
179+ unget(c);
180+ /* read the first char */
181+ /* To identify a function */
182+ if (strcmp(yylval.cp, "function") == 0) {
183+ int ret = yylex(0);
184+ /* read the function name after "function" */
185+ if (ret == WORD)
186+ return (FUNC);
187+ zzerr();
188+ }
189+ {
190+ struct func* f = find_func(yylval.cp);
191+ if (f != NULL) {
192+ exec_func(f);
193+ return RETURN;
194+ }
195+ }
196+ if (yylval.cp != NULL && strcmp(yylval.cp, "return") == 0) {
197+ return RETURN;
198+ } //funccode:end
199 return WORD;
200 }
201
202+static void register_func(int begin, int end) //funccode:start
203+{
204+ struct func *p;
205+ int i;
206+ for (i = 0; i < MAX_FUNCS; i++) {
207+ if (funcs[i].name == NULL) {
208+ p = &funcs[i];
209+ break;
210+ }
211+ }
212+ if (i == MAX_FUNCS) {
213+ fprintf(stderr, "Too much functions beyond limit\n");
214+ leave();
215+ }
216+ p->name = xstrdup(yylval.cp);
217+ //fprintf(stderr, "register function,%d,%d,%s\n", begin, end, p->name);
218+ KSDBG_PRINT_FUNCNAME;
219+ /* io stream */
220+ p->begin_addr = begin;
221+ p->end_addr = end;
222+}
223+
224+static struct func* find_func(char* name)
225+{
226+ int i;
227+ for (i = 0; i < MAX_FUNCS; i++) {
228+ if (funcs[i].name == NULL)
229+ continue;
230+ if (!strcmp(funcs[i].name, name))
231+ return &funcs[i];
232+ }
233+ KSDBG_PRINT_FUNCNAME;
234+ //fprintf(stderr, "not found the function %s\n", name);
235+ return NULL;
236+ //zzerr();
237+}
238+
239+/* Begin to execute the function */
240+static int cur_frame = 0;
241+
242+static void exec_func(struct func* f)
243+{
244+ int c;
245+ int temp_argc;
246+ char** temp_argv;
247+ struct iobuf *bp;
248+
249+ /* create a new frame, save the argument and return address to this frame */
250+ frame[cur_frame].argc = dolc;
251+ frame[cur_frame].argv = dolv;
252+
253+ cur_frame++;
254+ /* do some argument parse and set arguments */
255+ temp_argv = xmalloc(sizeof(char *));
256+ temp_argv[0] = xstrdup(f->name);
257+ temp_argc = 0;
258+ global_env.iop->argp->afpos--;
259+ global_env.iop->argp->afbuf->bufp--;
260+// unget(c);
261+ while (((c = yylex(0)) != '\n') && (yylval.cp != NULL)) {
262+ temp_argc++;
263+ temp_argv = xrealloc(temp_argv, sizeof(char *) * (temp_argc+1));
264+ /* parse $ var if passed argument is a variable */
265+ if (yylval.cp[0] == '$') {
266+ struct var *arg = lookup(&yylval.cp[1]);
267+ temp_argv[temp_argc] = xstrdup(arg->value);
268+ //fprintf(stderr, "arg->value=%s\n", arg->value);
269+ } else {
270+ temp_argv[temp_argc] = xstrdup(yylval.cp);
271+ //fprintf(stderr, "ARG:%s\n", yylval.cp);
272+ }
273+ }
274+ /*
275+ global_env.iop->argp->afpos--;
276+ global_env.iop->argp->afbuf->bufp--;
277+ */
278+ dolc = temp_argc;
279+ dolv = temp_argv;
280+ //unget(c);
281+ //while ((c = my_getc(0)) == ' ' || c == '\t') /* Skip whitespace */
282+ // continue;
283+ //unget(c);
284+ frame[cur_frame].saved_return_addr = global_env.iop->argp->afpos;
285+
286+ /* get function begin address and execute this function */
287+
288+ bp = global_env.iop->argp->afbuf;
289+ bp->bufp = &(bp->buf[f->begin_addr]);
290+ global_env.iop->argp->afpos = f->begin_addr;
291+
292+ /* func_finished=0 means we are in a function and func_finished=1 means we are executing a function */
293+ func_finished = 0;
294+
295+ //fprintf(stderr, "exec function %s\n", f->name);
296+ KSDBG_PRINT_FUNCNAME;
297+ for (;;) {
298+ //fprintf(stderr, "afpos=%d,%s\n", global_env.iop->argp->afpos, yylval.cp);
299+ if (global_env.iop->argp->afpos == f->end_addr)
300+ break;
301+ onecommand();
302+ /* we return from a function, when func_finished = 1 */
303+ if (func_finished)
304+ break;
305+ }
306+
307+ {
308+ //fprintf(stderr, "%s is finished @%d!\n", f->name, global_env.iop->argp->afpos);
309+ int ret = frame[cur_frame].saved_return_addr;
310+ /* workaround code for \n */
311+ if (dolc)
312+ ret--;
313+ /* get return address from current frame and jump to */
314+ global_env.iop->argp->afpos = ret;
315+ global_env.iop->argp->afbuf->bufp = &(global_env.iop->argp->afbuf->buf[ret]);
316+ }
317+ /*
318+ fprintf(stderr, "******** after execution ********************\n");
319+ fprintf(stderr, " %s \n############# %d\n", global_env.iop->argp->afbuf->bufp, ret);
320+ fprintf(stderr, "*******************************\n");
321+ */
322+ /* we return to previous frame */
323+ cur_frame--;
324+ /* free some space occupied by argument */
325+ while (dolc--)
326+ free(dolv[dolc]);
327+ free(dolv);
328+
329+ /* recover argument for last function */
330+ dolv = frame[cur_frame].argv;
331+ dolc = frame[cur_frame].argc;
332+ /* If we are not in the outest frame, we should set
333+ * func_finished to 0 that means we still in some function */
334+ if (cur_frame != 0)
335+ func_finished = 0;
336+} //funccode:end
337
338 static int collect(int c, int c1)
339 {
340@@ -2601,6 +2839,10 @@ static int execute(struct op *t, int *pi
341 execute(t->right->right, pin, pout, /* no_fork: */ 0);
342 }
343 break;
344+ case TFUNC: //funccode:start
345+ break;
346+ case TRETURN:
347+ break; //funccode:end
348
349 case TCASE:
350 cp = evalstr(t->str, DOSUB | DOTRIM);