Re: [gentoo-portage-dev] [PATCH] isolated-functions.sh: Do not define any aliases.

2018-11-05 Thread Zac Medico
On 11/05/2018 12:12 PM, Ulrich Müller wrote:
> save_IFS and restore_IFS are the only aliases that Portage defines,
> and they are used exactly once. Rewrite __source_all_bashrcs() not to
> depend on them, and remove their definitions.
> 
> The intention is to drop the expand_aliases shell option at some time
> in the future.
> 
> Signed-off-by: Ulrich Müller 
> ---
>  bin/ebuild.sh | 8 ++--
>  bin/isolated-functions.sh | 2 --
>  2 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/bin/ebuild.sh b/bin/ebuild.sh
> index 5491c4f58..00524d019 100755
> --- a/bin/ebuild.sh
> +++ b/bin/ebuild.sh
> @@ -421,13 +421,9 @@ __source_all_bashrcs() {
>  
>   if [[ $EBUILD_PHASE != depend ]] ; then
>   # source the existing profile.bashrcs.
> - save_IFS
> - IFS=$'\n'
> - local bashenv_files=($PORTAGE_BASHRC_FILES)
> - restore_IFS
> - for x in "${bashenv_files[@]}" ; do
> + while read -r x; do
>   __try_source "${x}"
> - done
> + done <<<"${PORTAGE_BASHRC_FILES}"
>   fi
>  
>   # The user's bashrc is the ONLY non-portage bit of code
> diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
> index 39b0ad344..22a6dbb0f 100644
> --- a/bin/isolated-functions.sh
> +++ b/bin/isolated-functions.sh
> @@ -11,8 +11,6 @@ fi
>  # We need this next line for "die" and "assert". It expands
>  # It _must_ preceed all the calls to die and assert.
>  shopt -s expand_aliases
> -alias save_IFS='[ "${IFS:-unset}" != "unset" ] && old_IFS="${IFS}"'
> -alias restore_IFS='if [ "${old_IFS:-unset}" != "unset" ]; then 
> IFS="${old_IFS}"; unset old_IFS; else unset IFS; fi'
>  
>  assert() {
>   local x pipestatus=${PIPESTATUS[*]}
> 

Looks good, please merge.
-- 
Thanks,
Zac



signature.asc
Description: OpenPGP digital signature


[gentoo-portage-dev] [PATCH] isolated-functions.sh: Do not define any aliases.

2018-11-05 Thread Ulrich Müller
save_IFS and restore_IFS are the only aliases that Portage defines,
and they are used exactly once. Rewrite __source_all_bashrcs() not to
depend on them, and remove their definitions.

The intention is to drop the expand_aliases shell option at some time
in the future.

Signed-off-by: Ulrich Müller 
---
 bin/ebuild.sh | 8 ++--
 bin/isolated-functions.sh | 2 --
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 5491c4f58..00524d019 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -421,13 +421,9 @@ __source_all_bashrcs() {
 
if [[ $EBUILD_PHASE != depend ]] ; then
# source the existing profile.bashrcs.
-   save_IFS
-   IFS=$'\n'
-   local bashenv_files=($PORTAGE_BASHRC_FILES)
-   restore_IFS
-   for x in "${bashenv_files[@]}" ; do
+   while read -r x; do
__try_source "${x}"
-   done
+   done <<<"${PORTAGE_BASHRC_FILES}"
fi
 
# The user's bashrc is the ONLY non-portage bit of code
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 39b0ad344..22a6dbb0f 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -11,8 +11,6 @@ fi
 # We need this next line for "die" and "assert". It expands
 # It _must_ preceed all the calls to die and assert.
 shopt -s expand_aliases
-alias save_IFS='[ "${IFS:-unset}" != "unset" ] && old_IFS="${IFS}"'
-alias restore_IFS='if [ "${old_IFS:-unset}" != "unset" ]; then 
IFS="${old_IFS}"; unset old_IFS; else unset IFS; fi'
 
 assert() {
local x pipestatus=${PIPESTATUS[*]}
-- 
2.19.1



signature.asc
Description: PGP signature