From: Joey Hess Date: Mon, 22 Oct 2007 00:02:18 +0000 (-0400) Subject: getcwd might fail if the working directory is deleted. deal with it. X-Git-Url: https://git.madduck.net/code/myrepos.git/commitdiff_plain/d752aeb38d80a8342ba88c5fe5483be61b987182?ds=sidebyside;hp=ec4e590670f444fdbea5ad72dbda9cfdd4eac4b0 getcwd might fail if the working directory is deleted. deal with it. --- diff --git a/mr b/mr index d9cde93..59d6a69 100755 --- a/mr +++ b/mr @@ -286,7 +286,6 @@ $SIG{INT}=sub { $ENV{MR_CONFIG}="$ENV{HOME}/.mrconfig"; my $config_overridden=0; -my $directory=getcwd(); my $verbose=0; my $stats=0; my $no_recurse=0; @@ -295,6 +294,7 @@ my %config; my %configfiles; my %knownactions; my %alias; +my $directory=getcwd(); Getopt::Long::Configure("no_permute"); my $result=GetOptions( @@ -310,6 +310,9 @@ if (! $result || @ARGV < 1) { "(Use mr help for man page.)\n"); } +if (! defined $directory) { + die("mr: failed to determine working directory\n"); +} # Make sure MR_CONFIG is an absolute path, but don't use abs_path since # the config file might be a symlink to elsewhere, and the directory it's