-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnc.lua
95 lines (73 loc) · 1.79 KB
/
nc.lua
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
function init()
local MYNUMTEST=0
local word
if not MYARG then
MYARG=""
end
if not MYOPTARG then
MYOPTARG=""
end
if not ADDHELP then
ADDHELP=""
end
if not MYDESC then
MYDESC=""
end
if not myversion then
myversion=""
end
local f = assert (io.popen ("/usr/local/bin/cbsd -c version 2>/dev/null"))
local bin_version=""
for line in f:lines() do
bin_version=( bin_version .. line )
end -- for loop
if ( bin_version ~= myversion ) then
print( "Warning: CBSD is " .. bin_version .. " while workdir initializated for " .. myversion .. ". Please re-run: cbsd initenv" )
end
for word in string.gmatch( MYOPTARG .. " " .. MYARG, "[^%s]+" ) do MYNUMTEST=MYNUMTEST+1 end
if ( arg[1]=="--args" ) then
print ( greeting .. " " .. MYNUMTEST )
for word in string.gmatch( MYOPTARG .. " " .. MYARG, "[^%s]+") do
print ( word )
end
os.exit(0)
end
if ( arg[1]=="--help" ) then
if not CBSDMODULE then
CBSDMODULE="sys"
end
print ( "[" .. CBSDMODULE .. "] " .. MYDESC )
print ( "require: " .. MYARG )
print ( "opt: " .. MYOPTARG )
if ADDHELP then print ( ADDHELP ) end
if MANPAGE then print ( "Check out manual page: " .. MANPAGE ) end
if EXTHELP then print ( "External help: " .. cbsddocsrc .. "/" .. EXTHELP ) end
os.exit(0)
end
dofile(localcbsdconf)
local i=1
while arg[i] do
local x = string.find( arg[i] , "=", 1, true )
if x then
local ARG=string.sub( arg[i], 1, x-1 )
local VAL=string.sub( arg[i], x+1, -1 )
local s=ARG .. "='" .. VAL .. "'"
assert(loadstring(s))()
end
i = i + 1
end
for word in string.gmatch ( MYARG, "[^%s]+" ) do
local s= [[
if not jname then
exist=0
else
exist=1
end
]]
assert(loadstring(s))()
if ( exist == 0 ) then
print ( "Please set: " .. word )
os.exit(1)
end
end
end