1
0
mirror of https://github.com/wfjm/w11.git synced 2026-01-30 21:52:12 +00:00

bin/*: drop superfluous exists for

This commit is contained in:
wfjm
2019-08-02 23:34:18 +02:00
parent 4f447bc05a
commit 84540478cd
16 changed files with 90 additions and 74 deletions

View File

@@ -1,10 +1,11 @@
#!/usr/bin/perl -w
# $Id: github_md2html 1172 2019-06-29 07:27:24Z mueller $
# $Id: github_md2html 1189 2019-07-13 16:41:07Z mueller $
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2016-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# Revision History:
# Date Rev Version Comment
# 2019-07-13 1189 1.1.5 drop superfluous exists for $opts
# 2018-12-18 1089 1.1.4 add and use bailout
# 2018-10-19 1057 1.1.3 add --verbose; don't list up-to-date files anymore
# 2018-07-02 1033 1.1.2 use non-greedy match in -stand code
@@ -34,7 +35,7 @@ my $url_css_ghmdbody = "https://wfjm.github.io/css/github-markdown-body.css";
autoflush STDOUT 1 if (-p STDOUT); # autoflush if output into pipe
autoflush STDOUT 1 if (-t STDOUT); # autoflush if output into term
if (exists $opts{help}) {
if ($opts{help}) {
print_help();
exit 0;
}
@@ -77,7 +78,7 @@ sub do_request {
for (my $nretry=0; $nretry<10; $nretry++) {
my $res = $ua->request($req);
if (exists $opts{dump}) {
if ($opts{dump}) {
print "------------------------------------------------------\n";
print "response for $ifile\n";
print $res->as_string,"\n";
@@ -115,7 +116,7 @@ sub do_request {
sub do_md2html {
my ($ifile) = @_;
my $ofile = "$ifile.html";
my $doit = exists $opts{force} || (not -e $ofile);
my $doit = $opts{force} || (not -e $ofile);
unless ($doit) {
# -M returns <script_start_time> - <file_modify_time> in fractional days
@@ -166,7 +167,7 @@ sub do_md2html {
$req->content($idata);
}
if (exists $opts{dump}) {
if ($opts{dump}) {
print "------------------------------------------------------\n";
print "request for $ifile\n";
print $req->as_string,"\n";
@@ -177,7 +178,7 @@ sub do_md2html {
my $html = $res->decoded_content;
if (exists $opts{standalone}) {
if ($opts{standalone}) {
$html =~ s{<a(.*?)href="(.+?)"}{ # non-greedy matches !!
my $hopt = $1;
my $href = "$2";
@@ -185,15 +186,15 @@ sub do_md2html {
if ($href =~ m|^(.+\.md)(#.*)?$|) {
$href = $1 . '.html';
$href .= $2 if defined $2;
print " hmap: $href\n" if exists $opts{trace};
print " hmap: $href\n" if $opts{trace};
} else {
if (-d "$ifile_path/$href") {
$href =~ s|/$||; # drop trailing '/'
if (-r "$ifile_path/$href/README.md") {
$href .= '/README.md.html';
print " dmap: $href: ok\n" if exists $opts{trace};
print " dmap: $href: ok\n" if $opts{trace};
} else {
print " dmap: $href: skipped\n" if exists $opts{trace};
print " dmap: $href: skipped\n" if $opts{trace};
}
}
}