commit: cc4270eeb9b737ecd4332b417524976ede25a323 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> AuthorDate: Mon Jun 12 15:56:19 2023 +0000 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> CommitDate: Mon Jun 12 15:56:19 2023 +0000 URL: https://gitweb.gentoo.org/proj/eselect.git/commit/?id=cc4270ee
env.eselect: More robust file type detection * modules/env.eselect (is_envfile): Make detection of text file more robust. Bug 908401. Bug: https://bugs.gentoo.org/908401 Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> ChangeLog | 3 +++ modules/env.eselect | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5532ba..96cee04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2023-06-12 Ulrich Müller <u...@gentoo.org> + * modules/env.eselect (is_envfile): Make detection of text file + more robust. Bug 908401. + * misc/eselect-mode.el (eselect-mode): Drop XEmacs compatibility code. diff --git a/modules/env.eselect b/modules/env.eselect index 6334d7c..7161e10 100644 --- a/modules/env.eselect +++ b/modules/env.eselect @@ -1,5 +1,5 @@ # -*-eselect-*- vim: ft=eselect -# Copyright 2005-2020 Gentoo Authors +# Copyright 2005-2023 Gentoo Authors # Distributed under the terms of the GNU GPL version 2 or later inherit config multilib package-manager @@ -46,9 +46,10 @@ is_envfile() { [[ -n ${envfile##*~} ]] || return 1 [[ ${envfile##*.} != bak ]] || return 1 - mime=$(POSIXLY_CORRECT=1 file -i "${envfile}" \ - | cut -d ' ' -f 2 | sed -e 's/;$//') - if ! has ${mime} ${MIME_WHITELIST}; then + mime=$(POSIXLY_CORRECT=1 file -bi -e soft "${envfile}") \ + || die "'file' command failed" + mime=${mime%%;*} + if ! has "${mime}" ${MIME_WHITELIST}; then echo "Skipping non-text file ${envfile}." return 1 fi