Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All of bash history No such file or directory error on directories with spaces

Tags:

bash

I have been attempting to implement the functionality described in the blog article "All of bash history revisited". Basically what the scripts enable you to do is keep all of your bash history forever and across multiple sessions.

Someone has kindly made all of the code easily accessible on Github.

However whenever I use a directory with spaces:

cd ~/Desktop/
mkdir "dir with spaces"
cd dir\ with\ spaces/

the next time I log in I get an errors like the following:

-bash: pushd: /Users/jack/Desktop/dir: No such file or directory
-bash: pushd: with: No such file or directory
-bash: pushd: spaces: No such file or directory

The only reference that I understood didn't seem to be causing the problem:

# Now change to the new dir and add to the top of the stack
pushd "${the_new_dir}" > /dev/null

I'm hoping some bash scripting expert can point out the error in the code so I can patch it.

like image 944
Jack Avatar asked Oct 05 '22 19:10

Jack


1 Answers

This was the culprit:

for x in `hd 20` `pwd`; do cd_func $x ; done

Replace with:

( hd 20; pwd ) | while read x; do cd_func "$x"; done

Pull request issued at github repo.

like image 187
djoot Avatar answered Oct 13 '22 11:10

djoot