DECOMP(1) NAME decomp SYNOPSIS decomp [-n] [-s sep] flg:opt [arg ...] DESCRIPTION flags and options are: -n: put trailing '\n' -s sep: output separater with the default '\t' these are only for debugging. In the first argument of Decomp, "flg" and "opt" are strings that denotes flags and options respectively for the rc script. For example "abc:de" means: ('a', 'b', 'c') are flags and ('d','e') are options. These defalt values and Optional values are to be given in the rc script. To understand the role of Decomp, let begin with an example well known "ls" command. We can write either in composed flag style ls -pld path or in decomposed flag style ls -p -l -d path These are both OK. Allowing both composed and decomposed style are common in progams written in C. However programs written in rc are not. In rc script, we offen write code to parse flags and options like below: while(~ $1 -*){ switch($1){ case -a aflag = 1 case -b shift bopt = $1 ... case * usage } shift } However this simple code assumes decomposed arguments. Decomp is command line parser designed for use in rc script. Decomp decomposes composed arguments to decomposed ones, so that it designed that rc script can accept command lines: [FO ...] [T] [arg ...] where FO is a composed(or decomposed) flag or option part, and T is a terminator ("-" or "--"), and arg is an argument. We can omit T when the first argument does not begin with '-'. The terminator is passed to rc as "-" even if "--" is given. Thus, adding a few lines in the rc script, the script accepts composed flags and options. The common style will be: nl=' ' # NL *=`$nl{decomp -s $nl flg:opt $*} if(~ $status -?*) usage while(~ $1 -?*){ ... case * usage } } if(~ $1 -) shift Plan 9 already has "aux/getflags". However the usage is not simple and not easy to understand. The live example will be found in /rc/bin/ape/ls. Decomp is an alternative to getflags. SOURCE http://p9.nyx.link/netlib/cmd/decomp/ AUTHER Kenji Arisawa