diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /security/nss/tests/path_uniq | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | uxp-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz |
Add m-esr52 at 52.6.0
Diffstat (limited to 'security/nss/tests/path_uniq')
-rwxr-xr-x | security/nss/tests/path_uniq | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/security/nss/tests/path_uniq b/security/nss/tests/path_uniq new file mode 100755 index 0000000000..f29f60a00e --- /dev/null +++ b/security/nss/tests/path_uniq @@ -0,0 +1,107 @@ +#! /bin/perl + +######################################################################## +# +# /u/sonmi/bin/path_uniq +# +# this script makes components of a PATH like string unique cand prints +# it to stdout +# +# parameters +# ---------- +# PATH +# +# options +# ------- +# -d delimiter - default : +# -s shortens the path +# +# usefull enhancements: in the usage part, try to guess what was meant as +# a path and echo it to stdout to not break for PATHs with blanks +# +######################################################################## + +sub usage { + print STDERR "usage $0 [-s] [-d <delimiter>] PATH\n"; + print STDERR " this script makes components of the PATH unique, if you\n"; + print STDERR " pass in a searchpath A:B:C:A:B:E it will print A:B:C:E to\n"; + print STDERR " the stdout\n\n"; + print STDERR " -s will mercylessly cut components from the path, \n"; + print STDERR " use at your own risk\n\n"; + print STDERR " the parameters you gave were: \n"; + for ( $i = 0; $i <= $#ARGV; $i++ ) { + print STDERR " $ARGV[$i]\n"; + } + exit ; +} + + +$i = 0; +$j = 0; +$delimiter = ":"; +$searchpath = ""; +@pathcomponents; +$found=0; +$newpath=""; +$shorten=0; + +for ( $i=0; $i <= $#ARGV; $i++) { + if ( $ARGV[$i] eq '-d' ) { + $delimiter = $ARGV[++$i]; + } elsif ( $ARGV[$i] eq '-s' ) { + $shorten=1; + } else { + $searchpath = $ARGV[$i]; + } +} +if ( $searchpath eq "" ) { + usage; +} +#print STDERR "delimiter $delimiter\n"; +#print STDERR "shorten $shorten\n"; +#print STDERR "searchpath $searchpath\n"; + +@pathcomponents=split($delimiter, $searchpath); + +for ( $i = 0; $i <= $#pathcomponents; $i++ ) { + $found=0; + if ( $shorten == 1 ) { + if ( "\/tools\/ns-arch\/sparc_sun_solaris2\.4\/lib\/sparcworks\/SUNWspro/bin" eq $pathcomponents[$i] || + "\/h\/tortoise\/export\/share\/builds\/tools\/sparc_sun_solaris2\.5\.1\/perl5\.004\/bin" eq $pathcomponents[$i] || + "\/usr\/dist\/local\/exe" eq $pathcomponents[$i] || + "\/opt\/SUNWspro\/bin" eq $pathcomponents[$i] || + "\/opt\/SUNWwabi\/bin" eq $pathcomponents[$i] || + "\/u\/svbld\/bin" eq $pathcomponents[$i] || + "\/usr\/demos" eq $pathcomponents[$i] || + "\/usr\/audio\/bin" eq $pathcomponents[$i] || + "\/usr\/openwin\/demo" eq $pathcomponents[$i] || + "\/tools\/contrib\/bin" eq $pathcomponents[$i] || + "\/usr\/etc\/" eq $pathcomponents[$i] || + "\/usr\/demos\/bin" eq $pathcomponents[$i] ) { + + + #print "dumped: $pathcomponents[$i]\n"; + next; + } + #print "keep: $pathcomponents[$i]\n"; + } + for ( $j = 0; $j < $i; $j++ ) { + if ( $pathcomponents[$j] eq $pathcomponents[$i] ) { + #print "$i and $j match - $pathcomponents[$i] - $pathcomponents[$j]\n"; + $found=1; + last; + } + } + if ( $found == 0 ) { + #print "$pathcomponents[$i]:"; + if ($i == 0) { + $newpath = $pathcomponents[$i]; + } else { + $newpath=join($delimiter, $newpath,$pathcomponents[$i]); + } + } +} +print "$newpath\n"; +exit; + + |