Created
December 17, 2021 17:29
-
-
Save goddoe/af5f4fc93fba09fb8c2163fbb7f5aef6 to your computer and use it in GitHub Desktop.
curr script dir
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
| $ cat test.sh | |
| #!/usr/bin/env bash | |
| SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) | |
| echo $SCRIPT_DIR; | |
| $ ./exps/test.sh | |
| /abs/path/to/exps | |
| $ cd exps | |
| $ ./test.sh | |
| /abs/path/to/exps | |
| $ cat test_2.sh | |
| #!/usr/bin/env bash | |
| SCRIPT_DIR=$(dirname $0) | |
| echo $SCRIPT_DIR; | |
| $ ./exps/test_2.sh | |
| ./exps | |
| $ cd exps | |
| $ ./test_2.sh | |
| . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment