HenrikBengtsson / conda-stage

conda-stage: Stage a Conda Environment on Local Disk
https://github.com/HenrikBengtsson/conda-stage
ISC License
7 stars 0 forks source link

Add support for vanilla 'sh' #31

Open HenrikBengtsson opened 2 years ago

HenrikBengtsson commented 2 years ago

Issue

eval $(conda-stage --source)

is not supported by vanilla sh. It was only designed and tests for bash, with the assumption it would work also on sh, but it doesn't.

Troubleshooting

The function:

eval $(conda-stage --source)

produces a shell function conda-stage() function;

$ bin/conda-stage --source | head
#! /usr/bin/env bash

CONDA_STAGE_HOME=$(dirname "$(dirname "${BASH_SOURCE%/}")")
[[ -L "${CONDA_STAGE_HOME}" ]] && CONDA_STAGE_HOME=$(readlink "${CONDA_STAGE_HOME}")
CONDA_STAGE_HOME=$(realpath "${CONDA_STAGE_HOME}")

function conda-stage() {
    local tf_res
    local tf_log
    local exit_code

There are several problems with this, where conda-stage is not a valid function name in sh. Turns out sh does not accept hyphens in function names.