aboutsummaryrefslogtreecommitdiffstats
path: root/test/readdir0.awk
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2014-04-13 14:30:56 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2014-04-13 14:30:56 -0400
commit94e3f93395de538d73826e128281a3ea9591a5a9 (patch)
tree45257e4b024537c5e0e5a3037a99ea9765583c99 /test/readdir0.awk
parentc4300d657ba49db0b6d0f0884f41a29622edc58b (diff)
parenta4b59faf911743b30f2e6e979c4f9c1ea0669ac3 (diff)
downloadegawk-94e3f93395de538d73826e128281a3ea9591a5a9.tar.gz
egawk-94e3f93395de538d73826e128281a3ea9591a5a9.tar.bz2
egawk-94e3f93395de538d73826e128281a3ea9591a5a9.zip
Merge branch 'master' into select
Diffstat (limited to 'test/readdir0.awk')
-rw-r--r--test/readdir0.awk36
1 files changed, 29 insertions, 7 deletions
diff --git a/test/readdir0.awk b/test/readdir0.awk
index c98ac674..2b7674a4 100644
--- a/test/readdir0.awk
+++ b/test/readdir0.awk
@@ -1,4 +1,9 @@
+# NOTE: This program is not a generalized parser for the output of 'ls'.
+# It's job is to read the output of ls from the gawk source code directory,
+# where we know there are no symbolic links, nor are there files with
+# spaces in their file names, etc.
BEGIN {
+ # analyze results from readdir extension
while ((getline x < extout) > 0) {
numrec++
if ((split(x, f, "/") == 3) && (f[3] == "u"))
@@ -11,12 +16,29 @@ BEGIN {
}
}
-{
- ino = $1
- name = $NF
- type = substr($2, 1, 1)
- if (type == "-")
- type = "f"
+BEGIN {
+ for (i = 1; (getline < dirlist) > 0; i++) {
+ # inode number is $1, filename is read of record
+ inode = $1
+ $1 = ""
+ $0 = $0
+ sub(/^ */, "")
+ names[i] = $0
+ ino[names[i]] = inode
+ }
+ close(dirlist)
+
+ for (j = 1; (getline < longlist) > 0; j++) {
+ type_let = substr($0, 1, 1)
+ if (type_let == "-")
+ type_let = "f"
+ type[$NF] = type_let
+ }
+ close(longlist)
- printf "%s/%s/%s\n", ino, name, (ftype_unknown ? "u" : type)
+ if (i != j)
+ printf("mismatch: %d from `ls -afi' and %d from `ls -lna'\n", i, j) > "/dev/stderr"
+
+ for (i = 1; i in names; i++)
+ printf("%s/%s/%s\n", ino[names[i]], names[i], (ftype_unknown ? "u" : type[names[i]]))
}