Skip to content

Commit

Permalink
Perl does not have a 'false' keyword.
Browse files Browse the repository at this point in the history
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
Juerd committed Jul 11, 2012
1 parent fcbdbbe commit 36e7d22
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Irssi/irssinotifier.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#use strict;
use strict;
#use warnings;

use Irssi;
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 36e7d22

Please sign in to comment.