zsh-workers
 help / color / mirror / code / Atom feed
* cannot `cd $_` to $_ containing spaces
@ 2020-10-13 19:30 Soren Roth
  2020-10-13 19:47 ` Matthew Martin
  2020-10-14  7:25 ` Roman Perepelitsa
  0 siblings, 2 replies; 4+ messages in thread
From: Soren Roth @ 2020-10-13 19:30 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

I made a directory with a space in the name, and tried to cd into it using
$_, and failed. Just trying to be a good citizen, I wouldn't be surprised
if this is known or somehow a feature.


~ % mkdir ArcGIS\ SDKs

~ % cd $_

cd: string not in pwd: ArcGIS



~ % echo $SHELL

/bin/zsh


~ % uname -a

Darwin XXXXX 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT
2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64


~ % zsh --version

zsh 5.7.1 (x86_64-apple-darwin19.0)

[-- Attachment #2: Type: text/html, Size: 5045 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cannot `cd $_` to $_ containing spaces
  2020-10-13 19:30 cannot `cd $_` to $_ containing spaces Soren Roth
@ 2020-10-13 19:47 ` Matthew Martin
  2020-10-14  7:25 ` Roman Perepelitsa
  1 sibling, 0 replies; 4+ messages in thread
From: Matthew Martin @ 2020-10-13 19:47 UTC (permalink / raw)
  To: zsh-workers

On Tue, Oct 13, 2020 at 12:30:57PM -0700, Soren Roth wrote:
> I made a directory with a space in the name, and tried to cd into it using
> $_, and failed. Just trying to be a good citizen, I wouldn't be surprised
> if this is known or somehow a feature.
> 
> 
> ~ % mkdir ArcGIS\ SDKs
> 
> ~ % cd $_
> 
> cd: string not in pwd: ArcGIS

This appears to be an issue with some part of your setup. It works in
zsh -f.

% PROMPT='%% ' zsh -f
% mkdir foo\ bar
% cd $_
% pwd
/home/phy1729/foo bar


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cannot `cd $_` to $_ containing spaces
  2020-10-13 19:30 cannot `cd $_` to $_ containing spaces Soren Roth
  2020-10-13 19:47 ` Matthew Martin
@ 2020-10-14  7:25 ` Roman Perepelitsa
  2020-10-14 20:49   ` Daniel Shahaf
  1 sibling, 1 reply; 4+ messages in thread
From: Roman Perepelitsa @ 2020-10-14  7:25 UTC (permalink / raw)
  To: Soren Roth; +Cc: Zsh hackers list

On Tue, Oct 13, 2020 at 9:31 PM Soren Roth <sorenoid@gmail.com> 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 "$_"

Roman.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cannot `cd $_` to $_ containing spaces
  2020-10-14  7:25 ` Roman Perepelitsa
@ 2020-10-14 20:49   ` Daniel Shahaf
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2020-10-14 20:49 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Soren Roth, Zsh hackers list

Roman Perepelitsa wrote on Wed, 14 Oct 2020 09:25 +0200:
> On Tue, Oct 13, 2020 at 9:31 PM Soren Roth <sorenoid@gmail.com> 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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-14 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 19:30 cannot `cd $_` to $_ containing spaces Soren Roth
2020-10-13 19:47 ` Matthew Martin
2020-10-14  7:25 ` Roman Perepelitsa
2020-10-14 20:49   ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).