From: Ian Jackson Date: Sun, 27 Oct 2013 20:12:36 +0000 (+0000) Subject: pregen: wip X-Git-Tag: test~8 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?p=d.git;a=commitdiff_plain;h=ce7dd1d5b3660369c4656f7c78f5eb28e16f5719 pregen: wip --- diff --git a/evade-mail-pregen b/evade-mail-pregen index a375437..9fcafc6 100755 --- a/evade-mail-pregen +++ b/evade-mail-pregen @@ -45,7 +45,7 @@ sub comment_make ($) { sub run_generator { my @genargs = @_; - open P, "-!", $generator, @genargs or fail "fork $generator: $!"; + open P, "-|", $generator, @genargs or fail "fork $generator: $!"; while (

) { my ($alias,$comment); if (m/^\# user/) { @@ -70,6 +70,7 @@ sub run_generator { $by_number[$row->{Number}] = $row; $min_number = $row->{Number} if (!defined $min_number) || $min_number > $row->{Number}; + } } $?=0; $!=0; close P or fail "$generator $genargs[0] failed ($! $?)\n"; } @@ -126,8 +127,8 @@ $us: Losing track of next number ($wanted), due to use of -N; $us: will start next alias at #0, unless you say (e.g.) "range $wanted". END } - exec $generator, qw(update), $target->{Alias}, @ARGV; - fail "exec $generator: $!"; + exec $generator, qw(update), $target->{Alias}, @ARGV + or fail "exec $generator: $!"; } sub action_assign { @@ -185,12 +186,12 @@ for (;;) { last unless $ARGV[0] =~ m/^-/; my $arg = shift @ARGV; last if $arg =~ m/^--?$/; - while ($arg !~ m/^-$/) { + while ($arg =~ m/^-./) { if ($arg =~ s/^-[ldFm]/-/) { push @genopts, $arg; - } elsif ($arg =~ s/^-G//) { - $generator = $'; #'; - } elsif ($arg =~ s/^-N//) { + } elsif ($arg =~ s/^-G(.*)//) { + $generator = $1; + } elsif ($arg =~ s/^-N/-/) { $no_generate = 1; } else { badusage "unknown option \`$arg'"; @@ -209,16 +210,18 @@ $comment_pattern =~ m/^#/s or badusage "comment pattern must start with \`#'"; $comment_re = $comment_pattern; $comment_re =~ s/\W/\\$&/g; -($comment_re =~ s'\'([1-9]\d{0,8})'g) == 1 #' - or badusage "comment pattern must contain \`' exactly once"; +($comment_re =~ s'\\'([1-9]\d{0,8})'g) == 1 #' + or badusage "comment pattern (\`$comment_pattern')". + " must contain \`' exactly once"; -@ARGV or badusage "missing action\n"; +@ARGV or badusage "missing action"; my $action = shift @ARGV; fetch_list(); $action =~ y/-/_/; -my $actionsub = { no strict qw(refs); \&{"action_$action"}; } +my $actionsub; +{ no strict qw(refs); $actionsub = \&{"action_$action"}; } defined $actionsub or badusage "unknown action $action"; $actionsub->();