You are not logged in.

#1 2012-03-31 02:59:23

SudoGrep
Member
Registered: 2012-03-31
Posts: 2

cd has troubles with spaces in filenames

I think it was after I last updated or the time before that.. but for whatever reason, cd is ignoring my attempts to escape the spaces in filenames.

ex:
$ cd Server\ Backup/
bash: cd: Server: No such file or directory

It's a little annoying, and as much as I want to I can't just go renaming all of my friends's directories.

Has anyone else experienced this?

Last edited by SudoGrep (2012-03-31 02:59:48)

Offline

#2 2012-03-31 03:10:15

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: cd has troubles with spaces in filenames

Cannot reproduce:

[karol@black foo5]$ file foo\ bar\ baz/
foo bar baz/: directory
[karol@black foo5]$ cd foo\ bar\ baz/
[karol@black foo bar baz]$ 

Are you using tab-completion e.g. 'cd Server<tab>' should complete the directory name.

Offline

#3 2012-03-31 03:24:27

SudoGrep
Member
Registered: 2012-03-31
Posts: 2

Re: cd has troubles with spaces in filenames

I know tab completion, and that's exactly what I'm using to generate that.

$ file Server\ Backup/
Server Backup/: directory

Everything else works, it's just cd that's being ridiculous.

Offline

#4 2012-03-31 17:43:20

ronmon
Member
Registered: 2011-04-15
Posts: 48

Re: cd has troubles with spaces in filenames

Try it like this:

cd ./Server\ Backup/

Although you are much better off not using invalid characters if you can help it.

Offline

#5 2012-04-01 03:24:48

ConnorBehan
Package Maintainer (PM)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,359
Website

Re: cd has troubles with spaces in filenames

It seems no one asked what shell you are using. I am using bash and cannot reproduce your bug. Does installing bash-completion make a difference?


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

#6 2012-04-01 12:28:18

jac
Member
From: /home/jac
Registered: 2009-05-19
Posts: 431
Website

Re: cd has troubles with spaces in filenames

ronmon wrote:

Although you are much better off not using invalid characters if you can help it.

The only invalid characters for filenames in UNIX are forward slashes and nulls. [don't quote me on that, my point is that spaces are valid characters and programs should handle them properly]

ConnorBehan wrote:

It seems no one asked what shell you are using.

The output in the OP seems to imply bash wink


@SudoGrep: you say you're using tab completion to get that line. Does it work by just manually typing a backslash space there?

Last edited by jac (2012-04-01 12:31:44)

Offline

#7 2012-04-01 15:58:13

dodo3773
Member
Registered: 2011-03-17
Posts: 820

Re: cd has troubles with spaces in filenames

Does "chdir" work? May be something in your bashrc / zshrc file that's messing you up.

Offline

#8 2012-04-01 16:22:23

Vain
Member
Registered: 2008-10-19
Posts: 183

Re: cd has troubles with spaces in filenames

dodo3773 wrote:

May be something in your bashrc / zshrc file that's messing you up.

I agree. Have a look at the output of

type cd

to see what’s going on.

Offline

#9 2012-04-01 22:08:50

ConnorBehan
Package Maintainer (PM)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,359
Website

Re: cd has troubles with spaces in filenames

jac wrote:

The only invalid characters for filenames in UNIX are forward slashes and nulls. [don't quote me on that, my point is that spaces are valid characters and programs should handle them properly]

I will quote you anyway! Some filesystems allow the forward slash. But you're right... I don't know any where space isn't allowed.


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

Board footer

Powered by FluxBB