not sure if this is relevant, but on my system BAT0 does not exist and neither does "charge_now"

perhaps the folder path is os version specific and I'm off-track??? but I would not expect something fundamental to be arbitrary.

I'm running ubuntu hardy 8.04 on a Toshiba Laptop, and what I have is:

/sys/class/power_supply/
ADP1
BAT1

and inside of BAT1 instead of "charge_" everything says "energy_"

/sys/class/power_supply/BAT1
energy_full
energy_now

while I agree with the bug poster about the dangers of parsing LS and enjoyed reading the very well written article that he points to.

In this scenario we are dealing with well-known names provided by the system. so I think it is safe in this specific scenario to parse a name when we already know in advance what that name should be.

The only question becomes one of security, if someone put a bogus name with a newline to fool us, would anything bad happen? I suspect that the answer is the worse that could happen is an error message.