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

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!news.uiowa.edu!news.weeg.uiowa.edu!dkeber
  3. From: dkeber@news.weeg.uiowa.edu (David Keber)
  4. Subject: GNU bash shell -- how to do csh alias things in bash functions
  5. Message-ID: <1992Jul24.195840.11711@news.weeg.uiowa.edu>
  6. Keywords: bash csh shell alias functions GNU
  7. Organization: University of Iowa - Weeg Computing Center
  8. Date: Fri, 24 Jul 1992 19:58:40 GMT
  9. Lines: 47
  10.  
  11. I am switching over from the csh shell to the GNU bash shell, and am
  12. having some troubles getting equivalent alias commands between the two.
  13.  
  14. Specifically, I have two directory related aliases in csh like this:
  15.  
  16.     alias dir='ls -aFglNqsT \!* | more'
  17.     alias ls='ls -CFq \!* | more'
  18.  
  19. My understanding is that you cannot put command line arguments into
  20. bash aliases (right?), so I wrote the following two bash functions:
  21.  
  22.     dir () { ls -aFglNqsT $1 | more ; }
  23.     ls () { ls -CFq $1 | more ; }
  24.  
  25. based of the example of functions given in the man page (btw/why the
  26. semicolon at the end?).  THESE FUNCTIONS DO NOT WORK.  If I rename
  27. the ls function to foo, then they both end up working correctly!
  28. Otherwise, I get some error message about fork processes.  Evidently,
  29. bash doesn't like you "functioning" UNIX commands?  I want to do an
  30. ls with the -CFq arguements almost all the time just by typing "ls".
  31. Is this somehow not possible in bash?
  32.  
  33. Another question I had was in converting the following alias:
  34.  
  35.     alias whereis "find ~ -name '\!*' -print | more"
  36.  
  37. the function I wrote was:
  38.  
  39.     whereis() { find ~ -name $1 -print | more }
  40.  
  41. For some reason, this function won't work with the single quotes just
  42. after the -name option and before the -print function (why?).  As it
  43. is now, it just works unreliably.  In csh, this is supposed to give a
  44. list of all files matching a specific pattern, for example
  45.  
  46.           whereis *.ps
  47.  
  48. would list the full pathname of any file that ended in ".ps".
  49.  
  50. This function in the bash shell, will only list one, or maybe more,
  51. but usually not all of the files that end in ".ps".  Why not?
  52.  
  53. befuddled,
  54. Dave                                               dkeber@umaxc.weeg.uiowa.edu
  55.  
  56.  
  57.  
  58.