-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathchkJson
153 lines (136 loc) · 5.11 KB
/
chkJson
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
-- -*- lua -*-
local sys_lua_path = "@sys_lua_path@"
if (sys_lua_path:sub(1,1) == "@") then
sys_lua_path = package.path
end
local sys_lua_cpath = "@sys_lua_cpath@"
if (sys_lua_cpath:sub(1,1) == "@") then
sys_lua_cpath = package.cpath
end
package.path = sys_lua_path
package.cpath = sys_lua_cpath
local arg_0 = arg[0]
_G._DEBUG = false
local posix = require("posix")
local readlink = posix.readlink
local stat = posix.stat
local st = stat(arg_0)
while (st.type == "link") do
local lnk = readlink(arg_0)
if (arg_0:find("/") and (lnk:find("^/") == nil)) then
local dir = arg_0:gsub("/[^/]*$","")
lnk = dir .. "/" .. lnk
end
arg_0 = lnk
st = stat(arg_0)
end
local ia,ja = arg_0:find(".*/")
local LuaCommandName = false
local LuaCommandName_dir = "./"
if (ia) then
LuaCommandName_dir = arg_0:sub(1,ja)
LuaCommandName = arg_0:sub(ja+1)
end
package.path = LuaCommandName_dir .. "?.lua;" ..
LuaCommandName_dir .. "../tools/?.lua;" ..
LuaCommandName_dir .. "../tools/?/init.lua;" ..
LuaCommandName_dir .. "../shells/?.lua;" ..
LuaCommandName_dir .. "?/init.lua;" ..
sys_lua_path
package.cpath = LuaCommandName_dir .. "../lib/?.so;"..
sys_lua_cpath
require("strict")
require("serializeTbl")
if ( _VERSION ~= "Lua 5.1" ) then
require("declare")
declare("loadstring")
loadstring = load
end
local Dbg = require("Dbg")
local json = require("json")
function main()
local configT = {
lmodV = { rule = "have"},
lfsV = { rule = "have"},
lua_term_A = { rule = "have"},
luaV = { rule = "have"},
mpath_init = { rule = "have"},
modRC = { rule = "have"},
siteName = { rule = "have"},
sysName = { rule = "have"},
syshost = { rule = "have"},
uname = { rule = "have"},
z01_admin = { rule = "have"},
prefix_site = { rule = "have"},
path_hash = { rule = "have"},
allowTCL = { rule = "match", value = "yes"},
autoSwap = { rule = "match", value = "yes"},
case = { rule = "match", value = "no"},
colorize = { rule = "match", value = "yes"},
disable1N = { rule = "match", value = "no"},
dot_files = { rule = "match", value = "yes"},
dupPaths = { rule = "match", value = "no"},
exactMatch = { rule = "match", value = "no"},
expMCmd = { rule = "match", value = "yes"},
hiddenItalic = { rule = "match", value = "no"},
lang = { rule = "match", value = "en"},
lang_site = { rule = "match", value = "<empty>"},
ld_lib_path = { rule = "match", value = "<empty>"},
ld_preload = { rule = "match", value = "<empty>"},
lua_cpath = { rule = "match", value = "@sys_lua_cpath@"},
lua_path = { rule = "match", value = "@sys_lua_path@"},
lua_term = { rule = "match", value = "no"},
mpath_av = { rule = "match", value = "no"},
mpath_root = { rule = "match", value = ""},
numSC = { rule = "match", value = 0},
pager = { rule = "match", value = "less"},
pager_opts = { rule = "match", value = "-XqMREF"},
path_lua = { rule = "match", value = "lua"},
pin_v = { rule = "match", value = "no"},
pkg = { rule = "match", value = "Pkg"},
prefix = { rule = "match", value = "@PREFIX@"},
prpnd_blk = { rule = "match", value = "normal"},
redirect = { rule = "match", value = "no"},
settarg = { rule = "match", value = "no"},
shell = { rule = "match", value = "bash"},
sitePkg = { rule = "match", value = "standard"},
spdr_ignore = { rule = "match", value = "no"},
spdr_loads = { rule = "match", value = "no"},
tm_ancient = { rule = "match", value = 86400},
tm_short = { rule = "match", value = 2},
tm_threshold = { rule = "match", value = 1},
tmod_rule = { rule = "match", value = "no"},
tmod_find1st = { rule = "match", value = "no"},
tracing = { rule = "match", value = "no"},
}
local s = io.read()
local t = json.decode(s)
local match = true
for k, v in pairs(configT) do
local testV = t.configT[k]
if (testV == nil) then
io.stderr:write("Json is missing key: ",k,"\n")
match = false
elseif (v.rule == "match" and testV ~= v.value) then
io.stderr:write("Json key: ",k," has the wrong value: testV: ",testV,", v.value: ",v.value,"\n")
match = false
end
end
if (match) then
io.stderr:write("configT matches\n")
end
if (type(t.rcfileA) == "table") then
io.stderr:write("rcfileA is a table\n")
if (#t.rcfileA == 2) then
io.stderr:write("rcfileA has two entries\n")
end
else
io.stderr:write("rcfileA is not a table\n")
end
if (type(t.propT) == "table") then
io.stderr:write("propT is a table\n")
else
io.stderr:write("propT is not a table\n")
end
end
main()