File: rcfile.patch

package info (click to toggle)
tedia2sql 1.2.12-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 384 kB
  • ctags: 553
  • sloc: perl: 2,196; sql: 1,683; makefile: 31; sh: 24
file content (47 lines) | stat: -rw-r--r-- 1,965 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
diff -ru tedia2sql.orig/tedia2sql tedia2sql/tedia2sql
--- tedia2sql.orig/tedia2sql	2004-12-12 16:21:50.000000000 -0200
+++ tedia2sql/tedia2sql	2005-02-16 18:02:36.246507968 -0200
@@ -170,7 +170,11 @@
 # Don't put a username or password in this script! Put such a thing
 # into the rcfile! Read the rcfile and do a sanity check on it
 my $rcFileName = undef;
-if ($0 =~ /(.*?)\.\w+$/) { $rcFileName = "$1rc"; } else { $rcFileName = "$0rc"; }
+if ($0 =~ /[\/\\]?(\w+)(\.\w+)?$/) { 
+	$rcFileName = "$1rc"; 
+} else { 
+	$rcFileName = "$0rc"; 
+}
 my $cfg = parseRCFile ($rcFileName);
 
 # if they don't pass -s commandline arg, get pref from RCfile
@@ -3242,21 +3246,16 @@
 	#
 	# if rcfile has PARAM .= VAL then @PARAM will exist with
 	# each successive element of VAL being PUSHed onto the array
-	if (open (RCFILE, "< $rcFileName")) {
-		# Use the default (generally the local rcfile)
-	} elsif ($rcFileName =~ /.*?\/(\w+)$/) {
-		# Couldn't open the default rcfile, 
-		# Try a user specific rcfile
-		my $userrc = $ENV{HOME} . "/.$1";
-		unless ( open(RCFILE, "< $userrc") ) {
-			# Couldn't opent he user specific rcfile,
-			# Try a systemwide rcfile
-			my $systemrc = "/etc/$1";
-			open (RCFILE, "< $systemrc") || die "Can't open $rcFileName, $userrc, or $systemrc. Can't determine what the rcfile should be...";
-			if ($verbose) { print "Using System RC: $systemrc\n"; }
-		}
+	my $rcFileNameUser = $ENV{HOME} . "/.$rcFileName";
+	my $rcFileNameSystem = "/etc/" . $rcFileName;
+	if (open (RCFILE, "< $rcFileNameUser")) {
+		# first try the user defined rcfile
+		$rcFileName = $rcFileNameUser;
+	} elsif (open (RCFILE, "< $rcFileNameSystem")) {
+		# fallback to systemwide rcfile
+		$rcFileName = $rcFileNameSystem;
 	} else {
-		die "Can't open $rcFileName and can't determine what the rcfile should be...";
+		die "Can't open $rcFileNameUser or $rcFileNameSystem";
 	}
 
 	push (@{$cfg->{_rcFileName}}, {file=>$rcFileName,date=>scalar (localtime())});