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 while entering a directory from a directory with spaces on the name #222

Open
Dominiquini opened this issue Dec 17, 2023 · 2 comments · May be fixed by #229
Open

Error while entering a directory from a directory with spaces on the name #222

Dominiquini opened this issue Dec 17, 2023 · 2 comments · May be fixed by #229

Comments

@Dominiquini
Copy link

Dominiquini commented Dec 17, 2023

What did you expect to happen?
The terminal should behave normally and the 'enhancd' should log the new visited PATH

What actually happened?
A error is printed on the terminal:

Output

find: ‘/home/rafaeldominiquini/Documents/Projects/ZZZ’: No such file or directory
find: ‘-’: No such file or directory
find: ‘Others’: No such file or directory

Additional context

  1. Delete enhancd.log (The bug only happens the first time the directory is visited!)
  2. Create a dir "/home/username/dir with space/destination"
  3. Navigate to the dir "dir with space": cd /home/username/dir\ with\ space
  4. Navigate to "destination": cd destination
  5. Error is printed on the terminal

Some debug with set -x:

...
+++++ for dir in "${dirs[@]}"
+++++ command find '/home/rafaeldominiquini/Documents/Projects/ZZZ - Others/ugrep' -maxdepth 1 -type d -name '\.*' -prune -o -type d -print
+++++ for dir in "${dirs[@]}"
+++++ command find /home/rafaeldominiquini/Documents/Projects/ZZZ -maxdepth 1 -type d -name '\.*' -prune -o -type d -print
find: ‘/home/rafaeldominiquini/Documents/Projects/ZZZ’: No such file or directory
+++++ for dir in "${dirs[@]}"
+++++ command find - -maxdepth 1 -type d -name '\.*' -prune -o -type d -print
find: ‘-’: No such file or directory
+++++ for dir in "${dirs[@]}"
+++++ command find Others -maxdepth 1 -type d -name '\.*' -prune -o -type d -print
find: ‘Others’: No such file or directory
...

The bug is on the file 'filepath.sh' on the line 22!

Testing on BASH in Ubuntu 22.04 (WSL2 under Windows 10)
App version: "master"

Thanks

@Dominiquini
Copy link
Author

I was able to fix this bug:

fix.patch

Take a look if this don't break anything!

Thanks.

@jeebak
Copy link

jeebak commented Jun 25, 2024

I was able to fix this bug:

fix.patch

Take a look if this don't break anything!

Thanks.

Ah, nice! This seems to work too:

diff --git a/src/filepath.sh b/src/filepath.sh
index e62b08c..1a3ec4c 100644
--- a/src/filepath.sh
+++ b/src/filepath.sh
@@ -15,7 +15,7 @@ __enhancd::filepath::walk()
 
   # __enhancd::filepath::get_parent_dirs does not return $PWD itself,
   # so add it to the array explicitly
-  dirs=( "${PWD}" $(__enhancd::filepath::get_parent_dirs "${1:-${PWD}}") )
+  IFS=$'\n' dirs=( "${PWD}" $(__enhancd::filepath::get_parent_dirs "${1:-${PWD}}") )
 
   for dir in "${dirs[@]}"
   do

Either shouldn't break anything, IMHO.

@iamKunal iamKunal linked a pull request Jan 3, 2025 that will close this issue
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 a pull request may close this issue.

2 participants