From: Steve Hancock Date: Sun, 4 Dec 2022 21:38:39 +0000 (-0800) Subject: automate location of git home X-Git-Tag: 20221112.02~25 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8e76ff1cba4724378d51d059e3fbe913fbe1bdc9;p=perltidy.git automate location of git home --- diff --git a/dev-bin/get_perltidy.pl b/dev-bin/get_perltidy.pl index 3810b521..982a5f00 100755 --- a/dev-bin/get_perltidy.pl +++ b/dev-bin/get_perltidy.pl @@ -4,8 +4,19 @@ use warnings; use Getopt::Long; #--------------------------------------------------------- -# Define the git home of perltidy on this computer: -my $PERLTIDY_GIT = '/home/steve/src/perldev/perltidy/git'; +# Try to find the git home of perltidy on this computer. +# Assuming that this program is git/dev_bin/get_perltidy.pl, +# or a symlink to that, then we can get its path: +use Cwd qw(abs_path); +my $absolute_path = abs_path( readlink $0 ); +print "path is $absolute_path\n"; +use File::Basename; +my ( $name, $path, $suffix ) = fileparse($absolute_path); +my $PERLTIDY_GIT = $path . "../"; + +# If this doesn't work, then replace the above with a specific +# definition here: +# my $PERLTIDY_GIT = '/home/.../git #--------------------------------------------------------- @@ -14,7 +25,7 @@ if ( !-e $pm2pl ) { die <