diff options
author | Ulrich Müller <ulm@gentoo.org> | 2023-06-12 17:56:19 +0200 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2023-06-12 17:56:19 +0200 |
commit | cc4270eeb9b737ecd4332b417524976ede25a323 (patch) | |
tree | fbe7df753d719728c6b79feb9b05d92a3482ebc5 /modules | |
parent | eselect-mode: Drop XEmacs compatibility code (diff) | |
download | eselect-cc4270eeb9b737ecd4332b417524976ede25a323.tar.gz eselect-cc4270eeb9b737ecd4332b417524976ede25a323.tar.bz2 eselect-cc4270eeb9b737ecd4332b417524976ede25a323.zip |
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@gentoo.org>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/env.eselect | 9 |
1 files changed, 5 insertions, 4 deletions
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 |