hw.pl に「更新したい日記が既にあることが保証されている」という状況で本来の「ちょっとした更新」と同じ動作を行うオプション(-x オプション)を追加するパッチを作ってみました。hw.pl 1.0.2 に対するパッチです。
--- hw.pl-1.0.2 Thu Sep 9 22:23:48 2004
+++ hw.pl Thu Sep 30 05:51:32 2004
@@ -15,7 +15,7 @@
# modify it under the same terms as Perl itself.
#
use strict;
-my $VERSION = "1.0.2";
+my $VERSION = "1.0.2+";
use LWP::UserAgent;
use HTTP::Request::Common;
@@ -89,6 +89,7 @@
my %cmd_opt = (
'd' => 0, # "debug" flag.
't' => 0, # "trivial" flag.
+ 'x' => 0, # "trivial update for existing diaries" flag
'u' => "", # "username" option.
'p' => "", # "password" option.
'a' => "", # "agent" option.
@@ -101,12 +102,13 @@
);
$Getopt::Std::STANDARD_HELP_VERSION = 1;
-getopts("tdu:p:a:T:cg:f:Mn:", \%cmd_opt) or error_exit("Unknown option.");
+getopts("txdu:p:a:T:cg:f:Mn:", \%cmd_opt) or error_exit("Unknown option.");
if ($cmd_opt{d}) {
print_debug("Debug flag on.");
print_debug("Cookie flag on.") if $cmd_opt{c};
print_debug("Trivial flag on.") if $cmd_opt{t};
+ print_debug("Super trivial flag on.") if $cmd_opt{x};
&VERSION_MESSAGE();
}
@@ -304,6 +306,12 @@
sub update_diary_entry($$$$$$) {
my ($year, $month, $day, $title, $body, $imgfile) = @_;
+ if ($cmd_opt{x}) { # super trivial mode. no CLEAR, no CREATE.
+ $cmd_opt{t} = 1;
+ doit_and_retry("update_diary_entry: POST.", sub { return post_it($year, $month, $day, $title, $body, $imgfile) });
+ return;
+ }
+
if ($cmd_opt{t}) {
# clear existing entry. if the entry does not exist, it has no effect.
doit_and_retry("update_diary_entry: CLEAR.", sub { return post_it($year, $month, $day, "", "", "") });このオプションを -t オプションのかわりに使うとキーワードリンクが消失する副作用([id:rna:20040923#p4])がなくなります。ただし、更新したい日記がサーバ上にない場合には日記が作成されず終了してしまうので注意してください。この場合でもエラーメッセージは出力しないので更新したつもりで実は更新していなかったという事故が起こり得ます。そんなわけでこのパッチは危険を覚悟の上でご利用下さい。