mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "5408e68e1910639db4fc080dee9d1db392764ffd" and "9defa737f4351f639882f0576cbafdd0de71f1fd" have entirely different histories.
5408e68e19
...
9defa737f4
10
hilbish.go
10
hilbish.go
|
@ -14,7 +14,6 @@ import (
|
||||||
var exports = map[string]lua.LGFunction {
|
var exports = map[string]lua.LGFunction {
|
||||||
"run": run,
|
"run": run,
|
||||||
"flag": flag,
|
"flag": flag,
|
||||||
"cwd": cwd,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func HilbishLoader(L *lua.LState) int {
|
func HilbishLoader(L *lua.LState) int {
|
||||||
|
@ -54,12 +53,3 @@ func flag(L *lua.LState) int {
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func cwd(L *lua.LState) int {
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
|
|
||||||
L.Push(lua.LString(cwd))
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
6
lua.go
6
lua.go
|
@ -12,7 +12,6 @@ import (
|
||||||
"hilbish/golibs/fs"
|
"hilbish/golibs/fs"
|
||||||
|
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"layeh.com/gopher-luar"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var minimalconf = `
|
var minimalconf = `
|
||||||
|
@ -31,7 +30,6 @@ func LuaInit() {
|
||||||
l.SetGlobal("alias", l.NewFunction(hshalias))
|
l.SetGlobal("alias", l.NewFunction(hshalias))
|
||||||
l.SetGlobal("appendPath", l.NewFunction(hshappendPath))
|
l.SetGlobal("appendPath", l.NewFunction(hshappendPath))
|
||||||
l.SetGlobal("exec", l.NewFunction(hshexec))
|
l.SetGlobal("exec", l.NewFunction(hshexec))
|
||||||
l.SetGlobal("goro", luar.New(l, hshgoroutine))
|
|
||||||
|
|
||||||
// yes this is stupid, i know
|
// yes this is stupid, i know
|
||||||
l.PreloadModule("hilbish", HilbishLoader)
|
l.PreloadModule("hilbish", HilbishLoader)
|
||||||
|
@ -153,7 +151,3 @@ func hshexec(L *lua.LState) int {
|
||||||
syscall.Exec(cmdPath, cmdArgs, os.Environ())
|
syscall.Exec(cmdPath, cmdArgs, os.Environ())
|
||||||
return 0 // random thought: does this ever return?
|
return 0 // random thought: does this ever return?
|
||||||
}
|
}
|
||||||
|
|
||||||
func hshgoroutine(gofunc func()) {
|
|
||||||
go gofunc()
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
local fs = require 'fs'
|
local fs = require 'fs'
|
||||||
local commander = require 'commander'
|
local commander = require 'commander'
|
||||||
local bait = require 'bait'
|
local bait = require 'bait'
|
||||||
local old_dir = hilbish.cwd()
|
|
||||||
|
|
||||||
-- Builtins
|
-- Builtins
|
||||||
commander.register('cd', function (args)
|
commander.register('cd', function (args)
|
||||||
|
@ -14,13 +13,7 @@ commander.register('cd', function (args)
|
||||||
path = path .. tostring(args[i]) .. ' '
|
path = path .. tostring(args[i]) .. ' '
|
||||||
end
|
end
|
||||||
path = path:gsub('$%$','\0'):gsub('${([%w_]+)}', os.getenv)
|
path = path:gsub('$%$','\0'):gsub('${([%w_]+)}', os.getenv)
|
||||||
:gsub('$([%w_]+)', os.getenv):gsub('%z','$'):gsub("%s+", "")
|
:gsub('$([%w_]+)', os.getenv):gsub('%z','$')
|
||||||
|
|
||||||
if path == '-' then
|
|
||||||
path = old_dir
|
|
||||||
print(path)
|
|
||||||
end
|
|
||||||
old_dir = hilbish.cwd()
|
|
||||||
|
|
||||||
local ok, err = pcall(function() fs.cd(path) end)
|
local ok, err = pcall(function() fs.cd(path) end)
|
||||||
if not ok then
|
if not ok then
|
||||||
|
|
Loading…
Reference in New Issue