Merge pull request #512 from dylanaraps/shellcheck
Travis: Add shellcheck
This commit is contained in:
commit
53f8f2eb28
2 changed files with 26 additions and 15 deletions
10
.travis.yml
10
.travis.yml
|
@ -1,6 +1,13 @@
|
|||
language: bash
|
||||
sudo: required
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- debian-sid
|
||||
packages:
|
||||
- shellcheck
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
@ -11,3 +18,6 @@ before_install:
|
|||
|
||||
script:
|
||||
- time ./neofetch --ascii --config travis --ascii_distro travis -v
|
||||
# See this wiki page for why we're disabling these errors.
|
||||
# https://github.com/dylanaraps/neofetch/wiki/Shellcheck-Exclusions
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then shellcheck neofetch -e SC1090,SC2009,SC2012,SC2016,SC2034,SC2128,SC2153,SC2154,SC2178,SC2010; fi
|
||||
|
|
29
neofetch
29
neofetch
|
@ -44,7 +44,7 @@ get_distro() {
|
|||
|
||||
case "$os" in
|
||||
"Linux" | "GNU")
|
||||
if [[ "$(< /proc/version)" =~ "Microsoft" || "$(< /proc/sys/kernel/osrelease)" =~ "Microsoft" ]]; then
|
||||
if [[ "$(< /proc/version)" == *"Microsoft"* || "$(< /proc/sys/kernel/osrelease)" == *"Microsoft"* ]]; then
|
||||
case "$distro_shorthand" in
|
||||
"on") distro="$(lsb_release -sir) [Windows 10]" ;;
|
||||
"tiny") distro="Windows 10" ;;
|
||||
|
@ -283,7 +283,7 @@ get_kernel() {
|
|||
esac
|
||||
|
||||
# Hardcode kernel settings in BSDs
|
||||
if [[ "$os" == "BSD" && "$distro" =~ "$kernel_name" ]]; then
|
||||
if [[ "$os" == "BSD" && "$distro" == *"$kernel_name"* ]]; then
|
||||
case "$distro_shorthand" in
|
||||
"on" | "tiny") kernel="$kernel_version" ;;
|
||||
*) unset kernel ;;
|
||||
|
@ -965,7 +965,7 @@ get_gpu() {
|
|||
;;
|
||||
esac
|
||||
|
||||
[[ "$gpu" =~ "intel" ]] && \
|
||||
[[ "$gpu" == *"intel"* ]] && \
|
||||
gpu="Intel Integrated Graphics"
|
||||
;;
|
||||
|
||||
|
@ -1294,7 +1294,7 @@ get_resolution() {
|
|||
scale_factor="$(/usr/libexec/PlistBuddy -c "Print DisplayAnyUserSets:0:0:Resolution" /Library/Preferences/com.apple.windowserver.plist)"
|
||||
|
||||
# If no refresh rate is empty.
|
||||
[[ "$resolution" =~ "@ Hz" ]] && \
|
||||
[[ "$resolution" == *"@ Hz"* ]] && \
|
||||
resolution="${resolution//@ Hz}"
|
||||
|
||||
(("${scale_factor%.*}" == 2)) && \
|
||||
|
@ -1305,7 +1305,7 @@ get_resolution() {
|
|||
resolution="${resolution// @ [0-9][0-9][0-9]Hz}"
|
||||
fi
|
||||
|
||||
[[ "$resolution" =~ "0Hz" ]] && \
|
||||
[[ "$resolution" == *"0Hz"* ]] && \
|
||||
resolution="${resolution// @ 0Hz}"
|
||||
;;
|
||||
|
||||
|
@ -1588,11 +1588,11 @@ get_disk() {
|
|||
# df flags
|
||||
case "$os" in
|
||||
"Linux" | "iPhone OS" | "Windows" | "Solaris" | "GNU")
|
||||
df_flags="-h -l --total"
|
||||
df_flags=(-h -l --total)
|
||||
df_dir="total"
|
||||
|
||||
case "$distro" in
|
||||
"OpenWRT"*) df_flags="-h"; df_dir="rootfs" ;;
|
||||
"OpenWRT"*) df_flags=(-h); df_dir="rootfs" ;;
|
||||
"Android"*) return ;;
|
||||
esac
|
||||
;;
|
||||
|
@ -1600,7 +1600,7 @@ get_disk() {
|
|||
"Mac OS X" | "BSD" | "Haiku")
|
||||
case "$distro" in
|
||||
"FreeBSD"* | *"OS X"* | "Mac"*)
|
||||
df_flags="-l -H /"
|
||||
df_flags=(-l -H /)
|
||||
df_dir="/"
|
||||
;;
|
||||
|
||||
|
@ -1610,7 +1610,7 @@ get_disk() {
|
|||
esac
|
||||
|
||||
# Get the disk info
|
||||
disk="$(df $df_flags | awk -v dir="$df_dir" '$0 ~ dir {print $2 ":" $3 ":" $5}')"
|
||||
disk="$(df "${df_flags[@]}" | awk -v dir="$df_dir" '$0 ~ dir {print $2 ":" $3 ":" $5}')"
|
||||
|
||||
# Format the output
|
||||
disk_used="${disk#*:}"
|
||||
|
@ -2096,20 +2096,20 @@ get_term_size() {
|
|||
# get the terminal size.
|
||||
if [[ -n "$TMUX" ]]; then
|
||||
printf "%b" "\033Ptmux;\033\033[14t\033\033[c\033\\"
|
||||
read_flags="-d c"
|
||||
read_flags=(-d c)
|
||||
|
||||
elif [[ "$image_program" == "tycat" ]]; then
|
||||
printf "%b" "\033}qs\000"
|
||||
|
||||
else
|
||||
printf "%b" "\033[14t\033[c"
|
||||
read_flags="-d c"
|
||||
read_flags=(-d c)
|
||||
fi
|
||||
|
||||
# The escape codes above print the desired output as
|
||||
# user input so we have to use read to store the out
|
||||
# -put as a variable.
|
||||
builtin read -s -t 1 ${read_flags} -r term_size
|
||||
builtin read -s -t 1 "${read_flags[@]}" -r term_size
|
||||
|
||||
# Split the string into height/width.
|
||||
if [[ "$image_program" == "tycat" ]]; then
|
||||
|
@ -2529,6 +2529,7 @@ trim() {
|
|||
# '${1//[[:space:]]/ }' to remove newlines beofre we trim the whitespace.
|
||||
|
||||
set -f
|
||||
# shellcheck disable=2086
|
||||
builtin echo -E ${1//[[:space:]]/ }
|
||||
set +f
|
||||
}
|
||||
|
@ -2712,7 +2713,7 @@ get_distro_colors() {
|
|||
# equal 'distro'.
|
||||
if [[ "${ascii_colors[0]}" != "distro" ]]; then
|
||||
color_text="off"
|
||||
set_colors ${ascii_colors[@]}
|
||||
set_colors "${ascii_colors[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -2724,7 +2725,7 @@ set_colors() {
|
|||
c5="$(color "$5")${ascii_bold}"
|
||||
c6="$(color "$6")${ascii_bold}"
|
||||
|
||||
[[ "$color_text" != "off" ]] && set_text_colors $@
|
||||
[[ "$color_text" != "off" ]] && set_text_colors "$@"
|
||||
}
|
||||
|
||||
set_text_colors() {
|
||||
|
|
Loading…
Reference in a new issue