summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2018-06-02 10:39:18 -0600
committerAaron Ball <nullspoon@oper.io>2018-06-02 10:39:18 -0600
commitc0b905ef5cacb1f52dedde0d329c223d3dd29a90 (patch)
treec30a6fa2dd79693c55634a214296644912310cf3
parented18399ed844789b161b947f3000fc393f85cc0d (diff)
downloadbin-c0b905ef5cacb1f52dedde0d329c223d3dd29a90.tar.gz
bin-c0b905ef5cacb1f52dedde0d329c223d3dd29a90.tar.xz
pt:Fixed various printf statements
Some passwords that started with one or two - characters would break printf. Added the -- switch to avoid further switch parsing. Also quoted a couple of variables to avoid problems with spaces. Changed xdotool type rate to 20 ms between characters, since some services don't like people who type with 15 ms between chars.
-rwxr-xr-xpt12
1 files changed, 6 insertions, 6 deletions
diff --git a/pt b/pt
index 91aa0cc..eb1674a 100755
--- a/pt
+++ b/pt
@@ -29,7 +29,7 @@ function log {
if [[ $(type -p notify-send) != '' ]]; then
notify-send "$(basename ${0}):" "${msg}"
fi
- echo ${msg}
+ printf -- '%s\n' "${msg}"
}
@@ -73,7 +73,7 @@ getfield() {
local _delim="${2:-}"
local _field="${3:-}"
- printf "${_content}" \
+ printf -- "%s" "${_content}" \
| sed -n "s/${_field}${_delim} *\(.*\)/\1/p" \
| head -n 1
}
@@ -96,11 +96,11 @@ function main {
# Check if the password exists in the store
# Also, copy the contents into a variable if it exists
- _passentry=$(pass ${@} 2>/dev/null)
+ _passentry="$(pass ${@} 2>/dev/null)"
[[ $? -gt 0 ]] && log "Error: '${@}' is not in the password store" && exit 1
# Parse pass output into appropriate variables
- _passpassword=$(printf "${_passentry}" | head -n1)
+ _passpassword=$(printf -- "%s" "${_passentry}" | head -n1)
_passusername=$(getfield "${_passentry}" ':' username)
_passdelim=$(getfield "${_passentry}" ':' delim)
_passsubmit=$(getfield "${_passentry}" ':' submit)
@@ -113,9 +113,9 @@ function main {
fi
# Type the password
- xdotool type --delay 15 "${_passusername}"
+ xdotool type --delay 20 "${_passusername}"
xdotool key "${_delim}"
- xdotool type --delay 15 "${_passpassword}"
+ xdotool type --delay 20 "${_passpassword}"
[ "${_submit}" = 1 ] && xdotool key Return
}

Generated by cgit