From 24e466b1a5f2503fd14728de79476bfd819fc198 Mon Sep 17 00:00:00 2001 From: Mike Detwiler Date: Wed, 14 Dec 2022 07:22:09 -0500 Subject: [PATCH] Issue #131: Ensure local bindir is first in PATH Signed-off-by: Mike Detwiler --- data/bash/common/.bash_profile.in | 12 +++++++++--- data/bash/common/.bashrc.in | 30 ++++++++++++------------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/data/bash/common/.bash_profile.in b/data/bash/common/.bash_profile.in index ac86d4c..cc3962b 100644 --- a/data/bash/common/.bash_profile.in +++ b/data/bash/common/.bash_profile.in @@ -1,18 +1,24 @@ # source the system wide bashrc if it exists if [ -f /etc/bash.bashrc ] ; then - source /etc/bash.bashrc + source /etc/bash.bashrc fi # source the users bashrc if it exists if [ -f "$HOME/.bashrc" ] ; then - source "$HOME/.bashrc" + source "$HOME/.bashrc" fi _toolbox_name=$(__toolbox_name) # source customizations if [ -f "@pkgconfdir@/$_toolbox_name/profile" ]; then - source "@pkgconfdir@/$_toolbox_name/profile" + source "@pkgconfdir@/$_toolbox_name/profile" +fi + +# Set PATH so it includes user's private bin dirs if they exist +if type -t pathmung &>/dev/null; then + pathmung @bindir@ + pathmung @sbindir@ fi unset _toolbox_name diff --git a/data/bash/common/.bashrc.in b/data/bash/common/.bashrc.in index 7b2bc60..b5ff39a 100644 --- a/data/bash/common/.bashrc.in +++ b/data/bash/common/.bashrc.in @@ -1,15 +1,15 @@ # Determin toolbox name function __toolbox_name() { - if [[ -f @TOOLBOX_ENV_FILE@ ]]; then - if [[ -f @CONTAINER_ENV_FILE@ ]]; then - toolbox_name=$(source @CONTAINER_ENV_FILE@ && printf $name) + if [[ -f @TOOLBOX_ENV_FILE@ ]]; then + if [[ -f @CONTAINER_ENV_FILE@ ]]; then + toolbox_name=$(source @CONTAINER_ENV_FILE@ && printf $name) + else + toolbox_name=$(hostname) + fi else - toolbox_name=$(hostname) + toolbox_name=$(hostname) fi - else - toolbox_name=$(hostname) - fi printf "$toolbox_name" } # toolbox_name() export -f __toolbox_name @@ -18,32 +18,26 @@ _toolbox_name=$(__toolbox_name) # Source global definitions if [ -f "@pkgconfdir@/$_toolbox_name/global-bash" ]; then - source "@pkgconfdir@/$_toolbox_name/global-bash" + source "@pkgconfdir@/$_toolbox_name/global-bash" fi # User specific aliases and functions if [ -f "@pkgconfdir@/$_toolbox_name/functions" ]; then - source "@pkgconfdir@/$_toolbox_name/functions" -fi - -# Set PATH so it includes user's private bin dirs if they exist -if type -t pathmung &>/dev/null; then - pathmung @bindir@ - pathmung @sbindir@ + source "@pkgconfdir@/$_toolbox_name/functions" fi # Add Homebrew directories to PATH if [ -f "@pkgconfdir@/$_toolbox_name/homebrew-pathmung" ]; then - source "@pkgconfdir@/$_toolbox_name/homebrew-pathmung" + source "@pkgconfdir@/$_toolbox_name/homebrew-pathmung" fi # Add Windows Python 3 directories to PATH if [ -f "@pkgconfdir@/$_toolbox_name/win-python-pathmung" ]; then - source "@pkgconfdir@/$_toolbox_name/win-python-pathmung" + source "@pkgconfdir@/$_toolbox_name/win-python-pathmung" fi if [ -f "@pkgconfdir@/$_toolbox_name/bashrc" ]; then - source "@pkgconfdir@/$_toolbox_name/bashrc" + source "@pkgconfdir@/$_toolbox_name/bashrc" fi unset _toolbox_name