commit 35a3cb2e8ad43e8bb796570379ccd80d0b3a37bc
parent ef3102c5e9c8c927afc0c463f0bbe372a75a815b
Author: Chris Down <chris@chrisdown.name>
Date: Sun, 29 Oct 2017 02:04:37 +0000
Use /proc/self/fd/2 instead of /dev/stderr where possible
/dev/stderr is not standardised, whereas /proc/self/fd is provided by
the kernel. Add a fallback for non-Linux.
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/clipmenud b/clipmenud
@@ -12,8 +12,15 @@ cache_file=$cache_dir/line_cache
lock_file=$cache_dir/lock
lock_timeout=2
+xsel_log=/dev/null
+for file in /proc/self/fd/2 /dev/stderr; do
+ [[ -e "$file" ]] || continue
+ xsel_log="$file"
+ break
+done
+
_xsel() {
- timeout 1 xsel --logfile /dev/stderr "$@"
+ timeout 1 xsel --logfile "$xsel_log" "$@"
}
get_first_line() {