From ab4f8d32912e6d3e003d1b43152c0c18c442d7ef Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Mon, 17 Mar 2008 06:49:44 +0100 Subject: [PATCH] New function xsystem_hint, for autoreconf. * lib/Autom4te/FileUtils.pm (handle_exec_errors): New argument $hint, show if the executing program does not exist. (xsystem_hint): New function, like xsystem but allows to pass a hint. Signed-off-by: Ralf Wildenhues --- ChangeLog | 7 +++++++ lib/Automake/FileUtils.pm | 42 ++++++++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2918bbaab..465d94142 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-03-17 Ralf Wildenhues + + * lib/Autom4te/FileUtils.pm (handle_exec_errors): New argument + $hint, show if the executing program does not exist. + (xsystem_hint): New function, like xsystem but allows to pass + a hint. + 2008-03-11 Peter Breitenlohner Implement the `notrans_' prefix for untransformed manpages. diff --git a/lib/Automake/FileUtils.pm b/lib/Automake/FileUtils.pm index 34c48e32e..2200be049 100644 --- a/lib/Automake/FileUtils.pm +++ b/lib/Automake/FileUtils.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ use vars qw (@ISA @EXPORT); @EXPORT = qw (&open_quote &contents &find_file &mtime &update_file &up_to_date_p - &xsystem &xqx &dir_has_case_matching_file &reset_dir_cache); + &xsystem &xsystem_hint &xqx &dir_has_case_matching_file &reset_dir_cache); =item C @@ -231,23 +231,32 @@ sub up_to_date_p ($@) } -=item C +=item C Display an error message for C<$command>, based on the content of C<$?> and C<$!>. Be quiet if the command exited normally -with C<$expected_exit_code>. +with C<$expected_exit_code>. If C<$hint> is given, display that as well +if the command failed to run at all. =cut -sub handle_exec_errors ($;$) +sub handle_exec_errors ($;$$) { - my ($command, $expected) = @_; + my ($command, $expected, $hint) = @_; $expected = 0 unless defined $expected; + if (defined $hint) + { + $hint = "\n" . $hint; + } + else + { + $hint = ''; + } $command = (split (' ', $command))[0]; if ($!) { - fatal "failed to run $command: $!"; + fatal "failed to run $command: $!" . $hint; } else { @@ -316,6 +325,25 @@ sub xsystem (@) } +=item C + +Same as C, but allows to pass a hint that will be displayed +in case the command failed to run at all. + +=cut + +sub xsystem_hint (@) +{ + my ($hint, @command) = @_; + + verb "running: @command"; + + $! = 0; + handle_exec_errors "@command", 0, $hint + if system @command; +} + + =item C Return the contents of C<$file_name>. -- 2.47.2