Uploaded image for project: 'Ratis'
  1. Ratis
  2. RATIS-1340

Ratis scripts' discovery of Bash source path is incompatible with CDPATH.

    XMLWordPrintableJSON

Details

    Description

      Several Bash scripts in Ratis use this common idiom to discover the current source path and then build relative paths from it:

      DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
      

      This mostly works well, but it isn't compatible with interactive shells using the CDPATH environment variable to provide a custom search path for resolving the directory referenced by cd. (See bash man page discussion of "CDPATH" and how the resolved directory is "written to the standard output.")

      The standard solution is to redirect stdout of cd to /dev/null:

      DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
      

      Some Ratis scripts already do this, but not all.

      Attachments

        Issue Links

          Activity

            People

              cnauroth Chris Nauroth
              cnauroth Chris Nauroth
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m