cvs commit: p5ee/App-Context/lib/App/Conf File.pm

[email protected] (Stephen Adkins)
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
cvsuser     05/08/09 12:06:31

  Modified:    App-Context/lib/App/Conf File.pm
  Log:
  fix the app.pl problem for program named app
  
  Revision  Changes    Path
  1.9       +11 -5     p5ee/App-Context/lib/App/Conf/File.pm
  
  Index: File.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Context/lib/App/Conf/File.pm,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- File.pm	10 Nov 2004 15:41:32 -0000	1.8
  +++ File.pm	9 Aug 2005 19:06:31 -0000	1.9
  @@ -51,7 +51,8 @@
           #    initialization configuration file.
           #################################################################
           my $prog_dir = $0;                   # start with the full script path
  -        if ($prog_dir =~ m!^/!) {            # absolute path
  +        $prog_dir =~ s!\\!/!g;               # convert to POSIX-compliant "/" path
  +        if ($prog_dir =~ m!^([a-z]:)?/!i) {  # absolute path
               # i.e. /usr/local/bin/app, /app
               $prog_dir =~ s!/[^/]+$!!;        # trim off the program name
           }
  @@ -72,12 +73,17 @@
           #################################################################
           $app = $options->{app} || "app";
           $conf_type = $options->{conf_type} || "pl";
  +        my $prog_suffix = "";
  +        if ($0 =~ /\.([a-z]+)$/i) {
  +            $prog_suffix = lc($1);
  +        }
           push(@conf_file, "$ENV{HOME}/.app/$app.$conf_type") if ($ENV{HOME} && $app ne "app");
  -        push(@conf_file, "$prog_dir/$app.$conf_type") if ($app ne "app");
  +        push(@conf_file, "$prog_dir/$app.$conf_type") if ($app ne "app" && $conf_type ne $prog_suffix);
           push(@conf_file, "$prefix/etc/app/$app.$conf_type") if ($app ne "app");
           push(@conf_file, "$ENV{HOME}/.app/app.$conf_type") if ($ENV{HOME});
  -        push(@conf_file, "$prog_dir/app.$conf_type");
  +        push(@conf_file, "$prog_dir/app.$conf_type") if ($conf_type ne $prog_suffix);
           push(@conf_file, "$prefix/etc/app/app.$conf_type");
  +        push(@conf_file, "/etc/app/app.$conf_type");
       }
   
       #################################################################
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.