[PATCH] clip(): support single-binary coreutils

Graham Christensen graham at grahamc.com
Fri Dec 20 04:07:19 CET 2019


I don't quite grok the patch, however it has been part of the Nixpkgs
tree since 2016:
https://github.com/NixOS/nixpkgs/blob/c0628397e14f6ad4307cfa8a34738af88833e51f/pkgs/tools/security/pass/set-correct-program-name-for-sleep.patch

Sending it upstream to a public review, and in case it is useful for
other distributions who also use a single-binary coreutils.

---
 src/password-store.sh  | 4 ++--
 src/platform/cygwin.sh | 4 ++--
 src/platform/darwin.sh | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index 77f3eda..76bbecc 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -173,11 +173,11 @@ clip() {
 	# This base64 business is because bash cannot store binary data in a shell
 	# variable. Specifically, it cannot store nulls nor (non-trivally) store
 	# trailing new lines.
-	pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
+	pkill -P $(pgrep -f "^$sleep_argv0") 2>/dev/null && sleep 0.5
 	local before="$("${paste_cmd[@]}" 2>/dev/null | $BASE64)"
 	echo -n "$1" | "${copy_cmd[@]}" || die "Error: Could not copy data to the clipboard"
 	(
-		( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '$CLIP_TIME' & wait" )
+		( exec -a "$sleep_argv0" bash <(echo trap 'kill %1' TERM\; sleep "$CLIP_TIME & wait") )
 		local now="$("${paste_cmd[@]}" | $BASE64)"
 		[[ $now != $(echo -n "$1" | $BASE64) ]] && before="$now"

diff --git a/src/platform/cygwin.sh b/src/platform/cygwin.sh
index 5a8d5ea..423e0ce 100644
--- a/src/platform/cygwin.sh
+++ b/src/platform/cygwin.sh
@@ -3,11 +3,11 @@

 clip() {
 	local sleep_argv0="password store sleep on display $DISPLAY"
-	pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
+	pkill -P $(pgrep -f "^$sleep_argv0") 2>/dev/null && sleep 0.5
 	local before="$($BASE64 < /dev/clipboard)"
 	echo -n "$1" > /dev/clipboard
 	(
-		( exec -a "$sleep_argv0" sleep "$CLIP_TIME" )
+		( exec -a "$sleep_argv0" bash <(echo sleep "$CLIP_TIME") )
 		local now="$($BASE64 < /dev/clipboard)"
 		[[ $now != $(echo -n "$1" | $BASE64) ]] && before="$now"
 		echo "$before" | $BASE64 -d > /dev/clipboard
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 342ecce..9e12837 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -3,11 +3,11 @@

 clip() {
 	local sleep_argv0="password store sleep for user $(id -u)"
-	pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
+	pkill -P $(pgrep -f "^$sleep_argv0") 2>/dev/null && sleep 0.5
 	local before="$(pbpaste | $BASE64)"
 	echo -n "$1" | pbcopy
 	(
-		( exec -a "$sleep_argv0" sleep "$CLIP_TIME" )
+		( exec -a "$sleep_argv0" bash <(echo sleep "$CLIP_TIME") )
 		local now="$(pbpaste | $BASE64)"
 		[[ $now != $(echo -n "$1" | $BASE64) ]] && before="$now"
 		echo "$before" | $BASE64 -d | pbcopy
--
2.23.1


More information about the Password-Store mailing list