Public bug reported:

Shellcheck detected an instance of
https://github.com/koalaman/shellcheck/wiki/SC2015 in the .bashrc that
ships with Ubuntu.

Here is the existing code:

test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval
"$(dircolors -b)"

It appears to be intended to behave like a ternary statement. The
existing code evaluates `eval "$(dircolors -b)"` if `test -r
~/.dircolors` is true and `eval "$(dircolors -b ~/.dircolors)"` is
false, which at face value doesn't appear to be the intention. According
to Shellcheck, it should instead be:

if [ -r ~/.dircolors ]; then
    eval "$(dircolors -b ~/.dircolors)"
else
    eval "$(dircolors -b)"
fi

This ensures that the else case only executes when test -r ~/.dircolors
is false.

ProblemType: Bug
DistroRelease: Ubuntu 21.10
Package: bash 5.1-3ubuntu2
ProcVersionSignature: Ubuntu 5.13.0-35.40-generic 5.13.19
Uname: Linux 5.13.0-35-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.11-0ubuntu71
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Mon Mar 21 00:28:18 2022
InstallationDate: Installed on 2020-12-09 (467 days ago)
InstallationMedia: Ubuntu 20.10 "Groovy Gorilla" - Release amd64 (20201022)
ProcEnviron:
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: bash
UpgradeStatus: Upgraded to impish on 2021-10-18 (154 days ago)

** Affects: bash (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug impish

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1965728

Title:
  default bashrc contains invalid ternary statement

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1965728/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to