Created
March 24, 2022 13:08
-
-
Save JacobJohansen/11fc2bc32f998df360fb50d67be6a287 to your computer and use it in GitHub Desktop.
Provides a solid way for scripts to run from no matter where they're executed from, even when simlinked for all nix systems with perl. most systems don't have readlink
This file contains 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/sh | |
relative_dir=`perl -e 'use Cwd "realpath";$pwd = realpath(shift); $pwd =~ s/\/[^\/]*$//; print $pwd' $0` | |
cd $relative_dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment