Fix static analysis errors

This commit is contained in:
Marty Oehme 2019-07-24 10:54:06 +02:00
parent 05c189cfa4
commit bedf7e18a9
4 changed files with 27 additions and 25 deletions

View file

@ -1,2 +1,5 @@
#!/bin/sh
# put personal scripts on the PATH to be callable
export PATH="$(du $HOME/.local/bin | cut -f2 | tr '\n' ':')$PATH"
PATH=$(du "$HOME"/.local/bin | cut -f2 | tr '\n' ':')$PATH
export PATH

View file

@ -1,2 +1,4 @@
#!/bin/sh
export LC_ALL="en_US.utf-8"
export LANG="en_US.utf-8"

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
## Integration at the Bottom
@ -32,7 +32,7 @@ _LIVE_AGENT_SOCK_LIST=()
_debug_print() {
if [[ $_DEBUG -gt 0 ]]; then
printf "%s\n" $1
printf "%s\n" "$1"
fi
}
@ -47,7 +47,7 @@ find_all_gpg_agent_sockets() {
}
find_all_gnome_keyring_agent_sockets() {
_GNOME_KEYRING_AGENT_SOCKETS=$(find /tmp/ -type s -name ssh 2>/dev/null | grep '/tmp/keyring-.*/ssh$')
_GNOME_KEYRING_AGENT_SOCKETS=$(find /tmp/ -type s -name "ssh" 2>/dev/null | grep '/tmp/keyring-.*/ssh$')
_debug_print "$_GNOME_KEYRING_AGENT_SOCKETS"
}
@ -88,33 +88,33 @@ test_agent_socket() {
find_live_gnome_keyring_agents() {
for i in $_GNOME_KEYRING_AGENT_SOCKETS; do
test_agent_socket $i
test_agent_socket "$i"
done
}
find_live_osx_keychain_agents() {
for i in $_OSX_KEYCHAIN_AGENT_SOCKETS; do
test_agent_socket $i
test_agent_socket "$i"
done
}
find_live_gpg_agents() {
for i in $_GPG_AGENT_SOCKETS; do
test_agent_socket $i
test_agent_socket "$i"
done
}
find_live_ssh_agents() {
for i in $_SSH_AGENT_SOCKETS; do
test_agent_socket $i
test_agent_socket "$i"
done
}
function fingerprints() {
local file="$1"
while read l; do
[[ -n $l && ${l###} == $l ]] && ssh-keygen -l -f /dev/stdin <<<$l
done <$file
while read -r l; do
[[ -n $l && ${l###} == "$l" ]] && ssh-keygen -l -f /dev/stdin <<<"$l"
done <"$file"
}
find_all_agent_sockets() {
@ -135,9 +135,6 @@ find_all_agent_sockets() {
_LIVE_AGENT_LIST=$(echo $_LIVE_AGENT_LIST | tr ' ' '\n' | sort -n -t: -k 2 -k 1 | uniq)
_LIVE_AGENT_SOCK_LIST=()
_debug_print "SORTED: $_LIVE_AGENT_LIST"
if [ -e ~/.ssh/authorized_keys ]; then
_FINGERPRINTS=$(fingerprints ~/.ssh/authorized_keys)
fi
if [[ $_SHOW_IDENTITY -gt 0 ]]; then
i=0
for a in $_LIVE_AGENT_LIST; do
@ -146,13 +143,11 @@ find_all_agent_sockets() {
# technically we could have multiple keys forwarded
# But I haven't seen anyone do it
akeys=$(SSH_AUTH_SOCK=$sock ssh-add -l)
key_size=$(echo ${akeys} | awk '{print $1}')
fingerprint=$(echo ${akeys} | awk '{print $2}')
remote_name=$(echo ${akeys} | awk '{print $3}')
fingerprint=$(echo "${akeys}" | awk '{print $2}')
if [ -e ~/.ssh/authorized_keys ]; then
authorized_entry=$(fingerprints ~/.ssh/authorized_keys | grep $fingerprint)
authorized_entry=$(fingerprints ~/.ssh/authorized_keys | grep "$fingerprint")
fi
comment=$(echo ${authorized_entry} | awk '{print $3,$4,$5,$6,$7}')
comment=$(echo "${authorized_entry}" | awk '{print $3,$4,$5,$6,$7}')
printf "export SSH_AUTH_SOCK=%s \t#%i) \t%s\n" "$sock" $((i + 1)) "$comment"
i=$((i + 1))
done
@ -162,7 +157,7 @@ find_all_agent_sockets() {
}
set_ssh_agent_socket() {
if [ "$1" = "-c" -o "$1" = "--choose" ]; then
if [ "$1" = "-c" ] || [ "$1" = "--choose" ]; then
find_all_agent_sockets -i
if [ -z "$_LIVE_AGENT_LIST" ]; then
@ -171,7 +166,7 @@ set_ssh_agent_socket() {
fi
echo -n "Choose (1-${#_LIVE_AGENT_SOCK_LIST[@]})? "
read choice
read -r choice
if [ -n "$choice" ]; then
n=$((choice - 1))
if [ -z "${_LIVE_AGENT_SOCK_LIST[$n]}" ]; then
@ -192,17 +187,17 @@ set_ssh_agent_socket() {
# set agent pid
if [ -n "$SSH_AUTH_SOCK" ]; then
export SSH_AGENT_PID=$(($(echo $SSH_AUTH_SOCK | cut -d. -f2) + 1))
export SSH_AGENT_PID=$(($(echo "$SSH_AUTH_SOCK" | cut -d. -f2) + 1))
fi
return 0
}
ssh-find-agent() {
if [ "$1" = "-c" -o "$1" = "--choose" ]; then
if [ "$1" = "-c" ] || [ "$1" = "--choose" ]; then
set_ssh_agent_socket -c
return $?
elif [ "$1" = "-a" -o "$1" = "--auto" ]; then
elif [ "$1" = "-a" ] || [ "$1" = "--auto" ]; then
set_ssh_agent_socket
return $?
else
@ -214,6 +209,6 @@ ssh-find-agent() {
# Automatically add ssh-agent to any new ssh connection
ssh-find-agent -a
if [ -z "$SSH_AUTH_SOCK" ]; then
eval $(ssh-agent) >/dev/null
eval "$(ssh-agent)" >/dev/null
ssh-add -l >/dev/null || alias ssh='ssh-add -l >/dev/null || ssh-add && unalias ssh; ssh'
fi

View file

@ -2,12 +2,14 @@
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
# shellcheck disable=SC2016
zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)*==34=34}:${(s.:.)LS_COLORS}")';
# Load any custom zsh completions we've installed
if [ -d ~/.zsh-completions ]; then
for completion in ~/.zsh-completions/*
do
# shellcheck source=/dev/null
source "$completion"
done
fi