Package: iwatch
Version: 0.2.2
Severity: normal
Hi,
iwatch had - for as long as I dare to remember - a somewhat strained
relationship with UTF-8 characters. Exempli gratia:
First shell:
iwatch -v -c 'ls %f' -e create .
Second shell:
touch mö
Output (first shell):
Watch .
[ 3/Jan/2011 23:24:35] IN_CREATE ./mö
[ 3/Jan/2011 23:24:35] * Command: ls ./mö
ls: cannot access ./mö: No such file or directory
I decided not to work around this behaviour any longer and try to get
iwatch to correctly pass on UTF-8 chars. And down Perl's
UTF-8/utf8/PerlIO hole I went... I have two very small patches
(+2 lines each, appended) that seem to produce what I like to think
could be correct behaviour. I tested variant 1 (see
iwatch.variant1.diff) and have it in (very limited) production use.
I would be happy to discuss the patches if anybody's interested - I
still haven't quite grasped what I actually did.
Best Regards,
Hagen Fuchs
-- System Information:
Debian Release: 5.0.7
Architecture: i386 (i686)
Kernel: Linux 2.6.26-2-686 (SMP w/2 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8) (ignored: LC_ALL
set to en_GB.utf8)
Shell: /bin/sh linked to /bin/bash
--- iwatch 2011-01-03 22:29:06.000000000 +0100
+++ iwatch.variant1 2011-01-03 22:33:32.000000000 +0100
@@ -416,6 +416,8 @@
$command =~ /^(.+)$/;
return if(!defined($1));
my $securecommand = $1;
+ # Force byte-string semantics [why does that work?].
+ utf8::downgrade($securecommand) if (utf8::is_utf8($securecommand));
system("$securecommand");
}
if(defined($Message) && $Path->{'alert'}) {
--- iwatch 2011-01-03 22:29:06.000000000 +0100
+++ iwatch.variant2 2011-01-03 22:32:23.000000000 +0100
@@ -19,6 +19,9 @@
use XML::SimpleObject::LibXML;
use POSIX;
use Sys::Syslog;
+# Force UTF-8 interpretation of strings and IO.
+use encoding 'utf-8';
+use open qw|:utf8 :std|;
my $PROGRAM = "iWatch";
my $VERSION = "0.2.2";