neofetch: remove uneeded quotes

This commit is contained in:
Dylan Araps 2019-10-28 09:13:17 +02:00
parent b81b69009e
commit c154aebc40
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 119 additions and 117 deletions

232
neofetch
View File

@ -851,75 +851,74 @@ get_os() {
} }
get_distro() { get_distro() {
[[ "$distro" ]] && return [[ $distro ]] && return
case "$os" in case $os in
"Linux" | "BSD" | "MINIX") Linux|BSD|MINIX)
if [[ -f "/bedrock/etc/bedrock-release" && "$PATH" == */bedrock/cross/* ]]; then if [[ -f /bedrock/etc/bedrock-release && $PATH == */bedrock/cross/* ]]; then
case "$distro_shorthand" in case $distro_shorthand in
"on" | "tiny") distro="Bedrock Linux" ;; on|tiny) distro="Bedrock Linux" ;;
*) distro="$(< /bedrock/etc/bedrock-release)" *) distro=$(< /bedrock/etc/bedrock-release)
esac esac
elif [[ -f "/etc/redstar-release" ]]; then
case "$distro_shorthand" in elif [[ -f /etc/redstar-release ]]; then
"on" | "tiny") distro="Red Star OS" ;; case $distro_shorthand in
on|tiny) distro="Red Star OS" ;;
*) distro="Red Star OS $(awk -F'[^0-9*]' '$0=$2' /etc/redstar-release)" *) distro="Red Star OS $(awk -F'[^0-9*]' '$0=$2' /etc/redstar-release)"
esac esac
elif [[ -f "/etc/siduction-version" ]]; then elif [[ -f /etc/siduction-version ]]; then
case "$distro_shorthand" in case $distro_shorthand in
"on" | "tiny") distro="Siduction" ;; on|tiny) distro=Siduction ;;
*) distro="Siduction ($(lsb_release -sic))" *) distro="Siduction ($(lsb_release -sic))"
esac esac
elif type -p pveversion >/dev/null; then elif type -p pveversion >/dev/null; then
case "$distro_shorthand" in case $distro_shorthand in
"on" | "tiny") distro="Proxmox VE" ;; on|tiny) distro="Proxmox VE" ;;
*) *)
distro="$(pveversion)" distro=$(pveversion)
distro="${distro#pve-manager/}" distro=${distro#pve-manager/}
distro="Proxmox VE ${distro%/*}" distro="Proxmox VE ${distro%/*}"
esac esac
elif type -p lsb_release >/dev/null; then elif type -p lsb_release >/dev/null; then
case "$distro_shorthand" in case $distro_shorthand in
"on") lsb_flags="-sir" ;; on) lsb_flags=-si ;;
"tiny") lsb_flags="-si" ;; tiny) lsb_flags=-si ;;
*) lsb_flags="-sd" ;; *) lsb_flags=-sd ;;
esac esac
distro="$(lsb_release "$lsb_flags")" distro=$(lsb_release "$lsb_flags")
elif [[ -f "/etc/os-release" || \ elif [[ -f /etc/os-release || \
-f "/usr/lib/os-release" || \ -f /usr/lib/os-release || \
-f "/etc/openwrt_release" || \ -f /etc/openwrt_release || \
-f "/etc/lsb-release" ]]; then -f /etc/lsb-release ]]; then
files=("/etc/os-release"
"/usr/lib/os-release"
"/etc/openwrt_release"
"/etc/lsb-release")
# Source the os-release file # Source the os-release file
for file in "${files[@]}"; do for file in /usr/lib/os-release /etc/os-release \
/etc/openwrt_release /etc/lsb-release; do
source "$file" && break source "$file" && break
done done
# Format the distro name. # Format the distro name.
case "$distro_shorthand" in case $distro_shorthand in
"on") distro="${NAME:-${DISTRIB_ID}} ${VERSION_ID:-${DISTRIB_RELEASE}}" ;; on) distro="${NAME:-${DISTRIB_ID}} ${VERSION_ID:-${DISTRIB_RELEASE}}" ;;
"tiny") distro="${NAME:-${DISTRIB_ID:-${TAILS_PRODUCT_NAME}}}" ;; tiny) distro="${NAME:-${DISTRIB_ID:-${TAILS_PRODUCT_NAME}}}" ;;
"off") distro="${PRETTY_NAME:-${DISTRIB_DESCRIPTION}} ${UBUNTU_CODENAME}" ;; off) distro="${PRETTY_NAME:-${DISTRIB_DESCRIPTION}} ${UBUNTU_CODENAME}" ;;
esac esac
elif [[ -f "/etc/GoboLinuxVersion" ]]; then elif [[ -f /etc/GoboLinuxVersion ]]; then
case "$distro_shorthand" in case $distro_shorthand in
"on" | "tiny") distro="GoboLinux" ;; on|tiny) distro=GoboLinux ;;
*) distro="GoboLinux $(< /etc/GoboLinuxVersion)" *) distro="GoboLinux $(< /etc/GoboLinuxVersion)"
esac esac
elif type -p crux >/dev/null; then elif type -p crux >/dev/null; then
distro="$(crux)" distro=$(crux)
case "$distro_shorthand" in case $distro_shorthand in
"on") distro="${distro//version}" ;; on) distro=${distro//version} ;;
"tiny") distro="${distro//version*}" ;; tiny) distro=${distro//version*}
esac esac
elif type -p tazpkg >/dev/null; then elif type -p tazpkg >/dev/null; then
@ -927,90 +926,91 @@ get_distro() {
elif type -p kpt >/dev/null && \ elif type -p kpt >/dev/null && \
type -p kpm >/dev/null; then type -p kpm >/dev/null; then
distro="KSLinux" distro=KSLinux
elif [[ -d "/system/app/" && -d "/system/priv-app" ]]; then elif [[ -d /system/app/ && -d /system/priv-app ]]; then
distro="Android $(getprop ro.build.version.release)" distro="Android $(getprop ro.build.version.release)"
# Chrome OS doesn't conform to the /etc/*-release standard. # Chrome OS doesn't conform to the /etc/*-release standard.
# While the file is a series of variables they can't be sourced # While the file is a series of variables they can't be sourced
# by the shell since the values aren't quoted. # by the shell since the values aren't quoted.
elif [[ -f "/etc/lsb-release" && "$(< /etc/lsb-release)" == *CHROMEOS* ]]; then elif [[ -f /etc/lsb-release && $(< /etc/lsb-release) == *CHROMEOS* ]]; then
distro="$(awk -F '=' '/NAME|VERSION/ {printf $2 " "}' /etc/lsb-release)" distro=$(awk -F '=' '/NAME|VERSION/ {printf $2 " "}' /etc/lsb-release)
elif type -p guix >/dev/null; then elif type -p guix >/dev/null; then
case "$distro_shorthand" in case $distro_shorthand in
"on" | "tiny") distro="Guix System" ;; on|tiny) distro="Guix System" ;;
*) distro="Guix System $(guix system -V | awk 'NR==1{printf $5}')" *) distro="Guix System $(guix system -V | awk 'NR==1{printf $5}')"
esac esac
else else
for release_file in /etc/*-release; do for release_file in /etc/*-release; do
distro+="$(< "$release_file")" distro+=$(< "$release_file")
done done
if [[ -z "$distro" ]]; then if [[ -z $distro ]]; then
case "$distro_shorthand" in case $distro_shorthand in
"on" | "tiny") distro="$kernel_name" ;; on|tiny) distro=$kernel_name ;;
*) distro="$kernel_name $kernel_version" ;; *) distro="$kernel_name $kernel_version" ;;
esac esac
distro="${distro/DragonFly/DragonFlyBSD}"
# Workarounds for FreeBSD based distros. distro=${distro/DragonFly/DragonFlyBSD}
[[ -f "/etc/pcbsd-lang" ]] && distro="PCBSD"
[[ -f "/etc/trueos-lang" ]] && distro="TrueOS"
# /etc/pacbsd-release is an empty file # Workarounds for some BSD based distros.
[[ -f "/etc/pacbsd-release" ]] && distro="PacBSD" [[ -f /etc/pcbsd-lang ]] && distro=PCBSD
[[ -f /etc/trueos-lang ]] && distro=TrueOS
[[ -f /etc/pacbsd-release ]] && distro=PacBSD
fi fi
fi fi
if [[ "$(< /proc/version)" == *Microsoft* || "$kernel_version" == *Microsoft* ]]; then if [[ $(< /proc/version) == *Microsoft* || $kernel_version == *Microsoft* ]]; then
case "$distro_shorthand" in case $distro_shorthand in
"on") distro+=" [Windows 10]" ;; on) distro+=" [Windows 10]" ;;
"tiny") distro="Windows 10" ;; tiny) distro="Windows 10" ;;
*) distro+=" on Windows 10" ;; *) distro+=" on Windows 10" ;;
esac esac
elif [[ "$(< /proc/version)" == *chrome-bot* || -f "/dev/cros_ec" ]]; then elif [[ $(< /proc/version) == *chrome-bot* || -f /dev/cros_ec ]]; then
case "$distro_shorthand" in case $distro_shorthand in
"on") distro+=" [Chrome OS]" ;; on) distro+=" [Chrome OS]" ;;
"tiny") distro="Chrome OS" ;; tiny) distro="Chrome OS" ;;
*) distro+=" on Chrome OS" ;; *) distro+=" on Chrome OS" ;;
esac esac
fi fi
distro="$(trim_quotes "$distro")" distro=$(trim_quotes "$distro")
distro="${distro/NAME=}" distro=${distro/NAME=}
;; ;;
"Mac OS X") "Mac OS X")
case "$osx_version" in case $osx_version in
"10.4"*) codename="Mac OS X Tiger" ;; 10.4*) codename="Mac OS X Tiger" ;;
"10.5"*) codename="Mac OS X Leopard" ;; 10.5*) codename="Mac OS X Leopard" ;;
"10.6"*) codename="Mac OS X Snow Leopard" ;; 10.6*) codename="Mac OS X Snow Leopard" ;;
"10.7"*) codename="Mac OS X Lion" ;; 10.7*) codename="Mac OS X Lion" ;;
"10.8"*) codename="OS X Mountain Lion" ;; 10.8*) codename="OS X Mountain Lion" ;;
"10.9"*) codename="OS X Mavericks" ;; 10.9*) codename="OS X Mavericks" ;;
"10.10"*) codename="OS X Yosemite" ;; 10.10*) codename="OS X Yosemite" ;;
"10.11"*) codename="OS X El Capitan" ;; 10.11*) codename="OS X El Capitan" ;;
"10.12"*) codename="macOS Sierra" ;; 10.12*) codename="macOS Sierra" ;;
"10.13"*) codename="macOS High Sierra" ;; 10.13*) codename="macOS High Sierra" ;;
"10.14"*) codename="macOS Mojave" ;; 10.14*) codename="macOS Mojave" ;;
"10.15"*) codename="macOS Catalina" ;; 10.15*) codename="macOS Catalina" ;;
*) codename="macOS" ;; *) codename=macOS ;;
esac esac
distro="$codename $osx_version $osx_build" distro="$codename $osx_version $osx_build"
case "$distro_shorthand" in case $distro_shorthand in
"on") distro="${distro/ ${osx_build}}" ;; on) distro=${distro/ ${osx_build}} ;;
"tiny")
case "$osx_version" in tiny)
"10."[4-7]*) distro="${distro/${codename}/Mac OS X}" ;; case $osx_version in
"10."[8-9]* | "10.1"[0-1]*) distro="${distro/${codename}/OS X}" ;; 10.[4-7]*) distro=${distro/${codename}/Mac OS X} ;;
"10.1"[2-4]*) distro="${distro/${codename}/macOS}" ;; 10.[8-9]*|10.1[0-1]*) distro=${distro/${codename}/OS X} ;;
10.1[2-4]*) distro=${distro/${codename}/macOS} ;;
esac esac
distro="${distro/ ${osx_build}}" distro=${distro/ ${osx_build}}
;; ;;
esac esac
;; ;;
@ -1018,57 +1018,59 @@ get_distro() {
"iPhone OS") "iPhone OS")
distro="iOS $osx_version" distro="iOS $osx_version"
# "uname -m" doesn't print architecture on iOS so we force it off. # "uname -m" doesn't print architecture on iOS.
os_arch="off" os_arch=off
;; ;;
"Windows") Windows)
distro="$(wmic os get Caption)" distro=$(wmic os get Caption)
distro="${distro/Caption}" distro=${distro/Caption}
distro="${distro/Microsoft }" distro=${distro/Microsoft }
;; ;;
"Solaris") Solaris)
case "$distro_shorthand" in case $distro_shorthand in
"on" | "tiny") distro="$(awk 'NR==1 {print $1,$3}' /etc/release)" ;; on|tiny) distro=$(awk 'NR==1 {print $1,$3}' /etc/release) ;;
*) distro="$(awk 'NR==1 {print $1,$2,$3}' /etc/release)" ;; *) distro=$(awk 'NR==1 {print $1,$2,$3}' /etc/release) ;;
esac esac
distro="${distro/\(*}" distro=${distro/\(*}
;; ;;
"Haiku") Haiku)
distro=Haiku distro=Haiku
;; ;;
"AIX") AIX)
distro="AIX $(oslevel)" distro="AIX $(oslevel)"
;; ;;
"IRIX") IRIX)
distro="IRIX ${kernel_version}" distro="IRIX ${kernel_version}"
;; ;;
"FreeMiNT") FreeMiNT)
distro="FreeMiNT" distro=FreeMiNT
;; ;;
esac esac
distro="${distro//Enterprise Server}" distro=${distro//Enterprise Server}
[[ -z "$distro" ]] && distro="$os (Unknown)" [[ $distro ]] || distro="$os (Unknown)"
# Get OS architecture. # Get OS architecture.
case "$os" in case $os in
"Solaris" | "AIX" | "Haiku" | "IRIX" | "FreeMiNT") Solaris|AIX|Haiku|IRIX|FreeMiNT)
machine_arch="$(uname -p)" ;; machine_arch=$(uname -p)
*) machine_arch="$kernel_machine" ;; ;;
*) machine_arch=$kernel_machine ;;
esac esac
[[ "$os_arch" == "on" ]] && \ [[ $os_arch == on ]] && \
distro+=" $machine_arch" distro+=" $machine_arch"
[[ "${ascii_distro:-auto}" == "auto" ]] && \ [[ ${ascii_distro:-auto} == auto ]] && \
ascii_distro="$(trim "$distro")" ascii_distro=$(trim "$distro")
} }
get_model() { get_model() {