home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume17 / parseargs / part07 < prev    next >
Encoding:
Internet Message Format  |  1991-03-18  |  61.3 KB

  1. From: brad@hcx1.ssd.csd.harris.com (Brad Appleton)
  2. Newsgroups: comp.sources.misc
  3. Subject: v17i052:  parseargs - functions to parse command line arguments, Part07/12
  4. Message-ID: <1991Mar18.155620.2062@sparky.IMD.Sterling.COM>
  5. Date: 18 Mar 91 15:56:20 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 00a33476 552c2895 40115535 19ba6afb
  8.  
  9. Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  10. Posting-number: Volume 17, Issue 52
  11. Archive-name: parseargs/part07
  12.  
  13. This is part 7 of parseargs
  14.  
  15. #!/bin/sh
  16. # this is Part.07 (part 7 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file parseargs/parseargs.h continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 7; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test ! -f _shar_wnt_.tmp; then
  33.     echo 'x - still skipping parseargs/parseargs.h'
  34. else
  35. echo 'x - continuing file parseargs/parseargs.h'
  36. sed 's/^X//' << 'SHAR_EOF' >> 'parseargs/parseargs.h' &&
  37. **    port vectors). An arg-vector is a structure which contains a count, an
  38. **    array of elements (i.e. an argc/argv pair), and an array of flags, one
  39. **    for each element of argv. There are two macros in defined in
  40. **    <parseargs.h> which are used for arg-vectors. ARGVEC_T may be used to
  41. **    declare a vector structure or a vector type; ARGVEC_EMPTY may be used
  42. **    to initialize the structure.  It is strongly recommended that ARGVEC_T
  43. **    be used to declare vector types in a typedef statement (particularly
  44. **    if one is using function prototypes) but for those who insist, it may
  45. **    be used to directly declare a  structure.  String-vectors will always
  46. **    have an extra NULL-pointer at the end such that:
  47. **
  48. **         ( StrVec.array[ StrVec.count ] == (char *)NULL )
  49. **
  50. **    is always true, and character-vectors will always have an extra NUL-
  51. **    character at the end such that:
  52. **
  53. **         ( CharVec.array[ CharVec.count ] == '\0' )
  54. **
  55. **    is always true. Integer and floating point vectors contain no extra
  56. **    "null" elements.
  57. **
  58. **    Once created, arg-vectors may be deallocated by calling the macro vec-
  59. **    Free or the macro vecDeepFree and passing it the arg-vector structure.
  60. **    The differemce between these two macros is that the latter will also
  61. **    free each item in the vector that required space to be allocated (at
  62. **    the expense of traversing the vector).  At this writing, the only
  63. **    predefined argument-type(s) that would benefit from vecDeepFree is
  64. **    argStr vectors.
  65. **
  66. **    An example use of arg-lists, and of arg-vectors follows:
  67. **
  68. **         #include <parseargs.h>
  69. **
  70. **         typedef ARGVEC_T(char *) strvec_t;
  71. **
  72. **         static ArgList  *StringList = ARGLISTNULL;
  73. **         static strvec_t  StringVec = ARGVEC_EMPTY(char *);
  74. **         static ARGVEC_T(int)  NumberVec = ARGVEC_EMPTY(int);
  75. **
  76. **         static
  77. **          CMD_OBJECT  Args
  78. **          CMD_NAME    "foo -- do whatever foo does"
  79. **          CMD_DESCRIPTION  "put a brief paragraph here"
  80. **          CMD_ARGUMENTS
  81. **            'l', ARGLIST, listStr, __ &StrList, "LiSt {list of strings}",
  82. **            's', ARGVEC,  argStr,  __ &StrVec,  "STRing {vector of strings}",
  83. **            'i', ARGVEC,  argInt,  __ &NumVec,  "NUMber {vector of numbers}",
  84. **            END_ARGUMENTS
  85. **          CMD_END
  86. **
  87. **         main( int argc, char *argv[] )
  88. **         {
  89. **            int i, *ls;
  90. **
  91. **            if ( parseargs(argv, Args) )  syserr( "parseargs failed" );
  92. **
  93. **            for ( ls = StrList, i=1 ; ls ; ls = L_NEXT(ls), i++ )
  94. **               printf( "List item %d=%s, flags=%x0\n",
  95. **                       i, L_STRING(ls), L_FLAGS(ls) );
  96. **
  97. **            for ( i = 0 ; i < StrVec.count ; i++ )
  98. **               printf( "String[%d]=%s, flags=%x0\n",
  99. **                       i, StrVec.array[i], StrVec.flags[i] );
  100. **
  101. **            for ( i = 0 ; i < NumVec.count ; i++ )
  102. **               printf( "Number[%d]=%s, flags=%x0\n",
  103. **                       i, NumVec.array[i], NumVec.flags[i] );
  104. **
  105. **            listFree( StrList );
  106. **            StrList = ARGLISTNULL;
  107. **
  108. **            vecDeepFree( StrVec, char * );
  109. **            vecFree( NumVec, int );
  110. **
  111. **            exit( 0 );
  112. **         }
  113. **
  114. **^^***********************************************************************/
  115. X
  116. X   /* definition of an arg-list */
  117. typedef struct arglist {
  118. X   struct arglist  *nl_next;  /* pointer to next item */
  119. X   ARBPTR           nl_val;   /* value of current item */
  120. X   argMask_t        nl_flags; /* flags for current item */
  121. } ArgList;
  122. #define ARGLISTNULL  (ArgList *)NULL
  123. X
  124. X   /* definition of an arg-list-head (the first two fields MUST exactly
  125. X   ** overlay with their corresponding elements in an ArgList struct)
  126. X   */
  127. typedef struct arglisthead {
  128. X   ArgList  *nl_next;  /* pointer to next item */
  129. X   ARBPTR    nl_val;   /* value of current item */
  130. X   argMask_t nl_flags; /* flags for current item */
  131. X   ArgList  *nl_tail;  /* pointer to last item */
  132. } ArgListHead;
  133. #define ARGLISTHEADNULL  (ArgListHead *)NULL
  134. X
  135. X   /*
  136. X   ** macros to manipulate arg-lists
  137. X   */
  138. #define L_STRING(ls)   ((char *)((ls)->nl_val))  /* Item as a string */
  139. #define L_NEXT(ls)     ((ls)->nl_next)           /* Next item of list */
  140. #define L_ADVANCE(ls)  (ls) = (ArgList *)L_NEXT(ls) /* Advance list ptr */
  141. #define L_FLAGS(ls)    ((ls)->nl_flags)          /* flags of current item */
  142. X
  143. X   /*
  144. X   ** macros to declare and initialize arg-vectors
  145. X   **   (NOTE: this wont work for vectors of function pointers)
  146. X   */
  147. #define ARGVEC_T(type) \
  148. X    struct { type  *array; unsigned short  count; argMask_t *flags; }
  149. #define ARGVEC_EMPTY(type) \
  150. X    { (type *) NULL, (unsigned short) 0, (argMask_t *) NULL }
  151. X
  152. X
  153. /**********************************************************************
  154. ** ^SECTION: PARSE-FLAGS
  155. **    The following bitmasks may be combined in order to modify the
  156. **    behavior of the parseargs library. The parse flags for a given
  157. **    may be set through the use of the parsecntl() function.
  158. */
  159. #define pa_PROMPT    0x0001
  160. /*    -- Prompt the user for any missing arguments that are required on the
  161. **       command-line. No special escaping or quoting is performed on the
  162. **       user input. Required arguments that expect a list of values will
  163. **       be repeatedly prompted for (one item per line) until a blank line
  164. **       (followed by a carriage return) is entered.
  165. */
  166. #define pa_IGNORE    0x0002
  167. /*    -- Ignore any unrecognized or improperly specified command-line arguments
  168. **       and continue execution of the program. Normally, if an argument is
  169. **       unmatched (or is improperly specified), a usage message is printed
  170. **       program execution is terminated.
  171. */
  172. #define pa_OPTSONLY  0x0004
  173. /*    -- Under UNIX, setting this flag will disable the parsing of long-option
  174. **       syntax. This will cause all arguments starting with '+' to always be
  175. **       treated as a positional parameter (instead of a long-option).
  176. */
  177. #define pa_KWDSONLY  0x0008
  178. /*    -- Under UNIX, setting this flag disables the parsing of single-character
  179. **       options.  This will cause all arguments starting with '-' to always
  180. **       be treated as a positional parameter (instead of an option).
  181. */
  182. #define pa_FLAGS1ST  0x0010
  183. /*    -- Setting this flag causes the parseargs library to force any and all
  184. **       non-positional arguments to be specified before any positional ones.
  185. **       As an example, under UNIX, if this flag is SET then parseargs will
  186. **       consider the command line "cmd -x arg" to consist of one option and
  187. **       one positional argument; however the command line "cmd arg -x" would
  188. **       be considered to consist of two positional arguments (the -x option
  189. **       will be unmatched).
  190. **
  191. **       If this flag is UNSET, then both of the previous examples are
  192. **       considered to consist of one option and one positional argument.
  193. */
  194. #define pa_ANYCASE   0x0020
  195. /*    -- Setting this flag cause character-case to be ignored when attempting
  196. **       to match single-character argument names (i.e. causes "-i" and "-I"
  197. **       will be considered equivalent).
  198. */
  199. #define pa_ARGV0     0x0040
  200. /*    -- Normally, the parseargs library will assume that the first argument
  201. **       on the command-line is the name of the command. Setting this flag
  202. **       tells parseargs that this is NOT the case and that the very first
  203. **       argument on the command-line is a bona-fide argument to the command.
  204. */
  205. #define pa_NOCHECK   0x0080
  206. /*    -- Setting this flag will prevent parseargs from checking for any 
  207. **       required arguments that were not given on the command-line. This
  208. **       is useful when more than one call to the parseargs library is needed
  209. **       to parse all the command-line arguments (which could occur if the
  210. **       command-line argument came from a file or from two argv-vectors).
  211. **
  212. **       Keeping this flag on until the final set of arguments is parsed will
  213. **       cause parseargs to not check for missing arguments until the last set
  214. **       of arguments has been parsed (by the final call to *parseargs).
  215. */
  216. #define pa_CONTINUE  0x0100
  217. /*    -- Setting this flag will cause subsequent calls to the parseargs library
  218. **       to NOT reset the current command-state. Hence, all arguments will not
  219. **       be initially set to "NOT GIVEN" and other (normal) initializations are
  220. **       not be performed.  This is useful in conjunction with the pa_NOCHECK
  221. **       when more than one call to parseargs is required to parse all the
  222. **       command arguments. In this scenario, pa_CONTINUE should be unset (the
  223. **       default setting) for the very first call to parseargs, but should then
  224. **       be set before any subsequent calls to parseargs are made.
  225. */
  226. #define pa_NOCMDENV  0x0200
  227. /*    -- Setting this flag prevents parseargs from checking the <CMD-NAME>_ARGS
  228. **       environment variable for any user-defined default command arguments.
  229. */
  230. #define pa_COPYF     0x0400
  231. /*    -- When this flag is OFF (the default), a value of FALSE is provided as
  232. **       the <copyf> argument to all the arg-type (argXxxxx) functions when an
  233. **       argument is matched. Setting this flag will cause a value of TRUE to
  234. **       be provided as the <copyf> argument to all the arg-type (argXxxxx)
  235. **       functions when an argument is matched.
  236. */
  237. /**^^**********************************************************************/
  238. X
  239. X
  240. /**********************************************************************
  241. ** ^SECTION: PARSE-CNTLS - specify which attributes to get/set
  242. **    Each of the following function codes specifies an attribute that
  243. **    is to be manipulated by parsecntl(3).  The function code is the
  244. **    second parameter to parsecntl(3). With the exception of pc_ARGFLAGS,
  245. **    each of the function codes corresponds to a call to parsecntl(3) 
  246. **    using four parameters (pc_ARGFLAGS uses 5 parameters). In each case,
  247. **    the last parameter is either the address of a buffer to write the
  248. **    attribute to, or the actual buffer to read the attribute from 
  249. **    (depending upon the mode -- the third parameter to parsecntl).
  250. */
  251. typedef enum  {
  252. X   pc_PARSEFLAGS,
  253. /*    -- get/set parse flags
  254. **
  255. **    This function code is used to read and/or modify the existing parsing 
  256. **    parsing behavior. The fourth parameter to parsecntl should be a 
  257. **    combination of pc_XXXX bitmasks if the parse-flags are only being
  258. **    written, otherwise it should be a pointer to an argMask_t variable.
  259. */
  260. X   pc_ARGFLAGS,
  261. /*    -- get/set argument flags
  262. **
  263. **    This function code may only be used to read the argument-flags of
  264. **    a named argument. It is an error to specify a mode that attempts
  265. **    to write the argument-flags with this function code. The fourth
  266. **    parameter to parsecntl should be the keyword name of the argument
  267. **    whose flags are to be read. The fifth (and final) argument should
  268. **    be a pointer to the argMask_t variable which will receive the resulting
  269. **    argument-flags.
  270. */
  271. X   pc_DEFARGS,
  272. /*    -- get/set the default arguments
  273. **
  274. **    This function code is used to query or modify the current default
  275. **    argument-descriptor list for the given command. The fourth parameter
  276. **    to parsecntl should be the argument-descriptor array to assign as the
  277. **    new default-list (or the address of an argdesc-array if the default
  278. **    list is being retrieved).
  279. **
  280. **    If a given option/qualifier does not appear to match any items in the
  281. **    argdesc-array, a  default argdesc-array is then searched to match the
  282. **    option. If it is STILL unmatched then it is flagged as such. The
  283. **    default-argdesc array is automatically used by all programmer-defined
  284. **    argdesc-array but may be unset or reset using the pc_DEFARGS function
  285. **    of parsecntl(3). In such a  manner, a  programmer could specify a dif-
  286. **    ferent set of default-arguments to search for. Furthermore, default
  287. **    argdesc-arrays may also be assigned default argdesc-arrays, thus
  288. **    allowing the programmer to define a whole search-list of default
  289. **    argdesc-arrays for a given command.
  290. **
  291. **    This could prove useful in a situation where a set of commands have a
  292. **    few common-options and differ in their remaining ones. If the same
  293. **    main() were used for each command, then main could define one common
  294. **    argdesc-array and then a set of argdesc-arrays for each command. Main
  295. **    could then figure out which argdesc-array to used based on the name in
  296. **    argv[0], and set its default argdesc-array to be the common argdesc-
  297. **    array, as in the following:
  298. **
  299. **         #include <parseargs.h>
  300. **             .
  301. **             . variable declarations
  302. **             .
  303. **
  304. **         static ARGDESC common_args[] = {
  305. **            STARTOFARGS,
  306. **            'L', ARGOPT, argBool, __ &lflag, "list (list available items)"
  307. **            'I', ARGOPT, argStr, __ &item, "item (specify item to use)",
  308. **            ENDOFARGS
  309. **         };
  310. **
  311. **         static ARGDESC cmd1_args[] = {
  312. **            STARTOFARGS,
  313. **            's', ARGOPT, argBool, __ &sflag, "S (set S)",
  314. **            't', ARGOPT, argBool, __ &tflag, "T (set T)",
  315. **            ENDOFARGS
  316. **         };
  317. **
  318. **         static ARGDESC cmd2_args[] = {
  319. **            STARTOFARGS,
  320. **            'x', ARGOPT, argBool, __ &xflag, "X (set X)",
  321. **            'y', ARGOPT, argBool, __ &yflag, "Y (set Y)",
  322. **            ENDOFARGS
  323. **         };
  324. **
  325. **         main( argc, argv ) int argc; char *argv[];
  326. **         {
  327. **            ARGDESC *cmd = cmd1_args;
  328. **            int status;
  329. **
  330. **            if ( strcmp(*argv, "cmd2") == 0 ) cmd = cmd2_args;
  331. **
  332. **            if ( parsecntl( cmd, pc_DEFARGS, pc_WRITE, common_args ) != 0 )
  333. **               syserr( "unable to set default args" );
  334. **
  335. **            status = parseargs( argv, cmd );
  336. **                   .
  337. **                   .
  338. **                   .
  339. **         }
  340. **
  341. **    Note that in the above call to parsecntl(3), that zero will be
  342. **    returned upon success and non-zero upon failure. If pe_DEFARGS is
  343. **    returned, then cmd is already on common_args's list of defaults (and
  344. **    would result in an infinite loop while parsing).
  345. */
  346. X   pc_NAME,
  347. /*    -- get/set the command-name
  348. */
  349. X   pc_PURPOSE,
  350. /*    -- get/set the command-purpose
  351. */
  352. X   pc_DESCRIPTION
  353. /*    -- get/set the command-description
  354. */
  355. /*    Each of these last three function codes are used to modify or query the
  356. **    name, purpose, or description associated with a command. The fourth
  357. **    parameter to parsecntl should be the new string to use (or the address
  358. **    of the string, a char** variable, to recieve the current value).
  359. */
  360. } parsecntl_t;
  361. X
  362. /**^^**********************************************************************/
  363. X
  364. X
  365. /**********************************************************************
  366. ** ^SECTION: PARSE-MODES - modes to get/set command attributes.
  367. **    Parsecntl may be used to read current command attributes, write/assign
  368. **    new command attributes, or both. The mode argument to parsecntl
  369. **    determines the which of these three alternatives are desired. If the
  370. **    programmer merely wishes to assign new attributes, then invoking
  371. **    parsecntl in pc_WRITE mode and passing the new attributes will do the
  372. **    job. If the programmer wishes simply to query attributes, then
  373. **    invoking parsecntl in pc_READ mode and passing a pointer to the
  374. **    desired object in which to write the attribute settings will suffice.
  375. **
  376. **    If the programmer wishes to assign new attributes and at the same time
  377. **    find out what the attributes were before making the assignment, then
  378. **    programmer must invoke parsecntl for pc_RDWR mode and pass a pointer
  379. **    to the object containing the new attribute settings; When parsecntl
  380. **    returns, then (assuming it returns 0) the desired attributes will have
  381. **    been assigned and the object that contained the new attribute settings
  382. **    will now contain the attribute settings that were in effect before
  383. **    parsecntl was invoked.
  384. */
  385. typedef enum  {
  386. X   pc_READ,
  387. /*    -- read-mode: attributes are retrieved
  388. */
  389. X   pc_WRITE,
  390. /*    -- write-mode: attributes are assigned new values
  391. */
  392. X   pc_RDWR
  393. /*    -- read/write-mode: attributes are retrieved and then assigned
  394. */
  395. X
  396. } parsemode_t;
  397. /**^^**********************************************************************/
  398. X
  399. X
  400. X   /*
  401. X   ** private (implementation specific) definitions
  402. X   */
  403. #ifdef PARSEARGS_PRIVATE
  404. X
  405. X   /* macros to define command-line style specific character sequences */
  406. # ifdef amiga_style
  407. #   define  s_ARG_SEP  "=:"  /* AmigaDOS argument separator characters */
  408. # endif
  409. # ifdef ibm_style
  410. #   define  s_ARG_SEP  "="  /* MS-DOS and OS/2 argument separator characters */
  411. # endif
  412. # ifdef unix_style
  413. #   define  c_OPT_PFX  '-'   /* Unix option prefix character */
  414. #   define  c_KWD_PFX  '+'   /* Unix keyword prefix character */
  415. #   define  s_ARG_SEP  "=:"  /* Unix keyword-value separator characters */
  416. # endif
  417. # ifdef vms_style
  418. #   define  s_KWD_PFX  "/"   /* VMS qualifier prefix character */
  419. #   define  s_LSI_SEP  ",+"  /* VMS LiSt Item separator characters */
  420. #   define  s_ARG_SEP  "=:"  /* VMS qualifier-value separator characters */
  421. # endif
  422. X
  423. X
  424. X   /* call the function to parse the given argument-value string */
  425. # define HANDLE(ad,vp,pflags) ((*arg_type(ad))(ad, vp, BTEST(pflags, pa_COPYF)))
  426. X
  427. X
  428. X   /* parse-state flags */
  429. # define  ps_OLDSTYLE     0x01  /* force backward compatibility? */
  430. # define  ps_NOFLAGS      0x02  /* opt/kwd parsing in effect? */
  431. # define  ps_NOCMDENV     0x04  /* <CMD>_ARGS environment-variable parsed? */
  432. # define  ps_NOPARSECNTL  0x08  /* PARSECNTL environment-variable parsed? */
  433. X
  434. typedef unsigned char   ps_flags_t;
  435. X
  436. X
  437. X   /*
  438. X   ** structure to hold arg-desc pointers maintained in the command-context
  439. X   */
  440. typedef struct {
  441. X   ARGDESC  *default_argd;   /* pointer to default args */
  442. X   ARGDESC  *current_list;   /* pointer to ad with arglist (or argvector)
  443. X                             ** that is currently being appended.
  444. X                             */
  445. # ifdef amiga_style
  446. X     ARGDESC  *previous_ad;  /* pointer to previously matched ad */
  447. # endif
  448. } ARGDPTRS;
  449. X
  450. X   /*
  451. X   ** structures to replace the first and last argument descriptor
  452. X   ** in a command (each field must exactly overlay its counterpart
  453. X   ** in an ARGDESC struct).
  454. X   */
  455. typedef struct  {
  456. X   char        id;      /* id is ALWAYS '\0' for first and last ad */
  457. X   ps_flags_t  state_flags;  /* current parse-state */
  458. X   CONST char *argv0;   /* argv[0] from the command-line */
  459. X   ARGDPTRS   *argdp;   /* structure with ARGDESC pointers */
  460. X   CONST char *purpose; /* one-line purpose provided with CMD_NAME */
  461. } CTXDESC;  /* the command-context */
  462. X
  463. typedef struct  {
  464. X   char        id;      /* id is ALWAYS '\0' for first and last ad */
  465. X   argMask_t   parse_flags;  /* current parse-flag bitmasks */
  466. X   CONST char *name;    /* command-name provided with CMD_NAME */
  467. X   CTXDESC    *context; /* pointer to command-context */
  468. X   CONST char *description;  /* description provided with CMD_DESCRIPTION */
  469. } CMDDESC; /* the command-descriptor */
  470. X
  471. X   /*
  472. X   ** macros to extract command-line attributes in the command-object
  473. X   */
  474. # define  cmd_desc(cmd)         (CMDDESC *)cmd
  475. # define  cmd_id(cmd)           (cmd_desc(cmd)) -> id
  476. # define  cmd_flags(cmd)        (cmd_desc(cmd)) -> parse_flags
  477. # define  cmd_name(cmd)         (cmd_desc(cmd)) -> name
  478. # define  cmd_description(cmd)  (cmd_desc(cmd)) -> description
  479. # define  cmd_context(cmd)      (cmd_desc(cmd)) -> context
  480. # define  cmd_ctxid(cmd)        (cmd_context(cmd)) -> id
  481. # define  cmd_state(cmd)        (cmd_context(cmd)) -> state_flags
  482. # define  cmd_argv0(cmd)        (cmd_context(cmd)) -> argv0
  483. # define  cmd_purpose(cmd)      (cmd_context(cmd)) -> purpose
  484. # define  cmd_ptrs(cmd)         (cmd_context(cmd)) -> argdp
  485. # define  cmd_defargs(cmd)      (cmd_ptrs(cmd)) -> default_argd
  486. # define  cmd_list(cmd)         (cmd_ptrs(cmd)) -> current_list
  487. # ifdef amiga_style
  488. #   define  cmd_prev(cmd)  (cmd_ptrs(cmd)) -> previous_ad
  489. # endif
  490. X
  491. X   /* macro to determine if a command-object has been initialized */
  492. # define  CMD_isINIT(cmd)  \
  493. X   ( !cmd_id(cmd)  &&  cmd_context(cmd) )
  494. X
  495. X   /*
  496. X   ** macros to help ascertain argument type
  497. X   */
  498. # define ARG_isBOOLEAN(ad)   \
  499. X   ( arg_type(ad) == argBool  || arg_type(ad) == argSBool || \
  500. X     arg_type(ad) == argUBool || arg_type(ad) == argTBool    \
  501. X   )
  502. # define ARG_isPSEUDOARG(ad) \
  503. X   ( arg_type(ad) == argEnd   || \
  504. X     arg_type(ad) == argUsage || \
  505. X     arg_type(ad) == argDummy    \
  506. X   )
  507. X
  508. X   /*
  509. X   ** macros to assist in traversing a command-object
  510. X   */
  511. # define  ARG_FIRST(cmd)   ((cmd) + 1)
  512. # define  ARG_LAST(cmd)    ( ((ARGDESC *)cmd_context(cmd)) - 1 )
  513. # define  ARG_isEND(ad)    ( arg_cname(ad)  ==  '\0' )
  514. # define  ARG_ADVANCE(ad)  (ad)++
  515. # define  ARG_RETREAT(ad)  (ad)--
  516. X
  517. X
  518. /**********************************************************************
  519. ** ^SECTION: USAGECNTL
  520. **    Each of the different values in $USAGECNTL corresponds to a
  521. **    bitmask as follows:
  522. */
  523. # define  usg_NONE         0x0001
  524. /*    -- "Quiet", "Silent", and "None" : dont print usage
  525. */
  526. # define  usg_VERBOSE      0x0002
  527. /*    -- "Verbose", "!Terse" : print argument descriptions
  528. */
  529. # define  usg_OPTS         0x0004
  530. /*    -- "Options" -- print option syntax
  531. */
  532. # define usg_LONGOPTS     0x0008
  533. /*    -- "LongOpts", "KeyWords" : print long-option/keyword syntax
  534. */
  535. # define  usg_DESCRIPTION  0x0010
  536. /*    -- "Description" : print the command description
  537. */
  538. # define  usg_PAGED        0x0020
  539. /*    -- "Paged" : pipe the usage message through a paging program
  540. */
  541. /**^^**********************************************************************/
  542. X
  543. #endif /* PARSEARGS_PRIVATE */
  544. X
  545. X   /*
  546. X   ** pre-defined types available for ad_type
  547. X   */
  548. #ifndef PARSEARGS_NARGTYPES
  549. # define  ARGTYPE(name)  EXTERN  BOOL  name ARGS(( ARGDESC *, char *, BOOL ))
  550. X   ARGTYPE( argUsage );
  551. X   ARGTYPE( argEnd );
  552. X   ARGTYPE( argDummy );
  553. X   ARGTYPE( argBool );
  554. X   ARGTYPE( argSBool );
  555. X   ARGTYPE( argUBool );
  556. X   ARGTYPE( argTBool );
  557. X   ARGTYPE( argChar );
  558. X   ARGTYPE( argStr );
  559. X   ARGTYPE( argInt );
  560. X   ARGTYPE( argShort );
  561. X   ARGTYPE( argLong );
  562. X   ARGTYPE( argFloat );
  563. X   ARGTYPE( argDouble );
  564. X   ARGTYPE( listStr );
  565. X   EXTERN  VOID  listFree ARGS((ArgList *argls));
  566. # define vecFree(vec,type)  \
  567. X    do { \
  568. X        if ( vec.count > 0 ) { \
  569. X            if ( vec.array )  free( vec.array ); \
  570. X            if ( vec.flags )  free( vec.flags ); \
  571. X        } \
  572. X        vec.array = (type *)NULL; \
  573. X        vec.flags = (argMask_t *)NULL; \
  574. X        vec.count = 0; \
  575. X    } while ( 0 )
  576. # define vecDeepFree(vec,type)  \
  577. X    do { \
  578. X        register int i; \
  579. X \
  580. X        for ( i = 0 ; i < vec.count ; i++ ) \
  581. X            if ( BTEST(vec.flags[i], ARGCOPYF) ) \
  582. X                free( (ARBPTR) vec.array[i] ); \
  583. X \
  584. X        if ( vec.count > 0 ) { \
  585. X            if ( vec.array )  free( vec.array ); \
  586. X            if ( vec.flags )  free( vec.flags ); \
  587. X        } \
  588. X        vec.array = (type *)NULL; \
  589. X        vec.flags = (argMask_t *)NULL; \
  590. X        vec.count = 0; \
  591. X    } while ( 0 )
  592. X
  593. # undef ARGTYPE
  594. #endif  /* PARSEARGS_NARGTYPES */
  595. X
  596. X   /*
  597. X   ** parseargs library function-prototypes
  598. X   */
  599. #ifndef  PARSEARGS_NEXTERNS
  600. X   EXTERN int   fparseargs  ARGS(( FILE *, ARGDESC * ));
  601. X   EXTERN int   lparseargs  ARGS(( ArgList *, ARGDESC * ));
  602. X   EXTERN int   sparseargs  ARGS(( char *, ARGDESC * ));
  603. X   EXTERN int   vparseargs  ARGS(( ARGDESC *, int, ...));
  604. X   EXTERN int   parseargs   ARGS(( char **, ARGDESC * ));
  605. X   EXTERN int   parsecntl   ARGS(( ARGDESC *, parsecntl_t, parsemode_t, ...));
  606. X   EXTERN VOID  usage       ARGS(( const ARGDESC * ));
  607. X   EXTERN VOID  init_args   ARGS(( ARGDESC * ));
  608. X   extern CONST char *ProgName;
  609. #endif  /* PARSEARGS_NEXTERNS */
  610. X
  611. #endif  /* PARSEARGS_H */
  612. SHAR_EOF
  613. echo 'File parseargs/parseargs.h is complete' &&
  614. chmod 0664 parseargs/parseargs.h ||
  615. echo 'restore of parseargs/parseargs.h failed'
  616. Wc_c="`wc -c < 'parseargs/parseargs.h'`"
  617. test 42981 -eq "$Wc_c" ||
  618.     echo 'parseargs/parseargs.h: original size 42981, current size' "$Wc_c"
  619. rm -f _shar_wnt_.tmp
  620. fi
  621. # ============= parseargs/parseargs.pl ==============
  622. if test -f 'parseargs/parseargs.pl' -a X"$1" != X"-c"; then
  623.     echo 'x - skipping parseargs/parseargs.pl (File already exists)'
  624.     rm -f _shar_wnt_.tmp
  625. else
  626. > _shar_wnt_.tmp
  627. echo 'x - extracting parseargs/parseargs.pl (Text)'
  628. sed 's/^X//' << 'SHAR_EOF' > 'parseargs/parseargs.pl' &&
  629. ;#########################################################################
  630. ;# ^FILE: parseargs.pl - parseargs for perl programs
  631. ;#
  632. ;# ^DESCRIPTION:
  633. ;#    This file defines a perl function named parseargs to parse
  634. ;#    command-line arguments for perl scripts.
  635. ;#
  636. ;# ^HISTORY:
  637. ;#    02/25/91    Brad Appleton    <brad@ssd.csd.harris.com>    Created
  638. ;##^^#####################################################################
  639. X
  640. X
  641. ;########
  642. ;# ^FUNCTION: parseargs - parse command-line argument vectors
  643. ;#
  644. ;# ^SYNOPSIS:
  645. ;#    rc = &parseargs( @argv, $argd )
  646. ;#
  647. ;# ^PARAMETERS:
  648. ;#    argv -- the vector of command-line arguments (usually ARGV).
  649. ;#    argd -- the argument-description string
  650. ;#
  651. ;# ^DESCRIPTION:
  652. ;#    Parseargs will invoke parseargs(1) to parse the command-line given
  653. ;#    in <argv> for the command defined by <argd>.  The resulting values
  654. ;#    will be assigned to the variables indicated by the argument-description
  655. ;#    string.
  656. ;#
  657. ;# ^REQUIREMENTS:
  658. ;#    Any desired initial values for variables from the argument-description
  659. ;#    string should be assigned BEFORE calling this function.
  660. ;#
  661. ;#    The following global variables may be assigned before calling parseargs:
  662. ;#
  663. ;#       PARSEOPTS -- any extra options to pass to parseargs() (default="-u")
  664. ;#
  665. ;# ^SIDE-EFFECTS:
  666. ;#    The global variable PARSEARGS will contain the command-line used to
  667. ;#    invoke parseargs(1).
  668. ;#
  669. ;#    ARGV and ARGC may be reset, all other values are (re)set in <arr>.
  670. ;#
  671. ;# ^RETURN-VALUE:
  672. ;#    The exit code returned by parseargs(1).
  673. ;#
  674. ;# ^ALGORITHM:
  675. ;#    - set defaults for PARSEOPTS
  676. ;#    - build the parseargs command (dont forget to quote arguments).
  677. ;#    - run parseargs(1) and evaluate the output unless $?
  678. ;##^^####
  679. X
  680. sub parseargs {
  681. X    local(@argv) = @_;
  682. X    local($argd);
  683. X    local($parse_output);
  684. X    local($_);
  685. X    local($[) = 0;
  686. X    local($i);
  687. X
  688. X    $argd = pop( @argv );   ## get last arg and remove it
  689. X
  690. X    if ( $PARSEOPTS == "" ) {
  691. X        $PARSEOPTS = '-u';
  692. X    }
  693. X    $PARSEARGS = 'parseargs -s perl ' . $PARSEOPTS . " -- '" . $0 . "'";
  694. X    for ( $i = $[ ; $i <= $#argv ; $i++ ) {
  695. X      $argv[$i] =~ s/'/'\\''/g;
  696. X      $PARSEARGS .= " '" . $argv[$i] . "'";
  697. X    }
  698. X    $parse_output = `echo \'$argd\' | $PARSEARGS`;
  699. X    eval $parse_output unless $?;
  700. X    if ( $? ) {
  701. X      $! = 0;
  702. X      die "\n";
  703. X    }
  704. }
  705. X
  706. 1;
  707. SHAR_EOF
  708. chmod 0775 parseargs/parseargs.pl ||
  709. echo 'restore of parseargs/parseargs.pl failed'
  710. Wc_c="`wc -c < 'parseargs/parseargs.pl'`"
  711. test 2311 -eq "$Wc_c" ||
  712.     echo 'parseargs/parseargs.pl: original size 2311, current size' "$Wc_c"
  713. rm -f _shar_wnt_.tmp
  714. fi
  715. # ============= parseargs/parseargs1.txt ==============
  716. if test -f 'parseargs/parseargs1.txt' -a X"$1" != X"-c"; then
  717.     echo 'x - skipping parseargs/parseargs1.txt (File already exists)'
  718.     rm -f _shar_wnt_.tmp
  719. else
  720. > _shar_wnt_.tmp
  721. echo 'x - extracting parseargs/parseargs1.txt (Text)'
  722. sed 's/^X//' << 'SHAR_EOF' > 'parseargs/parseargs1.txt' &&
  723. X
  724. X
  725. X
  726. PARSEARGS(1)                         PARSEARGS(1)
  727. X
  728. X
  729. X
  730. NAME
  731. X     parseargs - parse command line arguments in shell scripts
  732. X
  733. SYNOPSIS
  734. X     parseargs     [-U] [-M] [-T string] [-F string] [-A]    [-a arg-
  735. X         spec] [-e name] [-f file] [-l]    [-o] [-s shell]
  736. X         [-u] [-i] [-p]    -- name    [arguments ...]
  737. X
  738. OPTIONS
  739. X     -U           just    print program usage, do    not parse the
  740. X           command line
  741. X
  742. X     -M           just    print (n|t)roff    -man manual page
  743. X           template, do    not parse the command line
  744. X
  745. X     -T    string       string to use for true boolean arguments
  746. X           (default=``TRUE'')
  747. X
  748. X     -F    string       string to use for false boolean arguments
  749. X           (default=``'')
  750. X
  751. X     -A           modify array    behavior for the specified shell.
  752. X
  753. X     -a    arg-spec   argument specification string
  754. X
  755. X     -e    name       read    the arg-spec string from the environment
  756. X           variable named name
  757. X
  758. X     -f    file       read    the arg-spec from file    (default=stdin)
  759. X
  760. X     -l           Long-options    only. Disable the parsing of
  761. X           (single-character) options.
  762. X
  763. X     -o           Options only. Disable the parsing of    long-
  764. X           options (keywords).
  765. X
  766. X     -s    shell       use shell command syntax  (default=``sh'')
  767. X
  768. X     -u           unset positional parameters before assigning
  769. X           variables
  770. X
  771. X     -p           prompt the user for missing required    arguments
  772. X
  773. X     -i           ignore bad command-line syntax and continue
  774. X           processing (instead of aborting)
  775. X
  776. ARGUMENTS
  777. X     --           Indicates that any remaining    options    are
  778. X           intended for    the calling program.
  779. X
  780. X     name       name    of calling program
  781. X
  782. X
  783. X
  784. X
  785. Page 1
  786. X
  787. X
  788. X
  789. X
  790. X
  791. X
  792. PARSEARGS(1)                         PARSEARGS(1)
  793. X
  794. X
  795. X
  796. X     arguments       arguments to    calling    program
  797. X
  798. DESCRIPTION
  799. X     Given a command name, a vector of string-valued arguments
  800. X     such as that passed to a shell script, and    a specification
  801. X     string describing the possible arguments, parseargs matches
  802. X     actual arguments to possible arguments, converts values to
  803. X     the desired type, and diagnoses problems such as missing
  804. X     arguments,    extra arguments, and argument values that are
  805. X     syntactically incorrect.  Other behavior such as prompting
  806. X     the user for missing arguments and    ignoring as command-line
  807. X     syntax may    be specified on    the command-line through the use
  808. X     of    various    options, or through the    use of the ``PARSECNTL''
  809. X     environment variable.
  810. X
  811. X     Given the command name and    the argument specification
  812. X     string, parseargs -U prints a reasonably friendly version of
  813. X     the usage of the calling program on standard diagnostic
  814. X     output. The ``verbosity'' of the usage message may    be
  815. X     controlled    through    the use    of the ``USAGECNTL'' environment
  816. X     variable.
  817. X
  818. X     Given the command name and    the argument specification
  819. X     string, parseargs -M prints a template of the command-syntax
  820. X     on    standard output    that is    suitable for input to nroff or
  821. X     troff using the -man macro    package.
  822. X
  823. X     The argument specification    string contains    one entry for
  824. X     each possible flag.  Entries in the arguments specification
  825. X     string are    separated by commas.  Each entry has five comma-
  826. X     separated fields:    a name,    some flags, a type, a variable-
  827. X     name, and a prompt.  Each of these    fields are described
  828. X     below:
  829. X
  830. X     name      The single character name of the    associated flag.
  831. X           For example, to indicate    that the program is
  832. X           expecting a ``-x'' flag,    this field would contain
  833. X           'x'.  Positional    arguments (those without a ``-x''
  834. X           prefix) are indicated by    passing    a ``space''
  835. X           character.
  836. X
  837. X     flags     Flags modifying the semantics of    this entry.
  838. X           These should have one of    ARGREQ to indicate a
  839. X           required    argument or ARGOPT to indicate an
  840. X           optional    argument (ARGOPT is the    default    unless
  841. X           ARGREQ is specified).  ARGPOS can be ``ored'' in
  842. X           to indicate a positional    argument that may also be
  843. X           keyword matched.     ARGNOVAL can be ``ored'' in to
  844. X           indicate    that an    argument is an option or a
  845. X           keyword that does not use an accompanying argument
  846. X           (such as    a boolean flag). This flag is only
  847. X           required    for corresponding argument types that are
  848. X
  849. X
  850. X
  851. Page 2
  852. X
  853. X
  854. X
  855. X
  856. X
  857. X
  858. PARSEARGS(1)                         PARSEARGS(1)
  859. X
  860. X
  861. X
  862. X           implemented by the programmer; parseargs    already
  863. X           knows which pre-defined argument    types take an
  864. X           argument.  ARGVALOPT can    be ``ored'' in to
  865. X           indicate    that an    argument to the    option may be
  866. X           optionally supplied on the command-line,    but is
  867. X           not required.  ARGVALREQ    can be ``ored''    in to
  868. X           indicate    that an    argument to the    option is
  869. X           required    (this is the default behavior for options
  870. X           that take arguments).  ARGLIST can be ``ored'' in
  871. X           (using the `|' character) to indicate that an
  872. X           argument    is actually a list of one or more
  873. X           arguments from the command line.     ARGHIDDEN can be
  874. X           ``ored''    in to indicate a flag that should not be
  875. X           printed in usage    messages - for example,    flags
  876. X           intended    for internal debugging purposes.
  877. X
  878. X     type      The type    of the argument.  Existing types include
  879. X           argUsage    (print usage message and exit),    argBool
  880. X           and argSBool (set Boolean flags), argUBool (unset
  881. X           Boolean flags), argStr (string-valued arguments),
  882. X           argChar (char-valued arguments),    argInt (native
  883. X           integer arguments), argShort (short integer
  884. X           arguments), argLong (long integer arguments),
  885. X           argFloat    (short floating    point arguments),
  886. X           argDouble (long floating    point arguments), and
  887. X           argDummy    (only used as part of usage message, not
  888. X           matched on command-line).
  889. X
  890. X     variable  The name    of the shell variable that should receive
  891. X           the converted value.
  892. X
  893. X     prompt    The string used when prompting interactively for
  894. X           argument    values,    and printed in usage messages.
  895. X           This string may be followed by a    textual
  896. X           description that    is enclosed in parentheses,
  897. X           square brackets,    curly braces, or angle brackets.
  898. X
  899. X     The argument specification    string must be terminated by the
  900. X     single string:  ``ENDOFARGS''.
  901. X
  902. X     Note that the comma character (',') is used to separate all
  903. X     fields within an entry, and to separate the entries
  904. X     themselves.  For this reason, no field in any entry may
  905. X     contain a comma unless it appears inside of double    or single
  906. X     quotes.
  907. X
  908. X     Parseargs will parse all command-line arguments for the
  909. X     calling script and    match them against the argument
  910. X     specification string provided. The    argument specification
  911. X     string is read from standard input    by default but may not
  912. X     come from a terminal. The argument    specification string may
  913. X     be    supplied as a single string argument by    using the -a
  914. X
  915. X
  916. X
  917. Page 3
  918. X
  919. X
  920. X
  921. X
  922. X
  923. X
  924. PARSEARGS(1)                         PARSEARGS(1)
  925. X
  926. X
  927. X
  928. X     ``string''    flag.  Long argument specification strings
  929. X     however, may limit    the number of arguments    to the script if
  930. X     there is a    limit to the number of arguments and/or
  931. X     characters    that may appear    on the command line.  For this
  932. X     reason, the argument specification    string may be stored: in
  933. X     an    environment variable using the -e name option; in a file
  934. X     and read using the    -f file    option;    or read    from standard
  935. X     input.  When using    the -e option, the user    must remember to
  936. X     use the name of an    environment variable (not a mere shell
  937. X     variable)!     The default behavior is to read the argument
  938. X     specification from    standard input.
  939. X
  940. SHELLS
  941. X     After the command line has    been parsed, parseargs will print
  942. X     on    standard output, a script to set the shell variables
  943. X     which correspond to arguments that    were present on    the
  944. X     command-line.  This script    may be evaluated by redirecting
  945. X     it    to a file and then executing the file, or by directly
  946. X     evaluating    the output from    parseargs (under most UNIX
  947. X     shells, this could    be done    using eval).  If any arguments on
  948. X     the command line contained    any special characters that
  949. X     needed to be escaped from the shell, these    characters will
  950. X     remain intact (not    be evaluated by    the shell) in the
  951. X     corresponding shell variable.
  952. X
  953. X     The -s shell option may be    used to    tell parseargs which
  954. X     shell syntax to use. At present, parseargs    only recognizes
  955. X     ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'',
  956. X     ``awk'', and ``perl'' as valid command interpreters. Awk
  957. X     output is slightly    different from that of the other shells
  958. X     in    that the actual    variable setting are not printed but each
  959. X     line of an    associative array is printed (the first    field is
  960. X     the array index, the second is the    value for that index).
  961. X     If    no shell is specified, then the    Bourne shell (``sh'')
  962. X     will be assumed.
  963. X
  964. X     If    the user wishes    to use a value other than ``TRUE'' for a
  965. X     boolean flag that is true,    this may be done using the -T
  966. X     string option.  The same may also be done for a boolean flag
  967. X     that is false using the -F    string option.
  968. X
  969. X     Parseargs will only set the values    of variables that
  970. X     correspond    to arguments that were given on    the command line.
  971. X     If    a particular argument was not supplied on the command
  972. X     line, then    no assignment is made for the corresponding shell
  973. X     variable and it will have the same    value that it had before
  974. X     parseargs was invoked. The    only exception to this is that if
  975. X     the -u option is specified, then the positional parameters
  976. X     are unset before any shell    variable assignments (which may
  977. X     reset the positional parameters) are made.
  978. X
  979. X
  980. X
  981. X
  982. X
  983. Page 4
  984. X
  985. X
  986. X
  987. X
  988. X
  989. X
  990. PARSEARGS(1)                         PARSEARGS(1)
  991. X
  992. X
  993. X
  994. X     The double-dash (``--'') which precedes the name and
  995. X     arguments of the calling program is needed    in order for
  996. X     parseargs to be able to distinguish options to itself from
  997. X     options for the calling program.
  998. X
  999. X     The default behavior of parseargs is allow    both single-
  1000. X     character options and long-options    (keywords) on the
  1001. X     command-line. The user may    specify    that only options (long-
  1002. X     options) are to be    permitted by specifying    the -o (-l)
  1003. X     option on the command-line.
  1004. X
  1005. OPTIONS    WITH OPTIONAL ARGUMENTS
  1006. X     Options that may take an optional argument    need special
  1007. X     consideration.  The shell programmer needs    to know    whether
  1008. X     or    not the    option was given, and (if given) if it was
  1009. X     accompanied by an argument. In order to accommodate this
  1010. X     need, parseargs will set an additional shell variable for
  1011. X     each argument that    is given the ARGVALOPT flag if it is
  1012. X     supplied on the command line regardless of    whether    or not it
  1013. X     was accompanied by    its optional argument.    If the user has
  1014. X     defined an    option which may optionally take an argument and
  1015. X     the option    appears    on the command line with or without its
  1016. X     associated    argument, then the shell variable <name>_flag
  1017. X     will be assigned the value    ``TRUE'' (or the value supplied
  1018. X     with the -T option    to parseargs) where <name> is the name of
  1019. X     the shell variable    associated with    the option in the
  1020. X     argument description string.
  1021. X
  1022. ARGUMENT LISTS
  1023. X     Parseargs treats ARGLIST arguments    in a special way. The
  1024. X     method used for setting up    an argument list depends largely
  1025. X     upon the syntax of    shell that was specified on the    command
  1026. X     line via the -s option (although ARGLIST arguments    are
  1027. X     treated exactly the same as ARGVEC    arguments).
  1028. X     Resetting the Positional Parameters to an Argument    List
  1029. X
  1030. X     For the Bourne, Bourne-Again, and Korn shells, if the
  1031. X     variable name corresponding to the    ARGLIST    argument is
  1032. X     ``--'', then the positional parameters of the calling
  1033. X     program will be re-assigned to the    contents of the    argument
  1034. X     list ($1 will be the first    item, $2 the second item, and so
  1035. X     on). In this particular case, the calling program may wish
  1036. X     to    use the    -u option to reset the positional parameters to
  1037. X     NULL before making    any shell-variable assignments (this way,
  1038. X     the positional parameters will be unset if    the associated
  1039. X     list of command line arguments is not encountered).
  1040. X
  1041. X     Similarly for the C and TC    shells,    if the variable    name
  1042. X     corresponding to the ARGLIST argument is ``argv'',    then the
  1043. X     positional    parameters of the calling program will be re-
  1044. X     assigned to the contents of the argument list.
  1045. X
  1046. X
  1047. X
  1048. X
  1049. Page 5
  1050. X
  1051. X
  1052. X
  1053. X
  1054. X
  1055. X
  1056. PARSEARGS(1)                         PARSEARGS(1)
  1057. X
  1058. X
  1059. X
  1060. X     For the Plan 9 shell (rc),    if the variable    name
  1061. X     corresponding to the ARGLIST argument is ``*'', then the
  1062. X     positional    parameters of the calling program will be re-
  1063. X     assigned to the contents of the argument list.
  1064. X
  1065. X     For the awk and perl, if the variable name    corresponding to
  1066. X     the ARGLIST argument is ``ARGV'', then the    positional
  1067. X     parameters    of the calling program will be re-assigned to the
  1068. X     contents of the argument list.
  1069. X     Bourne Shell Argument Lists
  1070. X
  1071. X     For the Bourne shell, if the associated variable name is NOT
  1072. X     ``--'' and    the -A option was NOT specified, then that
  1073. X     variable is treated as a regular shell variable and is
  1074. X     assigned using the    following syntax:
  1075. X      name='arg1 arg2  ...'
  1076. X     After invoking parseargs, if you wish to go through all the
  1077. X     words in the variable name    and one    of the words in    name
  1078. X     contains an IFS character (such as    a space    or a tab), then
  1079. X     that particular word will be treated by the Bourne    shell as
  1080. X     two distinct words.
  1081. X
  1082. X     Also for the Bourne shell,    If the associated variable name
  1083. X     is    NOT ``--'' and the -A option WAS specified, then that
  1084. X     variable is treated as the    root name of an    array that is set
  1085. X     using the following syntax:
  1086. X      name1='arg1'
  1087. X      name2='arg2'
  1088. X          ...
  1089. X     and the variable ``name_count'' will be set to contain the
  1090. X     number of items in    the array.  The    user may then step
  1091. X     through all the items in the array    using the following
  1092. X     syntax:
  1093. X      i=1
  1094. X      while    [ $i -le $name_count ] ; do
  1095. X        eval echo "item #$i    is: " \$name$i
  1096. X        i=`expr $i + 1`
  1097. X      done
  1098. X     Korn Shell    Argument Lists
  1099. X
  1100. X     For the Korn shell, if the    associated variable name is NOT
  1101. X     ``--'', then that variable    is treated as an array and is
  1102. X     assigned using the    -A option of the set command. The first
  1103. X     item will be in ${name[0]}, the second item will be in
  1104. X     ${name[1]}, etc ..., and all items    may be given by
  1105. X     ${name[*]}    or ${name[@]}.    If the associated variable name
  1106. X     is    NOT ``--'' and the -A option WAS specified, then that
  1107. X     variable is assigned using    the +A option of the set command
  1108. X     (which preserves any array    elements that were not
  1109. X     overwritten by the    set command).
  1110. X     It    should be noted    that there is a    bug in versions    of the
  1111. X     Korn shell    earlier    than 11/16/88a,    in which the following:
  1112. X
  1113. X
  1114. X
  1115. Page 6
  1116. X
  1117. X
  1118. X
  1119. X
  1120. X
  1121. X
  1122. PARSEARGS(1)                         PARSEARGS(1)
  1123. X
  1124. X
  1125. X
  1126. X      set  -A  name     'arg1'     'arg2'     ...
  1127. X     causes the    positional parameters to be overwritten    as an
  1128. X     unintentional side-effect.    If your    version    of the Korn shell
  1129. X     is    earlier    than this and you wish to keep the contents of
  1130. X     your positional parameters    after invoking parseargs than you
  1131. X     must save them yourself before you    call parseargs.    This may
  1132. X     be    accomplished by    the following:
  1133. X      set  -A  save_parms  "$@"
  1134. X     C and TC Shell Argument Lists
  1135. X
  1136. X     For the C and TC shells, ARGLIST variables    are treated as
  1137. X     word-lists    and are    assigned using the following syntax:
  1138. X      set  name = (    'arg1'    'arg2'    ... )
  1139. X     The first item will be in $name[1], the second item will be
  1140. X     in    $name[2], etc ..., and all items may be    given by $name.
  1141. X     Notice that Korn shell arrays start at index zero whereas C
  1142. X     and TC shell word-lists start at index one.
  1143. X
  1144. X     Bourne-Again Shell    Argument Lists
  1145. X
  1146. X     At    present, the Free Software Foundation's    Bourne-Again
  1147. X     shell is treated exactly the same as the Bourne Shell. This
  1148. X     will change when bash supports arrays.
  1149. X     Plan 9 Shell Argument Lists
  1150. X
  1151. X     For the Plan 9 shell, if the associated variable name is not
  1152. X     ``*'' then    it is considered to be word-list and set using
  1153. X     the following syntax:
  1154. X      name=( 'arg1'     'arg2'     ... )
  1155. X
  1156. X     Awk Argument Lists
  1157. X     For awk, if the -A    option is not given, then the output for
  1158. X     thes variable-list    will be    a line with the    variable name,
  1159. X     followed by a line    with each of the values    (each value will
  1160. X     be    separated with the field separator specified using the -S
  1161. X     option - which defaults to    a space).
  1162. X      name
  1163. X      arg1    arg2  ...
  1164. X     If    the -A option is given,    then the associated variable is
  1165. X     considered    the root name of an array. The ouput for the
  1166. X     array will    consist    of two lines for each item in the list
  1167. X     (as in the    following expample):
  1168. X      name1
  1169. X      arg1
  1170. X
  1171. X      name2
  1172. X      arg2
  1173. X
  1174. X     and the variable ``name_count'' will have an output line
  1175. X     showing the number    of items in the    array.
  1176. X
  1177. X
  1178. X
  1179. X
  1180. X
  1181. Page 7
  1182. X
  1183. X
  1184. X
  1185. X
  1186. X
  1187. X
  1188. PARSEARGS(1)                         PARSEARGS(1)
  1189. X
  1190. X
  1191. X
  1192. X     Perl Argument Lists
  1193. X
  1194. X     For perl, each argument list is considered    an array and is
  1195. X     set using the following syntax:
  1196. X      @name=( arg1 , arg2 ,     ... )
  1197. X
  1198. X
  1199. X     The word-lists used by the    C shell, the arrays used by the
  1200. X     Korn shell, the Plan 9 shell, awk,    perl, and the positional
  1201. X     parameters    used by    all shells (if overwritten by parseargs)
  1202. X     will preserve any IFS characters in their contents.  That is
  1203. X     to    say that if an item in one of the aforementioned multi-
  1204. X     word lists    contains any IFS characters, it    will not be split
  1205. X     up    into multiple items but    will remain a single item which
  1206. X     contains IFS characters.
  1207. X
  1208. SUPPLYING DEFAULT ARGUMENTS
  1209. X     Programs that use parseargs may be    given default arguments
  1210. X     under UNIX    and PCs    through    the use    of environment variables
  1211. X     (symbols are used for VMS systems). If a  C-program or
  1212. X     shell-script uses parseargs to implement a    command    named
  1213. X     ``cmd'' then the environment variable ``CMD_ARGS''    will be
  1214. X     parsed for    any "default" arguments    before the command-line
  1215. X     is    parsed.     The command-line will over-ride any options that
  1216. X     are specified in this environment variable    (except    that
  1217. X     ARGLISTs and ARGVECs set in ``CMD_ARGS'' will be appended
  1218. X     from the command-line
  1219. X
  1220. X     It    is important to    note that the contents of the
  1221. X     ``CMD_ARGS'' environment variable are NOT expanded    by the
  1222. X     shell and hence any special characters (such as quotes or
  1223. X     back-slashes) will    NOT be escaped or removed by parseargs.
  1224. X     Furthermore, it will not be possible to try and use a tab,
  1225. X     space, or newline character in the    environment variable as
  1226. X     anything other than an argument separator.
  1227. X
  1228. X     Lastly, parts of an option    specification in ``CMD_ARGS'' may
  1229. X     NOT be continued on the command-line. As an example, if -f
  1230. X     requires an argument and CMD_ARGS="-f", then the command-
  1231. X     line "cmd    bah" will NOT assign "bah" as the argument to -f
  1232. X     but will instead complain about a missing argument    for -f.
  1233. X     Similarly,    if -l takes a list of arguments    and CMD_ARGS="-l
  1234. X     item1 item2", then    the command-line "cmd  bah", will NOT
  1235. X     assign "bah" to the end of    the list containing "item1" and
  1236. X     "item2" but will instead treat "bah" as the first positional
  1237. X     parameter on the command-line.
  1238. X
  1239. PARSING    BEHAVIOR
  1240. X     The programmer may    control    parsing    behavior through the use
  1241. X     of    parsecntl(3).  The user    may set    his (or    her) own desired
  1242. X     parsing behavior through the use of the ``PARSECNTL''
  1243. X     environment variable.  By indicating any number of    flags
  1244. X
  1245. X
  1246. X
  1247. Page 8
  1248. X
  1249. X
  1250. X
  1251. X
  1252. X
  1253. X
  1254. PARSEARGS(1)                         PARSEARGS(1)
  1255. X
  1256. X
  1257. X
  1258. X     (possibly negated)    the user will directly modify the
  1259. X     behavior of the parseargs library.    Flags may be combined by
  1260. X     placing a `+' or `|' character in between flags. A    switch is
  1261. X     negated by    immediately preceding it with a    `!' or `-'
  1262. X     character.     The possible ``flags''    are given by the
  1263. X     following table. Flags are    case-insensitive.
  1264. X
  1265. X     Prompt
  1266. X      Prompt the user for any missing arguments that are
  1267. X      required on the command-line.    No special escaping or
  1268. X      quoting is performed on the user input. Required
  1269. X      arguments that expect    a list of values will be
  1270. X      repeatedly prompted for (one item per    line) until a
  1271. X      blank    line (followed by a carriage return) is    entered.
  1272. X
  1273. X     Ignore
  1274. X      Ignore any unrecognized or improperly    specified
  1275. X      command-line arguments and continue execution    of the
  1276. X      program. Normally, if    an argument is unmatched (or is
  1277. X      improperly specified), a usage message is printed
  1278. X      program execution is terminated.
  1279. X
  1280. X     OptsOnly
  1281. X      Under    UNIX, setting this flag    will disable the parsing
  1282. X      of long-option syntax. This will cause all arguments
  1283. X      starting with    '+' to always be treated as a positional
  1284. X      parameter (instead of    a long-option).
  1285. X
  1286. X     KwdsOnly
  1287. X      Under    UNIX, setting this flag    disables the parsing of
  1288. X      single-character options.  This will cause all
  1289. X      arguments starting with '-' to always    be treated as a
  1290. X      positional parameter (instead    of an option).
  1291. X
  1292. X     LoptsOnly
  1293. X      Same as KwdsOnly.
  1294. X
  1295. X     Flags1st
  1296. X      Setting this flag causes the parseargs library to force
  1297. X      any and all non-positional arguments to be specified
  1298. X      before any positional    ones.  As an example, under UNIX,
  1299. X      if this flag is SET then parseargs will consider the
  1300. X      command line "cmd -x arg" to consist of one option and
  1301. X      one positional argument; however the command line "cmd
  1302. X      arg -x" would    be considered to consist of two
  1303. X      positional arguments (the -x option will be unmatched).
  1304. X
  1305. X      If this flag is UNSET, then both of the previous
  1306. X      examples are considered to consist of    one option and
  1307. X      one positional argument.
  1308. X
  1309. X     CaseIgnore
  1310. X
  1311. X
  1312. X
  1313. Page 9
  1314. X
  1315. X
  1316. X
  1317. X
  1318. X
  1319. X
  1320. PARSEARGS(1)                         PARSEARGS(1)
  1321. X
  1322. X
  1323. X
  1324. X      Setting this flag cause character-case to be ignored
  1325. X      when attempting to match single-character argument
  1326. X      names    (i.e. causes "-i" and "-I" will    be considered
  1327. X      equivalent).
  1328. X
  1329. X     If    the environment    variable ``PARSECNTL'' is empty    or
  1330. X     undefined,    then parsing behavior set by the programmer is
  1331. X     used.  If the programmer has not explicitly used
  1332. X     parsecntl(3) to modify the    parsing    behavior will be
  1333. X     ``!Prompt + !Ignore'' for Unix MS-DOS, OS/2, and AmigaDOS
  1334. X     systems, and ``Prompt'' for VMS systems.
  1335. X
  1336. USAGE MESSAGES
  1337. X     Through the use of    an environment variable    (or a VMS
  1338. X     symbol), the user may control the syntax and the verbosity
  1339. X     of    the command-usage messages that    are printed by parseargs.
  1340. X     The desired level of verbosity may    be set by defining the
  1341. X     environment variable ``USAGECNTL" to be a combination of
  1342. X     strings (case insensitive). The value of each string
  1343. X     controls one of three different ``modes'' of behavior in the
  1344. X     displaying    of usage messages:  The    first ``mode'' is
  1345. X     ``verbose'' mode, which controls whether or not a detailed
  1346. X     description of each argument should accompany the usual
  1347. X     command-line sysnopsis. If    verbose    mode is    ``off'', then
  1348. X     only a command-line synopsis is printed (this is also
  1349. X     refferred to as ``terse'' mode). The other    two ``modes''
  1350. X     control the displaying of option syntax and long-option
  1351. X     syntax. A mode may    be explicitly disabled by preceding its
  1352. X     corresponding string with the `!'    character. The ``modes''
  1353. X     which correspond to the possible values of    the ``USAGECNTL''
  1354. X     environment variable are given by the following table.
  1355. X
  1356. X
  1357. X     Quiet
  1358. X      No usage message of any kind is displayed.
  1359. X
  1360. X     Silent
  1361. X      Same as Quiet.
  1362. X
  1363. X     Paged
  1364. X      The usage message is piped to    a pager. The pager used
  1365. X      is named by the ``USAGE_PAGER'' environment variable.
  1366. X      If this variable is unset or empty (or is not    the name
  1367. X      of an    executable program) then the pager named by the
  1368. X      ``PAGER'' environment    variable us used.  If this
  1369. X      variable is unset or empty (or is not    the name of an
  1370. X      executable program) then /usr/ucb/more is used.
  1371. X
  1372. X     Description
  1373. X      The command description is printed.
  1374. X
  1375. X     Terse
  1376. X
  1377. X
  1378. X
  1379. Page 10
  1380. X
  1381. X
  1382. X
  1383. X
  1384. X
  1385. X
  1386. PARSEARGS(1)                         PARSEARGS(1)
  1387. X
  1388. X
  1389. X
  1390. X      Terse    mode, just print command-line synopsis.
  1391. X
  1392. X     Verbose
  1393. X      Verbose mode,    print descriptions for each argument
  1394. X
  1395. X     Options
  1396. X      Option syntax    is displayed.
  1397. X
  1398. X     LongOpts
  1399. X      Long-option syntax is    displayed.
  1400. X
  1401. X     KeyWords
  1402. X      Same as LongOpts.
  1403. X
  1404. X     If    the environment    variable ``USAGECNTL'' is empty    or
  1405. X     undefined,    then the default usage level (which is presently
  1406. X     ``Verbose + Options'') will be used.
  1407. X
  1408. EXAMPLES
  1409. X     As    a first    example, consider the following    argument
  1410. X     specification for a Bourne    shell script:
  1411. X
  1412. X     #!/bin/sh
  1413. X
  1414. X     RepCount=2;
  1415. X     Verbose="";
  1416. X     ARGSPEC="
  1417. X     'c', ARGOPT,          argInt,  RepCount, 'count    {# times to repeat}',
  1418. X     'v', ARGOPT,          argBool, Verbose,     'verbose {turn    on verbose mode}',
  1419. X     ' ', ARGREQ,          argStr,  InFile,     'input    {file to read from}',
  1420. X     ' ', ARGOPT,          argStr,  OutFile,     'output {file to write    to}',
  1421. X     'X', ARGHIDDEN,      argBool, XRated,     'xrated {naughty! naughty!}',
  1422. X     ' ', ARGOPT|ARGLIST, listStr, Files,     'files    {files to process}',
  1423. X     ENDOFARGS
  1424. X     "
  1425. X
  1426. X     eval `echo    "$ARGUMENTS" | parseargs -s sh -- $0 "$@"`
  1427. X
  1428. X     This describes a Bourne shell script accepting up to three
  1429. X     flag arguments and    one or two positional arguments, plus a
  1430. X     list of additional    file arguments.     Only the first
  1431. X     positional    argument is required.  The possible flags (in
  1432. X     UNIX) are:
  1433. X
  1434. X      -c count  An integer repetition count.  This defaults
  1435. X            to two.
  1436. X
  1437. X      -v        A Boolean ``verbose'' flag.     It defaults to
  1438. X            FALSE (an empty string).
  1439. X
  1440. X      -X        A Boolean ``X Rated'' flag.     This is not
  1441. X            printed in the usage message.
  1442. X
  1443. X
  1444. X
  1445. Page 11
  1446. X
  1447. X
  1448. X
  1449. X
  1450. X
  1451. X
  1452. PARSEARGS(1)                         PARSEARGS(1)
  1453. X
  1454. X
  1455. X
  1456. X     The two positional    arguments are both strings, as is the
  1457. X     final list.  If we    were to    invoke the above script    with the
  1458. X     following command line:
  1459. X      cmdname  -v  input_file  output_file    file1  file2
  1460. X
  1461. X     Then, after invoking parseargs, the following shell
  1462. X     variables would contain the following values:
  1463. X      $RepCount would evaluate to ``2''
  1464. X
  1465. X      $Verbose would evaluate to ``TRUE''
  1466. X      $InFile would    evaluate to ``input_file''
  1467. X
  1468. X      $OutFile would evaluate to ``output_file''
  1469. X      $Files would evaluate    to ``file1  file2''
  1470. X
  1471. X      $XRated would    be unset and would evaluate to an empty
  1472. X      string (``'').
  1473. X
  1474. X
  1475. X     Now let's present a more complete example.    The following
  1476. X     page shows    a Bourne shell script which uses parseargs to
  1477. X     parse its command line, echoes the    settings of all    its
  1478. X     associated    command    line variables,    and then prints    its
  1479. X     command usage.
  1480. X
  1481. X     #!/bin/sh
  1482. X     #      test.sh - Bourne shell script    to test    out the    parseargs command!
  1483. X     #
  1484. X     NAME="`basename $0`";  DOT=".";
  1485. X
  1486. X     ARGUMENTS="
  1487. X       '?', ARGHIDDEN, argUsage, NULL,      'Help    : print    usage and exit',
  1488. X       'S', ARGVALOPT, argStr,     string,  'STRing : optional string arg',
  1489. X       'g', ARGLIST,   argStr,     groups,  'newsGROUPS :    groups to test',
  1490. X       'r', ARGOPT,    argInt,     count,      'REPcount <# to repeat each group>',
  1491. X       'd', ARGOPT,    argStr,     dirname, 'DIRectory : working directory',
  1492. X       'x', ARGOPT,    argBool,     xflag,      'Xflag : turn    on X-mode',
  1493. X       'y', ARGOPT,    argUBool, yflag,      'Yflag : turn    off Y-mode',
  1494. X       's', ARGOPT,    argChar,     sepch,      'SEPchar : field separator',
  1495. X       'f', ARGLIST,   argStr,     files,      'files : files to process',
  1496. X       'n', ARGREQ|ARGPOS, argStr, name,  'name    : name to use',
  1497. X       ' ', ARGLIST,   argStr,     -- ,      'argv    : any remaining    arguments',
  1498. X       ENDOFARGS
  1499. X     "
  1500. X     export ARGUMENTS
  1501. X
  1502. X     yflag='TRUE'     ## set defaults (dir=".";    count=1; sepch=',') ##
  1503. X
  1504. X     ##    parse command-line and save assignments    in a temporary file ##
  1505. X     parseargs -s sh -e    ARGUMENTS -u --    "$NAME"    "$@" >/tmp/tmp$$
  1506. X     if    [ $? -ne 0 ]
  1507. X       then rm -f /tmp/tmp$$; exit 2  ## non-zero status (usage    given)
  1508. X
  1509. X
  1510. X
  1511. Page 12
  1512. X
  1513. X
  1514. X
  1515. X
  1516. X
  1517. X
  1518. PARSEARGS(1)                         PARSEARGS(1)
  1519. X
  1520. X
  1521. X
  1522. X     fi
  1523. X
  1524. X     ##    evaluate results from parseargs    and remove temporary file
  1525. X     $DOT /tmp/tmp$$;  rm -f /tmp/tmp$$
  1526. X
  1527. X     ##    echo  the parsed arguments (use    defaults if not    defined)
  1528. X     echo "ARGUMENTS:"
  1529. X     echo "=========="
  1530. X     echo "Name='$name', Count='${count:-1}'"
  1531. X     echo "XFlag='$xflag', YFlag='$yflag'"
  1532. X     echo "Directory='${dirname:-"."}',    SepChar='${sepch:-","}'"
  1533. X     echo "Groups='$groups'"
  1534. X     echo "Files='$files'"
  1535. X     if    [ "$string_flag" ]
  1536. X       then string=${string:-"!string arg ommitted on cmd-line!"}
  1537. X       else string="default string"
  1538. X     fi
  1539. X     echo "String='$string'"
  1540. X     echo "New Positional Parameters='$*'"
  1541. X
  1542. X     parseargs -a "$ARGUMENTS" -U "$NAME"     ## print usage ##
  1543. X
  1544. DIAGNOSTICS
  1545. X     Parseargs may exit    with one of the    following status codes:
  1546. X
  1547. X
  1548. X     -1      Some type of system error occurred during execution,
  1549. X      causing the program to exit prematurely.
  1550. X
  1551. X     0      Normal exit status (no problems were encountered).
  1552. X
  1553. X     1      The calling program specified    the -U or the -M option
  1554. X      to parseargs,    or specified an    argUsage flag on the
  1555. X      command line.     Only the appropriate message is
  1556. X      displayed.
  1557. X
  1558. X     2      A command line syntax    error was encountered by
  1559. X      parseargs. The offending command line    argument may have
  1560. X      been intended    for either parseargs or    for the    calling
  1561. X      program.
  1562. X
  1563. X     3      The environment variable that    was specified with the -e
  1564. X      option is either NULL    (has an    empty value) or    does not
  1565. X      exist. Perhaps the user specified a shell variable
  1566. X      and/or forgot    to export it.
  1567. X
  1568. X     4      A syntax error was encountered in the    argument
  1569. X      specification    string that was    specified to parseargs.
  1570. X
  1571. FILES
  1572. X     /usr/local/parseargs.pl
  1573. X      This file defines a perl function named parseargs to
  1574. X
  1575. X
  1576. X
  1577. Page 13
  1578. X
  1579. X
  1580. X
  1581. X
  1582. X
  1583. X
  1584. PARSEARGS(1)                         PARSEARGS(1)
  1585. X
  1586. X
  1587. X
  1588. X      parse    arguments more conveniently for    perl-scripts. The
  1589. X      function is both documented and implemented in this
  1590. X      file.    The user should    ``require'' this file in his/her
  1591. X      perl-script before invoking the function.
  1592. X
  1593. X     /usr/local/parseargs.awk
  1594. X      This file defines an awk function named parseargs to
  1595. X      parse    arguments more conveniently for    awk-scripts. The
  1596. X      function is both documented and implemented in this
  1597. X      file.    The user should    include    this file in his/her
  1598. X      awk-script before invoking the function.
  1599. X
  1600. SEE ALSO
  1601. X     argtype(3), parseargs(3), parsecntl(3)
  1602. X
  1603. CAVEATS
  1604. X     Because of    the way    argument parsing is implemented    under
  1605. X     UNIX, MS-DOS, and OS/2, option arguments which contain a
  1606. X     leading dash (`-')    (or whatever the option    prefix character
  1607. X     is    defined    to be) may not be specified as a separate
  1608. X     argument on the command line, it must be part of the same
  1609. X     argument. That is to say that if a    program    has a -f option
  1610. X     that requires a string argument, then the following:
  1611. X      -f-arg
  1612. X
  1613. X     will properly assign the string ``-arg'' to the option
  1614. X     whereas the following:
  1615. X      -f -arg
  1616. X
  1617. X     will be interpreted by parseargs as two option strings: the
  1618. X     first of which (``-f'') is    missing    a required argument and
  1619. X     the second    of which (``-arg'') will most likely be    flagged
  1620. X     as    an invalid option.
  1621. X
  1622. X     Similarly,    if the user requires an    ARGLIST    option to take
  1623. X     multiple arguments    with leading dashes then the following
  1624. X     method must be used: It is    a ``feature'' of parseargs that
  1625. X     ARGLIST arguments are always appended to the current list of
  1626. X     arguments for the given option. Thus, if ``-f'' is    an option
  1627. X     taking a list of arguments, then the following are    all
  1628. X     equivalent:
  1629. X      -farg1 arg2
  1630. X
  1631. X      -f arg1 arg2
  1632. X      -farg1 -farg2
  1633. X
  1634. X      -f arg1 -f arg2
  1635. X     Hence multiple ``leading dash'' arguments may specified as
  1636. X     follows:
  1637. X
  1638. X      -f-dash_arg1 -f-dash_arg2  ...
  1639. X
  1640. X
  1641. X
  1642. X
  1643. Page 14
  1644. X
  1645. X
  1646. X
  1647. X
  1648. X
  1649. X
  1650. PARSEARGS(1)                         PARSEARGS(1)
  1651. X
  1652. X
  1653. X
  1654. BUGS
  1655. X     It    does not make sense to use any arguments of type argTBool
  1656. X     since parseargs currently has no way of knowing what the
  1657. X     initial value of the variable is. For this    reason,    argTBool
  1658. X     is    not recognized as a valid argument type    (even though it
  1659. X     is    used by    parseargs(3)). By the same token, since    the user
  1660. X     cannot create their own arguments types on    the fly    from a
  1661. X     shell-script, ARGNOVAL is not recognized as a valid argument
  1662. X     flag.
  1663. X
  1664. X     Commas will not be    interpreted properly if    any field in the
  1665. X     argument specification string contains double quotes that
  1666. X     are nested    inside of double quotes, or single quotes that
  1667. X     are nested    inside of single quotes.
  1668. X
  1669. X     Inside the    argument specification string, any repeated
  1670. X     string of commas that does    not appear inside of double or
  1671. X     single quotes will    be treated as a    single comma.
  1672. X
  1673. X     Text descriptions for argument entries are    automatically
  1674. X     formatted in usage    messages. Any attempt by the user to
  1675. X     include tabs and/or newlines in the description will cause
  1676. X     it    to be formatted    improperly.
  1677. X
  1678. X     Parseargs cannot properly preserve    any newlines in    shell
  1679. X     variables if the eval command is used to read its output
  1680. X     (this is a    shortcoming of the eval    command, not of
  1681. X     parseargs). If the    user is    concerned about    this particular
  1682. X     case, then    the user should    redirect the output from
  1683. X     parseargs to a temporary file and use the source command in
  1684. X     csh or the    dot command (`.') in sh    and ksh, to interpret the
  1685. X     results; otherwise, newlines will be translated into spaces,
  1686. SHAR_EOF
  1687. true || echo 'restore of parseargs/parseargs1.txt failed'
  1688. fi
  1689. echo 'End of  part 7'
  1690. echo 'File parseargs/parseargs1.txt is continued in part 8'
  1691. echo 8 > _shar_seq_.tmp
  1692. exit 0
  1693. exit 0 # Just in case...
  1694. -- 
  1695. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1696. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1697. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1698. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1699.