Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message on non-directory argument #697

Open
Michel-Haber opened this issue Feb 15, 2024 · 2 comments
Open

Error message on non-directory argument #697

Michel-Haber opened this issue Feb 15, 2024 · 2 comments

Comments

@Michel-Haber
Copy link

Hello,
I was trying out zoxide when I ran into the following behavior:

When I run:
z <filename> where filename is an actual file not a directory, the error message I get back from zoxide is:
"zoxide: no match found"

This same command with the bash cd:
cd <filename> returns:
"bash: cd: ./reading: Not a directory"

It would be much nicer IMO if zoxide could return a similar error message, instead of the current one, as "no match found" could imply that the target doesn't exist, rather than it not being a directory.

@Fil
Copy link

Fil commented Feb 15, 2024

my number 1 ask for a better cd would be to get to the directory that contains a file, rather than error

@Michel-Haber
Copy link
Author

@Fil I'm not exactly sure how I feel about that. On the one hand it may make things smoother, but on the other, it can really cause problems and confusion. Imagine the following scenario:

dir1/
| dir2/
|| myfile
| diir2
| myfile

Imagine wanting to erase dir1/dir2/myfile:
cd dir1/dir2

But type instead:
cd dir1/diir2

And then:
rm myfile

In such a scenario, you might end up erasing the wrong file. I can conceive of other cases where this behavior would be problematic such as if a directory is replaced by a file and a non-updated script wreaks havoc in its parent dir.

For me an explicit error, though inconvenient in many cases, is definitely safer.

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

No branches or pull requests

2 participants