gbranden pushed a commit to branch master in repository groff. commit 1a572a793841ba5e7b341e99ae5325475a2acbb3 Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Sat Aug 2 07:41:18 2025 -0500
[gperl]: Revise usage and version messages. * contrib/gperl/gperl.pl: Rename scalar `version` to `gperl_version`. Add scalar `groff_version`, and make its value robust to use of the program directly from the source tree or in built form, copying a technique from groff's `chem` contributed component. Stop accepting abbreviated forms of `--help` and `--version` options, apart from `-h` and `-v`. Developers have over the decades come to repent of this old, terrible idea, because it prevents them from adding an option name that is a leading substring of another without changing the semantics of existing command lines. Bump minor component of `gperl_version` accordingly. (usage, version): Reuse subroutines from grog(1), updating usage message appropriately and formatting version report per GNU Coding Standards. NEWS: Report CLI change. Also revise comment header to stop stating that this contributed component is "part of groff"; it is not. See the "LICENSES" file in the groff source distribution (or at the top of its Git repository). Contributed components are not necessarily distributed under the GNU GPLv3, and this one is not--it uses GNU GPLv2 per its author's wishes. Also add a copyright notice for myself. I've never executed copyright assignment paperwork with the FSF, so my changes to gperl since 2022 can't be under the FSF's copyright. N.B., I don't actually know whether Bernd Warken or anyone else performed such assignment, either. Nobody automatically hands you that information when you become a GNU maintainer (or tells you where you can look for it). So the notice (and others) might require further revision. --- NEWS | 4 +++ contrib/gperl/ChangeLog | 17 +++++++++++ contrib/gperl/gperl.pl | 75 ++++++++++++++++++++++++++++++++----------------- 3 files changed, 71 insertions(+), 25 deletions(-) diff --git a/NEWS b/NEWS index d5e5df997..5411af872 100644 --- a/NEWS +++ b/NEWS @@ -759,6 +759,10 @@ Utilities Miscellaneous ------------- +* The contributed program gperl no longer accepts abbreviated forms of + the long options `--help` and `--version`. The respective synonymous + short options `-h` and `-v` remain. + * Font description files now support a variant of the "charset" directive: "charset-range" works like the existing "charset" directive except that the glyph descriptions use a `name` of the form diff --git a/contrib/gperl/ChangeLog b/contrib/gperl/ChangeLog index a014b8c37..0c3599d35 100644 --- a/contrib/gperl/ChangeLog +++ b/contrib/gperl/ChangeLog @@ -1,3 +1,20 @@ +2025-08-02 G. Branden Robinson <g.branden.robin...@gmail.com> + + * gperl.pl: Revise usage and version messages. Rename scalar + `version` to `gperl_version`. Add scalar `groff_version`, and + make its value robust to use of the program directly from the + source tree or in built form, copying a technique from groff's + `chem` contributed component. Stop accepting abbreviated forms + of `--help` and `--version` options, apart from `-h` and `-v`. + Developers have over the decades come to repent of this old, + terrible idea, because it prevents them from adding an option + name that is a leading substring of another without changing the + semantics of existing command lines. Bump minor component of + `gperl_version` accordingly. + (usage, version): Reuse subroutines from grog(1), updating usage + message appropriately and formatting version report per GNU + Coding Standards. + 2023-07-17 G. Branden Robinson <g.branden.robin...@gmail.com> * gperl.pl: Stop endorsing shebang line space myth. See diff --git a/contrib/gperl/gperl.pl b/contrib/gperl/gperl.pl index a96b4ae38..7dde1d628 100755 --- a/contrib/gperl/gperl.pl +++ b/contrib/gperl/gperl.pl @@ -1,25 +1,25 @@ #!/usr/bin/env perl -# gperl - add Perl part to groff files, this is the preprocessor for that - +# gperl - preprocess troff(1) input to execute embedded Perl code +# # Copyright (C) 2014-2020 Free Software Foundation, Inc. - +# 2025 G. Branden Robinson +# # Written by Bernd Warken <groff-bernd.warken...@web.de>. - -my $version = '1.2.6'; - -# This file is part of 'gperl', which is part of 'groff'. - -# 'groff' is free software; you can redistribute it and/or modify it +# Enhanced by: G. Branden Robinson <g.branden.robin...@gmail.com> +# +# This file is part of 'gperl'. +# +# 'gperl' is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. - -# 'groff' is distributed in the hope that it will be useful, but +# +# 'gperl' is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. - +# # You can find a copy of the GNU General Public License in the internet # at <http://www.gnu.org/licenses/gpl-2.0.html>. @@ -47,6 +47,17 @@ use Cwd; # $Bin is the directory where this script is located use FindBin; +my $gperl_version = '1.3.0'; +my $groff_version = 'DEVELOPMENT'; + +my $is_in_source_tree; +{ + $is_in_source_tree = 1 if '@VERSION@' eq '@' . 'VERSION' . '@'; +} + +if (!$is_in_source_tree) { + $groff_version = '@VERSION@'; +} ######################################################################## # system variables and exported variables @@ -81,24 +92,38 @@ if ($before_make) { $at_at{'G'} = '@g@'; } +(undef, undef, my $program_name) = File::Spec->splitpath($0); + +sub usage { + my $stream = *STDOUT; + my $had_error = shift; + $stream = *STDERR if $had_error; + my $gperl = $program_name; + print $stream "usage: $gperl [file ...]\n" . + "usage: $gperl {-v | --version}\n" . + "usage: $gperl {-h | --help}\n"; + unless ($had_error) { + # Omit some newlines due to `$\` voodoo. + print $stream "" . +"Filter troff(1) input, executing Perl code on lines between\n" . +"'.Perl start' and '.Perl end'. See the gperl(1) manual page."; + } + exit $had_error; +} + +sub version { + # Omit newline due to `$\` voodoo. + print "$program_name (groff $groff_version) $gperl_version"; + exit 0; +} ######################################################################## # options ######################################################################## -foreach (@ARGV) { - if ( /^(-h|--h|--he|--hel|--help)$/ ) { - print q(Usage for the 'gperl' program:); - print 'gperl [-] [--] [filespec...] normal file name arguments'; - print 'gperl [-h|--help] gives usage information'; - print 'gperl [-v|--version] displays the version number'; - print q(This program is a 'groff' preprocessor that handles Perl ) . - q(parts in 'roff' files.); - exit; - } elsif ( /^(-v|--v|--ve|--ver|--vers|--versi|--versio|--version)$/ ) { - print "gperl (groff @VERSION@) version $version"; - exit; - } +foreach my $arg (@ARGV) { + usage(0) if ($arg eq '-h' || $arg eq '--help'); + version() if ($arg eq '-v' || $arg eq '--version'); } _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit