Bug 912902: basename not guaranteed to work for Shell tools

This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-06-11 12:15:59 -03:00
parent 87f32cc857
commit 93cb6f8ebf
2 changed files with 8 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env bash
TOOL="pt-sift"
# This program is part of Percona Toolkit: http://www.percona.com/software/
# See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal
# notices and disclaimers.
@@ -536,7 +538,8 @@ main() {
# Execute the program if it was not included from another file. This makes it
# possible to include without executing, and thus test.
if [ "$(basename "$0")" = "pt-sift" ] || [ "$(basename "$0")" = "bash" -a "$_" = "$0" ]; then
if [ "${0##*/}" = "$TOOL" ] \
|| [ "${0##*/}" = "bash" -a "$_" = "$0" ]; then
main "$@"
fi