Created
December 23, 2013 22:23
-
-
Save josephwecker/8105846 to your computer and use it in GitHub Desktop.
Slightly more robust "current directory" for bash script if ruby is already a dependency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
D=`ruby -e 'puts File.dirname(File.realpath(File.expand_path("'${BASH_SOURCE[0]}'")))'` | |
pushd "${D}" >/dev/null | |
# ... Do stuff ... | |
popd >/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment