From 3c4356418238157e80135b41af892c6bcfd2b060 Mon Sep 17 00:00:00 2001 From: "supritsj@Arch" Date: Tue, 26 Nov 2024 19:29:10 +0530 Subject: [PATCH] use "xarg -0" instead of trim --- plugins/gpgs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/gpgs b/plugins/gpgs index 16e1750a..3d434c37 100755 --- a/plugins/gpgs +++ b/plugins/gpgs @@ -12,6 +12,7 @@ # Shell: POSIX compliant # Author: wassup05 +file=$1 selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} printf "(s)election/(c)urrent? [default=c] " @@ -19,18 +20,20 @@ read -r file_resp printf "(s)ign/(c)learsign/(d)etach-sig? [default=s] " read -r sig_resp -if [ "$file_resp" = "s" ]; then - files=$(tr '\0' '\n' < "$selection") -else - files=$1 -fi +getfiles(){ + if [ "$file_resp" = "s" ]; then + cat "$selection" + else + printf "%s\0" "$file" + fi +} if [ "$sig_resp" = "c" ]; then - printf "%s" "$files" | xargs -I{} gpg --clearsign {} + getfiles | xargs -0 -I{} gpg --clearsign {} elif [ "$sig_resp" = "d" ]; then - printf "%s" "$files" | xargs -I{} gpg --detach-sig --output "{}.sig" + getfiles | xargs -0 -I{} gpg --detach-sig --output "{}.sig" else - printf "%s" "$files" | xargs -I{} gpg --sign --output "{}.sig" {} + getfiles | xargs -0 -I{} gpg --sign --output "{}.sig" {} fi # Clear selection