From de2fa5334835557d45ce1144491ff5bc566e6978 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Mon, 2 Feb 2026 20:13:26 +0100 Subject: [PATCH] shell/*: run shellcheck on it --- shell/aliases.sh | 9 ++++----- shell/cd.sh | 14 +++++++------- shell/paths.sh | 26 ++++++++++---------------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/shell/aliases.sh b/shell/aliases.sh index 1534ac7..d8ab68a 100755 --- a/shell/aliases.sh +++ b/shell/aliases.sh @@ -95,14 +95,13 @@ alias pacman-update='sudo pacman -Syu' alias aur-update='yay -Syua' # NIX: -alias nix-list-results='ls -l /nix/var/nix/gcroots/auto/' nixpkgs-build() { - if [[ $# -lt 1 ]]; then + if [ "$#" -lt 1 ]; then echo "Usage: nixpkgs-build [parameters...]" return 1 fi - local pkg="$1" + pkg=$1 shift if command -v nom >/dev/null 2>&1; then @@ -129,8 +128,8 @@ alias ttime_black="sh -c \"sleep 300 && notify-send -u critical 'The tea is read for INTERFACE in /sys/class/net/*; do [ -e "$INTERFACE" ] || break # incase it is empty INTERFACE=$(basename "$INTERFACE") - alias ping-all-$INTERFACE="ping -6 ff02::1%$INTERFACE" - alias ping-routes-$INTERFACE="ping -6 ff02::2%$INTERFACE" + alias "ping-all-$INTERFACE"="ping -6 ff02::1%$INTERFACE" + alias "ping-routes-$INTERFACE"="ping -6 ff02::2%$INTERFACE" done alias sort-by-size="du -hsc * | sort -hk1" diff --git a/shell/cd.sh b/shell/cd.sh index 6079d82..d476c26 100755 --- a/shell/cd.sh +++ b/shell/cd.sh @@ -2,13 +2,13 @@ #correct some fast tipped cds c() { - if [ "$1" = "d.." ]; then - cd ..; - pwd; + if [ "${1}" = "d.." ]; then + cd .. || return + pwd fi - if [ -d "$1" ]; then - cd "$1" || exit; - pwd; + if [ -d "${1}" ]; then + cd "${1}" || return + pwd fi - return 0; + return 0 } diff --git a/shell/paths.sh b/shell/paths.sh index cd86352..fffe0f2 100755 --- a/shell/paths.sh +++ b/shell/paths.sh @@ -1,21 +1,15 @@ #!/bin/sh -# Append our default paths -appendpath () { - case ":$PATH:" in - *:"$1":*) - ;; - *) - if [ -d "$1" ]; then - export PATH="${PATH:+$PATH:}$1" - fi - esac +set_path(){ + if [ -d "${1}" ]; then + export PATH="${1}:${PATH}" + fi } -appendpath ~/.local/bin -appendpath ~/.bin +set_path ~/.local/bin +set_path ~/.bin -export GOPATH=$HOME/.go -export GOBIN=$HOME/.gobin -appendpath "$GOPATH"/bin -appendpath "$GOBIN" +export GOPATH="${HOME}/.go" +export GOBIN="${HOME}/.gobin" +set_path "${GOPATH}/bin" +set_path "${GOBIN}"