home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.19 / text0012.txt < prev    next >
Encoding:
Internet Message Format  |  1990-05-17  |  2.2 KB

  1. From: Maarten Litmaath <uunet!cs.vu.nl!maart>
  2.  
  3. In article <1990Mar16.194728.21389@usenet.ins.cwru.edu> of the newsgroup
  4. gnu.bash.bug, chet@cwns1.CWRU.EDU (Chet Ramey) writes:
  5. )...
  6. )Sorry Maarten, it's not a bug.  It's how aliases are defined to behave.  The
  7. )part I left out (because it's come up here before) is that aliases are 
  8. )expanded when a command is *read*, not when it is executed.  Call that a
  9. )design error, if you like, but bash and ksh do it the same way.
  10.  
  11. Conclusion: sometimes a `;' and a newline are NOT equivalent.  `Of course',
  12. you might say, but I maintain it's a design bug, because of the unexpected
  13. results.  Why can I say
  14.  
  15.     for i in *; do foo; done
  16.  
  17. instead of
  18.  
  19.     for i in *
  20.     do foo
  21.     done
  22.  
  23. but not
  24.  
  25.     alias foo=bar; foo
  26.  
  27. instead of
  28.  
  29.     alias foo=bar
  30.     foo
  31.  
  32. ?
  33.  
  34. )...  Alias expansion is done
  35. )when the command line is tokenized (at least it should be, and I have
  36. )redone expansion so it is -- vanilla bash does expansion on whole lines at
  37. )a time).  So all aliases get expanded before any `alias' commands are
  38. )executed.  [...]
  39.  
  40. I say: divide the line in logical commands and execute them in turn,
  41. expanding aliases and functions at execution time.  That's far more natural
  42. and I don't think it's much more difficult to program.
  43.  
  44. )>Bourne shell functions have the correct behavior.
  45. )
  46. )Bourne shell functions are not a complete replacement for bash/ksh aliases;
  47. )they never will be.  It's possible, for instance, to write an alias
  48. )`remote' such that 'remote x ls -l /bin/*' will pass its arguments to a
  49. )remote machine x for evaluation; that's not possible with functions because
  50. )globbing is done before the function is called.  [...]
  51.  
  52. Ridiculous!  If I say
  53.  
  54.     command /bin/*
  55.  
  56. then I don't want behavior dependent on the nature of `command'!
  57. That's precisely the bug recently discussed in comp.unix.questions:
  58.  
  59.     $ x=external
  60.     $ x=internal pwd >/dev/null
  61.     $ echo "pwd is an $x command in this version of the shell"
  62.  
  63. You do NOT repeat NOT want to make the same mistake again!
  64. (And POSIX neither.)
  65.  
  66. If I want argument evaluation on the remote machine, I will quote the
  67. arguments, thank you!
  68. --
  69.  1) Will 4.5BSD have wait5()?         |Maarten Litmaath @ VU Amsterdam:
  70.  2) Sleep(3) should be sleep(2) again.|maart@cs.vu.nl, uunet!mcsun!botter!maart
  71.  
  72. Volume-Number: Volume 19, Number 13
  73.  
  74.