groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 03/16: [chem]: Revise usage message, `argv[0]` handling.


From: G. Branden Robinson
Subject: [groff] 03/16: [chem]: Revise usage message, `argv[0]` handling.
Date: Sun, 15 Dec 2024 16:34:37 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 0c155ccb0bd9494f7dd28c051fb3d48a15070f9d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Dec 11 12:09:21 2024 -0600

    [chem]: Revise usage message, `argv[0]` handling.
    
    * contrib/chem/chem.pl: Revise approach to determining program name.
      This reverts the change on 9 December; the Perl interpreter does not
      populate `argv[0]` the same way that the shell typically does with
      execve(2).  Drop global scalar `chem` in favor of a new global scalar
      `prog`, populated by `File::Spec->splitpath()`.
    
      (usage, version): Migrate from `chem` to `prog`.
    
      (usage): Report only the "basename" of the script.  Revise and
      shorten command description.
---
 contrib/chem/ChangeLog | 11 +++++++++++
 contrib/chem/chem.pl   | 22 ++++++++++------------
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/contrib/chem/ChangeLog b/contrib/chem/ChangeLog
index c7b28686a..365fc6b0a 100644
--- a/contrib/chem/ChangeLog
+++ b/contrib/chem/ChangeLog
@@ -1,3 +1,14 @@
+2024-12-11  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * chem.pl: Revise approach to determining program name.  This
+       reverts the change on 9 December; the Perl interpreter does not
+       populate `argv[0]` the same way that the shell typically does
+       with execve(2).  Drop global scalar `chem` in favor of a new
+       global scalar `prog`, populated by `File::Spec->splitpath()`.
+       (usage, version): Migrate from `chem` to `prog`.
+       (usage): Report only the "basename" of the script.  Revise and
+       shorten command description.
+
 2024-12-09  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * chem.pl (usage): Revise usage message.  Organize like other
diff --git a/contrib/chem/chem.pl b/contrib/chem/chem.pl
index 1e387149a..64cd1abe5 100755
--- a/contrib/chem/chem.pl
+++ b/contrib/chem/chem.pl
@@ -40,11 +40,11 @@ use Math::Trig;
 
 # for catfile()
 use File::Spec;
+(undef,undef,my $prog)=File::Spec->splitpath($0);
 
 # $Bin is the directory where this script is located
 use FindBin;
 
-my $chem;
 my $File_chem_pic;
 
 my $is_in_source_tree;
@@ -58,13 +58,11 @@ if ($is_in_source_tree) {
   my $chem_dir = $FindBin::Bin;
   $makevar{'G'} = '';
   $File_chem_pic = File::Spec->catfile($chem_dir, 'chem.pic');
-  $chem = 'chem';
 } else {
   $groff_version = '@VERSION@';
   $makevar{'G'} = '@g@';
   $makevar{'PICDIR'} = '@PICDIR@';
   $File_chem_pic = File::Spec->catfile($makevar{'PICDIR'}, 'chem.pic');
-  $chem = $makevar{'G'} . 'chem';
 }
 
 
@@ -1198,22 +1196,22 @@ sub setparams {
 # This also informs the user with multiple versions available which they
 # are running.
 sub usage {
+  my $G = $makevar{'G'};
   print <<EOF;
-usage: $0 [file ...]
-usage: $0 { -v | --version }
-usage: $0 { -h | --help }
-
-$chem is a groff(1) preprocessor for producing chemical structure
-diagrams.  It produces input for the $makevar{'G'}pic preprocessor.  If
-no file operands are given, or if file is "-", the standard input stream
-is read.  See the $chem(1) manual page.
+usage: $prog [file ...]
+usage: $prog { -v | --version }
+usage: $prog { -h | --help }
+
+$prog is a groff(1) preprocessor for producing chemical structure
+diagrams.  It produces input for the ${G}pic(1) preprocessor.  See the
+$prog(1) manual page.
 EOF
 }
 
 
 sub version {
   print <<EOF;
-$chem (groff $groff_version) $chem_version
+$prog (groff $groff_version) $chem_version
 $copyright
 License GPLv2: GNU GPL version 2
 <https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]