commit: 0b3b8e4b89cd272fd84bce442345c0bbc2c601e8
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 6 09:50:13 2016 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb 6 09:50:13 2016 +0000
URL:
https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=0b3b8e4b
Handle missing configuration file gracefully
python.eselect.in | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/python.eselect.in b/python.eselect.in
index e05bff1..0945c63 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -32,6 +32,8 @@ get_installed_pythons() {
# includes both preferred implementations (in preference order)
# and disabled interpreters.
get_all_preferences() {
+ [[ -e ${CONFIG_PATH} ]] || return
+
local l
while read l; do
# skip comments
@@ -98,7 +100,10 @@ get_all_pythons() {
# Write new preference list. Preferences need to be passed
# as parameters (${@}).
write_preferences() {
- sed -n -e '/^#/p' "${CONFIG_PATH}" > "${CONFIG_PATH}".new || die
+ if [[ -e ${CONFIG_PATH} ]]; then
+ sed -n -e '/^#/p' "${CONFIG_PATH}" > "${CONFIG_PATH}".new || die
+ fi
+
local IFS=$'\n'
echo "${*}" >> "${CONFIG_PATH}".new || die