From 657223f051c929ffca4b11869caa5ab7375afac7 Mon Sep 17 00:00:00 2001 From: Petr Nyc Date: Fri, 5 Jun 2026 12:02:57 +0200 Subject: [PATCH] my mods for watcher.pl take 1 --- bin/watcher.pl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bin/watcher.pl b/bin/watcher.pl index 65de5a3..ef75545 100755 --- a/bin/watcher.pl +++ b/bin/watcher.pl @@ -22,7 +22,7 @@ use Fcntl qw(O_RDWR O_NONBLOCK); use IO::Select; use POSIX qw(strftime mkfifo); -my $SCRIPT = '/home/vmarek/watcher.pl'; +my $SCRIPT = '/Users/jetpac/bin/watcher.pl'; my $LINES = 20; my $COOLDOWN = $ENV{WATCHER_COOLDOWN} || 60; my $LOG_FILE = $ENV{WATCHER_LOG} || ''; @@ -259,11 +259,9 @@ sub rendered_last_lines { sub start_pipe { my ($sock, $pane, $event_path) = @_; - my $cmd = shell_quote($^X) . ' ' . - shell_quote($SCRIPT) . ' --watcher ' . - shell_quote($sock) . ' ' . - shell_quote($pane) . ' ' . - shell_quote($event_path); + my $cmd = join ' ', + map { tmux_pipe_shell_quote($_) } + ($^X, $SCRIPT, '--watcher', $sock, $pane, $event_path); return run_quiet( 'tmux', '-S', $sock, @@ -372,6 +370,13 @@ sub shell_quote { return "'$s'"; } +sub tmux_pipe_shell_quote { + my ($s) = @_; + # pipe-pane expands percent escapes in the shell command before execution. + $s =~ s/%/%%/g; + return shell_quote($s); +} + sub log_msg { my ($msg) = @_; my $ts = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime());