csh : How to remove redundant dirs from path

csh : How to remove redundant dirs from path

Post by Ravi Kum » Wed, 09 Nov 1994 08:29:28



yes! I hate csh and I do not use it. But I am forced to use it. I have to
source someone else's cshrc file and build my path. Several dirs are getting
double definedin the path and after a while csh says
"Warning: Ridiculously long path truncated"

someone save me from this csh anomoly. How can I shorten the path or make
csh accept arbitrarily long paths.

--

Cheers,

Ravi Kumar                                      PS: All opinions are mine.

 
 
 

csh : How to remove redundant dirs from path

Post by James Armstro » Thu, 10 Nov 1994 01:25:01



>yes! I hate csh and I do not use it. But I am forced to use it. I have to
>source someone else's cshrc file and build my path. Several dirs are getting
>double definedin the path and after a while csh says
>"Warning: Ridiculously long path truncated"

>someone save me from this csh anomoly. How can I shorten the path or make
>csh accept arbitrarily long paths.

Try this:

set npath
foreach elem ( $path )
        if ( ! -d $elem ) continue
        set needed
        foreach nelem ( $npath )
                if ( $nelem == $elem ) then
                        unset needed
                        break
                endif
        end
        if ( $?needed ) set npath = ( $npath $elem )
end
set path = ( $npath )
unset npath nelem elem needed

Not only will it eliminate duplicate entries, but it will also
eliminate directories that do not exist.  (If you use directory
elements that are not root based, you'll want to remove the line
"if ( ! -d $elem ) continue".)
--
James C. Armstrong, Jr.              | Scots wha hae wi' Wallace bled,


URL:                                 |     Or to victory!
        ftp://ftp.netcom.com/pub/jca/homepage.html

 
 
 

csh : How to remove redundant dirs from path

Post by Dave Carrig » Sat, 12 Nov 1994 03:52:35


 Ravi> yes! I hate csh and I do not use it. But I am forced to use
 Ravi> it. I have to source someone else's cshrc file and build my
 Ravi> path. Several dirs are getting double definedin the path and
 Ravi> after a while csh says "Warning: Ridiculously long path
 Ravi> truncated"

 Ravi> someone save me from this csh anomoly. How can I shorten the
 Ravi> path or make csh accept arbitrarily long paths.

Create this script and name it (say) fixpath

------------------------------
foreach (split(/:/, $ENV{"PATH"})) {

    $paths{$_} = 1;

Quote:}


------------------------------

To use it, type

  % setenv PATH `perl fixpath`

Note the backquotes!

You'll probably want to put this at the end of your .cshrc. If you
don't have perl, get it.

Dave Carrigan                            | Yow! As President I have to go
Systems and Network Manager              | vacuum my coin collection!
Canadian Forest Service                  |
Unix/VMS/TCP-IP/DECnet/Pathworks         |

 
 
 

csh : How to remove redundant dirs from path

Post by Marty Leisner 257 » Wed, 16 Nov 1994 08:59:31


: >
: >someone save me from this csh anomoly. How can I shorten the path or make
: >csh accept arbitrarily long paths.

: Try this:

: set npath
: foreach elem ( $path )
:         if ( ! -d $elem ) continue
:         set needed
:         foreach nelem ( $npath )
:                 if ( $nelem == $elem ) then
:                         unset needed
:                         break
:                 endif
:         end
:         if ( $?needed ) set npath = ( $npath $elem )
: end
: set path = ( $npath )
: unset npath nelem elem needed

I like this... I have something similar, where you give it
a set of paths and it appends bin, man and info and sets
these paths accordingly...

When I wrote this, after much headbanging, I gave up on the csh...;-)

: Not only will it eliminate duplicate entries, but it will also
: eliminate directories that do not exist.  (If you use directory
: elements that are not root based, you'll want to remove the line
: "if ( ! -d $elem ) continue".)
: --
: James C. Armstrong, Jr.              | Scots wha hae wi' Wallace bled,


: URL:                                 |     Or to victory!
:       ftp://ftp.netcom.com/pub/jca/homepage.html

--
marty

Member of the League for Programming Freedom
Object techonology is to software what microprocessors are to
hardware.
                Phillipe Kahn

 
 
 

1. How to trim the redundant paths in csh $PATH

[ post < 1K ]

Hi there,

A while ago, people posted some simple awk/sed command to trim the redundant
paths as the result of repeated source .cshrc.

If you have it handy, could you please email it to me?

Thanks,
Kerr

2. Running something in bg then printing to fg

3. weird... can't put a cd \dir\dir\dir\ in a .csh file...

4. Dual Booting with NT

5. csh: path or PATH?

6. Iomega ZIP drive support ?

7. csh/bash : path/PATH

8. doscmd & vga (raw mode)

9. (t)csh handling of $path and $PATH

10. Redundant Bins in Various X11 Dirs

11. A C shell trim redundant paths question

12. redundant data path to a1000

13. Redundant network paths