home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / question / 14814 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.8 KB  |  53 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!malgudi.oar.net!news.ans.net!cmcl2!panix!fnord
  3. From: fnord@panix.com (Cliff Heller)
  4. Subject: Re: Simple Korn shell question
  5. Message-ID: <1992Dec18.200047.11103@panix.com>
  6. Date: Fri, 18 Dec 1992 20:00:47 GMT
  7. References: <Bz9wnp.IHz@cs.uiuc.edu> <15208@hq.hq.af.mil>
  8. Organization: Right Bleedin' Church of Libertine Obfuscatology
  9. Lines: 42
  10.  
  11. In <15208@hq.hq.af.mil> lpeters@postmaster@hq.af.mil (Leslie D Peters) writes:
  12.  
  13. >In article <Bz9wnp.IHz@cs.uiuc.edu>, schwager@mike.cs.uiuc.edu (Mike Schwager) writes:
  14. >|> Got a quick one.  If I have an alias like this:
  15. >|> 
  16. >|> alias wow='echo $@ hello there'
  17. >|> 
  18. >|> or even,
  19. >|> 
  20. >|> alias wow="echo $@ hello there"
  21. >|> 
  22. >|> Then why do I get the following when I run the alias?  To wit,
  23. >|> 
  24. >|> $ wt WOW
  25. >|> hello there WOW
  26. >|> $ 
  27. >|> 
  28. >|> The argument(s) should be first!  Why not?  The same thing happens with the
  29. >|> print command.
  30.  
  31.  
  32. >My experience is that alias uses the parameters it's given at the
  33. >end.  For those actions where *I* need something else, my $HOME/bin 
  34. >directory grows a little bit larger.
  35.  
  36. The actual fact is that ksh aliases do not accept parameters.
  37.  
  38. The $@ expands to the parameters that were passed to the shell. (Isn't it
  39. $* anyway?)
  40.  
  41. The difference between double and single quoting is when the $@ gets
  42. expanded, but in both cases it gets expanded to the same thing.  The WOW,
  43. that you stick on the command line just gets added to the command line
  44. after alias expansion.
  45.  
  46. If you want to use paramters, you have to define it as a function.
  47.  
  48. -- 
  49.     / \      Reverend fnord                 | "King Kong died for your sins!"
  50.    /   \     fnord@panix.com                | 
  51.   / <0> \                                   | "Don't just eat a hamburger, 
  52.  /_______\   Church of Obfuscatology, Inc.  |  eat the HELL out of it!"
  53.