Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: cannot `cd $_` to $_ containing spaces



Roman Perepelitsa wrote on Wed, 14 Oct 2020 09:25 +0200:
> On Tue, Oct 13, 2020 at 9:31 PM Soren Roth <sorenoid@xxxxxxxxx> wrote:
> > I made a directory with a space in the name, and tried to cd into it using $_, and failed.  
> 
> You probably have the SH_WORD_SPLIT option enabled. This option causes
> field splitting to be performed on unquoted parameter expansions, like
> in POSIX sh. You can turn it off by adding `unsetopt SH_WORD_SPLIT` to
> ~/.zshrc. Otherwise you need to quote parameter expansions to prevent
> field splitting (again, like in POSIX sh).
> 
>     cd "$_"

The SH_WORD_SPLIT option defaults to being disabled, so if you have it
enabled, you might wish to check why that's the case in the first
place, rather than simply to append an «unsetopt» to your configuration.




Messages sorted by: Reverse Date, Date, Thread, Author