Permalink
Browse files

Perl does not have a 'false' keyword.

In Perl, four values are false (0, "0", "", undef). Everything else is
considered true. In irssinotifier.pl, 'false' was an unquoted string, but
equivalent to the quoted string 'false', which evaluates to TRUE in boolean
context! Fortunately, Irssi::settings_add_bool doesn't evaluate the default
value in boolean context. It first coerces the value to an integer. The
string 'false' evaluates to 0 in numeric context, which in turn is false
in boolean context. The same would have happened given 'true', by the way.
This can all be very confusing, so let's just use the proper way of passing
booleans in Perl: as 0 and 1. :)

"use strict" prohibits the use of unquoted strings. It was commented, causing
the mistake to go unnoticed.
  • Loading branch information...
1 parent fcbdbbe commit 36e7d22df40e96c343785e9b7f196e1f29242ec1 Juerd Waalboer committed Jul 11, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 Irssi/irssinotifier.pl
@@ -1,4 +1,4 @@
-#use strict;
+use strict;
#use warnings;
use Irssi;
@@ -157,8 +157,8 @@ sub event_key_pressed {
Irssi::settings_add_str('IrssiNotifier', 'irssinotifier_encryption_password', 'password');
Irssi::settings_add_str('IrssiNotifier', 'irssinotifier_api_token', '');
-Irssi::settings_add_bool('IrssiNotifier', 'irssinotifier_away_only', false);
-Irssi::settings_add_bool('IrssiNotifier', 'irssinotifier_ignore_active_window', false);
+Irssi::settings_add_bool('IrssiNotifier', 'irssinotifier_away_only', 0);
+Irssi::settings_add_bool('IrssiNotifier', 'irssinotifier_ignore_active_window', 0);
Irssi::settings_add_int('IrssiNotifier', 'irssinotifier_require_idle_seconds', 0);
Irssi::signal_add('message irc action', 'public');

0 comments on commit 36e7d22

Please sign in to comment.