Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH v2 5/8] www-apps/postfixadmin: Replace path_exists with inline logic
Date: Thu, 09 Aug 2018 15:20:04
Message-Id: 20180809151602.11147-6-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH v2 0/8] eutils/path_exists removal by "Michał Górny"
1 Replace the call to path_exists with local filename expansion. While
2 at it, also kill the ugly ls-abuse in favor of using the results
3 of earlier expansion.
4 ---
5 www-apps/postfixadmin/postfixadmin-3.1.ebuild | 12 +++++++-----
6 1 file changed, 7 insertions(+), 5 deletions(-)
7
8 diff --git a/www-apps/postfixadmin/postfixadmin-3.1.ebuild b/www-apps/postfixadmin/postfixadmin-3.1.ebuild
9 index 3e69bc6b6573..5cb58aab877a 100644
10 --- a/www-apps/postfixadmin/postfixadmin-3.1.ebuild
11 +++ b/www-apps/postfixadmin/postfixadmin-3.1.ebuild
12 @@ -3,7 +3,7 @@
13
14 EAPI="6"
15
16 -inherit eutils user webapp
17 +inherit user webapp
18
19 DESCRIPTION="Web Based Management tool for Postfix style virtual domains and users"
20 HOMEPAGE="http://postfixadmin.sourceforge.net"
21 @@ -89,10 +89,12 @@ pkg_postinst() {
22 pkg_postrm() {
23 # Make sure we don't leave broken vacation.pl symlink
24 find -L "${ROOT}"/var/spool/vacation/ -type l -delete
25 - if [[ ! -e "${ROOT}"/var/spool/vacation/vacation.pl ]] &&
26 - path_exists "${ROOT}"/var/spool/vacation/vacation.pl-*; then
27 - ln -s $(LC_ALL=C ls -1 /var/spool/vacation/vacation.pl-* | tail -n1) \
28 - "${ROOT}"/var/spool/vacation/vacation.pl || die
29 + local shopt_save=$(shopt -p nullglob)
30 + shopt -s nullglob
31 + local vacation=( "${ROOT}"/var/spool/vacation/vacation.pl-* )
32 + ${shopt_save}
33 + if [[ ! -e "${ROOT}"/var/spool/vacation/vacation.pl && -n ${vacation[@]} ]]; then
34 + ln -s "${vacation[-1]}" "${ROOT}"/var/spool/vacation/vacation.pl || die
35 ewarn "/var/spool/vacation/vacation.pl was updated to point on most"
36 ewarn "recent verion, but please, do your own checks"
37 fi
38 --
39 2.18.0