From be5dca62c091e36ff4d693aab4b592e2888fcd94 Mon Sep 17 00:00:00 2001 From: espie Date: Tue, 10 Jul 2018 10:37:59 +0000 Subject: [PATCH] unify option parsing a bit more --- usr.sbin/pkg_add/OpenBSD/AddDelete.pm | 7 ++++++- usr.sbin/pkg_add/OpenBSD/PkgAdd.pm | 12 +----------- usr.sbin/pkg_add/OpenBSD/PkgDelete.pm | 7 +------ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm index 546b95e574c..18846933123 100644 --- a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm +++ b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: AddDelete.pm,v 1.81 2018/07/09 14:51:15 espie Exp $ +# $OpenBSD: AddDelete.pm,v 1.82 2018/07/10 10:37:59 espie Exp $ # # Copyright (c) 2007-2010 Marc Espie # @@ -231,6 +231,11 @@ sub handle_options if (defined $ENV{PKG_CHECKSUM}) { $state->{subst}->add('checksum', 1); } + my $base = $state->opt('B') // ''; + if ($base ne '') { + $base.='/' unless $base =~ m/\/$/o; + } + $state->{destdir} = $base; } sub init diff --git a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm index 3512bb6a9be..2eb84359fd9 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgAdd.pm,v 1.103 2018/06/24 19:59:35 espie Exp $ +# $OpenBSD: PkgAdd.pm,v 1.104 2018/07/10 10:37:59 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -129,16 +129,6 @@ sub handle_options $state->usage("bad option: -P #1", $state->opt('P')); } } - if (defined $state->opt('B')) { - $state->{destdir} = $state->opt('B'); - } - if (defined $state->{destdir}) { - $state->{destdir}.='/'; - } else { - $state->{destdir} = ''; - } - - $state->{hard_replace} = $state->opt('r'); $state->{newupdates} = $state->opt('u') || $state->opt('U'); $state->{allow_replacing} = $state->{hard_replace} || diff --git a/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm b/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm index 472ec0c7394..c1ca5b7fcb2 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm @@ -1,6 +1,6 @@ #!/usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgDelete.pm,v 1.44 2018/07/10 10:18:34 espie Exp $ +# $OpenBSD: PkgDelete.pm,v 1.45 2018/07/10 10:37:59 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie # @@ -103,11 +103,6 @@ sub handle_options $state->SUPER::handle_options('X', '[-acimnqsVvXx] [-B pkg-destdir] [-D name[=value]] [pkg-name ...]'); - my $base = $state->opt('B') // ''; - if ($base ne '') { - $base.='/' unless $base =~ m/\/$/o; - } - $state->{destdir} = $base; $state->{exclude} = $state->opt('X'); } -- 2.20.1