shell tools: globbing

This commit is contained in:
kepler155c@gmail.com
2019-05-10 08:08:49 -04:00
parent 8ea2598254
commit 86cba3b585
35 changed files with 303 additions and 432 deletions

25
shellex/which.lua Normal file
View File

@@ -0,0 +1,25 @@
local shell = require("shellex.shell")
local args = shell.parse(...)
if #args == 0 then
io.write("Usage: which <program>\n")
return 255
end
for i = 1, #args do
local result, reason = shell.resolveProgram(args[i])
if not result then
result = shell.getAlias(args[i])
if result then
result = args[i] .. ": aliased to " .. result
end
end
if result then
print(result)
else
io.stderr:write(args[i] .. ": " .. reason .. "\n")
return 1
end
end