Package: iwatch Version: 0.2.1-3 Severity: normal Tags: patch If a file being watched contains one of the formats available for substitution in a command, the command will not be executed. $ iwatch -c 'echo %f' -e close_write . [ 4/Nov/2009 13:43:20] IN_CLOSE_WRITE ./_%f_ [ 4/Nov/2009 13:43:20] * ./_%f_ is closed ^C
Expected output is like: $ ./iwatch -c 'echo %f' -e close_write . [ 4/Nov/2009 13:43:29] IN_CLOSE_WRITE ./_%f_ [ 4/Nov/2009 13:43:29] * ./_%f_ is closed [ 4/Nov/2009 13:43:29] * Command: echo ./_%f_ ./_%f_ ^C Fix is attached. -- System Information: Debian Release: 5.0.3 APT prefers stable APT policy: (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.26-2-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages iwatch depends on: ii libevent-perl 1.11-1 Generic Perl event loop ii liblinux-inotify2-perl 1:1.1-2.1+b1 scalable directory/file change not ii libmail-sendmail-perl 0.79-5 Send email from a perl script ii libxml-simpleobject-libx 0.53-1 Simple oo representation of an XML ii perl-modules 5.10.0-19lenny2 Core Perl modules ii postfix [mail-transport- 2.5.5-1.1 High-performance mail transport ag iwatch recommends no packages. iwatch suggests no packages. -- no debconf information
--- iwatch.ORIG 2009-11-04 09:06:35.000000000 +0100 +++ iwatch 2009-11-04 09:58:39.000000000 +0100 @@ -34,7 +34,7 @@ sub mywatch; sub pathwatch; sub getMask; -sub stringf; +sub stringf ($%); $Getopt::Std::STANDARD_HELP_VERSION = 1; my %options=(); @@ -395,18 +395,19 @@ } } -sub stringf() { - my $ind; - my ($string,%format) = @_; - foreach my $key (keys %format) { - $ind = index $string,"%$key"; - next if($ind == -1); - substr($string,$ind,2) = &{$format{$key}}; - $string = stringf($string,%format); - } +sub stringf($%) { + my ($string, %format) = @_; + my $re = join("|", map { "%".quotemeta } keys(%format)); + $string =~ s/$re/_stringf($&, \%format)/ge; $string; } +sub _stringf { + my ($s,$f) = @_; + $s =~ s/^\%//; + &{$f->{$s}}; +} + sub Usage { VERSION_MESSAGE(); HELP_MESSAGE();