trying to build dash: awk and sort bugs uncovered
Denis Vlasenko
vda.linux at googlemail.com
Mon Jan 1 07:24:42 PST 2007
In case some awk guru is around:
I tried to build dash (Debian ash) and found the following.
(The same text is also attached to prevent tab mangling:
testcases have tabs in a few places)!
awk: trouble with positional variables?
echo -n "\
3 ALIAS ALIASCMD
4 BG BGCMD
" | awk '{ printf "#define %s (builtincmd + %d)\n", $3, $1}'
-bbox +coreutils:
-#define ALIASCMD3 (builtincmd + 0)
-#define BGCMD4 (builtincmd + 0)
+#define ALIASCMD (builtincmd + 3)
+#define BGCMD (builtincmd + 4)
awk: "awk: cmd. line:4: Too few arguments for builtin"
awk '{
opt = ""
if (NF > 2) {
opt = substr($2, 2)
$2 = $3
}
printf "\t{ \"%s\", %s, %d },\n", $1, $2,
(opt ~ /s/) + (opt ~ /[su]/) * 2 + (opt ~ /a/) * 4
}'
input is:
: -s truecmd
. -s dotcmd
[ testcmd
alias -au aliascmd
bg -u bgcmd
break -s breakcmd
...
chokes on "a a a", works on "a a" but output is not correct:
-bbox +coreutils:
- { "aa", , 0 },
+ { "a", a, 0 },
sort -u -k 3.3: incorrect workings of -u[nigue] option:
-bbox +coreutils:
3 alias aliascmd
4 bg bgcmd
5 break breakcmd
- 9 continue breakcmd
6 cd cdcmd
- 7 chdir cdcmd
8 command commandcmd
1 . dotcmd
10 echo echocmd
sort -k 1,1: doesn't seem to be important:
-bbox +coreutils:
-. -s dotcmd
: -s truecmd
+. -s dotcmd
[ testcmd
alias -au aliascmd
bg -u bgcmd
--
vda
-------------- next part --------------
awk: trouble with positional variables?
echo -n "\
3 ALIAS ALIASCMD
4 BG BGCMD
" | awk '{ printf "#define %s (builtincmd + %d)\n", $3, $1}'
-bbox +coreutils:
-#define ALIASCMD3 (builtincmd + 0)
-#define BGCMD4 (builtincmd + 0)
+#define ALIASCMD (builtincmd + 3)
+#define BGCMD (builtincmd + 4)
awk: "awk: cmd. line:4: Too few arguments for builtin"
awk '{
opt = ""
if (NF > 2) {
opt = substr($2, 2)
$2 = $3
}
printf "\t{ \"%s\", %s, %d },\n", $1, $2,
(opt ~ /s/) + (opt ~ /[su]/) * 2 + (opt ~ /a/) * 4
}'
input is:
: -s truecmd
. -s dotcmd
[ testcmd
alias -au aliascmd
bg -u bgcmd
break -s breakcmd
...
chokes on "a a a", works on "a a" but output is not correct:
-bbox +coreutils:
- { "aa", , 0 },
+ { "a", a, 0 },
sort -u -k 3.3: incorrect workings of -u[nigue] option:
-bbox +coreutils:
3 alias aliascmd
4 bg bgcmd
5 break breakcmd
- 9 continue breakcmd
6 cd cdcmd
- 7 chdir cdcmd
8 command commandcmd
1 . dotcmd
10 echo echocmd
sort -k 1,1: doesn't seem to be important:
-bbox +coreutils:
-. -s dotcmd
: -s truecmd
+. -s dotcmd
[ testcmd
alias -au aliascmd
bg -u bgcmd
More information about the busybox
mailing list