Bug 1426858

Summary: tlp-stat syntax error lines 1217 and 1221 unary operator expected
Product: [Fedora] Fedora Reporter: Eric Lavarde <elavarde>
Component: tlpAssignee: Jeremy Newton <alexjnewt>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: alexjnewt, oliver
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tlp-0.9-4.fc24 tlp-0.9-4.fc25 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-11 11:50:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric Lavarde 2017-02-25 20:34:07 UTC
Description of problem:
Calling tlp-stat end with two error messages due to syntax error in the script.

Version-Release number of selected component (if applicable):
tlp-0.9-2.fc25.noarch

How reproducible:
Always

Steps to Reproduce:
1. call tlp-stat

Actual results:
The output ends with:
/bin/tlp-stat: line 1217: [: -ne: unary operator expected
/bin/tlp-stat: line 1221: [: -ne: unary operator expected

Expected results:
No syntax error message.

Additional info:
Looking at the code, I guess that it's due to:
cat: /sys/class/power_supply/BAT1/energy_full_design: No such device
cat: /sys/class/power_supply/BAT1/energy_full: No such device
meaning that $ed and $ef are not set, which the code doesn't expect.

Comment 1 Jeremy Newton 2017-02-27 21:25:47 UTC
I would say this is due to both /sys/class/power_supply/BAT1/energy_full and /sys/class/power_supply/BAT1/charge_full being missing on your system. Can you confirm this?

Comment 2 Eric Lavarde 2017-02-28 05:56:57 UTC
Actually, the files were there but they were not related to any device (if I remove the battery, the message becomes "No such file or directory"). It was probably due to the battery being completely empty: after a load the files and their devices were there again.

Your analysis is kind of correct, but the script should be improved to catch cleanly such use case.

Comment 3 Jeremy Newton 2017-03-01 16:33:02 UTC
Understood, I've contacted upstream and I will be back-porting a fix.

Thanks for your feedback!

Comment 4 Fedora Update System 2017-03-03 02:51:19 UTC
tlp-0.9-4.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2017-3467d39a3e

Comment 5 Fedora Update System 2017-03-03 02:51:27 UTC
tlp-0.9-4.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2017-63643860fe

Comment 6 Fedora Update System 2017-03-03 22:49:44 UTC
tlp-0.9-4.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-3467d39a3e

Comment 7 Fedora Update System 2017-03-04 00:50:12 UTC
tlp-0.9-4.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-63643860fe

Comment 8 Fedora Update System 2017-03-11 11:50:23 UTC
tlp-0.9-4.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2017-03-11 12:20:25 UTC
tlp-0.9-4.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.