Skip to content

Commit

Permalink
refactor, add -eou pipefail
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed May 13, 2024
1 parent 8ec4627 commit f1464ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/rapids-configure-conda-channels
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/bin/bash
# A utility script that configures conda channels

set -euo pipefail

conda_channel_in_config() {
channel_id=${1:?err}
conda config --json --get channels \
| jq -r --arg c "${channel_id}" '."get"."channels" | any(. == $c )'
| channel_id="${channel_id}" jq -r --exit-status '.get.channels | any(. == env.channel_id )'
}

# Only try to run 'conda config --remove' if the channel exists in the config.
# This is here to avoid errors if this script is invoked multiple times in the same
remove_conda_channel() {
channel_id=${1:?err}
in_config=$(conda_channel_in_config "${channel_id}")
if [[ "${in_config}" == "true" ]]; then
if conda_channel_in_config "${channel_id}" > /dev/null; then
conda config --system --remove channels "${channel_id}"
else
echo "[rapids-configure-conda-channels] channel '${channel_id}' not found via 'conda config --get channels'"
Expand Down

0 comments on commit f1464ce

Please sign in to comment.