From 93cb6f8ebf7518bf0f3e41214dadf8ebbf46870d Mon Sep 17 00:00:00 2001 From: "Brian Fraser fraserb@gmail.com" <> Date: Mon, 11 Jun 2012 12:15:59 -0300 Subject: [PATCH] Bug 912902: basename not guaranteed to work for Shell tools --- bin/pt-pmp | 5 ++++- bin/pt-sift | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/pt-pmp b/bin/pt-pmp index bab0dc24..d4164f06 100755 --- a/bin/pt-pmp +++ b/bin/pt-pmp @@ -4,6 +4,8 @@ # See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal # notices and disclaimers. +TOOL="pt-pmp" + # ########################################################################### # tmpdir package # This package is a copy without comments from the original. The original @@ -212,7 +214,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-pmp" ] || [ "$(basename "$0")" = "bash" -a "$_" = "$0" ]; then +if [ "${0##*/}" = "$TOOL" ] \ + || [ "${0##*/}" = "bash" -a "$_" = "$0" ]; then mk_tmpdir main "$@" rm_tmpdir diff --git a/bin/pt-sift b/bin/pt-sift index cc29b3d9..c0615821 100755 --- a/bin/pt-sift +++ b/bin/pt-sift @@ -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