1 |
commit: 16c504f37e471540d3835e7f2fe6beb1f133e29b |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Mar 24 20:58:34 2017 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Apr 14 16:27:52 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=16c504f3 |
7 |
|
8 |
estack.eclass: Use 'shopt -p -o' to restore 'set' flags |
9 |
|
10 |
Use 'shopt -p -o' to obtain the current set of 'set' flags, and to |
11 |
restore them on popping. Unlike $-, it is output in command form (alike |
12 |
'shopt -p'), removing the need for separate logic in eshopts_pop. |
13 |
|
14 |
eclass/estack.eclass | 9 ++------- |
15 |
1 file changed, 2 insertions(+), 7 deletions(-) |
16 |
|
17 |
diff --git a/eclass/estack.eclass b/eclass/estack.eclass |
18 |
index 19c388f3d8d..f548abf8c28 100644 |
19 |
--- a/eclass/estack.eclass |
20 |
+++ b/eclass/estack.eclass |
21 |
@@ -158,7 +158,7 @@ eshopts_push() { |
22 |
[[ $# -eq 0 ]] && return 0 |
23 |
shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*" |
24 |
else |
25 |
- estack_push eshopts $- |
26 |
+ estack_push eshopts "$(shopt -p -o)" |
27 |
[[ $# -eq 0 ]] && return 0 |
28 |
set "$@" || die "${FUNCNAME}: bad options to set: $*" |
29 |
fi |
30 |
@@ -172,12 +172,7 @@ eshopts_push() { |
31 |
eshopts_pop() { |
32 |
local s |
33 |
estack_pop eshopts s || die "${FUNCNAME}: unbalanced push" |
34 |
- if [[ ${s} == "shopt -"* ]] ; then |
35 |
- eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}" |
36 |
- else |
37 |
- set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-" |
38 |
- set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}" |
39 |
- fi |
40 |
+ eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}" |
41 |
} |
42 |
|
43 |
# @FUNCTION: eumask_push |