Skip to content
  • Mark Olesen's avatar
    BUG: etc/bashrc incorrect behaviour if sourced locally (issue #280) · b8448671
    Mark Olesen authored
    - It is incorrect to prefix the assignment with an 'export' since this
      automatically marks the overall command as successful and circumvents
      the fallback.
    
      There is no simple way to have proper behaviour when sourced with a
      local directory path, but at least it now uses the fallback.
    
      It is still easy to wreak the mechanism with valid but confusing input.
      For example,
    
         ". /path/to/openfoam/etc/././bashrc"
    
      The only real certainty is that "${BASH_SOURCE%/*}"
      should point to the 'etc/' directory. In which case,
    
          cd ${BASH_SOURCE%/*}    # <- now in the etc/ directory
          pwd=$(pwd -P)           # <- fully-qualified path to etc/
          pwd=${pwd%/*/*}         # <- up two parent levels
    
      - This works with ". ./bashrc", but fails with ". bashrc"
        (probably not so common).
      - Con: The construct requires an additional sub-shell.
    b8448671