cd don't take wildcards no more?

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
erw1
Level 3
Level 3
Posts: 145
Joined: Sun Apr 08, 2018 12:58 am

cd don't take wildcards no more?

Post by erw1 »

I just upgraded from 18.3 to 19.1. Now I get this unprecedented behavior:

Code: Select all

~/Downloads $ ls
install-tl-20190222  install-tl-unx.tar.gz
$ cd ins*
bash: cd: too many arguments
But this works:

Code: Select all

$ cd install-tl-2019*
There should be no ambiguity using the first version as `install-tl-unx.tar.gz` not a directory. Any suggestion?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
x64/LM 23+Xfce
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

Re: cd don't take wildcards no more?

Post by rene »

Worse still, "cd" has never taken wildcards since inception of UNIX -- which isn't to say you are not in fact reporting a bug.

First, as to former, the way wildcard expansion works on UNIX is that the shell does the expanding; the "cd" command itself sees only the already expanded command line, i.e., "install-tl-20190222 install-tl-unx.tar.gz" in your case, the first argument of which is a bona fide cd-able directory. Clearly "cd" can functionally take a single argument only, and as such the 19.1 error message makes sense. You are however right that it doesn't complain on 18.3 and if we check its man page (the bash man page, since "cd" is a shell built-in), we are presented the following statement:

Code: Select all

cd [-L|[-P [-e]] [-@]] [dir]
    Change the current directory to dir.  if dir is not supplied, the value of the HOME shell variable is the default.
    Any additional arguments following dir are ignored.
Mint 18.3's bash 4.3 followed its own documentation, Mint 19.1's bash 4.4 contradicts it. If we check POSIX we are not presented an explicit statement but are arguably provided the fact that the Mint 19.1 behaviour is conforming, the 18.3 one not, simply from the synopsis:

https://pubs.opengroup.org/onlinepubs/9 ... es/cd.html

Code: Select all

SYNOPSIS

    cd [-L|-P] [directory]

    cd -
That is: that synopsis is not saying "[directory...]" as would be the case if it in fact allowed for more than one argument.

In any case you are looking at a (bash) documentation bug at best, and more people have noticed: https://bugs.launchpad.net/ubuntu/+sour ... ug/1683576. Turns out, then, this is new optional behaviour, and Ubuntu enabling it means they'd have to document it as well if they were to be for some unfathomable reason set on keeping the new behaviour.

The in that report mentioned Ask Ubuntu link, https://askubuntu.com/questions/992192/ ... d-behavior, provides instructions for either recompiling bash or overriding "cd" to behave according to the documentation again. If you in fact deeply care about the issue, you'd go comment on that launchpad bug, because, yes, although I wouldn't have expected so before beginning this reply, indeed it's a bug of sorts...
Locked

Return to “Scripts & Bash”