cd with wild card causes error too many arguments

Comments, suggestions, compliments, etc
Post Reply
fps079
Posts: 4
Joined: 2020/12/05 22:00:52

cd with wild card causes error too many arguments

Post by fps079 » 2020/12/05 22:08:22

using cd to directory ApacheDirectoryStudio like so:

#cd Apache*

causes an error:

bash: cd: too many arguments

Someone please tell me this is a bug and being fixed in the next issue of bash. Doesn't anyone use regular expressions any longer?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: cd with wild card causes error too many arguments

Post by TrevorH » 2020/12/06 00:59:40

It's not a bug, it's a user error. You have multiple things that match the pattern you gave to cd and cd expects one and only one argument.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

fps079
Posts: 4
Joined: 2020/12/05 22:00:52

Re: cd with wild card causes error too many arguments

Post by fps079 » 2020/12/06 13:55:18

Ummm...no, it is a bug, or at least unexpected behavior based on a few years of experience with UNIX shells. I have one directory in my current directory, using a wild card as I am should return an unambiguous path for cd command.

I have been using cd like this for years, still am on other versions of LINUX. This is new, and unwelcomed, behavior from a bash shell. I believe it is a bug.

[root@jupiter apache]# ls -l
total 147892
drwxr-xr-x 6 root root 196 Apr 11 2020 ApacheDirectoryStudio
-rw-r--r-- 1 root root 151438336 Dec 5 13:50 ApacheDirectoryStudio-2.0.0.v20200411-M15-linux.gtk.x86_64.tar
[root@jupiter apache]# cd Apach*
bash: cd: too many arguments
[root@jupiter apache]#

tunk
Posts: 1205
Joined: 2017/02/22 15:08:17

Re: cd with wild card causes error too many arguments

Post by tunk » 2020/12/07 13:38:56

It (sort of) works in C7: it takes the first file/directory alfabetically
sorted and if that's a directory, it works. Not so in C8.

fps079
Posts: 4
Joined: 2020/12/05 22:00:52

Re: cd with wild card causes error too many arguments

Post by fps079 » 2020/12/12 18:36:09

Well, now I don't have to worry about it.

Moving on to Oracle Linux, where that command works.....

fps079
Posts: 4
Joined: 2020/12/05 22:00:52

Re: cd with wild card causes error too many arguments

Post by fps079 » 2020/12/12 18:38:08

TrevorH wrote:
2020/12/06 00:59:40
It's not a bug, it's a user error. You have multiple things that match the pattern you gave to cd and cd expects one and only one argument.
So try Oracle Linux since CentOS is now a memory...where this command works, and you can write me about what a bug the command is and I can write you about my 35 years of UNIX.....

sml
Posts: 305
Joined: 2020/01/17 09:01:44

Re: cd with wild card causes error too many arguments

Post by sml » 2021/01/11 16:19:24

From the Bash 4.4rc1 changelog:
There is a new option settable in config-top.h that makes multiple directory arguments to `cd' a fatal error.
If you want the old behavior then recompile Bash with this #define unset.

Post Reply