pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/bootstrap Added a function get_optarg that avoids code...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/92a2d0d41103
branches:  trunk
changeset: 494501:92a2d0d41103
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed May 25 07:06:54 2005 +0000

description:
Added a function get_optarg that avoids code duplication in the option
parsing code. For maximum portability it uses the expr(1) command
instead of sed(1), the same way as it is done in the core of the latest
GNU configure scripts.

diffstat:

 bootstrap/bootstrap |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (42 lines):

diff -r f141f32f9425 -r 92a2d0d41103 bootstrap/bootstrap
--- a/bootstrap/bootstrap       Wed May 25 03:39:44 2005 +0000
+++ b/bootstrap/bootstrap       Wed May 25 07:06:54 2005 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: bootstrap,v 1.37 2005/05/14 02:12:48 rillig Exp $
+# $NetBSD: bootstrap,v 1.38 2005/05/25 07:06:54 rillig Exp $
 #
 #
 # Copyright (c) 2001-2002 Alistair G. Crooks.  All rights reserved.
@@ -225,21 +225,26 @@
        $cpprog -R $_src/* $wrkdir/$_dst
 }
 
+get_optarg()
+{
+       expr "x$1" : "x[^=]*=\\(.*\\)"
+}
+
 build_start=`date`
 echo_msg "bootstrap command: $0 $@"
 echo_msg "bootstrap started: $build_start"
 
 while [ $# -gt 0 ]; do
        case $1 in
-       --workdir=*)    wrkdir=`echo x"$1" | sed 's,^[^=]*=,,'` ;;
+       --workdir=*)    wrkdir=`get_optarg "$1"` ;;
        --workdir)      wrkdir="$2"; shift ;;
-       --prefix=*)     prefix=`echo x"$1" | sed 's,^[^=]*=,,'`;
+       --prefix=*)     prefix=`get_optarg "$1"`;
                        sysconfdir=${prefix}/etc ;;
        --prefix)       prefix="$2"; shift;
                        sysconfdir=${prefix}/etc ;;
-       --pkgdbdir=*)   pkgdbdir=`echo x"$1" | sed 's,^[^=]*=,,'` ;;
+       --pkgdbdir=*)   pkgdbdir=`get_optarg "$1"` ;;
        --pkgdbdir)     pkgdbdir="$2"; shift ;;
-       --sysconfdir=*) sysconfdir=`echo x"$1" | sed 's,^[^=]*=,,'` ;;
+       --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
        --sysconfdir)   sysconfdir="$2"; shift ;;
        --ignore-case-check) ignorecasecheck=yes ;;
        --ignore-user-check) ignoreusercheck=yes ;;



Home | Main Index | Thread Index | Old Index