5

我一直在尝试实现博客文章“重访所有 bash 历史”中描述的功能。基本上,脚本使您能够做的就是永久保留所有 bash 历史记录并跨越多个会话。

有人好心地在 Github 上轻松访问了所有代码。

但是,每当我使用带空格的目录时:

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

下次登录时,我收到如下错误:

-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

我理解的唯一参考似乎没有引起问题:

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

我希望一些 bash 脚本专家可以指出代码中的错误,以便我可以修补它。

4

1 回答 1

4

这是罪魁祸首:

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

用。。。来代替:

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

在 github repo 上发布的拉取请求。

于 2013-03-07T22:28:11.610 回答