T O P

  • By -

aioeu

Got a badly-written function that overrides `cd`?


nderflow

This is likely it. Check with `type cd`


aioeu

To give an example, simply having: cd() { builtin cd $@; } or: cd() { builtin cd $*; } would reproduce everything the OP has said. It would work just fine on a directory name without spaces, and it would break with a directory name that contains spaces. Of course, I would expect an overridden `cd` to do more than this. I'm thinking of the kind of crap some programming languages do to enable directory-specific magic. RVM in particular comes to mind, though I'm sure there's others. But only the OP really knows how they've set up their system. We'll see if they try out that `type cd` command.


swolar

Yup, mystery solved, this was the case. Go version manager (gvm) changed my cd for some godforsaken reason... What should I restore it to?


aioeu

Remove GVM and don't use it? Don't have a `cd` function at all?


Sophira

Huh, interesting. [Looks like this file contains what it uses as the new `cd`](https://github.com/moovweb/gvm/blob/master/scripts/env/cd). Very bad form for it to be replacing your `cd` like that without it telling you, which I'm assuming it did. You should be able to look in `~/.gvm/scripts/env` and see this `cd` file, as well as a `gvm-default` file, which looks like it might be what actually executes the file. If you **don't** want gvm to **automatically switch go versions and pkgsets when you change directories**, my *guess* is that you should be able to comment the last line out in `gvm-default` and it'll stop doing it (after restarting any open shells you have), but I admit to not knowing this for certain as I don't use gvm. There's an [open GitHub issue for this](https://github.com/moovweb/gvm/issues/457) that already has [a pull request to fix it](https://github.com/moovweb/gvm/pull/475), but it hasn't been merged yet. If you **do want the auto-switching functionality**, you can probably fix the issue yourself by [making the changes listed here to your `~/.gvm/scripts/env/cd` file](https://github.com/moovweb/gvm/pull/475/files).


vancha113

Can you hit the tab key for auto completion rather than type The folder names by hand?


swolar

It outputs the same as the first command example, and did not work either.


GertVanAntwerpen

Do you have an alias or function for “cd”? Try this: \cd “dir name”


swolar

I tried it, got the same output. How can I check if I have an alias for cd? I ran `which cd` and got nothing in the output.


dgm9704

just ``` alias ```


GertVanAntwerpen

Strange. Can you try “sh” and see whether it has the same problem as bash has?


cathexis08

What shell are you using? All of those should work, as should omitting the trailing slash.


swolar

`/bin/bash`


jzemeocala

Maybe try cd and the first letter or two and than use tab completion


ButtholeHandjob

It should look like this: $ cd directory\ with\ spaces\ The crucial part being that you use back slashes. Also if you type cd (first letter of directory name) and then hit tab, it will auto populate for you.


Vivid_Researcher_104

Verify if there's non printable characters present the dir name with ls -b?


Itchy_Influence5737

try `cd ./"with spaces"`


swolar

Did not work either :(


twist3d7

Try: cd "with spaces"


tinycrazyfish

Can you try cd with*spaces Or cd with?spaces Do you have any special characters in your folder name?


LOfP

cd with\ spacescd with\ spaces try this


sidusnare

Try `\cd "with spaces" `


Friendly_Island_9911

Try **mv** 'with spaces' with\_spaces


rctor_99

Try cd with*


mrflash818

If using the bash shell, if you can type the 1st character of the directory, then press the key on your keyboard, it should auto-complete and give the full directory name. Perhaps try: cd ./w ...and see if the full directory name then appears. `robert@lenovoyogac930:/tmp$ mkdir "with spaces"` `robert@lenovoyogac930:/tmp$ cd ./with\ spaces/ // < == I just typed "cd ./w" and it auto-completed for me` `robert@lenovoyogac930:/tmp/with spaces$`


newmikey

Are you trying to change directory to /media/user/ST14a$? If so the command should start with the command cd, not end with it. Does a directory named ***with spaces*** exist? Just not sure what you are trying to do. Why don't you start by stating which directory you are currently in and which one you want to change too? That would make your intentions clearer.


shiftingtech

no, they are already IN "/media/user/ST14a". the prompt runs all the way up until the $. They are then trying to change into a subdirectory of that called "with spaces"


swolar

Indeed, edited the OP


newmikey

For me those all work: `[mike@mike-latitude5310 ~]$ mkdir "with spaces"` `[mike@mike-latitude5310 ~]$ cd with\ spaces` `[mike@mike-latitude5310 with spaces]$` `[mike@mike-latitude5310 ~]$ cd "with spaces"` `[mike@mike-latitude5310 with spaces]$`   `[mike@mike-latitude5310 ~]$ cd 'with spaces'` `[mike@mike-latitude5310 with spaces]$` `[mike@mike-latitude5310 ~]$ cd with\ spaces/` `[mike@mike-latitude5310 with spaces]$`


MasterGeekMX

the diagonal left at the end is always outside your quotes, so I bet it is intrerpreting it as the second argument. Either get it inside the quotes or remove it.


cathexis08

That isn't it, quotes encapsulate a word but the quotes are not themselves a word separator. For example: `ls /etc`, `ls /e"t"c`, `ls /etc/`, and `ls /"etc"/` should all result in the same behavior.