Show HN: Shello – Wrangle environment variables

by shayneoon 9/15/23, 4:15 PMwith 7 comments
by kazinatoron 9/16/23, 7:04 AM

Single five-star review in Apple store by user "Codecious" 09/07/2023

> Well, Shello there ;)

> Why hasn't someone thought of this before? Once I added the bash shell function (see their website) it was super easy to swap between sets of envars. This will make life as a developer a bit more enjoyable :)"

Nope; totally not astroturfed by a sock puppet of the author!

by kazinatoron 9/17/23, 2:50 PM

This is some kind of GUI for editing files containing environment variables.

Instead of those files being stored in a shell script format that could simply be sourced, the author provides a badly written shell function to read those files one by one, parse the environment variables and export them. (I'm pasting it below so it is clear what I'm referring to in case it changes.)

The system is flawed because the shell function doesn't remove environment variables; it only adds them.

If we select environment set A, then B and then a A again, it is not the same as just selecting A, as it should be. The environment is polluted by left-over B variables.

In addition, the GUI program has a vanishingly small target audience, consisting possibly of just the author.

Out of the entire population working with shell scripts and environment variables, there has to be a subset which for whatever reason has to juggle among sets of environment variables, and in that subset, those have to be found who would would prefer a platform-specific GUI app from the Apple store to edit the environment variables rather than their favorite text editor.

  ## shello -- for managing environment variables
  shello () {
    envFilePath="$HOME/Library/Containers/app.shello/Data/envs/$1"

    # Check if the file exists
    if [ -f "$envFilePath" ]; then
      # Read each line from the file and set environment variables
      while IFS= read -r line || [[ -n "$line" ]]; do
        # Split line into KEY and VALUE
        key=$(echo "$line" | cut -d '=' -f1)
        value=$(echo "$line" | cut -d '=' -f2-)

        # Set the environment variable
        export "$key"="$value"

        #  uncomment the line below if you want to print each key
        # echo "Setting $key from shello "
      done < "$envFilePath"

      export "SHELLO_CURRENT_ENV"="$1"
      echo " shello env --> $1"
    else
      echo "File not found: $envFilePath"
    fi
  }

by pedalpeteon 9/15/23, 10:58 PM

I really wanted this to be a service that manages environment variables locally and in the cloud.

When we've set this up in the past, it was a bit of a pain to have local envs, and cloud envs, and the build system needs to get the cloud ones, etc. etc.