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 3/3] multiprocesing.eclass: Remove redirect_alloc_fd
Date: Tue, 02 Jan 2018 12:44:04
Message-Id: 20180102124241.21995-3-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/3] multiprocessing.eclass: Remove multijob_* functions by "Michał Górny"
1 Remove the redirect_alloc_fd function that is no longer used since
2 the removal of multijob* functions. The function is complex, has little
3 potential use and an equivalent functionality is built-in in newer bash
4 versions, making it completely unnecessary for EAPI 6.
5 ---
6 eclass/multiprocessing.eclass | 35 -----------------------------------
7 1 file changed, 35 deletions(-)
8
9 diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
10 index 6ca9b4fa7850..3e8b2f9d2540 100644
11 --- a/eclass/multiprocessing.eclass
12 +++ b/eclass/multiprocessing.eclass
13 @@ -100,39 +100,4 @@ makeopts_loadavg() {
14 echo ${lavg:-${2:-999}}
15 }
16
17 -# @FUNCTION: redirect_alloc_fd
18 -# @USAGE: <var> <file> [redirection]
19 -# @DESCRIPTION:
20 -# Find a free fd and redirect the specified file via it. Store the new
21 -# fd in the specified variable. Useful for the cases where we don't care
22 -# about the exact fd #.
23 -redirect_alloc_fd() {
24 - local var=$1 file=$2 redir=${3:-"<>"}
25 -
26 - # Make sure /dev/fd is sane on Linux hosts. #479656
27 - if [[ ! -L /dev/fd && ${CBUILD} == *linux* ]] ; then
28 - eerror "You're missing a /dev/fd symlink to /proc/self/fd."
29 - eerror "Please fix the symlink and check your boot scripts (udev/etc...)."
30 - die "/dev/fd is broken"
31 - fi
32 -
33 - if [[ $(( (BASH_VERSINFO[0] << 8) + BASH_VERSINFO[1] )) -ge $(( (4 << 8) + 1 )) ]] ; then
34 - # Newer bash provides this functionality.
35 - eval "exec {${var}}${redir}'${file}'"
36 - else
37 - # Need to provide the functionality ourselves.
38 - local fd=10
39 - while :; do
40 - # Make sure the fd isn't open. It could be a char device,
41 - # or a symlink (possibly broken) to something else.
42 - if [[ ! -e /dev/fd/${fd} ]] && [[ ! -L /dev/fd/${fd} ]] ; then
43 - eval "exec ${fd}${redir}'${file}'" && break
44 - fi
45 - [[ ${fd} -gt 1024 ]] && die 'could not locate a free temp fd !?'
46 - : $(( ++fd ))
47 - done
48 - : $(( ${var} = fd ))
49 - fi
50 -}
51 -
52 fi
53 --
54 2.16.0.rc0