Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 4
    Nice! Could be made shorter replacing "pushd[...] popd /dev/null" by SCRIPT_PATH=readlink -f $(dirname "${VIRTUAL_ENV}"); Commented Nov 29, 2009 at 11:34
  • 1
    This is by far the most "stable" version I've seen. Thank you! Commented Jan 26, 2010 at 8:19
  • 5
    And instead of using pushd ...; would not it be better to use $(cd dirname "${SCRIPT_PATH}" && pwd)? But anyway great script! Commented Aug 18, 2010 at 10:16
  • 7
    It's dangerous for a script to cd out of its current directory in the hope of cding back again later: The script may not have permission to change directory back to the directory that was current when it was invoked. (Same goes for pushd/popd) Commented Nov 6, 2012 at 1:15
  • 8
    readlink -f is GNU-specific. BSD readlink does not have that option. Commented Jun 3, 2014 at 16:48