helpThe GNU Bourne-Again SHell - Support: sr #110671, cd does not ignore additional...

 
 

sr #110671: cd does not ignore additional arguments

Submitter:  None
Submitted:  Mon 06 Jun 2022 07:15:02 AM UTC
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Tue 07 Jun 2022 02:47:24 PM UTC, comment #2: 

This was fixed almost exactly a year ago.

Chet Ramey <chet>
Project Administrator
Tue 07 Jun 2022 02:10:54 AM UTC, comment #1: 

The Bash developers should delete the sentence "Any additional arguments following dir are ignored." from the description of the "cd" builtin command in the manual, because that wouldn't help if the invoker of the "cd" command would like to for example change to the last of the given additional directories rather than the first.

Both use cases -- change to the first as well as to the last (or any other directory out of the directory list) -- could be achieved by using an array variable:

   declare -a dirs && dirs=( some_globbing/*/patterns/ ) &&

To change to the first one of the directories found, one could do

   cd -- "${dirs[0]}"

To change to the last one of the directories found, one could do

   cd -- "${dirs["$(( ${#dirs[@]} - 1 ))"}"

Anonymous
Mon 06 Jun 2022 07:15:02 AM UTC, original submission:  

the man page states:

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. ...

Actually the cd fails with "Too many arguments" if there are arguments following dir.

This is a common issue when using globstar expansion in an interactive shell.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-06-07 chet StatusNone Done

    Back to the top


    Powered by Savane 3.9