forked from osmarks/potatOS
grep program
This commit is contained in:
parent
5e67897a70
commit
49eaf55b95
4
manifest
4
manifest
@ -1,2 +1,2 @@
|
|||||||
{"build":188,"description":"heavlisp stdlib bundling fix (throwerror should really throw an error)","files":{"LICENSES":"f3549d84d66eb53dd4a421a4341d77d3d217c1b117d67e3be8f5211adcda0952","autorun.lua":"af5c21733a989d61aaed06788d818bbc96a3f7e13e16c57c9bf4d833b6cc3848","bin/5rot26.lua":"91b66cd6d4b33081b25c456142dd7efcb894e819e842693c9e1e17ff48872ff5","bin/ccemux.lua":"239476f58835b86bbcac31ce8af3c3acd3d198a55ab9ada78c62fbf358625a98","bin/chronometer.lua":"db5363993a04382145aef7db2fbe262f0bf10697a589e1e2d2f9ce0f87430dd8","bin/kristminer.lua":"7e7f9fe2a6493d584ad6926cda915e02c1c3d800dc209680898ce930d0bb0e6f","bin/livegps.lua":"c3d17d495cda01aa1261e4c4fcd43439b29af422671972117ec34f68e32c5bba","bin/loading.lua":"c85f7aa1765170325155b921c1fceeb62643f552f12d41b529a22af3a67f5a97","bin/potatoflight.lua":"2fbb0b6f8d78728d8cb0ec64af1bc598bd00cb55f202378e7acdb86bba71efd1","bin/potatoplex.lua":"86c9e7597bbe23d7de7e7f1bfc976d0b94dcdf3af9e6c7c6c9b18b98596898c8","bin/relay.lua":"261ae6c220b83506e3326e8f2b091d246baae458ff0d2ee87512be2c4e35a75d","bin/tryhaskell.lua":"07810d85145da65a3e434154c79d5a9d72f2dcbe59c8d6829040fb925df878ec","potatobios.lua":"7593e0f9d0755eea05e3c0fff5c4c9e036745a8cbc20e9e19609d8743a77b87e","signing-key.tbl":"b32af5229c23af3bc03d538e42751b26044e404a7b1af064ed89894efe421607","startup":"f17bfb9b4322c4467dc9170d50827f2d75717e5c3125d734f21f3406657917bc","stdlib.hvl":"a6fd2620068f47794a9bbeed77bee3fd4962f848e6dd7c75137b30cd5665272e","update-key.hex":"8d8afb7a45833bb7d68f929421ad60a211d4d73e0ee03b24dc0106ba1de2e1a0","xlib/00_cbor.lua":"464b075e4f094b8db42506bd4bdaad0db87699ea7fbf80e5b87739b4aa9279af","xlib/01_skynet.lua":"9cb565d639a0acd7c763c3e7422482532cd0bda0cdfcc720089ab4a87e551339","xlib/03_heavlisp.lua":"82cdabd5286058c0ea4f27956f8c1144e198769c8b8ce9e91b26c930d711f710"},"sizes":{"LICENSES":4725,"autorun.lua":182346,"bin/5rot26.lua":914,"bin/ccemux.lua":1673,"bin/chronometer.lua":1152,"bin/kristminer.lua":5566,"bin/livegps.lua":980,"bin/loading.lua":7707,"bin/potatoflight.lua":3417,"bin/potatoplex.lua":6526,"bin/relay.lua":3075,"bin/tryhaskell.lua":1867,"potatobios.lua":71272,"signing-key.tbl":190,"startup":8313,"stdlib.hvl":851,"update-key.hex":44,"xlib/00_cbor.lua":15808,"xlib/01_skynet.lua":3286,"xlib/03_heavlisp.lua":15643},"timestamp":1611963170}
|
{"build":189,"description":"grep program","files":{"LICENSES":"f3549d84d66eb53dd4a421a4341d77d3d217c1b117d67e3be8f5211adcda0952","autorun.lua":"b93bd7db544007665e23f7a9e3f5bdc3af1c7280db82d71a49ce77f25edb13ef","bin/5rot26.lua":"91b66cd6d4b33081b25c456142dd7efcb894e819e842693c9e1e17ff48872ff5","bin/ccemux.lua":"239476f58835b86bbcac31ce8af3c3acd3d198a55ab9ada78c62fbf358625a98","bin/chronometer.lua":"db5363993a04382145aef7db2fbe262f0bf10697a589e1e2d2f9ce0f87430dd8","bin/grep.lua":"1509bc267867b933e528ab74cfbc2a15fa2df0ec7389df4f9033194ab9037865","bin/kristminer.lua":"7e7f9fe2a6493d584ad6926cda915e02c1c3d800dc209680898ce930d0bb0e6f","bin/livegps.lua":"c3d17d495cda01aa1261e4c4fcd43439b29af422671972117ec34f68e32c5bba","bin/loading.lua":"c85f7aa1765170325155b921c1fceeb62643f552f12d41b529a22af3a67f5a97","bin/potatoflight.lua":"2fbb0b6f8d78728d8cb0ec64af1bc598bd00cb55f202378e7acdb86bba71efd1","bin/potatoplex.lua":"86c9e7597bbe23d7de7e7f1bfc976d0b94dcdf3af9e6c7c6c9b18b98596898c8","bin/relay.lua":"261ae6c220b83506e3326e8f2b091d246baae458ff0d2ee87512be2c4e35a75d","bin/tryhaskell.lua":"07810d85145da65a3e434154c79d5a9d72f2dcbe59c8d6829040fb925df878ec","potatobios.lua":"7593e0f9d0755eea05e3c0fff5c4c9e036745a8cbc20e9e19609d8743a77b87e","signing-key.tbl":"b32af5229c23af3bc03d538e42751b26044e404a7b1af064ed89894efe421607","startup":"f17bfb9b4322c4467dc9170d50827f2d75717e5c3125d734f21f3406657917bc","stdlib.hvl":"a6fd2620068f47794a9bbeed77bee3fd4962f848e6dd7c75137b30cd5665272e","update-key.hex":"8d8afb7a45833bb7d68f929421ad60a211d4d73e0ee03b24dc0106ba1de2e1a0","xlib/00_cbor.lua":"464b075e4f094b8db42506bd4bdaad0db87699ea7fbf80e5b87739b4aa9279af","xlib/01_skynet.lua":"9cb565d639a0acd7c763c3e7422482532cd0bda0cdfcc720089ab4a87e551339","xlib/03_heavlisp.lua":"82cdabd5286058c0ea4f27956f8c1144e198769c8b8ce9e91b26c930d711f710"},"sizes":{"LICENSES":4725,"autorun.lua":182345,"bin/5rot26.lua":914,"bin/ccemux.lua":1673,"bin/chronometer.lua":1152,"bin/grep.lua":1196,"bin/kristminer.lua":5566,"bin/livegps.lua":980,"bin/loading.lua":7707,"bin/potatoflight.lua":3417,"bin/potatoplex.lua":6526,"bin/relay.lua":3075,"bin/tryhaskell.lua":1867,"potatobios.lua":71272,"signing-key.tbl":190,"startup":8313,"stdlib.hvl":851,"update-key.hex":44,"xlib/00_cbor.lua":15808,"xlib/01_skynet.lua":3286,"xlib/03_heavlisp.lua":15643},"timestamp":1612011951}
|
||||||
{"hash":"68bbb5e12a6d76f3a5d38ba953a0b921bb609747daf61d18b9742e3f84ed7e63","sig":"c19cad6e6cb04d899318a782861cb0c0a59012f517519c11413125f92e7317d1ba1f5406643ee18be41b"}
|
{"hash":"ec458d2a2dc6d17253414d89071379e83a572194a4debfc17a6c6ec20735cc27","sig":"3046d409d01d8bc3a6958194ff70d771b35c3129130ef308f6d5b7d62ea19e209028819ec3af6cd88103"}
|
36
src/bin/grep.lua
Normal file
36
src/bin/grep.lua
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
local pattern, file = ...
|
||||||
|
if not pattern then error "At least a pattern is required" end
|
||||||
|
if file and not fs.exists(file) then error(("%s does not exist"):format(file)) end
|
||||||
|
if not file then file = "." end
|
||||||
|
|
||||||
|
local function scan_file(filepath)
|
||||||
|
local filepath = fs.combine(filepath, "")
|
||||||
|
if fs.isDir(filepath) then
|
||||||
|
for _, basename in pairs(fs.list(filepath)) do
|
||||||
|
scan_file(fs.combine(filepath, basename))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local fh = fs.open(filepath, "r")
|
||||||
|
local count = 1
|
||||||
|
local has_printed_filename = false
|
||||||
|
while true do
|
||||||
|
local line = fh.readLine()
|
||||||
|
if line == nil then break end
|
||||||
|
if line:match(pattern) then
|
||||||
|
if not has_printed_filename then
|
||||||
|
if term.isColor() then term.setTextColor(colors.blue) end
|
||||||
|
print(filepath)
|
||||||
|
end
|
||||||
|
if term.isColor() then term.setTextColor(colors.lime) end
|
||||||
|
write(tostring(count) .. ": ")
|
||||||
|
if term.isColor() then term.setTextColor(colors.white) end
|
||||||
|
textutils.pagedPrint(line)
|
||||||
|
has_printed_filename = true
|
||||||
|
end
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
fh.close()
|
||||||
|
end
|
||||||
|
|
||||||
|
scan_file(file)
|
@ -1223,7 +1223,7 @@ if mfst then
|
|||||||
verified = ("false %s"):format(tostring(mfst.verification_error))
|
verified = ("false %s"):format(tostring(mfst.verification_error))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
print("Signature verified:", verified)
|
print("Signature verified", verified)
|
||||||
else
|
else
|
||||||
print "Manifest not found in registry. Extended data unavailable."
|
print "Manifest not found in registry. Extended data unavailable."
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user