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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Ulrich Mueller-2
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 <[hidden email]>
---
 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 (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Zac Medico-2
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 <[hidden email]>
> ---
>  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 (1000 bytes) Download Attachment