Posting it here something that is puzzling me; upgrading an application server from Jessie to Stretch broke a bash script.

Upon investigation, we narrowed it to a change of behaviour of the cd command. I am not discussing here if what the script is doing is a good idea, or if it could be improved, I am just focusing in a behaviour change /awareness of changes mindset.


$echo *-*
xxxx-1.0b xxxx-run
$cd *-*

cd works and cds to the first directory ; actually *-run is a symbolic link to the same directory.


$echo *-*
xxxx-1.0b xxxx-run
$cd *-*
bash: cd: too many arguments

bash is 4.3.30(1) in Jessie, and 4.4.12(1) in Stretch.

Why the change in behaviour between Jessie and Stretch?


See the Relase Notes of bash 4.4, especially

qq. There is a new option settable in config-top.h that makes multiple directory arguments to cd a fatal error.

BTW, I didn't know. I just googled for "bash cd number 4.4".

  • 8
    Interesting. A Good Thing imho as it avoids silently discarding additional arguments when one has an escaping bug. – spectras Jun 27 '17 at 13:02
  • @spectras Interesting comment, while I suspected it could have implications security-wise, was not looking from that angle. – Rui F Ribeiro Jun 27 '17 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.