Skip to content

Commit

Permalink
shellcheck: ignore SC2016, it is always intentional
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Oct 21, 2024
1 parent 7001569 commit 5261780
Show file tree
Hide file tree
Showing 39 changed files with 6 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://github.com/trunk-io/configs
enable=all
source-path=SCRIPTDIR
disable=SC2154,SC2164,SC2250,SC2310,SC2249,SC2312,SC1090,SC1091,SC2317
disable=SC2154,SC2164,SC2250,SC2310,SC2249,SC2312,SC1090,SC1091,SC2317,SC2016
1 change: 0 additions & 1 deletion commands.beta/get-codec
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function get_codec() (
fi

if test "$option_verbose" = 'no'; then
# trunk-ignore(shellcheck/SC2016)
ffprobe -i "$option_path" 2>&1 | echo-regexp -fon --regexp='Audio: ([\w\d-]+)' --replace='$1'
else
ffprobe -i "$option_path"
Expand Down
2 changes: 0 additions & 2 deletions commands.beta/itunes-owners
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function itunes_owners() (
local song_count=0
function fetch_songs {
echo-style --header2="Fetching songs to $song_list"
# trunk-ignore(shellcheck/SC2016)
echo-regexp -ong --regexp='<string>file://(.+)</string>' --replace='$1' <"$database" |
echo-url-decode --stdin |
echo-html-decode --stdin >"$song_list"
Expand All @@ -74,7 +73,6 @@ function itunes_owners() (
fi

# fetch owner
# trunk-ignore(shellcheck/SC2016)
owner="$(ffprobe -i "$song" 2>&1 | echo-regexp -o --regexp='account_id\s*:\s*(.+)' --replace='$1')"

# write
Expand Down
2 changes: 0 additions & 2 deletions commands.beta/mac-address-helper
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function mac_address_helper() (
# Action

function act_new {
# trunk-ignore(shellcheck/SC2016)
openssl rand -hex 6 | echo-regexp -g '(..)' '$1:' | echo-regexp ':$' ''
# openssl rand -hex 6 | gsed 's/\(..\)/\1:/g; s/./0/2; s/.$//'
}
Expand All @@ -75,7 +74,6 @@ function mac_address_helper() (
if test -z "$interface"; then
help '<interface> was missing for: ' --code='mac-address-helper get <interface>' $'\n' 'Typically ' --code='en0' ' or ' --code='p2p0' ' is used.'
fi
# trunk-ignore(shellcheck/SC2016)
sudo-helper -- ifconfig "$interface" ether | echo-regexp -fon --regexp='ether ([\w\d:]+)' --replace='$1'
}

Expand Down
1 change: 0 additions & 1 deletion commands.beta/setup-server
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ function setup_server() (
# verify nordvpn connection
local vpn_address vpn_prefix clear_address clear_prefix
if nordvpn status | echo-regexp -q --regexp='Status: Connected'; then
# trunk-ignore(shellcheck/SC2016)
vpn_address="$(nordvpn status | echo-regexp -o --regexp='(?:Server )?IP: (.+)' --replace='$1')"
vpn_prefix="$(__print_lines "$vpn_address" | echo-regexp -o --regexp='^[0-9]+[.][0-9]+[.][0-9]+[.]')"
clear_address="$(what-is-my-ip remote)"
Expand Down
2 changes: 0 additions & 2 deletions commands/choose
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ function choose_() (
# process
local item='' inputs=() tmp=()
local option_question=()
# trunk-ignore(shellcheck/SC2016)
local option_label='no' option_visual='' option_return='$VALUE'
local defaults_exact=() defaults_fuzzy=() option_confirm_solo='yes' option_confirm_default='yes' option_confirm_input='no'
local option_required='no' option_multi='no'
Expand All @@ -559,7 +558,6 @@ function choose_() (
;;
'--visual='*) option_visual="${item#*=}" ;;
'--return='*) option_return="${item#*=}" ;;
# trunk-ignore(shellcheck/SC2016)
'--index') option_return='$INDEX' ;;
'--default-exact='* | '--default='*) defaults_exact+=("${item#*=}") ;;
'--defaults-exact='* | '--defaults='*)
Expand Down
1 change: 0 additions & 1 deletion commands/config-helper
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ function config_helper_test() (
sleep "$delay"
__print_lines '$env.VALUE="hello\world"' >"$test_file"
sleep "$delay"
# trunk-ignore-all(shellcheck/SC2016)
eval-tester --name='test-dollar-signs-01' --stderr="$expected_stderr" \
-- eval-no-color -- config-helper --no-quiet --file="$test_file" -- \
--string-find='$env.VALUE' --string-replace='$env.VALUE="HELLO\WORLD"'
Expand Down
4 changes: 1 addition & 3 deletions commands/dorothy
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ function dorothy_() (
return
elif __command_exists -- fish; then
# this isn't --validate, but it is a last resort
# trunk-ignore(shellcheck/SC2016)
fish -c 'builtin realpath "$argv[1]"' -- "$path"
return
else
Expand Down Expand Up @@ -1352,13 +1351,12 @@ function dorothy_() (
echo-style --h3='Configuring Nu'
setup-util-nu

# trunk-ignore(shellcheck/SC2016)
# configure
config-helper --file="$(nu -c 'echo $nu.loginshell-path')" -- \
--find='.+? # Dorothy' --replace="source '$DOROTHY/init.nu' # Dorothy"

echo-style --g3='Configuring Nu'
elif __command_exists -- nu; then
# trunk-ignore(shellcheck/SC2016)
config-helper --file="$(nu -c 'echo $nu.loginshell-path')" -- \
--find='.+? # Dorothy' --replace=''
fi
Expand Down
2 changes: 0 additions & 2 deletions commands/dorothy-config
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ function dorothy_config() (
EOF
elif test "$extension" = 'sh'; then
# sh uses [.] instead of [source]
# trunk-ignore(shellcheck/SC2016)
source_filepath="${default_filepath/"$DOROTHY"/'$DOROTHY'}"
cat <<-EOF >>"$temp_filepath"
# load the default configuration
Expand All @@ -242,7 +241,6 @@ function dorothy_config() (
EOF
else
# fish, zsh, bash
# trunk-ignore(shellcheck/SC2016)
source_filepath="${default_filepath/"$DOROTHY"/'$DOROTHY'}"
cat <<-EOF >>"$temp_filepath"
# load the default configuration
Expand Down
1 change: 0 additions & 1 deletion commands/echo-magnet-hash
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function echo_magnet_hash() (
# Action

function on_line {
# trunk-ignore(shellcheck/SC2016)
hash="$(echo-regexp -o 'btih:([\w\d]+)' '$1' -- "$1" || :)"
if test -n "$hash"; then
# convert to lowercase
Expand Down
1 change: 0 additions & 1 deletion commands/echo-regexp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
# trunk-ignore-all(shellcheck/SC2016)

function echo_regexp_test() (
source "$DOROTHY/sources/bash.bash"
Expand Down
1 change: 0 additions & 1 deletion commands/fs-bytes
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function fs_bytes() (
# get apparent size in bytes
local path
for path in "${option_paths[@]}"; do
# trunk-ignore(shellcheck/SC2016)
dust -sbcP -ob -d0 "$path" | echo-regexp -fo '^(\d+)B' '$1'
done
)
Expand Down
1 change: 0 additions & 1 deletion commands/fs-kilobytes
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function fs_kilobytes() (
# get apparent size in bytes
local path
for path in "${option_paths[@]}"; do
# trunk-ignore(shellcheck/SC2016)
dust -sbcP -ok -d0 "$path" | echo-regexp -fo '^(\d+)K' '$1'
done
)
Expand Down
1 change: 0 additions & 1 deletion commands/fs-megabytes
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function fs_megabytes() (
# get apparent size in bytes
local path
for path in "${option_paths[@]}"; do
# trunk-ignore(shellcheck/SC2016)
dust -sbcP -om -d0 "$path" | echo-regexp -fo '^(\d+)M' '$1'
done
)
Expand Down
11 changes: 4 additions & 7 deletions commands/fs-realpath
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,9 @@ function fs_realpath() (
return 45 # ENOTSUP 45 Operation not supported
fi
}
function fish_capable {
__command_exists -- fish
# trunk-ignore(shellcheck/SC2016)
test "$(version-compare "$(fish -c 'echo $FISH_VERSION')" 3.3.0)" -ge 0
function __fish_capable {
__command_exists -- fish && test "$(version-compare "$(fish -c 'echo $FISH_VERSION')" 3.3.0)" -ge 0
return
}
function do_fish_realpath {
# don't support unsupported args
Expand All @@ -291,7 +290,7 @@ function fs_realpath() (
fi

local fish_status
eval_capture --statusvar=fish_status -- fish_capable
eval_capture --statusvar=fish_status -- __fish_capable
if test "$fish_status" -ne 0; then
return 45 # ENOTSUP 45 Operation not supported
fi
Expand All @@ -312,10 +311,8 @@ function fs_realpath() (

if test "$option_relative" = 'no' -a "$option_validate" = 'no'; then
if test "$option_resolve" = 'no'; then
# trunk-ignore(shellcheck/SC2016)
fish -c 'builtin realpath --no-symlinks "$argv[1]"' -- "$path"
else
# trunk-ignore(shellcheck/SC2016)
fish -c 'builtin realpath "$argv[1]"' -- "$path"
fi
else
Expand Down
1 change: 0 additions & 1 deletion commands/get-devices
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
# trunk-ignore-all(shellcheck/SC2016)

# https://unix.stackexchange.com/a/364496/50703
# https://unix.stackexchange.com/a/364458/50703
Expand Down
2 changes: 0 additions & 2 deletions commands/get-local-to-remote
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function get_local_to_remote() (
fi
mapfile -t parts < <(echo-split $'\t' -- "$remote")
volume="${parts[0]}"
# trunk-ignore(shellcheck/SC2016)
path="$(echo-regexp --regexp="^$volume(.+)" --replace='$1' -- "$option_target")"
if test -n "$path"; then
server="${parts[1]}"
Expand All @@ -77,7 +76,6 @@ function get_local_to_remote() (

if test -n "$result"; then
local example_result
# trunk-ignore(shellcheck/SC2016)
example_result="$(echo-regexp --regexp='(.+)@(.+?)([.].+)?:(.+)' --replace='a-login-user@$2:/mnt$4' -- "$result")"
echo-style 'The local to remote conversion for ' --code="$option_target" ' will probably be something like these, but not these, as the username will be a local login username, and the mount point will be the local mount point rather than the remote mount point, as such, these are only suggestions to guide what the correct combination could be:' --newline \
--code="$result" --newline \
Expand Down
1 change: 0 additions & 1 deletion commands/get-opensuse-release
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function get_opensuse_release() (
if is-opensuse && test -f /etc/os-release; then
# config-helper /etc/os-release -- \
# --field=NAME --field=VERSION | "$bin_gsed_or_sed" -e 's/"//g' -e 's/ /_/g' | echo-join '_' --stdin
# trunk-ignore(shellcheck/SC2016)
echo-regexp -fongm '^\s*(NAME|VERSION)="*(.+?)"*$' '$2' </etc/os-release | echo-regexp -g '[_\s\n]+' '_'
else
return 1
Expand Down
1 change: 0 additions & 1 deletion commands/get-url-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ function get_url_upgrade() (
local url="$1" protocol result

# remove superflous trailing slash
# trunk-ignore(shellcheck/SC2016)
url="$(echo-regexp '([.][a-z]+)[/]$' '$1' -- "$url")"

# test the original url
Expand Down
1 change: 0 additions & 1 deletion commands/get-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
# trunk-ignore-all(shellcheck/SC2016)

function get_volumes() (
source "$DOROTHY/sources/bash.bash"
Expand Down
5 changes: 0 additions & 5 deletions commands/git-helper
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ function git_helper() (
try run the following and try again:
EOF
# trunk-ignore(shellcheck/SC2016)
echo-regexp -gomn '^(.+)=.*$' 'git config --global --unset $1' -- "$local_lines"
# trunk-ignore(shellcheck/SC2016)
echo-regexp -gomn '^(.+)=.*$' 'git config --unset $1' -- "$local_lines"
fi

Expand All @@ -298,7 +296,6 @@ function git_helper() (
}

function get_github_slug {
# trunk-ignore(shellcheck/SC2016)
git remote -v | echo-regexp -o --regexp='.+?github[.]com[:/](.+?)[.]git.+' --replace='$1'
}

Expand All @@ -307,7 +304,6 @@ function git_helper() (
}

function get_first_commit_hash {
# trunk-ignore(shellcheck/SC2016)
get_first_commit_entry | echo-regexp -o --regexp='(.+?) .+' --replace='$1'
}

Expand Down Expand Up @@ -345,7 +341,6 @@ function git_helper() (
# Adjustments

local emails
# trunk-ignore(shellcheck/SC2016)
mapfile -t emails < <(git shortlog --summary --email | echo-regexp -ong --regexp='<(.+?)>' --replace='$1')

old_email="$(
Expand Down
1 change: 0 additions & 1 deletion commands/is-bash-version-outdated
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function is_bash_version_outdated_test() (

local bash_version_latest_available
bash_version_latest_available="$(
# trunk-ignore(shellcheck/SC2016)
fetch 'https://ftp.gnu.org/gnu/bash/?C=M;O=D' | echo-regexp -o --regexp='href="bash-([0-9.]+?)[.]tar[.]gz"' --replace='$1'
)"
echo-style --h2='latest known bash version is the latest available bash version'
Expand Down
2 changes: 0 additions & 2 deletions commands/mount-helper
Original file line number Diff line number Diff line change
Expand Up @@ -1379,10 +1379,8 @@ function mount_helper() (
function update_existing_mounts {
local haystack="$1"
if is-mac; then
# trunk-ignore(shellcheck/SC2016)
mapfile -t EXISTING_MOUNTS < <(echo-regexp -ong --regexp=" on (.+?) \(" --replace='$1' -- "$haystack")
else
# trunk-ignore(shellcheck/SC2016)
mapfile -t EXISTING_MOUNTS < <(echo-regexp -ong --regexp=" on (.+?) type " --replace='$1' -- "$haystack")
fi
}
Expand Down
1 change: 0 additions & 1 deletion commands/network-interface
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ function network_interface() (
# An asterisk (*) denotes that a network service is disabled.
networksetup -listallnetworkservices | grep --invert-match --fixed-strings --regexp='*'
else
# trunk-ignore(shellcheck/SC2016)
resolvectl status --no-pager | echo-regexp -ong --regexp='Link \d \((.+?)\)' --replace='$1'
fi
}
Expand Down
2 changes: 0 additions & 2 deletions commands/secret
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,8 @@ function secret_() (
local vault="${1-}" item="${2-}" field="${3-}" tuples
local wants
if test "${4-}" = '--label'; then
# trunk-ignore(shellcheck/SC2016)
wants='$LABEL'
else
# trunk-ignore(shellcheck/SC2016)
wants='$VALUE'
fi

Expand Down
1 change: 0 additions & 1 deletion commands/setup-dns
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,6 @@ EOF

# write the names to the file if it is empty
if test ! -s "$dnscrypt_names_file"; then
# trunk-ignore(shellcheck/SC2016)
fetch 'https://download.dnscrypt.info/resolvers-list/v2/public-resolvers.md' | echo-regexp -ongm --regexp='^## (.+)$' --replace='$1' >"$dnscrypt_names_file"
fi

Expand Down
1 change: 0 additions & 1 deletion commands/setup-util
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,6 @@ function setup_util() (
if test "$option_action" = 'uninstall'; then
# if uninstalling, use the package name
packages[download_index]="$(
# trunk-ignore(shellcheck/SC2016)
dpkg -I "$download_filepath" | echo-regexp -o --regexp='Package:\s+(.+)' --replace='$1'
)"
else
Expand Down
1 change: 0 additions & 1 deletion commands/setup-util-1password-cli
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function setup_util_1password_cli() (
platform="$(uname -s)"

# fetcch latest cli version
# trunk-ignore(shellcheck/SC2016)
version="v$(fetch 'https://app-updates.agilebits.com/product_history/CLI2' | echo-regexp -o --regexp='https://cache.agilebits.com/dist/1P/op2/pkg/v([^/-]+)/' --replace='$1')"

# fetch appropriate platform url for that cli version
Expand Down
1 change: 0 additions & 1 deletion commands/setup-util-bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
# trunk-ignore-all(shellcheck/SC2016)

# https://repology.org/project/bash/versions

Expand Down
2 changes: 0 additions & 2 deletions commands/setup-util-nerd-fonts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ function setup_util_nerd_fonts() (
if __is_brew; then
local choices=()
mapfile -t choices < <(
# trunk-ignore(shellcheck/SC2016)
brew search --cask --quiet '/-nerd-font$/' | echo-regexp -ong --regexp='font-(.+?)-nerd-font' --replace='$1'
)
local selection=()
Expand Down Expand Up @@ -51,7 +50,6 @@ function setup_util_nerd_fonts() (
for asset in "${assets[@]}"; do
choices+=(
"$asset"
# trunk-ignore(shellcheck/SC2016)
"$(echo-regexp -o --regexp='([^/]+?)[.]tar[.]xz$' --replace='$1'-- "$asset")"
)
done
Expand Down
1 change: 0 additions & 1 deletion commands/setup-util-node
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function setup_util_node() (
# Helpers

function __get_nvm_versions {
# trunk-ignore(shellcheck/SC2016)
nvm-env -- nvm ls --no-colors --no-alias | echo-regexp -ong --regexp='v([^\s]+)' --replace='$1'
}

Expand Down
1 change: 0 additions & 1 deletion commands/setup-util-nu
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function setup_util_nu() (
}
function do_configure {
# ensure nushell configuration directory exists (needed for [dorothy install])
# trunk-ignore(shellcheck/SC2016)
__mkdirp "$(nu -c 'echo $nu.default-config-dir')"

# ensure [themes/starship.nu] works
Expand Down
1 change: 0 additions & 1 deletion commands/ssh-helper
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ function ssh_helper() (
setup-util-jq --quiet --optional
setup-util-deno --quiet --optional
# fetch and extract keys, prepend [github.com ] to non-empty-lines (non-empty necessary for sd), append to known_hosts
# trunk-ignore(shellcheck/SC2016)
if __command_exists -- curl jq deno && fetch 'https://api.github.com/meta' | jq -r '.ssh_keys | .[]' | echo-regexp -fgmn '^(.+)$' 'github.com $1' >>"$HOME/.ssh/known_hosts"; then
: # success
else
Expand Down
1 change: 0 additions & 1 deletion commands/unziptar
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ function unziptar_() (
trap dmg_unmount EXIT
# install what is necessary for identifying the DMG volume
# attach the DMG to a volume
# trunk-ignore(shellcheck/SC2016)
dmg_device="$(hdiutil attach -readonly -nobrowse -mountroot "$archive_directory" "$archive" | echo-wait | echo-regexp -fo --regexp='(/dev/.+?)\s' --replace='$1')"
function relocate {
cp -Rfv "$@"
Expand Down
Loading

0 comments on commit 5261780

Please sign in to comment.