diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-17 15:10:18 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-17 15:12:55 +1300 |
commit | 06dae018ff0b41bc6140a603f5cbf2b54b2fd3ae (patch) | |
tree | 7be425ef1a1eb11ad6f7ff1c8d55bb0f06e0d6d0 | |
parent | Add /j flag to :vimgrep shortcut (diff) | |
download | dotfiles-06dae018ff0b41bc6140a603f5cbf2b54b2fd3ae.tar.gz dotfiles-06dae018ff0b41bc6140a603f5cbf2b54b2fd3ae.zip |
Use `command` consistently, silence ShellCheck
ShellCheck (SC2164) is upset about these `cd` commands where the return
type isn't being checked, but they're all by design, as they're the last
command in the function, and thereby constitute the function's return
value implicitly.
Otherwise, this commit changes the shrc.d and profile.d subfiles to use
the `command` wrapper only where it's actually needed.
-rw-r--r-- | sh/profile.d/options.sh | 4 | ||||
-rw-r--r-- | sh/shrc.d/bd.sh | 3 | ||||
-rw-r--r-- | sh/shrc.d/gd.sh | 3 | ||||
-rw-r--r-- | sh/shrc.d/gt.sh | 3 | ||||
-rw-r--r-- | sh/shrc.d/mkcd.sh | 5 | ||||
-rw-r--r-- | sh/shrc.d/pd.sh | 3 | ||||
-rw-r--r-- | sh/shrc.d/rd.sh | 3 | ||||
-rw-r--r-- | sh/shrc.d/scr.sh | 3 | ||||
-rw-r--r-- | sh/shrc.d/sd.sh | 3 | ||||
-rw-r--r-- | sh/shrc.d/ud.sh | 3 | ||||
-rw-r--r-- | sh/shrc.d/vr.sh | 3 |
11 files changed, 23 insertions, 13 deletions
diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh index 58376fb3..c60dd140 100644 --- a/sh/profile.d/options.sh +++ b/sh/profile.d/options.sh @@ -13,7 +13,7 @@ options() { [ -d "$dir" ] && return # Create the directory and step into it - command -p mkdir -p -- "$dir" || return + mkdir -p -- "$dir" || return cd -- "$dir" || return # Write the program's --help output to a file, even if it's empty @@ -23,7 +23,7 @@ options() { # Iterate through remaining arguments (desired options), creating files to # show they're available if found in the help output for opt do - command -p grep -q -- \ + command grep -q -- \ '[^[:alnum:]]--'"$opt"'[^[:alnum:]]' help || continue touch -- "$opt" done diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index 29bde513..a942af6b 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -43,5 +43,6 @@ bd() { fi # We have a match; try and change into it - command cd -- "$1" + # shellcheck disable=SC2164 + cd -- "$1" } diff --git a/sh/shrc.d/gd.sh b/sh/shrc.d/gd.sh index 9f6a43e7..b9af480e 100644 --- a/sh/shrc.d/gd.sh +++ b/sh/shrc.d/gd.sh @@ -14,5 +14,6 @@ gd() { fi # Go to the marked directory - cd -- "$PMD" || return + # shellcheck disable=SC2164 + cd -- "$PMD" } diff --git a/sh/shrc.d/gt.sh b/sh/shrc.d/gt.sh index 7a52571d..193a2996 100644 --- a/sh/shrc.d/gt.sh +++ b/sh/shrc.d/gt.sh @@ -24,5 +24,6 @@ gt() { fi # Try to change into the determined directory, or root if empty - command cd -- "${1:-/}" + # shellcheck disable=SC2164 + cd -- "${1:-/}" } diff --git a/sh/shrc.d/mkcd.sh b/sh/shrc.d/mkcd.sh index cd882b51..bfe8a142 100644 --- a/sh/shrc.d/mkcd.sh +++ b/sh/shrc.d/mkcd.sh @@ -1,5 +1,6 @@ # Create a directory and change into it mkcd() { - command -p mkdir -p -- "$1" || return - command cd -- "$1" + mkdir -p -- "$1" || return + # shellcheck disable=SC2164 + cd -- "$1" } diff --git a/sh/shrc.d/pd.sh b/sh/shrc.d/pd.sh index e3a6daaa..d5257ba5 100644 --- a/sh/shrc.d/pd.sh +++ b/sh/shrc.d/pd.sh @@ -27,5 +27,6 @@ pd() { set -- "${1%/*}" # Try to change into the determined directory, or root if empty - command cd -- "${1:-/}" + # shellcheck disable=SC2164 + cd -- "${1:-/}" } diff --git a/sh/shrc.d/rd.sh b/sh/shrc.d/rd.sh index 9633713a..5fbd5ac5 100644 --- a/sh/shrc.d/rd.sh +++ b/sh/shrc.d/rd.sh @@ -35,5 +35,6 @@ rd() { esac # Try to change into the determined directory - command cd -- "$1" + # shellcheck disable=SC2164 + cd -- "$1" } diff --git a/sh/shrc.d/scr.sh b/sh/shrc.d/scr.sh index 9af8dd74..14a58ad1 100644 --- a/sh/shrc.d/scr.sh +++ b/sh/shrc.d/scr.sh @@ -2,5 +2,6 @@ # files into $HOME, and making the system do cleanup for me. Single optional # argument is the string to use for naming the directory; defaults to "scr". scr() { - cd -- "$(mktd "${1:-scr}")" || return + # shellcheck disable=SC2164 + cd -- "$(mktd "${1:-scr}")" } diff --git a/sh/shrc.d/sd.sh b/sh/shrc.d/sd.sh index 8b12c170..58d1a375 100644 --- a/sh/shrc.d/sd.sh +++ b/sh/shrc.d/sd.sh @@ -113,5 +113,6 @@ sd() { esac # Try and change into the first parameter - command cd -- "$1" + # shellcheck disable=SC2164 + cd -- "$1" } diff --git a/sh/shrc.d/ud.sh b/sh/shrc.d/ud.sh index 06234569..f7f33caf 100644 --- a/sh/shrc.d/ud.sh +++ b/sh/shrc.d/ud.sh @@ -42,5 +42,6 @@ ud() { shift # Try to change into the determined directory, or the root if blank - command cd -- "${1:-/}" + # shellcheck disable=SC2164 + cd -- "${1:-/}" } diff --git a/sh/shrc.d/vr.sh b/sh/shrc.d/vr.sh index c7057ec2..d9cfda62 100644 --- a/sh/shrc.d/vr.sh +++ b/sh/shrc.d/vr.sh @@ -59,5 +59,6 @@ vr() { [ -n "$1" ] || return # Try to change into the determined directory - command cd -- "$@" + # shellcheck disable=SC2164 + cd -- "$@" } |