Bug 469739 - Add support for displaying Vista UAC shield icon; r=joe sr=vladimir
[wine-gecko.git] / security / nss / tests / path_uniq
blobf29f60a00e76325501e866d336e3744a0283dabd
1 #! /bin/perl
3 ########################################################################
5 # /u/sonmi/bin/path_uniq
7 # this script makes components of a PATH like string unique cand prints
8 # it to stdout
10 # parameters
11 # ----------
12 # PATH
14 # options
15 # -------
16 # -d delimiter - default :
17 # -s shortens the path
19 # usefull enhancements: in the usage part, try to guess what was meant as
20 # a path and echo it to stdout to not break for PATHs with blanks
22 ########################################################################
24 sub usage {
25 print STDERR "usage $0 [-s] [-d <delimiter>] PATH\n";
26 print STDERR " this script makes components of the PATH unique, if you\n";
27 print STDERR " pass in a searchpath A:B:C:A:B:E it will print A:B:C:E to\n";
28 print STDERR " the stdout\n\n";
29 print STDERR " -s will mercylessly cut components from the path, \n";
30 print STDERR " use at your own risk\n\n";
31 print STDERR " the parameters you gave were: \n";
32 for ( $i = 0; $i <= $#ARGV; $i++ ) {
33 print STDERR " $ARGV[$i]\n";
35 exit ;
39 $i = 0;
40 $j = 0;
41 $delimiter = ":";
42 $searchpath = "";
43 @pathcomponents;
44 $found=0;
45 $newpath="";
46 $shorten=0;
48 for ( $i=0; $i <= $#ARGV; $i++) {
49 if ( $ARGV[$i] eq '-d' ) {
50 $delimiter = $ARGV[++$i];
51 } elsif ( $ARGV[$i] eq '-s' ) {
52 $shorten=1;
53 } else {
54 $searchpath = $ARGV[$i];
57 if ( $searchpath eq "" ) {
58 usage;
60 #print STDERR "delimiter $delimiter\n";
61 #print STDERR "shorten $shorten\n";
62 #print STDERR "searchpath $searchpath\n";
64 @pathcomponents=split($delimiter, $searchpath);
66 for ( $i = 0; $i <= $#pathcomponents; $i++ ) {
67 $found=0;
68 if ( $shorten == 1 ) {
69 if ( "\/tools\/ns-arch\/sparc_sun_solaris2\.4\/lib\/sparcworks\/SUNWspro/bin" eq $pathcomponents[$i] ||
70 "\/h\/tortoise\/export\/share\/builds\/tools\/sparc_sun_solaris2\.5\.1\/perl5\.004\/bin" eq $pathcomponents[$i] ||
71 "\/usr\/dist\/local\/exe" eq $pathcomponents[$i] ||
72 "\/opt\/SUNWspro\/bin" eq $pathcomponents[$i] ||
73 "\/opt\/SUNWwabi\/bin" eq $pathcomponents[$i] ||
74 "\/u\/svbld\/bin" eq $pathcomponents[$i] ||
75 "\/usr\/demos" eq $pathcomponents[$i] ||
76 "\/usr\/audio\/bin" eq $pathcomponents[$i] ||
77 "\/usr\/openwin\/demo" eq $pathcomponents[$i] ||
78 "\/tools\/contrib\/bin" eq $pathcomponents[$i] ||
79 "\/usr\/etc\/" eq $pathcomponents[$i] ||
80 "\/usr\/demos\/bin" eq $pathcomponents[$i] ) {
83 #print "dumped: $pathcomponents[$i]\n";
84 next;
86 #print "keep: $pathcomponents[$i]\n";
88 for ( $j = 0; $j < $i; $j++ ) {
89 if ( $pathcomponents[$j] eq $pathcomponents[$i] ) {
90 #print "$i and $j match - $pathcomponents[$i] - $pathcomponents[$j]\n";
91 $found=1;
92 last;
95 if ( $found == 0 ) {
96 #print "$pathcomponents[$i]:";
97 if ($i == 0) {
98 $newpath = $pathcomponents[$i];
99 } else {
100 $newpath=join($delimiter, $newpath,$pathcomponents[$i]);
104 print "$newpath\n";
105 exit;