home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / shell / 3241 < prev    next >
Encoding:
Text File  |  1992-07-31  |  1.2 KB  |  25 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!ugle.unit.no!news
  3. From: Harald.Eikrem@delab.sintef.no
  4. Subject: Re: sh equivalent of csh's `source` wanted
  5. Message-ID: <1992Jul31.162504*Harald.Eikrem@delab.sintef.no>
  6. Sender: news@ugle.unit.no (NetNews Administrator)
  7. Organization: SINTEF DELAB, Trondheim, Norway.
  8. References: <ericw.712530389@hobbes> <1992Jul31.082929.8331@prl.dec.com>
  9.     <1992Jul31.123358.795@usenet.ins.cwru.edu> <Bs931H.Dpv@news.cso.uiuc.edu>
  10. Date: 31 Jul 92 16:25:04
  11. Lines: 12
  12.  
  13. Anybody ever wondered about the csh (or better tcsh) equivalent of the Bourne
  14. shell `.' ?  Although I will not recommend its usage, this works:
  15.  
  16. # a 'source' command that scans $path for files with execute access, which
  17. # may fail desperately if the file isn't in a csh "sourceable" state:
  18. alias psource 'if "\!*" == "" eval "echo -n p; source"; set _f=(`which \!*`); if $#_f == 1 source "$_f"; if $#_f != 1 echo psource: "\!*": Command not found.; unset _f'
  19.  
  20. # a 'source' command that first looks for a direct path to the file to be
  21. # sourced, then tries $path:
  22. alias . 'if "\!*" == "" source; if -f "\!*" source "\!*"; if ! -f "\!*" eval "psource \!*"'
  23.  
  24.    :)  ~~harald E.
  25.