diff options
author | Michał Górny <mgorny@gentoo.org> | 2016-02-06 10:50:13 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2016-02-06 10:50:13 +0100 |
commit | 0b3b8e4b89cd272fd84bce442345c0bbc2c601e8 (patch) | |
tree | 1082890806b1c3d60ea37df7e355a3dd3e66b8e0 | |
parent | update: Ignore Python 2 preference update requests (diff) | |
download | eselect-python-0b3b8e4b89cd272fd84bce442345c0bbc2c601e8.tar.gz eselect-python-0b3b8e4b89cd272fd84bce442345c0bbc2c601e8.tar.bz2 eselect-python-0b3b8e4b89cd272fd84bce442345c0bbc2c601e8.zip |
Handle missing configuration file gracefully
-rw-r--r-- | python.eselect.in | 7 |
1 files changed, 6 insertions, 1 deletions
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 |