Update app-cleaner.sh

For allow use any script name. e.g. without `.sh`
This commit is contained in:
Dmitry Muravyev 2021-06-27 08:31:19 +03:00 committed by GitHub
parent 5575f2bbf3
commit 48cd510347
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,9 @@
#! /bin/bash #! /bin/bash
script_name=$(basename $0)
if [ -z "$1" ] || [ "$1" = "--help" ]; then if [ -z "$1" ] || [ "$1" = "--help" ]; then
printf "%s\n" "Usage: app-cleaner.sh /path/to/app.app" printf "%s\n" "Usage: $script_name /path/to/app.app"
exit 0 exit 0
fi fi
@ -27,7 +29,7 @@ sleep 1
app_name=$(basename $1 .app) app_name=$(basename $1 .app)
processes=($(pgrep -afil "$app_name" | grep -v "app-cleaner.sh")) processes=($(pgrep -afil "$app_name" | grep -v "$script_name"))
if [ ${#processes[@]} -gt 0 ]; then if [ ${#processes[@]} -gt 0 ]; then
printf "%s\n" "${processes[@]}" printf "%s\n" "${processes[@]}"