Some minor shellcheck fixes.
when cd fails (especially when operating on user-pws) the program should quit. Other than that just some Shell-Globbing prevention.
This commit is contained in:
parent
ef6b68abbf
commit
b88bb64072
24
rofi-pass
24
rofi-pass
@ -7,7 +7,7 @@ basecommand=$(echo "$0" | gawk '{ print $1 }')
|
|||||||
|
|
||||||
# get all password files and create an array
|
# get all password files and create an array
|
||||||
list_passwords() {
|
list_passwords() {
|
||||||
cd "${root}"
|
cd "${root}" || exit
|
||||||
passwords=( **/*.gpg )
|
passwords=( **/*.gpg )
|
||||||
|
|
||||||
for password in "${passwords[@]}"; do
|
for password in "${passwords[@]}"; do
|
||||||
@ -53,7 +53,7 @@ autopass () {
|
|||||||
for word in ${stuff["$AUTOTYPE_field"]}; do
|
for word in ${stuff["$AUTOTYPE_field"]}; do
|
||||||
if [[ $word == ":tab" ]]; then xdotool key Tab;
|
if [[ $word == ":tab" ]]; then xdotool key Tab;
|
||||||
elif [[ $word == ":space" ]]; then xdotool key space;
|
elif [[ $word == ":space" ]]; then xdotool key space;
|
||||||
elif [[ $word == ":delay" ]]; then sleep ${delay};
|
elif [[ $word == ":delay" ]]; then sleep "${delay}";
|
||||||
elif [[ $word == ":enter" ]]; then xdotool key Return;
|
elif [[ $word == ":enter" ]]; then xdotool key Return;
|
||||||
elif [[ $word == "pass" ]]; then echo -n "${password}" | xdotool type --clearmodifiers --file -;
|
elif [[ $word == "pass" ]]; then echo -n "${password}" | xdotool type --clearmodifiers --file -;
|
||||||
else echo -n "${stuff[${word}]}" | xdotool type --clearmodifiers --file -
|
else echo -n "${stuff[${word}]}" | xdotool type --clearmodifiers --file -
|
||||||
@ -333,7 +333,7 @@ showEntry () {
|
|||||||
echo "not doing anything"
|
echo "not doing anything"
|
||||||
else
|
else
|
||||||
if [[ -z $(echo -n "${stuff[${word}]}") ]]; then
|
if [[ -z $(echo -n "${stuff[${word}]}") ]]; then
|
||||||
xdotool type ${word}
|
xdotool type "${word}"
|
||||||
else
|
else
|
||||||
echo -n "${stuff[${word}]}" | xdotool type --clearmodifiers --file -
|
echo -n "${stuff[${word}]}" | xdotool type --clearmodifiers --file -
|
||||||
xdotool key ctrl+alt
|
xdotool key ctrl+alt
|
||||||
@ -342,7 +342,7 @@ showEntry () {
|
|||||||
if [[ ${count} == "off" ]]; then
|
if [[ ${count} == "off" ]]; then
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
sleep ${count}
|
sleep "${count}"
|
||||||
fi
|
fi
|
||||||
showEntry
|
showEntry
|
||||||
elif [[ ${rofi_exit} -eq 1 ]]; then
|
elif [[ ${rofi_exit} -eq 1 ]]; then
|
||||||
@ -362,7 +362,7 @@ manageEntry () {
|
|||||||
mainMenu
|
mainMenu
|
||||||
|
|
||||||
elif [[ $1 == "move" ]]; then
|
elif [[ $1 == "move" ]]; then
|
||||||
cd "${root}"
|
cd "${root}" || exit
|
||||||
selected_password2=$(basename "$selected_password" .gpg)
|
selected_password2=$(basename "$selected_password" .gpg)
|
||||||
group=$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2- | _rofi -dmenu -p "Choose Group > ")
|
group=$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2- | _rofi -dmenu -p "Choose Group > ")
|
||||||
if [[ $group == "" ]]; then exit; fi
|
if [[ $group == "" ]]; then exit; fi
|
||||||
@ -404,7 +404,7 @@ insertPass () {
|
|||||||
if [[ $insertmenu == "0 Return to Main Menu" ]]; then mainMenu
|
if [[ $insertmenu == "0 Return to Main Menu" ]]; then mainMenu
|
||||||
elif [[ $insertmenu == "" ]]; then exit
|
elif [[ $insertmenu == "" ]]; then exit
|
||||||
elif [[ $insertmenu == "* Accept Values and Add Password Entry" ]]; then
|
elif [[ $insertmenu == "* Accept Values and Add Password Entry" ]]; then
|
||||||
cd "${root}"
|
cd "${root}" || exit
|
||||||
group=$(echo -e "No Group\n---\n$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2-)" | _rofi -dmenu -p "Choose Group > ")
|
group=$(echo -e "No Group\n---\n$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2-)" | _rofi -dmenu -p "Choose Group > ")
|
||||||
if [[ "$group" == "No Group" ]]; then
|
if [[ "$group" == "No Group" ]]; then
|
||||||
PASSWORD_STORE_DIR="${root}" pass insert -m -f "${name}" < <(echo -e "${pass}\n${USERNAME_field}: ${user}\n---\n${URL_field}: ${domain}")
|
PASSWORD_STORE_DIR="${root}" pass insert -m -f "${name}" < <(echo -e "${pass}\n${USERNAME_field}: ${user}\n---\n${URL_field}: ${domain}")
|
||||||
@ -499,13 +499,13 @@ if [[ -f /etc/rofi-pass.conf ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check if local config exists and load it
|
# check if local config exists and load it
|
||||||
if [[ -f $HOME/.config/rofi-pass/config ]]; then
|
if [[ -f "$HOME/.config/rofi-pass/config" ]]; then
|
||||||
source $HOME/.config/rofi-pass/config
|
source "$HOME/.config/rofi-pass/config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create tmp dir
|
# create tmp dir
|
||||||
if [[ ! -d /tmp/$USER-rofi-pass ]]; then
|
if [[ ! -d /tmp/$USER-rofi-pass ]]; then
|
||||||
mkdir /tmp/$USER-rofi-pass
|
mkdir "/tmp/$USER-rofi-pass"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set help color
|
# set help color
|
||||||
@ -524,7 +524,7 @@ fi
|
|||||||
|
|
||||||
# check if alternative root directory was given on commandline
|
# check if alternative root directory was given on commandline
|
||||||
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]] && [[ $1 == "--last-used" || $1 == "--show-last" ]]; then
|
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]] && [[ $1 == "--last-used" || $1 == "--show-last" ]]; then
|
||||||
export root=$(awk -F ': ' '{ print $1 }' /tmp/$USER-rofi-pass/last_used)
|
export root; root=$(awk -F ': ' '{ print $1 }' "/tmp/$USER-rofi-pass/last_used")
|
||||||
elif [[ -n "$2" && "$1" == "--root" ]]; then
|
elif [[ -n "$2" && "$1" == "--root" ]]; then
|
||||||
export root="${2}"
|
export root="${2}"
|
||||||
elif [[ -n $root ]]; then
|
elif [[ -n $root ]]; then
|
||||||
@ -550,13 +550,13 @@ export PASSWORD_STORE_DIR="${root}"
|
|||||||
;;
|
;;
|
||||||
--last-used)
|
--last-used)
|
||||||
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
|
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
|
||||||
entry="$(awk -F ': ' '{ print $2 }' /tmp/$USER-rofi-pass/last_used)"
|
entry="$(awk -F ': ' '{ print $2 }' "/tmp/$USER-rofi-pass/last_used")"
|
||||||
fi
|
fi
|
||||||
mainMenu
|
mainMenu
|
||||||
;;
|
;;
|
||||||
--show-last)
|
--show-last)
|
||||||
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
|
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
|
||||||
selected_password="$(awk -F ': ' '{ print $2 }' /tmp/$USER-rofi-pass/last_used)" showEntry
|
selected_password="$(awk -F ': ' '{ print $2 }' "/tmp/$USER-rofi-pass/last_used")" showEntry
|
||||||
else
|
else
|
||||||
mainMenu
|
mainMenu
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user