Bug 1480307 - behavior change in "cd f*"
behavior change in "cd f*"
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
x86_64 Linux
unspecified Severity low
: ---
: ---
Assigned To: Siteshwar Vashisht
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2017-08-10 12:13 EDT by Karl Burkett
Modified: 2017-08-11 10:40 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2017-08-11 10:26:21 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Karl Burkett 2017-08-10 12:13:05 EDT
Description of problem:
cd wildcard behavior change from fedora 25.  Now, multiple dirs (f12, f13, f14) when the first is desired this "cd f*" returns "bash: cd: too many arguments"
Previous behavior took you into f12 directory.

Version-Release number of selected component (if applicable):
Bash version: bash.x86_64 4.4.12-6.fc26

How reproducible:

Steps to Reproduce:

Actual results:
See above

Expected results:
See above

Additional info:
Comment 1 Kamil Dudka 2017-08-11 03:36:54 EDT
This seems to be built-time configurable:

Note that no wildcard is needed to get the fatal error.  It triggers whenever 'cd' gets more than one arguments.
Comment 2 Siteshwar Vashisht 2017-08-11 06:39:20 EDT
It makes sense to show error message if multiple arguments are passed to 'cd'. Why do you think it's a bug ?
Comment 3 Karl Burkett 2017-08-11 09:40:18 EDT
It is a bug because this is a fundamental change in behavior with respect to wilecards. 

I, and I suspect others as well, use the wildcard as a shorthand method of specifying the first directory in a list of similar names.  For interactive use, going to the wrong directory is quickly obvious and for scripts, I doubt wildcard usage is common.

Now, in terms of implementation on the system, Fedora 26 has introduced several difficulties with a simple, core command:

  There is no longer a standalone cd command on the system:
  (/bin/cd and /usr/bin/cd contain the same code)
    $> cat /usr/bin/cd
    builtin cd "$@"

    Problems as I see them:
      /bin/sh is not the correct shell in general terms it's a symlink after all, 
        /bin/bash is specific and has the builtin.
      $@ is already expanded by the calling shell, so the new instance of bash 
        does not realize that this is a wildcard request.

Your thoughts?
Comment 4 Siteshwar Vashisht 2017-08-11 10:26:21 EDT
It is not a behavior change with wildcards. It is a change in terms of how 'cd' builtin handles it's arguments. It is non-intuitive to pass multiple arguments to cd builtin and expect it to ignore all arguments except first one. I fail to see how the example about '/usr/bin/cd' relates to this behavior. This behavior change was introduced with this commit[1]. The script under /usr/bin/cd is provided for POSIX compliance (See bug 820192) and was present before Fedora 26. 

[1] http://git.savannah.gnu.org/cgit/bash.git/diff/config-top.h?id=3475994a81ce49cf3a50b6ceeb5ad719986aa5f4
Comment 5 Karl Burkett 2017-08-11 10:40:19 EDT
We will just have to agree to disagree on this issue.  Strict enforcement does not necessarily make it right or acceptable to everyone.

Note You need to log in before you can comment on or make changes to this bug.