Page 1 of 1

cd with wild card causes error too many arguments

Posted: 2020/12/05 22:08:22
by fps079
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?

Re: cd with wild card causes error too many arguments

Posted: 2020/12/06 00:59:40
by TrevorH
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.

Re: cd with wild card causes error too many arguments

Posted: 2020/12/06 13:55:18
by fps079
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]#

Re: cd with wild card causes error too many arguments

Posted: 2020/12/07 13:38:56
by tunk
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.

Re: cd with wild card causes error too many arguments

Posted: 2020/12/12 18:36:09
by fps079
Well, now I don't have to worry about it.

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

Re: cd with wild card causes error too many arguments

Posted: 2020/12/12 18:38:08
by fps079
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.....

Re: cd with wild card causes error too many arguments

Posted: 2021/01/11 16:19:24
by sml
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.