From 17281a9de1116d13aa20bc4b971e1c61ba2d6a40 Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Sun, 10 Feb 2019 14:36:10 +0800 Subject: [PATCH] update doc --- README.md | 8 ++++---- z.lua | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7d68c23..1eefe6b 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,11 @@ z -b foo # cd to the parent directory starting with foo eval "$(lua /path/to/z.lua --init posix)" - For very old shells like ksh (Korn Shell), some keywords like `local` and `builtin` are unsupported, you can use: + For new posix shells like dash/ash, you can use: - eval "$(lua /path/to/z.lua --init posix legacy)" + eval "$(lua /path/to/z.lua --init posix new)" - To generate old posix compatible script. + To take advantage of keywords `local` and `builtin`. - Fish Shell: @@ -397,7 +397,7 @@ awk -F '\t' '{print $2 "|" $1 "|" 0}' $FN >> ~/.zlua ## History -- 1.4.4 (2019-02-10): supports legacy posix shells like ksh, init with `z.lua --init posix legacy`. +- 1.4.4 (2019-02-10): supports legacy posix shells like ksh. - 1.4.3 (2019-02-08): fixed minor issues. - 1.4.2 (2019-02-06): you can disabled path validation by `$_ZL_NO_CHECK`, and use `z --purge` to clear bad paths manually. - 1.4.1 (2019-02-06): fzf tab-completion in bash (@[BarbUk](https://github.com/BarbUk)), fixed hang in fish shell (close [#29](https://github.com/skywind3000/z.lua/issues/29)). diff --git a/z.lua b/z.lua index 5be590d..e273802 100755 --- a/z.lua +++ b/z.lua @@ -1790,12 +1790,12 @@ _zlua() { elif [ -n "$arg_mode" ]; then "$ZLUA_LUAEXE" "$ZLUA_SCRIPT" $arg_mode $arg_subdir $arg_type $arg_inter "$@" else - local dest=$("$ZLUA_LUAEXE" "$ZLUA_SCRIPT" --cd $arg_type $arg_subdir $arg_inter "$@") - if [ -n "$dest" ] && [ -d "$dest" ]; then + local zdest=$("$ZLUA_LUAEXE" "$ZLUA_SCRIPT" --cd $arg_type $arg_subdir $arg_inter "$@") + if [ -n "$zdest" ] && [ -d "$zdest" ]; then if [ -z "$_ZL_CD" ]; then - builtin cd "$dest" + builtin cd "$zdest" else - $_ZL_CD "$dest" + $_ZL_CD "$zdest" fi if [ -n "$_ZL_ECHO" ]; then pwd; fi fi @@ -1916,11 +1916,16 @@ function z_shell_init(opts) print('ZLUA_SCRIPT="' .. os.scriptname() .. '"') print('ZLUA_LUAEXE="' .. os.interpreter() .. '"') print('') - if not opts.legacy then + if not opts.posix then print(script_zlua) else - local script = script_zlua:gsub('local ', ''):gsub('builtin ', '') - print(script) + if opts.new or opts.modern then + print(script_zlua) + else + local script = script_zlua:gsub('local ', '') + script = script:gsub('builtin ', '') + print(script) + end end local prompt_hook = (os.getenv("_ZL_NO_PROMPT_COMMAND") == nil)