home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / shell / 3525 < prev    next >
Encoding:
Text File  |  1992-08-19  |  3.8 KB  |  90 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!ukma!darwin.sura.net!convex!convex!tchrist
  3. From: Tom Christiansen <tchrist@convex.COM>
  4. Subject: Re: Octal chmod status
  5. Originator: tchrist@pixel.convex.com
  6. Sender: usenet@news.eng.convex.com (news access account)
  7. Message-ID: <1992Aug19.130558.8488@news.eng.convex.com>
  8. Date: Wed, 19 Aug 1992 13:05:58 GMT
  9. Reply-To: tchrist@convex.COM (Tom Christiansen)
  10. References: <Bt0EEL.H1q@mudos.ann-arbor.mi.us> <1992Aug18.181609.8988@news.eng.convex.com> <Bt7t36.1w3@mudos.ann-arbor.mi.us>
  11. Nntp-Posting-Host: pixel.convex.com
  12. Organization: CONVEX Realtime Development, Colorado Springs, CO
  13. X-Disclaimer: This message was written by a user at CONVEX Computer
  14.               Corp. The opinions expressed are those of the user and
  15.               not necessarily those of CONVEX.
  16. Lines: 72
  17.  
  18. From the keyboard of mju@mudos.ann-arbor.mi.us (Marc Unangst):
  19. :In article <1992Aug18.181609.8988@news.eng.convex.com> tchrist@convex.COM (Tom Christiansen) writes:
  20. :>You might, and people might even use it if they want to lug
  21. :>another huge a.out and overly large and misplaceable foo.c 
  22. :>around with them wherever they go.  I'd just use this:
  23. :>
  24. :>    perl -e 'printf("%04o\n", (stat($ARGV[0]))[2] & 07777)'
  25. :
  26. :Hmm.  Huge a.out, huh?  Overly large foo.c, huh?  Hmm.
  27. :
  28. :mju@mudos:~$ ls -l getperms getperms.c
  29. :-rwxr-xr-x   1 mju      group       4780 Aug 19 01:06 getperms
  30. :-rw-r--r--   1 mju      group        445 Aug 15 01:08 getperms.c
  31. :mju@mudos:~$ cd /usr/local/bin
  32. :mju@mudos:/usr/local/bin$ ls -l perl*
  33. :lrwxrwxrwx   1 root     other          9 Aug 19 01:07 perl -> perl4.019
  34. :-rwxr-xr-x   1 bin      bin       283992 Aug 19 01:06 perl4.019
  35. :mju@mudos:/usr/local/bin$ cd ../src
  36. :mju@mudos:/usr/local/src$ ls -l perl-4.019.tar.Z
  37. :-rw-r--r--   1 mju      mju       801616 Aug 10 13:04 perl-4.019.tar.Z
  38. :mju@mudos:/usr/local/src$ exit
  39. :
  40. :Sure looks like my program is smaller.  Could just be an optical
  41. :illusion, though...
  42.  
  43. It is.  You're confused.
  44.  
  45.     % ls -l getperms*
  46.       60 -rwxr-xr-x  1 tchrist     60785 Aug 19 07:48 getperms
  47.        2 -rw-r--r--  1 tchrist       452 Aug 19 07:48 getperms.c
  48.        2 -rw-r--r--  1 tchrist        42 Aug 19 07:49 getperms.pl
  49.  
  50. You may only include the size of the perl compiler if you 
  51. include the size of the C compiler.  You may only include
  52. the size of the perl libraries if you include the size of
  53. the perl libraries.
  54.  
  55. I suspect that you neglected to include the shared libraries
  56. that your a.out would have sucked in.  
  57.  
  58. Notice that you KNOW perl is the right answer here because of
  59. the mystical significance of its program's length.
  60.  
  61. It took me mere seconds to write the perl solution.  It requires
  62. no separate a.out and source code, and can be easily embedded in 
  63. a shell script if you want.  How long does it take you to write
  64. the C code, compile it for every single architecture on which it
  65. might run, then copy the binary around to every machine you want
  66. to run it on?  
  67.  
  68.     % time perl getperms.pl .
  69.     0.008u 0.043s 0:00.03 50.0% 0+0k 0+0io 53pf+0w
  70.  
  71.     % time getperms .
  72.     0.001u 0.028s 0:00.02 50.0% 0+0k 0+0io 11pf+0w
  73.  
  74. Sure, the C solution does run faster: one one-hundredth of a second
  75. faster.  Big deal.  That infinitesimal time difference is surely not
  76. worth all the hassle of writing a C program for each and every little
  77. dohickey you need to whip up that's too inconvenient or inefficient to
  78. use the shell for.  If we all did that, we'd have 100 little special
  79. purpose binaries sitting around instead of using sed, awk, or perl, 
  80. and carrying our scripts, no longer self-conftained, around to wherever
  81. we needed them would be a major pain.
  82.  
  83. --tom
  84.  
  85. -- 
  86.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  87.  
  88. Besides, it's good to force C programmers to use the toolbox occasionally. :-)
  89.         --Larry Wall in <1991May31.181659.28817@jpl-devvax.jpl.nasa.gov>
  90.