Skip to content

Conversation

chrisant996
Copy link
Contributor

This commit makes z -i and z -I go interactive even with no args.

Refer to #122 for context.

In skywind3000#122 there's a note that z.lua intentionally doesn't
support `z -i` being interactive to maintain consistency with how z.sh
behaves with `z -i`.  But z.sh doesn't have a `-i` option, so I'm not
sure what is the intent.

This commit makes `z -i` and `z -I` go interactive even with no args.
@skywind3000 skywind3000 merged commit b63a38b into skywind3000:master May 16, 2025
@skywind3000
Copy link
Owner

thx

@skywind3000
Copy link
Owner

crashed when using "z -I" and press CTRL+D to terminate fzf without choosing anything:

图片

but z -I . works fine if you choose nothing in fzf.

@chrisant996
Copy link
Contributor Author

crashed when using "z -I" and press CTRL+D to terminate fzf without choosing anything:

图片

but z -I . works fine if you choose nothing in fzf.

That problem can only occur if _ZL_MATCH_MODE is set to something other than 0.
That's why I didn't encounter it -- I'm using the default value of _ZL_MATCH_MODE which is 0.

The fix is this:

diff --git a/z.lua b/z.lua
index 941c66e..171fdf4 100755
--- a/z.lua
+++ b/z.lua
@@ -1979,7 +1979,7 @@ function main(argv)
                        path = z_cd(args)
                        if path == nil and Z_MATCHMODE ~= 0 then
                                local last = args[#args]
-                               if os.path.isdir(last) then
+                               if last and os.path.isdir(last) then
                                        path = os.path.abspath(last)
                                        path = os.path.norm(path)
                                end

@chrisant996
Copy link
Contributor Author

I've updated the topic branch and submitted another pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants