Re: [PATCH] Avoiding warnings when piping to sensors-detect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jean.

> Hi Jaromir,
> 
> On Thu, 25 Jul 2013 12:49:51 -0400 (EDT), Jaromir Capik wrote:
> > The attached patch fixes <STDIN> handling when the user
> > input is taken from /dev/null.
> > I know this way of generating the config is undocumented
> > and therefore unsupported, but it seems people use it
> > that way as the script doesn't support running in
> > batch mode.
> > 
> > The patch was created for 3.3.4, but can be directly
> > applied on the latest sources too.
> > 
> > Please, merge the fix.
> 
> Hmm, as far as I can see this solves the same problem as this patch of
> mine I posted some months ago:
> http://marc.info/?l=lm-sensors&m=135091022118747&w=2
> 
> The only reason why I did not commit it yet is that I was waiting for
> feedback, but the original requester never provided it :(
> 
> If my patch works for you and your users then I'll just apply it.

I was unable to apply your patch directly, but
I believe it must work correctly.
Having a switch is always better than piping.
However, I know about users who already built their
solution with redirection and that's why I'd like to
propose one tiny modification of your patch in order
to make it more robust for cases like that.

Please, teplace the following line:

	return <STDIN>;

with this:

	return <STDIN> || '';


This would prevent the script from printing warnings about uninitialised
value. <STDIN> acts as uninitialised value when there are no more data
on the standard input. The modified expression returns empty string instead.

Regardless of the fact, that users should not use it that way,
it's more safe/correct.

Thanks in advance.

Regards,
Jaromir.

--
Jaromir Capik
Red Hat Czech, s.r.o.
Software Engineer / BaseOS

Email: jcapik@xxxxxxxxxx
Web: www.cz.redhat.com
Red Hat Czech s.r.o., Purkynova 99/71, 612 45, Brno, Czech Republic
IC: 27690016 

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors




[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux