home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / atari / st / tech / 4199 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  2.1 KB

  1. Path: sparky!uunet!mcsun!uknet!fulcrum!its!silver.its.bt.co.uk!jvt
  2. From: jvt@its.bt.co.uk (John Trickey)
  3. Newsgroups: comp.sys.atari.st.tech
  4. Subject: Re: Problems with ARGV
  5. Message-ID: <1992Jul30.171118.2682@its.bt.co.uk>
  6. Date: 30 Jul 92 17:11:18 GMT
  7. References: <92211.111512RESCHKE@DMSWWU1A.UNI-MUENSTER.DE> <1992Jul29.130755.27902@mks.com> <1992Jul29.221225.24054@mnemosyne.cs.du.edu>
  8. Sender: @its.bt.co.uk
  9. Organization: BT Group Computing Unix Support, Birmingham, UK
  10. Lines: 53
  11.  
  12. In article <1992Jul29.221225.24054@mnemosyne.cs.du.edu> ilepore@nyx.cs.du.edu (Ian Lepore) writes:
  13. >
  14. > > ARGV doesn't allow passing empty arguments
  15. > > use another env var to pass the position of the empty args
  16. > I don't like it.  It sounds needlessly complicated to create a whole 
  17. >'nother env var for this.  
  18.  
  19. Yes and no. I don't see the point of duplicating the information.
  20.  
  21. >  I have two variations on an idea for coping with this.  The first variation
  22. >assumes that we never pass binary values in the ARGV.  (IE, isprint() is 
  23. >TRUE for all chars appearing in the args in the ARGV area.)  In this case,
  24. >I'd recommend using \001 as a placeholder for an empty arg.  Using this,
  25. >   grep "" *.c
  26. >
  27. > would be passed as ARGV=\0grep\0\1\0*.c\0\0.  If my assumption is invalid,
  28. >and folks do pass binary data in ARGV, then use an escape system where an
  29. >empty arg is \1\1, but a true binary 1 is \1\2.  (You could even extend
  30. >this to allow passing binary zeros, escaped as \1\3 for example.)
  31. >
  32. >  Thoughts?
  33.  
  34. Am I missing something? It seems all too easy for me. Why not pass ARGC ?
  35.  
  36. so in the above example:
  37.  
  38. ARGC="3"
  39.  
  40. (assuming the cli does not interpret the *.c) and
  41.  
  42. ARGV="grep\0\0*.c\0"
  43.  
  44. (yes there are 2 \0 's on the end --- remember a str is terminated by \0)
  45.  
  46. then the startup code mimics
  47.     tmp = argc = atoi(getenv("ARGC"));
  48.     while (--tmp) {
  49.         . argv processing
  50.         .
  51.     }
  52.     . argv tidy up
  53.     main(argc, argv);
  54.  
  55. and you can pass null strings, binary data (as long as it does not
  56. contain \0) as much as you like.
  57.  
  58. -- 
  59. John Trickey <jvt@its.bt.co.uk>
  60.        Voice: +44 21 524 8200     Fax: +44 21 553 6120
  61. (Home) <john@its.bt.co.uk> || <john@g4rev.ampr.org> || G4REV @ GB7FLG
  62.        +44 21 308 8892
  63.