mirror of https://github.com/Hilbis/Hilbish
fix(commands/cd): set oldpwd when cd-ing with no args (fixes #225)
parent
97188e73a5
commit
c2db9e65fa
|
@ -8,14 +8,14 @@ commander.register('cd', function (args)
|
||||||
if #args > 1 then
|
if #args > 1 then
|
||||||
print("cd: too many arguments")
|
print("cd: too many arguments")
|
||||||
return 1
|
return 1
|
||||||
elseif #args > 0 then
|
end
|
||||||
local path = args[1]:gsub('$%$','\0'):gsub('${([%w_]+)}', os.getenv)
|
|
||||||
:gsub('$([%w_]+)', os.getenv):gsub('%z','$'):gsub('^%s*(.-)%s*$', '%1')
|
|
||||||
|
|
||||||
|
local path = args[1] and args[1] or hilbish.home
|
||||||
if path == '-' then
|
if path == '-' then
|
||||||
path = dirs.old
|
path = dirs.old
|
||||||
print(path)
|
print(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
dirs.setOld(hilbish.cwd())
|
dirs.setOld(hilbish.cwd())
|
||||||
dirs.push(path)
|
dirs.push(path)
|
||||||
|
|
||||||
|
@ -25,11 +25,4 @@ commander.register('cd', function (args)
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
bait.throw('cd', path)
|
bait.throw('cd', path)
|
||||||
|
|
||||||
return
|
|
||||||
end
|
|
||||||
fs.cd(hilbish.home)
|
|
||||||
bait.throw('cd', hilbish.home)
|
|
||||||
|
|
||||||
dirs.push(hilbish.home)
|
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue