aboutsummaryrefslogtreecommitdiffstats
path: root/pinentry-rofi.sh
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2023-08-07 08:32:49 +0200
committerMatěj Cepl <mcepl@cepl.eu>2023-08-11 11:59:01 +0200
commit764e0447b1d80d42ba8b28b5ca48b39652615f0b (patch)
treea8954279a2432727fa1aa8a751ee5c8222ce0816 /pinentry-rofi.sh
parent7a460a11a6a2ffe806fb3090a6c5adc72ee281ea (diff)
downloadpinentry-rofi-764e0447b1d80d42ba8b28b5ca48b39652615f0b.tar.gz
fix: fix removing element from a Bash array (it needs to be reinitialized).
Also, the output of `systemctl --user show-environment` contains new lines, not only spaces.
Diffstat (limited to 'pinentry-rofi.sh')
-rwxr-xr-xpinentry-rofi.sh16
1 files changed, 8 insertions, 8 deletions
diff --git a/pinentry-rofi.sh b/pinentry-rofi.sh
index 45e8d4e..0a1ce47 100755
--- a/pinentry-rofi.sh
+++ b/pinentry-rofi.sh
@@ -121,7 +121,7 @@ while : ; do
assuan_send "OK"
elif [[ "$line" =~ ^SETKEYINFO ]] ; then
IFS=" " read -ra line_arr <<< "$line"
- unset "line_arr[0]"
+ unset "line_arr[0]" && line_arr=("${line_arr[@]}")
if [[ "${line_arr[0]}" =~ ^--clear ]] ; then
keyinfo=""
else
@@ -141,7 +141,7 @@ while : ; do
#SETDESC Please enter the passphrase for the ssh key%0A ke:yf:in:ge:rp:ri:nt
# rofi << "-mesg" << $1.gsub("<", "&lt;").gsub(/%([0-9A-Fa-f]{2})/) { $1.to_i(16).chr }
IFS=" " read -ra line_arr <<< "$line"
- unset "line_arr[0]"
+ unset "line_arr[0]" && line_arr=("${line_arr[@]}")
win_mesg="${line_arr[*]}"
assuan_send "OK"
elif [[ "$line" =~ ^SETPROMPT ]] ; then
@@ -151,22 +151,22 @@ while : ; do
assuan_send "OK"
elif [[ "$line" =~ ^GETPIN ]] ; then
passw=None
- sys_env="$(systemctl --user show-environment)"
+ sys_env="$(systemctl --user show-environment | tr -s " \t\n" " ")"
IFS=" " read -ra sys_env_arr <<< "$sys_env"
for env_line in "${sys_env_arr[@]}" ; do
log_debug "env_line=${env_line}"
# GPIN_VALID=re.compile(r)
- if [[ "$env_line" =~ ^[A-Za-z_]+=\(.\+\)$ ]] ; then
+ if [[ "$env_line" =~ ^([A-Za-z][A-Za-z_]*)=(.+)$ ]] ; then
log_debug "env_match=${BASH_REMATCH[*]}"
export "${BASH_REMATCH[1]}=${BASH_REMATCH[2]}"
fi
done
-
- rofi_cmd+=" -p ${win_prompt}"
- rofi_cmd+=" -title ${win_title}"
+ rofi_cmd+=" -p '${win_prompt}'"
+ rofi_cmd+=" -title '${win_title}'"
if [[ -n "${win_mesg}" ]] ; then
- rofi_cmd+=" -mesg ${win_mesg}"
+ rofi_cmd+=" -mesg '${win_mesg}'"
fi
+ log_debug "${rofi_cmd}"
passw="$(eval "${rofi_cmd}")"
passw_err=$?
if [[ ${passw_err} -ne 0 ]] ; then