Open carnager opened 6 years ago
I'm happy to change this behavior, but I'm not sure what I would change it to. What would you rather Net::MPD do with $mpd->add(undef)
?
I guess it should simply do nothing and spit a warning about not being able to add "nothing"
The trouble for me is it seems a bit strange for add('')
and add(undef)
to behave so differently. Perhaps you could share the use case you have where add(undef)
adding the entire library is problematic.
From my perspective undef should be treated special since it also generates these warnings:
Use of uninitialized value $arg in substitution (s///) at /usr/share/perl5/Net/MPD.pm line 89, <GEN0> line 4411. Use of uninitialized value $arg in concatenation (.) or string at /usr/share/perl5/Net/MPD.pm line 90, <GEN0> line 4411.
And that '' might be send by intention but undef not and the behaviour will mostly just hide/mask bugs.
Best regards Fritz
That's a good argument. I will implement some argument checking against undef when I return from vacation.
Great thanks! And enjoy your holidays!
Just to add this input: mpc behaves the same way. If you run mpc add
(which will wait for stdin) and then hit Ctrl+d, nothing will be added.
MPD protocol specifies that an empty string adds the whole library (for historical reasons "/" also works). Net::MPD on the other hand also reacts this way if a value is not initialized at all.
Code example: