Merge pull request #23 from manhong2112/master

[=] change variable name of LuaExe and LuaScript
This commit is contained in:
Linwei
2019-02-04 04:10:41 +08:00
committed by GitHub
+16 -15
View File
@@ -4,7 +4,7 @@
-- z.lua - z.sh implementation in lua, by skywind 2018, 2019 -- z.lua - z.sh implementation in lua, by skywind 2018, 2019
-- Licensed under MIT license. -- Licensed under MIT license.
-- --
-- Version 1.3.0, Last Modified: 2019/02/04 00:06 -- Version 1.4.0, Last Modified: 2019/02/04 00:06
-- --
-- * 10x times faster than fasd and autojump -- * 10x times faster than fasd and autojump
-- * 3x times faster than rupa/z -- * 3x times faster than rupa/z
@@ -2082,12 +2082,12 @@ function Init-ZLua {
return return
} }
if (!$script:LuaExe) { if (!$script:ZLUA_LUAEXE) {
$script:LuaExe = "lua.exe" $script:ZLUA_LUAEXE = "lua.exe"
} }
if (!$script:LuaScript) { if (!$script:ZLUA_SCRIPT) {
$script:LuaScript = "z.lua" $script:ZLUA_SCRIPT = "z.lua"
} }
if (!$env:_ZL_CD) { if (!$env:_ZL_CD) {
@@ -2109,17 +2109,17 @@ function Init-ZLua {
if ($args[0] -eq "--add") { if ($args[0] -eq "--add") {
$_, $rest = $args $_, $rest = $args
$env:_ZL_RANDOM = Get-Random $env:_ZL_RANDOM = Get-Random
& $script:LuaExe $script:LuaScript --add $rest & $script:ZLUA_LUAEXE $script:ZLUA_SCRIPT --add $rest
return return
} elseif ($args[0] -eq "--complete") { } elseif ($args[0] -eq "--complete") {
$_, $rest = $args $_, $rest = $args
& $script:LuaExe $script:LuaScript --complete $rest & $script:ZLUA_LUAEXE $script:ZLUA_SCRIPT --complete $rest
return return
} }
$first = $args[0] $first = $args[0]
:loop while ($first) { :loop while ($first) {
switch ($first) { switch -casesensitive ($first) {
"-l" { "-l" {
$arg_mode = "-l" $arg_mode = "-l"
break break
@@ -2176,14 +2176,15 @@ function Init-ZLua {
} }
$env:PWD = ([string] $PWD) $env:PWD = ([string] $PWD)
if ($arg_mode -eq "-h") { if ($arg_mode -eq "-h") {
& $script:LuaExe $script:LuaScript -h & $script:ZLUA_LUAEXE $script:ZLUA_SCRIPT -h
} elseif ($arg_mode -eq "-l" -or $args.Length -eq 0) { } elseif ($arg_mode -eq "-l" -or $args.Length -eq 0) {
& $script:LuaExe $script:LuaScript -l $arg_subdir $arg_type $arg_strip $args & $script:ZLUA_LUAEXE $script:ZLUA_SCRIPT -l $arg_subdir $arg_type $arg_strip $args
} elseif ($arg_mode -ne "") { } elseif ($arg_mode -ne "") {
& $script:LuaExe $script:LuaScript $arg_mode $arg_subdir $arg_type $arg_inter $args & $script:ZLUA_LUAEXE $script:ZLUA_SCRIPT $arg_mode $arg_subdir $arg_type $arg_inter $args
} else { } else {
$dest = & $script:LuaExe $script:LuaScript --cd $arg_type $arg_subdir $arg_inter $args $dest = & $script:ZLUA_LUAEXE $script:ZLUA_SCRIPT --cd $arg_type $arg_subdir $arg_inter $args
if ($dest) { if ($dest) {
& $env:_ZL_CD "$dest" & $env:_ZL_CD "$dest"
if ($env:_ZL_ECHO) { if ($env:_ZL_ECHO) {
@@ -2216,12 +2217,12 @@ Init-ZLua
]] ]]
----------------------------------------------------------------------- -----------------------------------------------------------------------
-- initialize cmd -- initialize cmd/powershell
----------------------------------------------------------------------- -----------------------------------------------------------------------
function z_windows_init(opts) function z_windows_init(opts)
if opts.powershell ~= nil then if opts.powershell ~= nil then
print('$LuaExe = "' .. os.interpreter() .. '"') print('$ZLUA_LUAEXE = "' .. os.interpreter() .. '"')
print('$LuaScript = "' .. os.scriptname() .. '"') print('$ZLUA_SCRIPT = "' .. os.scriptname() .. '"')
if opts.enhanced ~= nil then if opts.enhanced ~= nil then
print('$env:_ZL_MATCH_MODE = 1') print('$env:_ZL_MATCH_MODE = 1')
end end