Bug 1480307 - behavior change in "cd f*"
Summary: behavior change in "cd f*"
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 26
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-10 16:13 UTC by Karl Burkett
Modified: 2017-08-11 14:40 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-08-11 14:26:21 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karl Burkett 2017-08-10 16:13:05 UTC
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:
Very.


Steps to Reproduce:
1.
2.
3.

Actual results:
See above

Expected results:
See above

Additional info:

Comment 1 Kamil Dudka 2017-08-11 07:36:54 UTC
This seems to be built-time configurable:
https://git.savannah.gnu.org/cgit/bash.git/tree/config-top.h?id=bc007799#n30

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 10:39:20 UTC
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 13:40:18 UTC
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
    #!/bin/sh
    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 14:26:21 UTC
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 14:40:19 UTC
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.