Skip to content

test/system: Test fixes due to changed behavior in new bash version#1699

Merged
debarshiray merged 2 commits intocontainers:mainfrom
DaliborKr:new_bash_test_fix
Aug 8, 2025
Merged

test/system: Test fixes due to changed behavior in new bash version#1699
debarshiray merged 2 commits intocontainers:mainfrom
DaliborKr:new_bash_test_fix

Conversation

@DaliborKr
Copy link
Copy Markdown
Collaborator

In the new version of bash, the error output has been changed, and this caused a test failure in Toolbx CI on Fedora Rawhide.

  • GNU bash, version 5.2.37 (bash-5.2.37-1.fc42.x86_64)
$ bash -c 'exec "$@"' bash /etc
bash: line 1: /etc: Is a directory
bash: line 1: exec: /etc: cannot execute: Is a directory
  • GNU bash, version 5.3.0 (bash-5.3.0-2.fc43.x86_64)
$ bash -c 'exec "$@"' bash /etc
bash: line 1: /etc: Is a directory

#1688 (review)

@DaliborKr DaliborKr requested a review from debarshiray as a code owner August 7, 2025 09:20
@softwarefactory-project-zuul
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the tests, @DaliborKr ! It looks good to me.

You made me curious and I went digging into the Bash sources to understand the exact change more.

I was able to reproduce the problem with just:

$ exec /etc
...

I was able to narrow it down to Bash commit b8c60bc9ca365f82. See how exec_builtin() handles EX_NOEXEC and EISDIR from shell_execve() to avoid printing a duplicate error message.

Bash is a weird project. It creates one massive commit for each release, so it's either very difficult or impossible to understand the changes. :)

debarshiray pushed a commit to DaliborKr/toolbox that referenced this pull request Aug 7, 2025
Bash 5.3.0 changed the error messages shown by its exec built-in [1].

With Bash 5.2.37:
  $ exec /etc
  bash: /etc: Is a directory
  bash: exec: /etc: cannot execute: Is a directory

With Bash 5.3.0:
  $ exec /etc
  bash: /etc: Is a directory

The 'assert' function cannot directly handle compound commands.  So,
those need to be wrapped in 'bash -c "..."' [2].

[1] Bash commit b8c60bc9ca365f82
    See how exec_builtin() handles EX_NOEXEC and EISDIR from
    shell_execve() to avoid printing a duplicate error message.
    https://cgit.git.savannah.gnu.org/cgit/bash.git/commit/?id=b8c60bc9ca365f82

[2] https://github.com/bats-core/bats-assert

containers#1688
containers#1699
@debarshiray
Copy link
Copy Markdown
Member

You made me curious and I went digging into the Bash sources to understand the exact change more.

I updated the commit message to add a reference to the Bash change.

debarshiray and others added 2 commits August 8, 2025 01:05
Detected by https://www.shellcheck.net/:
  Line 1255:
  if ! localtime_target=$(readlink /etc/localtime >/dev/null 2>&3) \
                        ^-- SC2327 (warning): This command substitution
                            will be empty because the command's output
                            gets redirected away.
                                                  ^-- SC2328 (error):
                                                      This redirection
                                                      takes output away
                                                      from the command
                                                      substitution.

See:
https://www.shellcheck.net/wiki/SC2327
https://www.shellcheck.net/wiki/SC2328

Fallout from 8db414d

containers#1701
Bash 5.3.0 changed the error messages shown by its exec built-in [1].

With Bash 5.2.37:
  $ exec /etc
  bash: /etc: Is a directory
  bash: exec: /etc: cannot execute: Is a directory

With Bash 5.3.0:
  $ exec /etc
  bash: /etc: Is a directory

The 'assert' function cannot directly handle compound commands.  So,
those need to be wrapped in 'bash -c "..."' [2].

[1] Bash commit b8c60bc9ca365f82
    See how exec_builtin() handles EX_NOEXEC and EISDIR from
    shell_execve() to avoid printing a duplicate error message.
    https://cgit.git.savannah.gnu.org/cgit/bash.git/commit/?id=b8c60bc9ca365f82

[2] https://github.com/bats-core/bats-assert

containers#1688
containers#1699
@softwarefactory-project-zuul
Copy link
Copy Markdown

@debarshiray
Copy link
Copy Markdown
Member

recheck

@debarshiray
Copy link
Copy Markdown
Member

Damn! The CI timed out. I'll merge once it passes.

@softwarefactory-project-zuul
Copy link
Copy Markdown

@debarshiray debarshiray merged commit 6c98db6 into containers:main Aug 8, 2025
3 checks passed
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jan 26, 2026
Bash 5.3.0 changed the error messages shown by its exec built-in [1].

With Bash 5.2.37:
  $ exec /etc
  bash: /etc: Is a directory
  bash: exec: /etc: cannot execute: Is a directory

With Bash 5.3.0:
  $ exec /etc
  bash: /etc: Is a directory

The 'assert' function cannot directly handle compound commands.  So,
those need to be wrapped in 'bash -c "..."' [2].

[1] Bash commit b8c60bc9ca365f82
    See how exec_builtin() handles EX_NOEXEC and EISDIR from
    shell_execve() to avoid printing a duplicate error message.
    https://cgit.git.savannah.gnu.org/cgit/bash.git/commit/?id=b8c60bc9ca365f82

[2] https://github.com/bats-core/bats-assert

containers#1688
containers#1699
containers#1739
(backported from commit 6c98db6)
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jan 27, 2026
Bash 5.3.0 changed the error messages shown by its exec built-in [1].

With Bash 5.2.37:
  $ exec /etc
  bash: /etc: Is a directory
  bash: exec: /etc: cannot execute: Is a directory

With Bash 5.3.0:
  $ exec /etc
  bash: /etc: Is a directory

The 'assert' function cannot directly handle compound commands.  So,
those need to be wrapped in 'bash -c "..."' [2].

[1] Bash commit b8c60bc9ca365f82
    See how exec_builtin() handles EX_NOEXEC and EISDIR from
    shell_execve() to avoid printing a duplicate error message.
    https://cgit.git.savannah.gnu.org/cgit/bash.git/commit/?id=b8c60bc9ca365f82

[2] https://github.com/bats-core/bats-assert

containers#1688
containers#1699
containers#1739
containers#1743
(backported from commit 6c98db6)
(cherry picked from commit 0090893)
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request Jan 27, 2026
Bash 5.3.0 changed the error messages shown by its exec built-in [1].

With Bash 5.2.37:
  $ exec /etc
  bash: /etc: Is a directory
  bash: exec: /etc: cannot execute: Is a directory

With Bash 5.3.0:
  $ exec /etc
  bash: /etc: Is a directory

The 'assert' function cannot directly handle compound commands.  So,
those need to be wrapped in 'bash -c "..."' [2].

[1] Bash commit b8c60bc9ca365f82
    See how exec_builtin() handles EX_NOEXEC and EISDIR from
    shell_execve() to avoid printing a duplicate error message.
    https://cgit.git.savannah.gnu.org/cgit/bash.git/commit/?id=b8c60bc9ca365f82

[2] https://github.com/bats-core/bats-assert

containers#1688
containers#1699
containers#1739
containers#1744
(backported from commit 6c98db6)
(cherry picked from commit 0090893)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants