Browse Source

Tweaked code in requires() so it doesn't break function auto complete in vscode

pull/648/head
Tim Kimber 5 years ago
parent
commit
39ddb2da7a
No known key found for this signature in database GPG Key ID: 3E1804964E76BD18
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      getssl

+ 5
- 3
getssl View File

@ -2073,16 +2073,18 @@ revoke_certificate() { # revoke a certificate
}
requires() { # check if required function is available
args=("${@}")
lastarg=${args[${#args[@]}-1]}
if [[ "$#" -gt 1 ]]; then # if more than 1 value, check list
for i in "$@"; do
if [[ "$i" == "${!#}" ]]; then # if on last variable then exit as not found
if [[ "$i" == "$lastarg" ]]; then # if on last variable then exit as not found
error_exit "this script requires one of: ${*:1:$(($#-1))}"
fi
res=$(command -v "$i" 2>/dev/null)
debug "checking for $i ... $res"
if [[ -n "$res" ]]; then # if function found, then set variable to function and return
debug "function $i found at $res - setting ${!#} to $i"
eval "${!#}=\$i"
debug "function $i found at $res - setting ${lastarg} to $i"
eval "${lastarg}=\$i"
return
fi
done


Loading…
Cancel
Save