[pacman-dev] [PATCH 2/2] libmakepkg: only save the shellopts we need

Eli Schwartz eschwartz at archlinux.org
Wed May 2 18:24:44 UTC 2018


micro-optimization: We only care about temporarily enforcing extglob, so
that is the only one we need to explicitly restore.

Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
---
 scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in | 4 ++--
 scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in    | 4 ++--
 scripts/libmakepkg/lint_pkgbuild/depends.sh.in      | 4 ++--
 scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in  | 4 ++--
 scripts/libmakepkg/util/pkgbuild.sh.in              | 4 ++--
 scripts/libmakepkg/util/util.sh.in                  | 4 ++--
 scripts/makepkg.sh.in                               | 2 +-
 7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
index a4f297d9..00a0d5de 100644
--- a/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
@@ -37,8 +37,8 @@ lint_checkdepends() {
 
 	get_pkgbuild_all_split_attributes checkdepends checkdepends_list
 
-	# save our shell options and turn on extglob
-	local shellopts=$(shopt -p)
+	# this function requires extglob - save current status to restore later
+	local shellopts=$(shopt -p extglob)
 	shopt -s extglob
 
 	for checkdepend in "${checkdepends_list[@]}"; do
diff --git a/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
index 0f81ddb1..54b8389d 100644
--- a/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
@@ -37,8 +37,8 @@ lint_conflicts() {
 
 	get_pkgbuild_all_split_attributes conflicts conflicts_list
 
-	# save our shell options and turn on extglob
-	local shellopts=$(shopt -p)
+	# this function requires extglob - save current status to restore later
+	local shellopts=$(shopt -p extglob)
 	shopt -s extglob
 
 	for conflict in "${conflicts_list[@]}"; do
diff --git a/scripts/libmakepkg/lint_pkgbuild/depends.sh.in b/scripts/libmakepkg/lint_pkgbuild/depends.sh.in
index cbd97706..09c1601f 100644
--- a/scripts/libmakepkg/lint_pkgbuild/depends.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/depends.sh.in
@@ -37,8 +37,8 @@ lint_depends() {
 
 	get_pkgbuild_all_split_attributes depends depends_list
 
-	# save our shell options and turn on extglob
-	local shellopts=$(shopt -p)
+	# this function requires extglob - save current status to restore later
+	local shellopts=$(shopt -p extglob)
 	shopt -s extglob
 
 	for depend in "${depends_list[@]}"; do
diff --git a/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in
index fc1549d5..8d70f7d9 100644
--- a/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in
@@ -37,8 +37,8 @@ lint_makedepends() {
 
 	get_pkgbuild_all_split_attributes makedepends makedepends_list
 
-	# save our shell options and turn on extglob
-	local shellopts=$(shopt -p)
+	# this function requires extglob - save current status to restore later
+	local shellopts=$(shopt -p extglob)
 	shopt -s extglob
 
 	for makedepend in "${makedepends_list[@]}"; do
diff --git a/scripts/libmakepkg/util/pkgbuild.sh.in b/scripts/libmakepkg/util/pkgbuild.sh.in
index 2db46f1f..632f314d 100644
--- a/scripts/libmakepkg/util/pkgbuild.sh.in
+++ b/scripts/libmakepkg/util/pkgbuild.sh.in
@@ -80,8 +80,8 @@ extract_function_variable() {
 		printf -v attr_regex '^[[:space:]]* %s\+?=[^(]' "$2"
 	fi
 
-	# save our shell options and turn on extglob
-	local shellopts=$(shopt -p)
+	# this function requires extglob - save current status to restore later
+	local shellopts=$(shopt -p extglob)
 	shopt -s extglob
 
 	while read -r; do
diff --git a/scripts/libmakepkg/util/util.sh.in b/scripts/libmakepkg/util/util.sh.in
index f9af5f32..726d2005 100644
--- a/scripts/libmakepkg/util/util.sh.in
+++ b/scripts/libmakepkg/util/util.sh.in
@@ -42,8 +42,8 @@ is_array() {
 	local v=$1
 	local ret=1
 
-	# this function requires extglob - save current options to restore later
-	local shellopts=$(shopt -p)
+	# this function requires extglob - save current status to restore later
+	local shellopts=$(shopt -p extglob)
 	shopt -s extglob
 
 	if [[ $(declare -p "$v") == declare\ -*([[:alnum:]])a*([[:alnum:]])\ * ]]; then
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index eee8a56c..b845c5d7 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -275,7 +275,7 @@ handle_deps() {
 
 	# we might need the new system environment
 	# save our shell options and turn off extglob
-	local shellopts=$(shopt -p)
+	local shellopts=$(shopt -p extglob)
 	shopt -u extglob
 	source /etc/profile &>/dev/null
 	eval "$shellopts"
-- 
2.17.0


More information about the pacman-dev mailing list