Control: tags -1 + patch

Um. idk if I tested this on something that just doesn't fail but yeah,
retesting on my palmtop now, I repro your result. The correct spelling is
  read -r ONLINE 2>/dev/null < "./$x/online" || ONLINE=
(and likewise for all the other variables)
to void the errors /before/ trying to open the file, and clear on ENOENT,
like the cats do.

Reverting 2e7b352c7bac543702d221736ed251f0ecadbb68 won't have any ill
effect (-a -> ] && [ is a cosmetic change for all real shells),
so either doing that or applying the attached patch should be equivalent.

Best,
From b90a10a6993bc8c1d9f730fcb0fd27ebfd1d03c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <[email protected]>
Date: Sat, 1 Nov 2025 18:00:42 +0100
Subject: [PATCH] lspower: correctly silence errors & clear on ENOENT
X-Mutt-PGP: OS

Fixes: 2e7b352c7bac543702d221736ed251f0ecadbb68
---
 lspower | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lspower b/lspower
index 7935120..bae3bb1 100755
--- a/lspower
+++ b/lspower
@@ -5,12 +5,12 @@ cd /sys/class/power_supply 2>/dev/null ||
 
 for x in *; do
 	[ -e "./$x/type" ] || continue
-	read -r ONLINE < "./$x/online" 2>/dev/null
-	read -r PRESENT < "./$x/present" 2>/dev/null
-	#read -r TYPE < "./$x/type" 2>/dev/null
-	read -r STATUS < "./$x/status" 2>/dev/null
-	read -r CAPACITY < "./$x/capacity" 2>/dev/null
-	read -r HEALTH < "./$x/health" 2>/dev/null
+	read -r ONLINE 2>/dev/null < "./$x/online" || ONLINE=
+	read -r PRESENT 2>/dev/null < "./$x/present" || PRESENT=
+	#read -r TYPE 2>/dev/null < "./$x/type" || TYPE=
+	read -r STATUS 2>/dev/null < "./$x/status" || STATUS=
+	read -r CAPACITY 2>/dev/null < "./$x/capacity" || CAPACITY=
+	read -r HEALTH 2>/dev/null < "./$x/health" || HEALTH=
 	ICON="?"
 
 	if [ "$ONLINE" != 1 ] && [ "$PRESENT" != 1 ]; then
-- 
2.39.5

Attachment: signature.asc
Description: PGP signature

Reply via email to