feat: make cd builtin work with env variables (resolves #43)

pull/46/head
sammy 2021-05-01 13:31:51 -04:00
parent 9b3f8e818c
commit 80029cfff3
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 2 additions and 0 deletions

View File

@ -12,6 +12,8 @@ commander.register('cd', function (args)
for i = 1, #args do
path = path .. tostring(args[i]) .. ' '
end
path = path:gsub('$%$','\0'):gsub('${([%w_]+)}', os.getenv)
:gsub('$([%w_]+)', os.getenv):gsub('%z','$')
local ok, err = pcall(function() fs.cd(path) end)
if not ok then