home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume19 / parseargs / patch05b < prev    next >
Encoding:
Text File  |  1991-05-17  |  55.4 KB  |  1,393 lines

  1. Newsgroups: comp.sources.misc
  2. From: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  3. Subject:  v19i083:  parseargs - functions to parse command line argument, Patch05b/5
  4. Message-ID: <1991May17.181553.22245@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 6a3c5a65019a2489257cc48e9e7ecaab
  6. Date: Fri, 17 May 1991 18:15:53 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  10. Posting-number: Volume 19, Issue 83
  11. Archive-name: parseargs/patch05b
  12. Patch-To: parseargs: Volume 17, Issue 45-57
  13.  
  14. #!/bin/sh
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file PATCH05 continued
  17. #
  18. if test ! -r _shar_seq_.tmp; then
  19.     echo 'Please unpack part 1 first!'
  20.     exit 1
  21. fi
  22. (read Scheck
  23.  if test "$Scheck" != 2; then
  24.     echo Please unpack part "$Scheck" next!
  25.     exit 1
  26.  else
  27.     exit 0
  28.  fi
  29. ) < _shar_seq_.tmp || exit 1
  30. if test ! -f _shar_wnt_.tmp; then
  31.     echo 'x - still skipping PATCH05'
  32. else
  33. echo 'x - continuing file PATCH05'
  34. sed 's/^X//' << 'SHAR_EOF' >> 'PATCH05' &&
  35. ! takes one parameter: the address of the first item in the arg-list.
  36. X  .PP
  37. X  An alternative to argument-lists is argument vectors (or arg-vectors).
  38. X  Arg-vectors use the \s-1ARGVEC\s+1 flag instead of the \s-1ARGLIST\s+1 flag
  39. X  and do not require a special \fIlistXxxx\fP function for each vector-type.
  40. X  Each of the \fIargXxxx\fP functions is responsible for handling vectors of its
  41. ! type (although some \fIargXxx\fP functions such as the boolean types do not
  42. ! support vectors). An arg-vector is a structure which contains a count, an
  43. ! array of elements (i.e. an \f4argc,argv\fP pair), and an array of flags,
  44. ! one for each element of argv. There are two macros in defined in
  45. X  \f4<parseargs.h>\fR which are used for arg-vectors. \s-1ARGVEC_T\s+1 may be
  46. X  used to declare a vector structure or a vector type;
  47. X  \s-1ARGVEC_EMPTY\s+1 may be used to initialize the structure.
  48. diff -cNr ../patchlevel4/doc/parseargs.man1 ./doc/parseargs.man1
  49. *** ../patchlevel4/doc/parseargs.man1    Thu May  2 11:01:33 1991
  50. --- ./doc/parseargs.man1    Thu May  2 14:35:21 1991
  51. ***************
  52. *** 12,31 ****
  53. X  .SH SYNOPSIS
  54. X  .TP 12
  55. X  \fBparseargs\fP
  56. ! [\fB\-U\fP]
  57. ! [\fB\-M\fP]
  58. X  [\fB\-T\fP\ \fIstring\fP]
  59. X  [\fB\-F\fP\ \fIstring\fP]
  60. - [\fB\-A\fP]
  61. X  [\fB\-a\fP\ \fIarg-spec\fP]
  62. X  [\fB\-e\fP\ \fIname\fP]
  63. X  [\fB\-f\fP\ \fIfile\fP]
  64. - [\fB\-l\fP]
  65. - [\fB\-o\fP]
  66. X  [\fB\-s\fP\ \fIshell\fP\^]
  67. - [\fB\-u\fP]
  68. - [\fB\-i\fP]
  69. - [\fB\-p\fP]
  70. X  \fB\-\^\-\fP
  71. X  \fIname\fP
  72. X  [\fIarguments\fP\ .\^.\^.\^]
  73. --- 12,25 ----
  74. X  .SH SYNOPSIS
  75. X  .TP 12
  76. X  \fBparseargs\fP
  77. ! [\fB\-#UMCAlouip1\fP]
  78. ! [\fB\-S\fP\ \fIseparator\fP]
  79. X  [\fB\-T\fP\ \fIstring\fP]
  80. X  [\fB\-F\fP\ \fIstring\fP]
  81. X  [\fB\-a\fP\ \fIarg-spec\fP]
  82. X  [\fB\-e\fP\ \fIname\fP]
  83. X  [\fB\-f\fP\ \fIfile\fP]
  84. X  [\fB\-s\fP\ \fIshell\fP\^]
  85. X  \fB\-\^\-\fP
  86. X  \fIname\fP
  87. X  [\fIarguments\fP\ .\^.\^.\^]
  88. ***************
  89. *** 32,37 ****
  90. --- 26,34 ----
  91. X  .\"-----------------------------------------------------------
  92. X  .SH OPTIONS
  93. X  .TP 14
  94. + \fB\-#\fP
  95. + just print the version and patchlevel, do not parse the command line
  96. + .TP 14
  97. X  \fB\-U\fP
  98. X  just print program usage, do not parse the command line
  99. X  .TP 14
  100. ***************
  101. *** 38,43 ****
  102. --- 35,43 ----
  103. X  \fB\-M\fP
  104. X  just print (n|t)roff \-man manual page template, do not parse the command line
  105. X  .TP 14
  106. + \fB-S\fP\ \fIseparator\fP
  107. + field-separator-string used to delimit array elements  (\fIdefault=``\0''\fP\|)
  108. + .TP 14
  109. X  \fB\-T\fP \fIstring\fP
  110. X  string to use for true boolean arguments\|  (\fIdefault=``\s-1TRUE\s+1\^''\fP\|)
  111. X  .TP 14
  112. ***************
  113. *** 44,49 ****
  114. --- 44,53 ----
  115. X  \fB\-F\fP \fIstring\fP
  116. X  string to use for false boolean arguments  (\fIdefault=``\^''\fP\|)
  117. X  .TP 14
  118. + \fB\-C\fP
  119. + Ignore the difference between upper and lower case when parsing single
  120. + character options.
  121. + .TP 14
  122. X  \fB\-A\fP
  123. X  modify array behavior for the specified shell.
  124. X  .TP 14
  125. ***************
  126. *** 73,78 ****
  127. --- 77,86 ----
  128. X  .TP 14
  129. X  \fB\-i\fP
  130. X  ignore bad command-line syntax and continue processing (instead of aborting)
  131. + .TP 14
  132. + \fB\-1\fP
  133. + Force any and all non-positional parameters to be specified before any
  134. + positional parameters on the command-line.
  135. X  .\"-----------------------------------------------------------
  136. X  .SH ARGUMENTS
  137. X  .TP 14
  138. ***************
  139. *** 89,95 ****
  140. X  .\"-----------------------------------------------------------
  141. X  .PP
  142. X  The argument specification string contains one entry for each possible flag.
  143. ! Entries in the arguments specification string are separated by commas.
  144. X  Each entry has five comma-separated fields:
  145. X  a name, some flags, a type, a variable-name, and a prompt.
  146. X  Each of these fields are described below:
  147. --- 97,103 ----
  148. X  .\"-----------------------------------------------------------
  149. X  .PP
  150. X  The argument specification string contains one entry for each possible flag.
  151. ! Entries in the argument specification string are separated by commas.
  152. X  Each entry has five comma-separated fields:
  153. X  a name, some flags, a type, a variable-name, and a prompt.
  154. X  Each of these fields are described below:
  155. ***************
  156. *** 110,134 ****
  157. X  to indicate an optional argument
  158. X  (\s-1ARGOPT\s+1 is the default unless \s-1ARGREQ\s+1 is specified).
  159. X  \s-1ARGPOS\s+1
  160. ! can be ``ored'' in to indicate a positional argument that may also
  161. X  be keyword matched.
  162. - \s-1ARGNOVAL\s+1
  163. - can be ``ored'' in to indicate that an argument is an option
  164. - or a keyword that does not use an accompanying argument (such as
  165. - a boolean flag). This flag is only required for corresponding argument
  166. - types that are implemented by the programmer; \fBparseargs\fP already
  167. - knows which pre-defined argument types take an argument.
  168. X  \s-1ARGVALOPT\s+1
  169. ! can be ``ored'' in to indicate that an argument to the option may be
  170. X  optionally supplied on the command-line, but is not required.
  171. X  \s-1ARGVALREQ\s+1
  172. ! can be ``ored'' in to indicate that an argument to the option is required
  173. X  (this is the default behavior for options that take arguments).
  174. X  \s-1ARGLIST\s+1
  175. ! can be ``ored'' in (using the `\^|\^' character) to indicate that an argument
  176. X  is actually a list of one or more arguments from the command line.
  177. X  \s-1ARGHIDDEN\s+1
  178. ! can be ``ored'' in to indicate a flag that should not be printed
  179. X  in usage messages \(em
  180. X  for example, flags intended for internal debugging purposes.
  181. X  .TP 10
  182. --- 118,136 ----
  183. X  to indicate an optional argument
  184. X  (\s-1ARGOPT\s+1 is the default unless \s-1ARGREQ\s+1 is specified).
  185. X  \s-1ARGPOS\s+1
  186. ! may be ``ored'' in to indicate a positional argument that may also
  187. X  be keyword matched.
  188. X  \s-1ARGVALOPT\s+1
  189. ! may be ``ored'' in to indicate that an argument to the option may be
  190. X  optionally supplied on the command-line, but is not required.
  191. X  \s-1ARGVALREQ\s+1
  192. ! may be ``ored'' in to indicate that an argument to the option is required
  193. X  (this is the default behavior for options that take arguments).
  194. X  \s-1ARGLIST\s+1
  195. ! may be ``ored'' in (using the `\^|\^' character) to indicate that an argument
  196. X  is actually a list of one or more arguments from the command line.
  197. X  \s-1ARGHIDDEN\s+1
  198. ! may be ``ored'' in to indicate a flag that should not be printed
  199. X  in usage messages \(em
  200. X  for example, flags intended for internal debugging purposes.
  201. X  .TP 10
  202. ***************
  203. *** 175,181 ****
  204. X  to the script if there is a limit to the number of arguments and/or characters
  205. X  that may appear on the command line.
  206. X  For this reason, the argument specification string may be stored: in an
  207. ! environment variable using the \fB-e\fP \fIname\fP option; in a file
  208. X  and read using the \fB\-f\fP \fIfile\fP option; or read from standard input.
  209. X  When using the \fB\-e\fP option, the user must remember to use the name
  210. X  of an environment variable (not a mere shell variable)!
  211. --- 177,183 ----
  212. X  to the script if there is a limit to the number of arguments and/or characters
  213. X  that may appear on the command line.
  214. X  For this reason, the argument specification string may be stored: in an
  215. ! environment variable using the \fB\-e\fP \fIname\fP option; in a file
  216. X  and read using the \fB\-f\fP \fIfile\fP option; or read from standard input.
  217. X  When using the \fB\-e\fP option, the user must remember to use the name
  218. X  of an environment variable (not a mere shell variable)!
  219. ***************
  220. *** 191,197 ****
  221. X  The default behavior of parseargs is to allow both single-character options and
  222. X  long-options (keywords) on the command-line. The user may specify that only
  223. X  options (long-options) are to be permitted by specifying the \fB\-o\fP
  224. ! (\fB\-l\) option on the command-line.
  225. X  .\"----------------------------------------------------------------
  226. X  .so argvalopt.inc
  227. X  .\"----------------------------------------------------------------
  228. --- 193,213 ----
  229. X  The default behavior of parseargs is to allow both single-character options and
  230. X  long-options (keywords) on the command-line. The user may specify that only
  231. X  options (long-options) are to be permitted by specifying the \fB\-o\fP
  232. ! (\fB\-l\fP) option on the command-line.
  233. ! .\"----------------------------------------------------------------
  234. ! .SH "SPECIFYING PARSE-BEHAVIOR"
  235. ! .PP
  236. ! The \fB\-C\fP, \fB\-p\fP, \fB\-i\fP, and \fB\-1\fP switches may be used to
  237. ! modify the command-line parsing behavior of the invoking script. Specifying
  238. ! \fB\-C\fP will cause case-differences in single-character options to be
  239. ! ignored. Specifying \fB\-p\fP will cause the user to be interactively prompted
  240. ! for any missing required arguments. Specifying \fB\-i\fP will cause
  241. ! syntactically incorrect arguments to be ignored (instead of having a usage
  242. ! message printed and execution terminated). Specifying \fB\-1\fP will force
  243. ! all non-positional parameters to precede any positional parameters on the
  244. ! command-line (hence anything on the command-line after a positional parameter
  245. ! that resembles a keyword parameter will nevertheles be interpreted as a
  246. ! positional parameter).
  247. X  .\"----------------------------------------------------------------
  248. X  .so argvalopt.inc
  249. X  .\"----------------------------------------------------------------
  250. ***************
  251. *** 227,233 ****
  252. X  ENDOFARGS
  253. X  "
  254. X  .sp 8p
  255. ! eval `echo "$ARGUMENTS" | parseargs \-s sh \-\|\- $0 "$@"`
  256. X  .sp 8p
  257. X  .ft R
  258. X  .fi
  259. --- 243,249 ----
  260. X  ENDOFARGS
  261. X  "
  262. X  .sp 8p
  263. ! eval `echo "$ARGSPEC" | parseargs \-s sh \-\|\- $0 "$@"`
  264. X  .sp 8p
  265. X  .ft R
  266. X  .fi
  267. ***************
  268. *** 300,308 ****
  269. X  Normal exit status (no problems were encountered).
  270. X  .TP 5
  271. X  \|\|1
  272. ! The calling program specified the \fB\-U\fP or the \fB\-M\fP option to
  273. ! \fBparseargs\fP, or specified an \fIargUsage\fP flag on the command line.
  274. ! Only the appropriate message is displayed.
  275. X  .TP 5
  276. X  \|\|2
  277. X  A command line syntax error was encountered by \fBparseargs\fP. The offending
  278. --- 316,324 ----
  279. X  Normal exit status (no problems were encountered).
  280. X  .TP 5
  281. X  \|\|1
  282. ! The calling program specified the \fB\-#\fP, the \fB\-U\fP or the \fB\-M\fP
  283. ! option to \fBparseargs\fP, or specified an \fIargUsage\fP flag on the command
  284. ! line.  Only the appropriate message is displayed.
  285. X  .TP 5
  286. X  \|\|2
  287. X  A command line syntax error was encountered by \fBparseargs\fP. The offending
  288. diff -cNr ../patchlevel4/doc/parseargs.man3 ./doc/parseargs.man3
  289. *** ../patchlevel4/doc/parseargs.man3    Thu May  2 11:01:45 1991
  290. --- ./doc/parseargs.man3    Thu May  2 14:35:24 1991
  291. ***************
  292. *** 2,19 ****
  293. X  .TH PARSEARGS 3
  294. X  .\"-----------------------------------------------------------
  295. X  .SH NAME
  296. ! parseargs, usage \- parse command line argument vectors
  297. X  .\"-----------------------------------------------------------
  298. X  .SH SYNOPSIS
  299. X  #include <parseargs.h>
  300. X  .PP
  301. X  .nf
  302. ! int  parseargs(  char *argv[],  ARGDESC *argd  )
  303. ! int  fparseargs(  FILE *fp,  ARGDESC *argd  )
  304. ! int  lparseargs(  ArgList *argls,  ARGDESC *argd  )
  305. ! int  sparseargs(  char *str,  ARGDESC *argd  )
  306. ! int  vparseargs(  ARGDESC *argd, int argc,  ...  )
  307. ! void  usage(  const ARGDESC *argd  )
  308. X  .fi
  309. X  .\"-----------------------------------------------------------
  310. X  .SH DESCRIPTION
  311. --- 2,20 ----
  312. X  .TH PARSEARGS 3
  313. X  .\"-----------------------------------------------------------
  314. X  .SH NAME
  315. ! parseargs \- parse command line argument vectors
  316. X  .\"-----------------------------------------------------------
  317. X  .SH SYNOPSIS
  318. X  #include <parseargs.h>
  319. X  .PP
  320. X  .nf
  321. ! int  parseargs(  char *argv\f4[]\fP,  ARGDESC *argd  );
  322. ! int  fparseargs(  FILE *fp,  ARGDESC *argd  );
  323. ! int  lparseargs(  ArgList *argls,  ARGDESC *argd  );
  324. ! int  sparseargs(  char *str,  ARGDESC *argd  );
  325. ! int  vparseargs(  ARGDESC *argd, int argc,  ...  );
  326. ! void  usage(  const ARGDESC *argd  );
  327. ! extern  const char *ProgName;
  328. X  .fi
  329. X  .\"-----------------------------------------------------------
  330. X  .SH DESCRIPTION
  331. ***************
  332. *** 23,28 ****
  333. --- 24,34 ----
  334. X  .so sparseargs3.inc
  335. X  .so vparseargs3.inc
  336. X  .so usage3.inc
  337. + .PP
  338. + After returning from any of the aforementioned functions, the global
  339. + string \fIProgName\fP will contain the name of the command corresponding
  340. + to the argument-descriptor array that was most recently operated upon by
  341. + one the functions in the \fIparseargs\fP(3) function library.
  342. X  .\"-----------------------------------------------------------
  343. X  .so argdesc.inc
  344. X  .\"-----------------------------------------------------------
  345. ***************
  346. *** 42,48 ****
  347. X  char    *InFile;
  348. X  char    *OutFile =    CHARNULL;
  349. X  BOOL    XRated =    FALSE;
  350. ! struct namelist *Files = NULL;
  351. X  
  352. X  ARGDESC Args[] =
  353. X  {
  354. --- 48,54 ----
  355. X  char    *InFile;
  356. X  char    *OutFile =    CHARNULL;
  357. X  BOOL    XRated =    FALSE;
  358. ! ArgList *Files =    ARGLISTNULL;
  359. X  
  360. X  ARGDESC Args[] =
  361. X  {
  362. ***************
  363. *** 52,58 ****
  364. X    ' ', ARGREQ,    argStr,  _\|_ &InFile,   "INPUTfile {input file}",
  365. X    ' ', ARGOPT,    argStr,  _\|_ &OutFile,  "OUTPUTfile {output file}",
  366. X    'X', ARGHIDDEN, argBool, _\|_ &XRated,   "XratedMODE {naughty stuff!}",
  367. !   ' ', ARGOPT\^|\^ARGLIST, argStr, _\|_ &Files, "File {files to be read}",
  368. X    ENDOFARGS
  369. X  };
  370. X  .ft R
  371. --- 58,64 ----
  372. X    ' ', ARGREQ,    argStr,  _\|_ &InFile,   "INPUTfile {input file}",
  373. X    ' ', ARGOPT,    argStr,  _\|_ &OutFile,  "OUTPUTfile {output file}",
  374. X    'X', ARGHIDDEN, argBool, _\|_ &XRated,   "XratedMODE {naughty stuff!}",
  375. !   ' ', ARGLIST,   listStr, _\|_ &Files,    "File {files to be read}",
  376. X    ENDOFARGS
  377. X  };
  378. X  .ft R
  379. ***************
  380. *** 116,158 ****
  381. X  .fi
  382. X  .RE
  383. X  .PP
  384. ! The
  385. ! .I argd
  386. ! argument points to the descriptor for the argument being converted.
  387. ! Its main use is to find the location in which to store the converted value,
  388. ! located in argd\(->ad_valp.
  389. ! The string value to be converted is passed in
  390. ! .IR vp
  391. X  (which will be \s-1NULL\s+1 if the \s-1ARGNOVAL\s+1 flag was set for the
  392. X  corresponding entry in the arg-descriptor table).
  393. ! The
  394. ! .I copyf
  395. ! flag is TRUE if the
  396. ! .I vp
  397. ! string value must be copied when saved.
  398. ! Most non-string types are copied implicitly
  399. ! (for example, integer arguments are stored in binary form,
  400. ! so the original string value need not be saved),
  401. ! so this argument can usually be ignored.
  402. ! Put simply, this flag is
  403. ! TRUE
  404. ! when
  405. ! .I vp
  406. ! points to a temporary buffer area.
  407. ! .PP
  408. ! If the type function successfully converts the value,
  409. ! and uses the entire value,
  410. ! it should return TRUE.
  411. ! If the type function successfully converts the value,
  412. ! and uses only \fIN\fP characters of the value,
  413. ! it should return -\fIN\fP.
  414. ! Otherwise,
  415. ! it should print a message using
  416. X  .IR usrerr (3)
  417. X  and return FALSE. This message should be of the form
  418. X  \fB"invalid xxxx option 'yyyy' for Zzzz"\fP, where xxxx is the type of the
  419. ! option, yyyy is the string passed in vp, and zzzz is the name (taken from
  420. ! \fBad\(->ad_prompt\fP).
  421. X  The \fIargXxxx\fP function is responsible for detecting if the given argument
  422. X  descriptor is an \s-1ARGVEC\s+1 argument and for taking the appropriate action.
  423. X  .PP
  424. --- 122,148 ----
  425. X  .fi
  426. X  .RE
  427. X  .PP
  428. ! The \f4ad\fP argument points to the descriptor for the argument being
  429. ! converted. Its main use is to find the location in which to store the
  430. ! converted value, located in ad\(->ad_valp.
  431. ! The string value to be converted is passed in \f4vp\fP
  432. X  (which will be \s-1NULL\s+1 if the \s-1ARGNOVAL\s+1 flag was set for the
  433. X  corresponding entry in the arg-descriptor table).
  434. ! The \f4copyf\fP flag is TRUE if the \f4vp\fP string value must be copied
  435. ! when saved.  Most non-string types are copied implicitly (for example,
  436. ! integer arguments are stored in binary form, so the original string value
  437. ! need not be saved), so this argument can usually be ignored.  Put simply,
  438. ! this flag is TRUE when \f4vp\fP points to a temporary buffer area.
  439. ! .PP
  440. ! If the type function successfully converts the value, and uses the entire
  441. ! value, it should return TRUE.  If the type function successfully converts
  442. ! the value, and uses only \fIN\fP characters of the value, it should return
  443. ! -\fIN\fP.  Otherwise, it should print a message using
  444. X  .IR usrerr (3)
  445. X  and return FALSE. This message should be of the form
  446. X  \fB"invalid xxxx option 'yyyy' for Zzzz"\fP, where xxxx is the type of the
  447. ! option, yyyy is the string passed in \f4vp\fP, and zzzz is the name (taken
  448. ! from \f4ad\(->ad_prompt\fP).
  449. X  The \fIargXxxx\fP function is responsible for detecting if the given argument
  450. X  descriptor is an \s-1ARGVEC\s+1 argument and for taking the appropriate action.
  451. X  .PP
  452. ***************
  453. *** 204,215 ****
  454. X  .\"------------------------------------------------------------------
  455. X  .SH LONG OPTIONS
  456. X  .PP
  457. ! Under \s-1UNIX\s+1, Parseargs also allows for long options in addition to
  458. ! single character options. Long options are denoted by a `\fB+\fP' character
  459. ! (which may be changed using \fIkeywordprefix\fP). The keyword that is
  460. ! used is the first word in the prompt field of an argument descriptor entry.
  461. ! Long options are case insensitive! An argument to a long option may be
  462. ! separated from the long option by an equal sign (`=') or by one or more
  463. X  whitespace characters.  Thus, if an entry looks like:
  464. X  .RS
  465. X  .sp 4p
  466. --- 194,211 ----
  467. X  .\"------------------------------------------------------------------
  468. X  .SH LONG OPTIONS
  469. X  .PP
  470. ! Under \s-1UNIX\s+1, \s-1MS-DOS\s+1, and \s-1OS\s+1/2,
  471. ! \fIparseargs\fP also allows for long
  472. ! options in addition to single character options.
  473. ! Under \s-1UNIX\s+1, long options are denoted by a `\fB+\fP' character.
  474. ! Under \s-1MS-DOS\s+1, and \s-1OS\s+1/2, long options are denoted by the second
  475. ! character in the \s-1SWITCHAR\s+1 environment variable. If there is no second
  476. ! character, then if the first character is `\-', then a `\fB+\fP' is used,
  477. ! otherwise a `\fB/\fP' is used.
  478. ! The keyword that is used is the first word in the prompt field of an
  479. ! argument descriptor entry. Long options are case insensitive!
  480. ! Under \s-1UNIX\s+1, an argument to a long option may be separated
  481. ! from the long option by an equal sign (`=') or by one or more
  482. X  whitespace characters.  Thus, if an entry looks like:
  483. X  .RS
  484. X  .sp 4p
  485. ***************
  486. *** 225,234 ****
  487. X  .PP
  488. X  The long option names for ``\fB\-?\fP'' in the default argument descriptor
  489. X  are ``\fB+help\fP'' and ``\fB+?\fP'' (respectively). In addition, ``\fB++\fP''
  490. ! or ``\fB+endopts\fP'' may be used to indicate the end of options so that
  491. X  all remaining arguments will be interpreted as positional parameters
  492. X  (even if one begins with a `\fB+\fP' or a `\fB\-\fP').
  493. X  .PP
  494. X  Under VAX/VMS and AmigaDOS, single-character options are not used and the
  495. X  ``long'' name (in the prompt field of an argument descriptor) is always used
  496. X  to match for possible arguments (or keywords, or qualifiers).
  497. --- 221,236 ----
  498. X  .PP
  499. X  The long option names for ``\fB\-?\fP'' in the default argument descriptor
  500. X  are ``\fB+help\fP'' and ``\fB+?\fP'' (respectively). In addition, ``\fB++\fP''
  501. ! may be used to indicate the end of options so that
  502. X  all remaining arguments will be interpreted as positional parameters
  503. X  (even if one begins with a `\fB+\fP' or a `\fB\-\fP').
  504. X  .PP
  505. + Under \s-1MS-DOS\s+1, and \s-1OS\s+1/2, an argument to a long-option must be
  506. + separated from the long option by an equal sign (`=') (unless the first
  507. + character of $SWITCHAR is a `\-', in which case \s-1UNIX\s+1 syntax is used).
  508. + The long option names for ``\fB/?\fP'' in the default argument descriptor
  509. + are ``\fB/help\fP'' and ``\fB/?\fP'' (respectively).
  510. + .PP
  511. X  Under VAX/VMS and AmigaDOS, single-character options are not used and the
  512. X  ``long'' name (in the prompt field of an argument descriptor) is always used
  513. X  to match for possible arguments (or keywords, or qualifiers).
  514. ***************
  515. *** 238,244 ****
  516. X  match all characters in the prompt field (as in ``\fB+count=4\fP'' and
  517. X  ``\fB+repcount=4\fP'').
  518. X  .PP
  519. ! Under \s-1UNIX\s+1 and \s-1VAX/VMS\s+1,
  520. X  only the number of characters required to uniquely identify the desired argument
  521. X  are needed, but at least two characters must be given (unless the prompt field
  522. X  is itself less than two characters long). This means that using the above
  523. --- 240,246 ----
  524. X  match all characters in the prompt field (as in ``\fB+count=4\fP'' and
  525. X  ``\fB+repcount=4\fP'').
  526. X  .PP
  527. ! Under all systems except AmigaDOS,
  528. X  only the number of characters required to uniquely identify the desired argument
  529. X  are needed, but at least two characters must be given (unless the prompt field
  530. X  is itself less than two characters long). This means that using the above
  531. ***************
  532. *** 255,264 ****
  533. X  .\"------------------------------------------------------------------
  534. X  .so returns.inc
  535. X  .\"------------------------------------------------------------------
  536. X  .SH SEE ALSO
  537. X  .IR argtype (3),
  538. X  .IR parseargs (1),
  539. ! .IR syserr (3)
  540. X  .br
  541. X  The ``C Advisor'' column in
  542. X  .ul
  543. --- 257,287 ----
  544. X  .\"------------------------------------------------------------------
  545. X  .so returns.inc
  546. X  .\"------------------------------------------------------------------
  547. + .so effects.inc
  548. + .\"------------------------------------------------------------------
  549. + .SH "DOCUMENTING YOUR COMMANDS"
  550. + .PP
  551. + The commands that you write with \fIparseargs\fP(3) may be documented
  552. + using \fIparseargs\fP(1). Just copy the argument descriptor array
  553. + into a separate file, and invoke \fIparseargs\fP(1) with the \fB\-M\fP
  554. + option and pass it the command-name (dont forget to redirect input 
  555. + to come from your newly created file). It is important to note that the
  556. + only portion of that argdesc array to insert into your file is the portion
  557. + starting with the very first command-line argument, all the way down to
  558. + (and including) the \s-1ENDOFARGS\s+1 or \s-1END_ARGUMENTS\s+1 entry.
  559. + .\"------------------------------------------------------------------
  560. + .SH FILES
  561. + .IP "\fI/usr/local/lib/libparse.a\fP"
  562. + Link library for parseargs.
  563. + .IP "\fI/usr/local/include/parseargs.h\fP"
  564. + Include file for parseargs.
  565. + .IP "\fI/usr/local/include/useful.h\fP"
  566. + Include file for portability.
  567. + .\"------------------------------------------------------------------
  568. X  .SH SEE ALSO
  569. X  .IR argtype (3),
  570. X  .IR parseargs (1),
  571. ! .IR parsecntl (3)
  572. X  .br
  573. X  The ``C Advisor'' column in
  574. X  .ul
  575. diff -cNr ../patchlevel4/doc/parseargs1.inc ./doc/parseargs1.inc
  576. *** ../patchlevel4/doc/parseargs1.inc    Thu May  2 11:01:54 1991
  577. --- ./doc/parseargs1.inc    Thu May  2 14:35:28 1991
  578. ***************
  579. *** 28,32 ****
  580. X  Given the command name and the argument specification string,
  581. X  .B parseargs \-M
  582. X  prints a template of the command-syntax on standard output that is
  583. ! suitable for input to \fInroff\fP or \fItroff\fP using the \-man 
  584. X  macro package.
  585. --- 28,37 ----
  586. X  Given the command name and the argument specification string,
  587. X  .B parseargs \-M
  588. X  prints a template of the command-syntax on standard output that is
  589. ! suitable for input to \fInroff\fP or \fItroff\fP using the \fI\-man\fP
  590. X  macro package.
  591. + .PP
  592. + Given no other arguments
  593. + \fBparseargs \-#\fP prints on standard output, the current version and
  594. + patchlevel of the running version of \fBparseargs\fP.
  595. diff -cNr ../patchlevel4/doc/parsecntl.man3 ./doc/parsecntl.man3
  596. *** ../patchlevel4/doc/parsecntl.man3    Thu May  2 10:56:24 1991
  597. --- ./doc/parsecntl.man3    Thu May  2 14:35:33 1991
  598. ***************
  599. *** 8,14 ****
  600. X  #include <parseargs.h>
  601. X  .PP
  602. X  .nf
  603. ! int  parsecntl( ARGDESC argd[\|],  parsecntl_t func,  parsemode_t mode,  ... )
  604. X  .fi
  605. X  
  606. X  .\"-----------------------------------
  607. --- 8,14 ----
  608. X  #include <parseargs.h>
  609. X  .PP
  610. X  .nf
  611. ! int  parsecntl( ARGDESC argd[\|],  parsecntl_t func,  parsemode_t mode,  ... );
  612. X  .fi
  613. X  
  614. X  .\"-----------------------------------
  615. ***************
  616. *** 24,35 ****
  617. X  .\"-----------------------------------
  618. X  .so returns.inc
  619. X  .\"-----------------------------------
  620. X  .SH SEE ALSO
  621. - .nf
  622. X  .IR argtype (3),
  623. X  .IR parseargs (3),
  624. X  .IR parseargs (1)
  625. - .fi
  626. X  .\"-----------------------------------
  627. X  .SH AUTHOR
  628. X  .PP
  629. --- 24,35 ----
  630. X  .\"-----------------------------------
  631. X  .so returns.inc
  632. X  .\"-----------------------------------
  633. + .so effects.inc
  634. + .\"-----------------------------------
  635. X  .SH SEE ALSO
  636. X  .IR argtype (3),
  637. X  .IR parseargs (3),
  638. X  .IR parseargs (1)
  639. X  .\"-----------------------------------
  640. X  .SH AUTHOR
  641. X  .PP
  642. diff -cNr ../patchlevel4/doc/parsecntl3.inc ./doc/parsecntl3.inc
  643. *** ../patchlevel4/doc/parsecntl3.inc    Thu May  2 10:56:24 1991
  644. --- ./doc/parsecntl3.inc    Thu May  2 14:35:36 1991
  645. ***************
  646. *** 28,35 ****
  647. X  then the desired attributes are copied into
  648. X  the object pointed to by the last parameter. If the mode is
  649. X  .I pc_\s-1WRITE\s+1,
  650. ! then the attributes from the last parameter are copied to the command-
  651. ! object. If mode is
  652. X  .I pc_\s-1RDWR\s+1,
  653. X  then the attributes pointed to by the last
  654. X  parameter are copied to the command-object, and then the previous value
  655. --- 28,35 ----
  656. X  then the desired attributes are copied into
  657. X  the object pointed to by the last parameter. If the mode is
  658. X  .I pc_\s-1WRITE\s+1,
  659. ! then the attributes from the last parameter are copied to the
  660. ! command-object. If mode is
  661. X  .I pc_\s-1RDWR\s+1,
  662. X  then the attributes pointed to by the last
  663. X  parameter are copied to the command-object, and then the previous value
  664. diff -cNr ../patchlevel4/doc/parsecntls.inc ./doc/parsecntls.inc
  665. *** ../patchlevel4/doc/parsecntls.inc    Thu May  2 10:56:25 1991
  666. --- ./doc/parsecntls.inc    Thu May  2 14:35:38 1991
  667. ***************
  668. *** 108,119 ****
  669. X  .ft R
  670. X  .fi
  671. X  
  672. ! Note that in the above call to
  673. ! .IR parsecntl(3),
  674. ! that zero will be
  675. X  returned upon success and non-zero upon failure. If pe_DEFARGS is
  676. ! returned, then cmd is already on common_args's list of defaults (and
  677. ! would result in an infinite loop while parsing).
  678. X  .\"---------------------------------------------
  679. X  .IP "\fIpc_\s-1NAME\s+1\fP"
  680. X  .IP "\fIpc_\s-1PURPOSE\s+1\fP"
  681. --- 108,117 ----
  682. X  .ft R
  683. X  .fi
  684. X  
  685. ! Note that in the above call to \fIparsecntl\fP\^(3), that zero will be
  686. X  returned upon success and non-zero upon failure. If pe_DEFARGS is
  687. ! returned, then \f4cmd\fP is already on \f4common_args\fP's list of defaults
  688. ! (and would result in an infinite loop while parsing).
  689. X  .\"---------------------------------------------
  690. X  .IP "\fIpc_\s-1NAME\s+1\fP"
  691. X  .IP "\fIpc_\s-1PURPOSE\s+1\fP"
  692. diff -cNr ../patchlevel4/doc/parseflags.inc ./doc/parseflags.inc
  693. *** ../patchlevel4/doc/parseflags.inc    Thu May  2 10:56:25 1991
  694. --- ./doc/parseflags.inc    Thu May  2 14:35:40 1991
  695. ***************
  696. *** 5,11 ****
  697. X  .SH "PARSE FLAGS"
  698. X  .PP
  699. X  The following bitmasks may be combined in order to modify the
  700. ! behavior of the parseargs library. The parse flags for a given
  701. X  may be set through the use of the \fIparsecntl\fP(3) function.
  702. X  .\"---------------------------------------------
  703. X  .IP "\fIpa_\s-1PROMPT\s+1\fP"
  704. --- 5,11 ----
  705. X  .SH "PARSE FLAGS"
  706. X  .PP
  707. X  The following bitmasks may be combined in order to modify the
  708. ! behavior of the \fIparseargs\fP library. The parse flags for a given
  709. X  may be set through the use of the \fIparsecntl\fP(3) function.
  710. X  .\"---------------------------------------------
  711. X  .IP "\fIpa_\s-1PROMPT\s+1\fP"
  712. ***************
  713. *** 17,24 ****
  714. X  .\"---------------------------------------------
  715. X  .IP "\fIpa_\s-1IGNORE\s+1\fP"
  716. X  Ignore any unrecognized or improperly specified command-line arguments
  717. ! and continue execution of the program. Normally, if an argument is
  718. ! unmatched (or is improperly specified), a usage message is printed
  719. X  program execution is terminated.
  720. X  .\"---------------------------------------------
  721. X  .IP "\fIpa_\s-1OPTSONLY\s+1\fP"
  722. --- 17,24 ----
  723. X  .\"---------------------------------------------
  724. X  .IP "\fIpa_\s-1IGNORE\s+1\fP"
  725. X  Ignore any unrecognized or improperly specified command-line arguments
  726. ! and continue execution of the program. Normally, if a required argument is
  727. ! unmatched (or an argument is improperly specified), a usage message is printed
  728. X  program execution is terminated.
  729. X  .\"---------------------------------------------
  730. X  .IP "\fIpa_\s-1OPTSONLY\s+1\fP"
  731. ***************
  732. *** 28,34 ****
  733. X  .\"---------------------------------------------
  734. X  .IP "\fIpa_\s-1KWDSONLY\s+1\fP"
  735. X  Under \s-1UNIX\s+1, setting this flag disables the parsing of single-character
  736. ! options.  This will cause all arguments starting with `-' to always
  737. X  be treated as a positional parameter (instead of an option).
  738. X  .\"---------------------------------------------
  739. X  .IP "\fIpa_\s-1FLAGS1ST\s+1\fP"
  740. --- 28,34 ----
  741. X  .\"---------------------------------------------
  742. X  .IP "\fIpa_\s-1KWDSONLY\s+1\fP"
  743. X  Under \s-1UNIX\s+1, setting this flag disables the parsing of single-character
  744. ! options.  This will cause all arguments starting with `\-' to always
  745. X  be treated as a positional parameter (instead of an option).
  746. X  .\"---------------------------------------------
  747. X  .IP "\fIpa_\s-1FLAGS1ST\s+1\fP"
  748. ***************
  749. *** 47,70 ****
  750. X  .IP "\fIpa_\s-1ANYCASE\s+1\fP"
  751. X  Setting this flag will cause character-case to be ignored when attempting
  752. X  to match single-character argument names (i.e. causes "\fB\-i\fP" and
  753. ! "\fB\-I\fP" will be considered equivalent).
  754. X  .\"---------------------------------------------
  755. X  .IP "\fIpa_\s-1ARGV0\s+1\fP"
  756. ! Normally, the parseargs library will assume that the first argument
  757. ! on the command-line is the name of the command. Setting this flag
  758. ! tells parseargs that this is \s-1NOT\s+1 the case and that the very first
  759. X  argument on the command-line is a bona-fide argument to the command.
  760. X  .\"---------------------------------------------
  761. X  .IP "\fIpa_\s-1NOCHECK\s+1\fP"
  762. ! Setting this flag will prevent parseargs from checking for any 
  763. X  required arguments that were not given on the command-line. This
  764. ! is useful when more than one call to the parseargs library is needed
  765. X  to parse all the command-line arguments (which could occur if the
  766. ! command-line argument came from a file or from two argv-vectors).
  767. X  
  768. X  Keeping this flag on until the final set of arguments is parsed will
  769. ! cause parseargs to not check for missing arguments until the last set
  770. ! of arguments has been parsed (by the final call to *parseargs).
  771. X  .\"---------------------------------------------
  772. X  .IP "\fIpa_\s-1CONTINUE\s+1\fP"
  773. X  Setting this flag will cause subsequent calls to the parseargs library
  774. --- 47,73 ----
  775. X  .IP "\fIpa_\s-1ANYCASE\s+1\fP"
  776. X  Setting this flag will cause character-case to be ignored when attempting
  777. X  to match single-character argument names (i.e. causes "\fB\-i\fP" and
  778. ! "\fB\-I\fP" to be considered equivalent).
  779. X  .\"---------------------------------------------
  780. X  .IP "\fIpa_\s-1ARGV0\s+1\fP"
  781. ! Normally, the \fIparseargs\fP library will assume that the first argument
  782. ! on the command-line is the name of the command. Setting this flag tells
  783. ! \fIparseargs\fP that this is \s-1NOT\s+1 the case and that the very first
  784. X  argument on the command-line is a bona-fide argument to the command.
  785. X  .\"---------------------------------------------
  786. X  .IP "\fIpa_\s-1NOCHECK\s+1\fP"
  787. ! Setting this flag will prevent \fIparseargs\fP from checking for any 
  788. X  required arguments that were not given on the command-line. This
  789. ! is useful when more than one call to the \fIparseargs\fP library is needed
  790. X  to parse all the command-line arguments (which could occur if the
  791. ! command-line argument came from a file or from two \f4argv\fP-vectors).
  792. ! When this flag is set, then each call to parseargs will check for missing
  793. ! required arguments (and will prompt the user for them if desired).
  794. X  
  795. X  Keeping this flag on until the final set of arguments is parsed will
  796. ! cause \fIparseargs\fP to not check for missing arguments until the last set
  797. ! of arguments has been parsed (by the final call to one of the functions 
  798. ! in the \fIparseargs\fP library).
  799. X  .\"---------------------------------------------
  800. X  .IP "\fIpa_\s-1CONTINUE\s+1\fP"
  801. X  Setting this flag will cause subsequent calls to the parseargs library
  802. diff -cNr ../patchlevel4/doc/parsemodes.inc ./doc/parsemodes.inc
  803. *** ../patchlevel4/doc/parsemodes.inc    Thu May  2 10:56:26 1991
  804. --- ./doc/parsemodes.inc    Thu May  2 14:35:43 1991
  805. ***************
  806. *** 6,12 ****
  807. X  .PP
  808. X  \fIParsecntl\fP may be used to read current command attributes, write
  809. X  (assign) new command attributes, or both. The mode argument to
  810. ! parsecntl determines the which of these three alternatives are
  811. X  desired. If the programmer merely wishes to assign new attributes,
  812. X  then invoking \fIparsecntl\fP in \fIpc_\s-1WRITE\s+1\fP mode and passing
  813. X  the new attributes will do the job. If the programmer wishes simply to query
  814. --- 6,12 ----
  815. X  .PP
  816. X  \fIParsecntl\fP may be used to read current command attributes, write
  817. X  (assign) new command attributes, or both. The mode argument to
  818. ! parsecntl determines which of these three alternatives are
  819. X  desired. If the programmer merely wishes to assign new attributes,
  820. X  then invoking \fIparsecntl\fP in \fIpc_\s-1WRITE\s+1\fP mode and passing
  821. X  the new attributes will do the job. If the programmer wishes simply to query
  822. ***************
  823. *** 21,24 ****
  824. X  When \fIparsecntl\fP returns, then (assuming it returns 0) the desired
  825. X  attributes will have been assigned and the object that contained the
  826. X  new attribute settings will now contain the attribute settings that
  827. ! were in effect before \fIparsecntl\fP was invoked.
  828. --- 21,24 ----
  829. X  When \fIparsecntl\fP returns, then (assuming it returns 0) the desired
  830. X  attributes will have been assigned and the object that contained the
  831. X  new attribute settings will now contain the attribute settings that
  832. ! were in effect immediately before \fIparsecntl\fP was invoked.
  833. diff -cNr ../patchlevel4/doc/sh_arrays.inc ./doc/sh_arrays.inc
  834. *** ../patchlevel4/doc/sh_arrays.inc    Thu May  2 11:01:59 1991
  835. --- ./doc/sh_arrays.inc    Thu May  2 14:35:48 1991
  836. ***************
  837. *** 9,15 ****
  838. X  setting up an argument list depends largely upon the syntax of shell
  839. X  that was specified on the command line via the \fB\-s\fP option
  840. X  (although \s-1ARGLIST\s+1 arguments are treated exactly the same as
  841. ! \s-1ARGVEC\s+1 arguments).
  842. X  .\"---------------
  843. X  .SS "Resetting the Positional Parameters to an Argument List"
  844. X  .PP
  845. --- 9,18 ----
  846. X  setting up an argument list depends largely upon the syntax of shell
  847. X  that was specified on the command line via the \fB\-s\fP option
  848. X  (although \s-1ARGLIST\s+1 arguments are treated exactly the same as
  849. ! \s-1ARGVEC\s+1 arguments). With the exception of \fIperl\fP which always
  850. ! uses a comma to separate array elements, all shells will use the string
  851. ! specified with the \fB\-S\fP option as the field separator between elements
  852. ! of an array (the default field separator is a space character).
  853. X  .\"---------------
  854. X  .SS "Resetting the Positional Parameters to an Argument List"
  855. X  .PP
  856. ***************
  857. *** 23,29 ****
  858. X  (this way, the positional parameters will be unset if the associated list
  859. X  of command line arguments is not encountered).
  860. X  .PP
  861. ! Similarly for the C and TC shells,
  862. X  if the variable name corresponding to the \s-1ARGLIST\s+1 argument is
  863. X  ``\fBargv\fP'', then the positional parameters of the calling program
  864. X  will be re-assigned to the contents of the argument list.
  865. --- 26,32 ----
  866. X  (this way, the positional parameters will be unset if the associated list
  867. X  of command line arguments is not encountered).
  868. X  .PP
  869. ! Similarly for the C & Z shells (\fIzsh, csh, tcsh, itcsh\fP),
  870. X  if the variable name corresponding to the \s-1ARGLIST\s+1 argument is
  871. X  ``\fBargv\fP'', then the positional parameters of the calling program
  872. X  will be re-assigned to the contents of the argument list.
  873. ***************
  874. *** 109,117 ****
  875. X  .RS
  876. X  \f4set  \-A  save_parms  "$@"\fP
  877. X  .RE
  878. ! .SS "C and TC Shell Argument Lists"
  879. X  .PP
  880. ! For the C and TC shells, \s-1ARGLIST\s+1 variables are treated as word-lists
  881. X  and are assigned using the following syntax:
  882. X  .sp 2p
  883. X  .RS
  884. --- 112,121 ----
  885. X  .RS
  886. X  \f4set  \-A  save_parms  "$@"\fP
  887. X  .RE
  888. ! .SS "C Shell Argument Lists"
  889. X  .PP
  890. ! For the C shells (\fIcsh, tcsh, itcsh\fP),
  891. ! \s-1ARGLIST\s+1 variables are treated as word-lists
  892. X  and are assigned using the following syntax:
  893. X  .sp 2p
  894. X  .RS
  895. ***************
  896. *** 120,126 ****
  897. X  .sp 2p
  898. X  The first item will be in \f4$name[1]\fP, the second item will be in
  899. X  \f4$name[2]\fP, etc ..., and all items may be given by \f4$name\fP.
  900. ! Notice that Korn shell arrays start at index zero whereas C and TC shell
  901. X  word-lists start at index one.
  902. X  .SS "Bourne-Again Shell Argument Lists"
  903. X  .PP
  904. --- 124,130 ----
  905. X  .sp 2p
  906. X  The first item will be in \f4$name[1]\fP, the second item will be in
  907. X  \f4$name[2]\fP, etc ..., and all items may be given by \f4$name\fP.
  908. ! Notice that Korn shell arrays start at index zero whereas C shell
  909. X  word-lists start at index one.
  910. X  .SS "Bourne-Again Shell Argument Lists"
  911. X  .PP
  912. ***************
  913. *** 130,136 ****
  914. X  .SS "Plan 9 Shell Argument Lists"
  915. X  .PP
  916. X  For the Plan 9 shell, if the associated variable name is not ``*'' then
  917. ! it is considered to be word-list and set using the following syntax:
  918. X  .nf
  919. X  .RS
  920. X  .ft 4
  921. --- 134,140 ----
  922. X  .SS "Plan 9 Shell Argument Lists"
  923. X  .PP
  924. X  For the Plan 9 shell, if the associated variable name is not ``*'' then
  925. ! it is considered to be a word-list and set using the following syntax:
  926. X  .nf
  927. X  .RS
  928. X  .ft 4
  929. ***************
  930. *** 138,145 ****
  931. X  .ft R
  932. X  .RE
  933. X  .fi
  934. X  .SS "Awk Argument Lists"
  935. ! For \fIawk\fP, if the \fB\-A\fP option is not given, then the output for thes
  936. X  variable-list will be a line with the variable name, followed by a line with
  937. X  each of the values (each value will be separated with the field separator
  938. X  specified using the \fB\-S\fP option - which defaults to a space). 
  939. --- 142,162 ----
  940. X  .ft R
  941. X  .RE
  942. X  .fi
  943. + .SS "Z Shell Argument Lists"
  944. + .PP
  945. + For the Z shell, \s-1ARGLIST\s+1 variables are treated as word-lists
  946. + and are assigned using the following syntax:
  947. + .sp 2p
  948. + .RS
  949. + \f4name = ( 'arg1'  'arg2'\fP  \fI...\fP\f4 )\fP
  950. + .RE
  951. + .sp 2p
  952. + The first item will be in \f4$name[1]\fP, the second item will be in
  953. + \f4$name[2]\fP, etc ..., and all items may be given by \f4$name\fP.
  954. + Notice that Korn shell arrays start at index zero whereas Z and C shell
  955. + word-lists start at index one.
  956. X  .SS "Awk Argument Lists"
  957. ! For \fIawk\fP, if the \fB\-A\fP option is not given, then the output for the
  958. X  variable-list will be a line with the variable name, followed by a line with
  959. X  each of the values (each value will be separated with the field separator
  960. X  specified using the \fB\-S\fP option - which defaults to a space). 
  961. ***************
  962. *** 154,160 ****
  963. X  If the \fB\-A\fP option is given, then the associated variable is considered
  964. X  the root name of an array. The ouput for the array
  965. X  will consist of two lines for each item in the list (as in the following
  966. ! expample):
  967. X  .nf
  968. X  .RS
  969. X  .ft 4
  970. --- 171,177 ----
  971. X  If the \fB\-A\fP option is given, then the associated variable is considered
  972. X  the root name of an array. The ouput for the array
  973. X  will consist of two lines for each item in the list (as in the following
  974. ! example):
  975. X  .nf
  976. X  .RS
  977. X  .ft 4
  978. ***************
  979. *** 178,191 ****
  980. X  .nf
  981. X  .RS
  982. X  .ft 4
  983. ! @name=( arg1 , arg2 ,  ... );
  984. X  .ft R
  985. X  .RE
  986. X  .fi
  987. X  .SS "A Final Note on Argument Lists"
  988. X  .PP
  989. ! The word-lists used by the C shell, the arrays used by the Korn shell, the 
  990. ! Plan 9 shell, \fIawk\fP, \fIperl\fP, and the positional parameters used by
  991. X  all shells (if overwritten by \fBparseargs\fP) will preserve any \s-1IFS\s+1
  992. X  characters in their contents.  That is to say that if an item in one of the
  993. X  aforementioned multi-word lists contains any \s-1IFS\s+1 characters, it will
  994. --- 195,208 ----
  995. X  .nf
  996. X  .RS
  997. X  .ft 4
  998. ! @name=( 'arg1' , 'arg2' ,  ... );
  999. X  .ft R
  1000. X  .RE
  1001. X  .fi
  1002. X  .SS "A Final Note on Argument Lists"
  1003. X  .PP
  1004. ! The word-lists used by the C and Z shells, the arrays used by the Korn shell,
  1005. ! the Plan 9 shell, \fIawk\fP, \fIperl\fP, and the positional parameters used by
  1006. X  all shells (if overwritten by \fBparseargs\fP) will preserve any \s-1IFS\s+1
  1007. X  characters in their contents.  That is to say that if an item in one of the
  1008. X  aforementioned multi-word lists contains any \s-1IFS\s+1 characters, it will
  1009. diff -cNr ../patchlevel4/doc/shells.inc ./doc/shells.inc
  1010. *** ../patchlevel4/doc/shells.inc    Thu May  2 11:02:07 1991
  1011. --- ./doc/shells.inc    Thu May  2 14:35:51 1991
  1012. ***************
  1013. *** 15,23 ****
  1014. X  (not be evaluated by the shell) in the corresponding shell variable.
  1015. X  .PP
  1016. X  The \fB\-s\fP \fIshell\fP option may be used to tell \fBparseargs\fP which
  1017. ! shell syntax to use. At present, \fBparseargs\fP only recognizes
  1018. ! ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'', ``awk'', and ``perl''
  1019. ! as valid command interpreters. \fIAwk\fP output is slightly different from 
  1020. X  that of the other shells in that the actual variable settings are not
  1021. X  printed but each line of an associative array is printed (the first field
  1022. X  is the array index, the second is the value for that index).
  1023. --- 15,40 ----
  1024. X  (not be evaluated by the shell) in the corresponding shell variable.
  1025. X  .PP
  1026. X  The \fB\-s\fP \fIshell\fP option may be used to tell \fBparseargs\fP which
  1027. ! shell syntax to use. At present, \fBparseargs\fP only recognizes the following
  1028. ! shells as valid command-interpreters:
  1029. ! .RS
  1030. ! .nf
  1031. ! sh
  1032. ! bash
  1033. ! ksh
  1034. ! csh
  1035. ! tcsh
  1036. ! itcsh
  1037. ! zsh
  1038. ! rc
  1039. ! awk
  1040. ! perl
  1041. ! .fi
  1042. ! .RE
  1043. ! .PP
  1044. ! \fIAwk\fP output is slightly different from 
  1045. X  that of the other shells in that the actual variable settings are not
  1046. X  printed but each line of an associative array is printed (the first field
  1047. X  is the array index, the second is the value for that index).
  1048. diff -cNr ../patchlevel4/doc/sparseargs3.inc ./doc/sparseargs3.inc
  1049. *** ../patchlevel4/doc/sparseargs3.inc    Thu May  2 10:56:29 1991
  1050. --- ./doc/sparseargs3.inc    Thu May  2 14:35:53 1991
  1051. ***************
  1052. *** 4,15 ****
  1053. X  .\"----------------------------------------------------------------------------
  1054. X  .PP
  1055. X  Given a single string and an argdesc array, \fIsparseargs\fP
  1056. ! will parse arguments from a string in much the same manner as \fIparseargs\fP.
  1057. X  .I Sparseargs
  1058. X  will split the given string up into a vector of whitespace
  1059. X  separated tokens and then attempt to parse the resultant vector as
  1060. ! if it were given as \fIargv[]\fP on the command-line.
  1061. X  NO special treatment is given to characters such as single-quotes,
  1062. X  double-quotes, or anything else. \fISparseargs\fP will always assume that
  1063. X  any whitespace characters are intended as argument separators.
  1064. --- 4,14 ----
  1065. X  .\"----------------------------------------------------------------------------
  1066. X  .PP
  1067. X  Given a single string and an argdesc array, \fIsparseargs\fP
  1068. ! will parse arguments from a string in much the manner as \fIparseargs\fP.
  1069. X  .I Sparseargs
  1070. X  will split the given string up into a vector of whitespace
  1071. X  separated tokens and then attempt to parse the resultant vector as
  1072. ! if it were given as \f4argv[]\fP on the command-line.
  1073. X  NO special treatment is given to characters such as single-quotes,
  1074. X  double-quotes, or anything else. \fISparseargs\fP will always assume that
  1075. X  any whitespace characters are intended as argument separators.
  1076. diff -cNr ../patchlevel4/doc/vparseargs3.inc ./doc/vparseargs3.inc
  1077. *** ../patchlevel4/doc/vparseargs3.inc    Thu May  2 10:56:30 1991
  1078. --- ./doc/vparseargs3.inc    Thu May  2 14:35:58 1991
  1079. ***************
  1080. *** 6,12 ****
  1081. X  .I Vparseargs
  1082. X  takes an argdesc array, the number of arguments to parse, and a
  1083. X  (possibly NULL terminated) list of argument-strings
  1084. ! and parses them in much the same manner as \fIparseargs\fP.
  1085. X  Unlike
  1086. X  .I sparseargs,
  1087. X  .I vparseargs
  1088. --- 6,12 ----
  1089. X  .I Vparseargs
  1090. X  takes an argdesc array, the number of arguments to parse, and a
  1091. X  (possibly NULL terminated) list of argument-strings
  1092. ! and parses them in the same manner as \fIparseargs\fP.
  1093. X  Unlike
  1094. X  .I sparseargs,
  1095. X  .I vparseargs
  1096. ***************
  1097. *** 13,16 ****
  1098. X  assumes that all parameters are already split up into tokens, hence any
  1099. X  whitespace characters contained in any of the string-parameters are used as
  1100. X  is (and will be considered a part of an argument name or value).
  1101. --- 13,15 ----
  1102. diff -cNr ../patchlevel4/ibm_args.c ./ibm_args.c
  1103. *** ../patchlevel4/ibm_args.c    Thu May  2 11:06:08 1991
  1104. --- ./ibm_args.c    Thu May  2 14:36:02 1991
  1105. ***************
  1106. *** 208,213 ****
  1107. --- 208,214 ----
  1108. X     get_prefixes();
  1109. X  
  1110. X     while ( av  &&  (p = *av++) ) {
  1111. +       /* is this a keyword */
  1112. X        if ( isKWD(p) &&
  1113. X            ( (OptPrefix != KwdPrefix) || *(p+2) && !strchr(s_ARG_SEP, *(p+2)) )
  1114. X           ) {
  1115. ***************
  1116. *** 251,256 ****
  1117. --- 252,262 ----
  1118. X              continue;
  1119. X           }
  1120. X  
  1121. +          /* reset the argument flags - if this arg was already given, some
  1122. +          ** of its flags may be set to indicate how it was given before.
  1123. +          ** we need to know how it was given now (but save the old ones
  1124. +          ** just in case the new one fails).
  1125. +          */
  1126. X           flags = arg_flags(ad);
  1127. X           if ( ARG_isGIVEN(ad) ) {
  1128. X              BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
  1129. ***************
  1130. *** 260,266 ****
  1131. X           BSET( arg_flags(ad), ARGKEYWORD );
  1132. X  
  1133. X           if( ARG_isMULTIVAL(ad) ) {
  1134. !             cmd_list(cmd) = ad;
  1135. X           }
  1136. X           else {
  1137. X              cmd_list(cmd) = ARGDESCNULL;
  1138. --- 266,272 ----
  1139. X           BSET( arg_flags(ad), ARGKEYWORD );
  1140. X  
  1141. X           if( ARG_isMULTIVAL(ad) ) {
  1142. !             cmd_list(cmd) = ad;  /* we matched a lst or a vector */
  1143. X           }
  1144. X           else {
  1145. X              cmd_list(cmd) = ARGDESCNULL;
  1146. ***************
  1147. *** 330,337 ****
  1148. X              continue;
  1149. X           }
  1150. X  
  1151. !             /* flag argument */
  1152. !          while (*p) {
  1153. X  
  1154. X                 /* find the flag in the list */
  1155. X              is_match = FALSE;
  1156. --- 336,348 ----
  1157. X              continue;
  1158. X           }
  1159. X  
  1160. !          /* We have a flag argument;
  1161. !          ** remember that in the case of single character keywords,
  1162. !          ** the conversion function (ad_type) tells us how many characters
  1163. !          ** were used. We need that information to decide how many 
  1164. !          ** characters to skip before the next iteration of the while loop.
  1165. !          */
  1166. !          while (*p) {  /* while not end of switch-chars */
  1167. X  
  1168. X                 /* find the flag in the list */
  1169. X              is_match = FALSE;
  1170. ***************
  1171. *** 363,368 ****
  1172. --- 374,384 ----
  1173. X                    continue;
  1174. X              }/* if unknown-option */
  1175. X  
  1176. +             /* reset the argument flags - if this arg was already given, some
  1177. +             ** of its flags may be set to indicate how it was given before.
  1178. +             ** we need to know how it was given now (but save the old ones
  1179. +             ** just in case the new one fails).
  1180. +             */
  1181. X              flags = arg_flags(ad);
  1182. X              if ( ARG_isGIVEN(ad) ) {
  1183. X                 BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
  1184. ***************
  1185. *** 370,376 ****
  1186. X              }
  1187. X  
  1188. X              if ( ARG_isMULTIVAL(ad) ) {
  1189. !                cmd_list(cmd) = ad;
  1190. X              }
  1191. X              else {
  1192. X                 cmd_list(cmd) = ARGDESCNULL;
  1193. --- 386,392 ----
  1194. X              }
  1195. X  
  1196. X              if ( ARG_isMULTIVAL(ad) ) {
  1197. !                cmd_list(cmd) = ad;  /* we matched a list (or a vector) */
  1198. X              }
  1199. X              else {
  1200. X                 cmd_list(cmd) = ARGDESCNULL;
  1201. ***************
  1202. *** 448,456 ****
  1203. X        }/*elif option*/
  1204. X        else {
  1205. X              /* parsing a list of arguments */
  1206. !          if ( cmd_list(cmd) ) {
  1207. X              ad = cmd_list(cmd);
  1208. !             flags = arg_flags(ad);
  1209. X              if ( ARG_isGIVEN(ad) ) {
  1210. X                 BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
  1211. X              }
  1212. --- 464,472 ----
  1213. X        }/*elif option*/
  1214. X        else {
  1215. X              /* parsing a list of arguments */
  1216. !          if ( cmd_list(cmd) ) {  /* we're in the middle of a list/vector */
  1217. X              ad = cmd_list(cmd);
  1218. !             flags = arg_flags(ad);  /* reset flags for this argv-item */
  1219. X              if ( ARG_isGIVEN(ad) ) {
  1220. X                 BCLEAR( arg_flags(ad), ARGVALSEP | ARGKEYWORD );
  1221. X              }
  1222. ***************
  1223. *** 495,500 ****
  1224. --- 511,517 ----
  1225. X              cmd_list(cmd) = ad;
  1226. X           }
  1227. X  
  1228. +          /* if FLAGS1ST is set then first positional marks end-of-flags */
  1229. X           if ( BTEST(cmd_flags(cmd), pa_FLAGS1ST) ) {
  1230. X              BSET( cmd_state(cmd), ps_NOFLAGS );
  1231. X           }
  1232. diff -cNr ../patchlevel4/parseargs.c ./parseargs.c
  1233. *** ../patchlevel4/parseargs.c    Thu May  2 11:06:09 1991
  1234. --- ./parseargs.c    Thu May  2 14:36:12 1991
  1235. ***************
  1236. *** 1,13 ****
  1237. X  /*************************************************************************
  1238. X  ** ^FILE: parseargs.c - command line interface to parseargs()
  1239. X  **
  1240. - ** ^DESCRIPTION:
  1241. X  **    This file implements the command-line interface to the parseargs
  1242. X  **    library. Under Unix, the user may use parseargs(1) (this program)
  1243. X  **    to parse command-line arguments for shell scripts.  At the present,
  1244. X  **    time, VMS/DCL is not yet supported (nor are MS-DOS Batch-files).
  1245. X  **
  1246. ! **
  1247. X  **    Given a command name, a vector of string-valued arguments such as that
  1248. X  **    passed to a shell script, and a specification string describing the
  1249. X  **    possible arguments, parseargs matches actual arguments to possible
  1250. --- 1,12 ----
  1251. X  /*************************************************************************
  1252. X  ** ^FILE: parseargs.c - command line interface to parseargs()
  1253. X  **
  1254. X  **    This file implements the command-line interface to the parseargs
  1255. X  **    library. Under Unix, the user may use parseargs(1) (this program)
  1256. X  **    to parse command-line arguments for shell scripts.  At the present,
  1257. X  **    time, VMS/DCL is not yet supported (nor are MS-DOS Batch-files).
  1258. X  **
  1259. ! ** ^DESCRIPTION:
  1260. X  **    Given a command name, a vector of string-valued arguments such as that
  1261. X  **    passed to a shell script, and a specification string describing the
  1262. X  **    possible arguments, parseargs matches actual arguments to possible
  1263. ***************
  1264. *** 158,176 ****
  1265. X  
  1266. X  /**************************************************************************
  1267. X  ** ^SECTION: SHELLS
  1268. ! **    After the command line has been parsed, parseargs will print on stan-
  1269. ! **    dard output, a script to set the shell variables which correspond to
  1270. ! **    arguments that were present on the command-line.  This script may be
  1271. ! **    evaluated by redirecting it to a file and then executing the file,
  1272. X  **    or by directly evaluating the output from parseargs (under most UNIX
  1273. ! **    shells, this could be done using eval).  If any arguments on the com-
  1274. ! **    mand line contained any special characters that needed to be escaped
  1275. ! **    from the shell, these characters will remain intact (not be evaluated
  1276. ! **    by the shell) in the corresponding shell variable.
  1277. X  **
  1278. X  **    The -s shell option may be used to tell parseargs which shell syntax
  1279. ! **    to use. At present, parseargs only recognizes "sh", "csh", "ksh",
  1280. ! **    "tcsh", "bash", "rc", "awk", and "perl" as valid command interpreters.
  1281. X  **    Awk output is slightly different from that of the other shells in that
  1282. X  **    the actual variable settings are not printed but each line of an
  1283. X  **    associative array is printed (the first field is the array index, the
  1284. --- 157,187 ----
  1285. X  
  1286. X  /**************************************************************************
  1287. X  ** ^SECTION: SHELLS
  1288. ! **    After the command line has been parsed, parseargs will print on
  1289. ! **    standard output, a script to set the shell variables which correspond
  1290. ! **    to arguments that were present on the command-line.  This script may
  1291. ! **    be evaluated by redirecting it to a file and then executing the file,
  1292. X  **    or by directly evaluating the output from parseargs (under most UNIX
  1293. ! **    shells, this could be done using eval).  If any arguments on the
  1294. ! **    command line contained any special characters that needed to be
  1295. ! **    escaped from the shell, these characters will remain intact (not be
  1296. ! **    evaluated by the shell) in the corresponding shell variable.
  1297. X  **
  1298. X  **    The -s shell option may be used to tell parseargs which shell syntax
  1299. ! **    to use. At present, parseargs only recognizes the following shells as
  1300. ! **    valid command-interpreters:
  1301. ! **
  1302. ! **         sh
  1303. ! **         bash
  1304. ! **         ksh
  1305. ! **         csh
  1306. ! **         tcsh
  1307. ! **         itcsh
  1308. ! **         zsh
  1309. ! **         rc
  1310. ! **         awk
  1311. ! **         perl
  1312. ! **
  1313. X  **    Awk output is slightly different from that of the other shells in that
  1314. X  **    the actual variable settings are not printed but each line of an
  1315. X  **    associative array is printed (the first field is the array index, the
  1316. ***************
  1317. *** 178,254 ****
  1318. X  **    the Bourne shell ("sh") will be assumed.
  1319. X  **
  1320. X  **    If the user wishes to use a value other than "TRUE" for a boolean
  1321. ! **    flag that is true, this may be done using the "-T string" option.
  1322. ! **    The same may also be done for a boolean flag that is false using the
  1323. ! **    "-F string" option.
  1324. X  **
  1325. X  **    Parseargs will only set the values of variables that correspond to
  1326. ! **    arguments that were given on the command line. If a particular argu-
  1327. ! **    ment was not supplied on the command line, then no assignment is made
  1328. ! **    for the corresponding shell variable and it will have the same value
  1329. ! **    that it had before parseargs was invoked. The only exception to this
  1330. ! **    is that if the -u option is specified, then the positional parameters
  1331. ! **    are unset before any shell variable assignments (which may reset the
  1332. ! **    positional parameters) are made.
  1333. X  ***^^*********************************************************************/
  1334. X  
  1335. !       /* #defines for possible shell names and corresponding types */
  1336. ! typedef short  shell_t;
  1337. ! #define  BASH  ((shell_t) 0)
  1338. ! #define  TCSH  ((shell_t) 1)
  1339. ! #define  CSH   ((shell_t) 2)
  1340. ! #define  KSH   ((shell_t) 3)
  1341. ! #define  SH    ((shell_t) 4)
  1342. ! #define  RC    ((shell_t) 5)
  1343. ! #define  AWK   ((shell_t) 6)
  1344. ! #define  PERL  ((shell_t) 7)
  1345. ! #define  BOURNE_AGAIN_SHELL  "bash"
  1346. ! #define  BOURNE_SHELL        "sh"
  1347. ! #define  KORN_SHELL          "ksh"
  1348. ! #define  C_SHELL             "csh"
  1349. ! #define  RC_SHELL            "rc"
  1350. ! #define  TC_SHELL            "tcsh"
  1351. ! #define  AWK_LANG            "awk"
  1352. ! #define  PERL_LANG           "perl"
  1353. X  
  1354. X     /* structure for shell-specific info */
  1355. X  typedef struct {
  1356. !    char  *varname;   /* name of variable containing the positional parameters */
  1357. !    char  *setcmd;    /* formatted string (%s is replaced with variable name) */
  1358. !    char  *prefix;    /* beginning for variable setting */
  1359. !    char  *suffix;    /* ending for variable setting */
  1360. X     char  *escape;    /* format to escape chars (%c is the char to escape) */
  1361. X     char  *metachars; /* special characters that need to be escaped */
  1362. X  } shell_info;
  1363. X  
  1364. !    /* array of shell info - indexed by the #define for the shell type */
  1365. X  static CONST shell_info  Shell[] = {
  1366. X  
  1367. !    /* BASH : Positional parms in -- ; Assignment Syntax: name="value"; */
  1368. !    { "--", "%s=",   "'",   "';\n",   "'\\%c'",   "'" },
  1369. X  
  1370. -    /* TCSH : Positional parms in argv ; Assignment Syntax: set name="value"; */
  1371. -    { "argv", "set %s=", "'",   "';\n",  "'\\%c'",   "'" },
  1372. -    /* CSH : Positional parms in argv ; Assignment Syntax: set name="value"; */
  1373. SHAR_EOF
  1374. true || echo 'restore of PATCH05 failed'
  1375. fi
  1376. echo 'End of  part 2'
  1377. echo 'File PATCH05 is continued in part 3'
  1378. echo 3 > _shar_seq_.tmp
  1379. exit 0
  1380. exit 0 # Just in case...
  1381. -- 
  1382. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1383. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1384. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1385. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1386.