gnusenpai / srcman

A package manager / AUR helper for Arch Linux that compiles packages from source.
GNU General Public License v2.0
0 stars 0 forks source link

Use environment variables #1

Open sector-f opened 8 years ago

sector-f commented 8 years ago

At the start of the script, you define four variables (although one, SRCMAN_BASHRC, is never used). Based on their usage, and the fact that they're uppercase, it seems as though you may be intending to read them from the environment.

Compare SRCMAN_SHELL=zsh to SRCMAN_SHELL="${SRCMAN_SHELL:-zsh}". The former assigns a value. The latter assigns either the value of a variable or a default value (if the variable is unset). The fact the two variables are the same in this example is coincidental. See this page for more information on parameter expansion.

Using environment variables allows the script to be changed at runtime rather than needing to be modified. For example, SRCMAN_SHELL=zsh ./srcman or SRCMAN_SHELL=bash ./srcman

gnusenpai commented 8 years ago

Thanks for taking the time to write and suggest this. I added this together with a basic config file implementation, so you can have permanent and temporary settings via environment variables. I'm sure my implementation of it is not the best or most secure way, but it'll work as a temporary solution. I'd like to hear your thoughts about this or other things I can do to improve srcman.