httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sander Temme <scte...@apache.org>
Subject Re: apxs -q [end of statement]
Date Thu, 01 Feb 2007 17:19:00 GMT

On Dec 8, 2006, at 1:56 PM, William A. Rowe, Jr. wrote:

> It always irked me that apxs -q {arbitraryvariable} throws up.   
> Which ones
> are valid anyways?

Yes, highly irksome.  How can Joe Developer find out which variables  
APXS knows?  Yes, they can read ${installbuilddir}/config_vars.mk,  
but how is that obvious?

> The attached patch would provide a list of the values from apxs -q
> if no variable name is passed.

+1

> Feedback?  If the list likes, please commit.

Yes! Like! I extended it a little bit to pretty-print the list.

Thoughts?

S.

-- 
sctemme@apache.org            http://www.temme.net/sander/
PGP FP: 51B4 8727 466A 0BC3 69F4  B7B8 B2BE BC40 1529 24AF


Index: support/apxs.in
===================================================================
--- support/apxs.in     (revision 501957)
+++ support/apxs.in     (working copy)
@@ -155,7 +155,7 @@
my $rc;
($rc, @ARGV) = &Getopts("qn:gco:I+D+L+l+W+S+eiaAp", @ARGV);
&usage if ($rc == 0);
-&usage if ($#ARGV == -1 and not $opt_g);
+&usage if ($#ARGV == -1 and not $opt_g and not $opt_q);
&usage if (not $opt_q and not ($opt_g and $opt_n) and not $opt_i and  
not $opt_c and not $opt_e);
#   argument handling
@@ -303,8 +303,26 @@
      ##
      ##  QUERY INFORMATION
      ##
-    my $result = get_vars(@args);
-    print "$result\n";
+    my $result;
+    if ($#args >= 0) {
+        $result = get_vars(@args);
+        print "$result\n";
+    } else {
+        # -q without var name prints all variables and their values
+        # Variable names in alphabetic order
+        my @vars = sort {uc($a) cmp uc($b)} keys %config_vars;
+
+        # Make the left column as wide as the longest variable name
+        my $width = 0;
+        foreach (@vars) {
+            my $l = length $_;
+            $width = $l unless ($l <= $width);
+        }
+
+        foreach (@vars) {
+            printf "%-${width}s = %s\n", $_, $config_vars{$_};
+        }
+    }
}
my $apr_config = get_vars("APR_CONFIG");




Mime
View raw message