Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idea for idempotent ENV updates #966

Open
coolaj86 opened this issue Feb 18, 2025 · 0 comments
Open

idea for idempotent ENV updates #966

coolaj86 opened this issue Feb 18, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@coolaj86
Copy link
Member

I was just noticing an interesting, idempotent way to update the PATH while trying to track down an issue with my cargo config:

PATH="$(fn_export "$PATH" "${HOME}/bin")"
PATH="$(fn_export "$PATH" "${HOME}/.local/bin")"
fn_export() {(
    b_path="${1}"
    b_new_path="${2}"

    case ":${b_path}:" in
        *:"${b_new_path}":*)
            ;;
        *)
            # Prepending path in case a system-installed path needs to be overridden
            b_path="${b_new_path}:${b_path}"
            ;;
    esac

    echo "${b_path}"
);}

What I like:

  • idempotent

What I don't like:

  • non-standard
  • non-portable (bash and fish would need different implementations)
@coolaj86 coolaj86 added the enhancement New feature or request label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant