improved the standard console handler to handle when ARGV has been overridden in a script
This commit is contained in:
@ -1 +0,0 @@
|
||||
$3 > 0 { print $1, $2 * $3; }
|
@ -1 +0,0 @@
|
||||
$3 == 0 { print $1; }
|
@ -1 +0,0 @@
|
||||
{ print NF, $1, $NF; }
|
@ -1 +0,0 @@
|
||||
{ print NR, $0; }
|
@ -1 +0,0 @@
|
||||
{ print "total pay for", $1, "is", $2 * $3; }
|
@ -1 +0,0 @@
|
||||
{ printf ("total pay for %s is $%.2f\n", $1, $2 * $3); }
|
@ -1 +0,0 @@
|
||||
{ printf ("%-8s $%6.2f\n", $1, $2 * $3); }
|
@ -1 +0,0 @@
|
||||
$2 >= 5
|
@ -1 +0,0 @@
|
||||
$2 * $3 > 50 { printf ("$%.2f for %s\n", $2 * $3, $1); }
|
@ -1 +0,0 @@
|
||||
$1 == "Susie"
|
@ -1 +0,0 @@
|
||||
/Susie/
|
@ -1 +0,0 @@
|
||||
$2 >= 4 || $3 >= 20
|
@ -1,2 +0,0 @@
|
||||
$2 >= 4
|
||||
$3 >= 20
|
@ -1 +0,0 @@
|
||||
!($2 < 4 && $3 < 20)
|
@ -1,5 +0,0 @@
|
||||
NF != 3 { print $0, "number of fields is not equal to 3"; }
|
||||
$2 < 3.35 { print $0, "rate is below minimum wage"; }
|
||||
$2 > 10 { print $0, "rate exceeds $10 per hour"; }
|
||||
$3 < 0 { print $0, "negative hours worked"; }
|
||||
$3 > 60 { print $0, "too many hours worked"; }
|
@ -1,2 +0,0 @@
|
||||
BEGIN { print "NAME RATE HOURS"; print ""; }
|
||||
{ print; }
|
@ -1,2 +0,0 @@
|
||||
$3 > 15 { emp = emp + 1; }
|
||||
END { print emp, "employees worked more than 15 hours"; }
|
@ -1 +0,0 @@
|
||||
END { print NR, "employees"; }
|
@ -1,5 +0,0 @@
|
||||
{ pay = pay + $2 * $3; }
|
||||
END { print NR, "employees";
|
||||
print "total pay is", pay;
|
||||
print "average pay is", pay/NR;
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
$2 > maxrate { maxrate = $2; maxemp = $1; }
|
||||
END { print "highest hourly rage:", maxrate, "for", maxemp; }
|
@ -1,2 +0,0 @@
|
||||
{ names = names $1 " "; }
|
||||
END { print names; }
|
@ -1,2 +0,0 @@
|
||||
{ last = $0; }
|
||||
END { print last; }
|
@ -1 +0,0 @@
|
||||
{ print $1, length($1); }
|
@ -1,4 +0,0 @@
|
||||
{ nc = nc + length($0) + 1;
|
||||
nw = nw + NF;
|
||||
}
|
||||
END { print NR, "lines,", nw, "words,", nc, "characters"; }
|
@ -1,7 +0,0 @@
|
||||
$2 > 6 { n = n + 1; pay = pay + $2 * $3; }
|
||||
END { if (n > 0)
|
||||
print n, "employees, total pay is", pay,
|
||||
"average pay is", pay/n;
|
||||
else
|
||||
print "no employees are paid more than $6/hour";
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
{
|
||||
line[NR] = $0;
|
||||
}
|
||||
|
||||
END {
|
||||
i = NR;
|
||||
while (i > 0)
|
||||
{
|
||||
print line[i];
|
||||
i = i - 1;
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
line[NR] = $0;
|
||||
}
|
||||
|
||||
END {
|
||||
i = NR;
|
||||
for (i = NR; i > 0; i = i - 1) print line[i];
|
||||
}
|
@ -39,11 +39,6 @@ run_init()
|
||||
run_script_for_init_main "$script"
|
||||
done
|
||||
|
||||
for script in emp-???.awk
|
||||
do
|
||||
run_script_for_init "$script" "emp-en.data"
|
||||
done
|
||||
|
||||
for script in cou-???.awk
|
||||
do
|
||||
run_script_for_init "$script" "cou-en.data"
|
||||
@ -153,20 +148,6 @@ run_test()
|
||||
}
|
||||
done
|
||||
|
||||
for script in emp-???.awk
|
||||
do
|
||||
run_script_for_test "$script" "emp-en.data"
|
||||
[ $? -ne 0 ] && {
|
||||
echo "###################################"
|
||||
echo "PROBLEM(S) DETECTED IN $script.".
|
||||
echo "###################################"
|
||||
|
||||
echo "Do you want to abort? [y/n]"
|
||||
read ans
|
||||
[ "$ans" = "y" -o "$ans" = "Y" ] && return 1
|
||||
}
|
||||
done
|
||||
|
||||
for script in cou-???.awk
|
||||
do
|
||||
run_script_for_test "$script" "cou-en.data"
|
||||
|
Reference in New Issue
Block a user