default bashrc contains invalid ternary statement
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Shellcheck detected an instance of https:/
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
ProcVersionSign
Uname: Linux 5.13.0-35-generic x86_64
NonfreeKernelMo
ApportVersion: 2.20.11-0ubuntu71
Architecture: amd64
CasperMD5CheckR
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_
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: bash
UpgradeStatus: Upgraded to impish on 2021-10-18 (154 days ago)