<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <META name="GENERATOR" content="hevea 1.09"> <LINK rel="stylesheet" type="text/css" href="omake-doc.css"> <TITLE>The standard objects</TITLE> </HEAD> <BODY > <img src="images/omake-manual.gif" border="0" align="top" alt=""><br> <TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=left NOWRAP>Jump to:</TD><TD VALIGN=top ALIGN=center NOWRAP>  </TD><TD ALIGN=left NOWRAP><A HREF="http://omake.metaprl.org/">OMake Home</A> • <A HREF="omake.html">Guide Home</A> • <A HREF="omake-doc.html">Guide (single-page)</A> • <A HREF="omake-toc.html">Contents (short)</A> • <A HREF="omake-contents.html">Contents (long)</A></TD></TR> <TR><TD ALIGN=left NOWRAP>Index:</TD><TD VALIGN=top ALIGN=center NOWRAP>  </TD><TD ALIGN=left NOWRAP><A HREF="omake-all-index.html">All</A> • <A HREF="omake-var-index.html">Variables</A> • <A HREF="omake-fun-index.html">Functions</A> • <A HREF="omake-obj-index.html">Objects</A> • <A HREF="omake-target-index.html">Targets</A> • <A HREF="omake-option-index.html">Options</A></TD></TR> </TABLE> <H1 CLASS="chapter"><A NAME="htoc326">Chapter 12</A>  The standard objects</H1><UL> <LI><A HREF="omake-pervasives.html#toc95">Pervasives objects</A></LI> </UL> <P> <A NAME="chapter:pervasives"></A> </P><P><CODE>Pervasives</CODE> defines the objects that are defined in all programs. The following objects are defined.</P><H2 CLASS="section"><A NAME="toc95"></A><A NAME="htoc327">12.1</A>  Pervasives objects</H2><H3 CLASS="subsection"><A NAME="htoc328">12.1.1</A>  Object</H3><P><A NAME="obj:Object"></A><A NAME="object:Object"></A><A NAME="@default344"></A><A NAME="@obj9"></A></P><P>Parent objects: none.</P><P>The <CODE>Object</CODE> object is the root object. Every class is a subclass of <CODE>Object</CODE>.</P><P>It provides the following fields:</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>$(o.object-length)</CODE>: the number of fields and methods in the object. </LI><LI CLASS="li-itemize"><CODE>$(o.object-mem <var>)</CODE>: returns <CODE>true</CODE> iff the <CODE><var></CODE> is a field or method of the object. </LI><LI CLASS="li-itemize"><CODE>$(o.object-add <var>, <value>)</CODE>: adds the field to the object, returning a new object. </LI><LI CLASS="li-itemize"><CODE>$(o.object-find <var>)</CODE>: fetches the field or method from the object; it is equivalent to <CODE>$(o.<var>)</CODE>, but the variable can be non-constant. </LI><LI CLASS="li-itemize"><CODE>$(o.object-map <fun>)</CODE>: maps a function over the object. The function should take two arguments; the first is a field name, the second is the value of that field. The result is a new object constructed from the values returned by the function. </LI><LI CLASS="li-itemize"><CODE>o.object-foreach</CODE>: the <CODE>object-foreach</CODE> form is equivalent to <CODE>object-map</CODE>, but with altered syntax.<PRE CLASS="verbatim"> o.object-foreach(<var1>, <var2>) <body> </PRE><P>For example, the following function prints all the fields of an object <CODE>o</CODE>.</P><PRE CLASS="verbatim"> PrintObject(o) = o.object-foreach(v, x) println($(v) = $(x)) </PRE><P>The <CODE>export</CODE> form is valid in a <CODE>object-foreach</CODE> body. The following function collects just the field names of an object.</P><PRE CLASS="verbatim"> FieldNames(o) = names[] = o.object-foreach(v, x) names[] += $(v) export return $(names) </PRE></LI></UL><H3 CLASS="subsection"><A NAME="htoc329">12.1.2</A>  Map</H3><P><A NAME="obj:Map"></A><A NAME="object:Map"></A><A NAME="@default345"></A><A NAME="@obj10"></A></P><P>Parent objects: <CODE>Object</CODE>.</P><P>A <CODE>Map</CODE> object is a dictionary from values to values. The <CODE><key></CODE> values are restricted to simple values: integers, floating-point numbers, strings, files, directories, and arrays of simple values.</P><P>The Map object provides the following methods.</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>$(o.length)</CODE>: the number of items in the map. </LI><LI CLASS="li-itemize"><CODE>$(o.mem <key>)</CODE>: returns <CODE>true</CODE> iff the <CODE><key></CODE> is defined in the map. </LI><LI CLASS="li-itemize"><CODE>$(o.add <key>, <value>)</CODE>: adds the field to the map, returning a new map. </LI><LI CLASS="li-itemize"><CODE>$(o.find <key>)</CODE>: fetches the field from the map. </LI><LI CLASS="li-itemize"><CODE>$(o.keys)</CODE>: fetches an array of all the keys in the map, in alphabetical order. </LI><LI CLASS="li-itemize"><CODE>$(o.values)</CODE>: fetches an array of all the values in the map, in the alphabetical order of the corresponding keys. </LI><LI CLASS="li-itemize"><CODE>$(o.map <fun>)</CODE>: maps a function over the map. The function should take two arguments; the first is a field name, the second is the value of that field. The result is a new object constructed from the values returned by the function. </LI><LI CLASS="li-itemize"><CODE>o.foreach</CODE>: the <CODE>foreach</CODE> form is equivalent to <CODE>map</CODE>, but with altered syntax.<PRE CLASS="verbatim"> o.foreach(<var1>, <var2>) <body> </PRE><P>For example, the following function prints all the fields of an object <CODE>o</CODE>.</P><PRE CLASS="verbatim"> PrintObject(o) = o.foreach(v, x) println($(v) = $(x)) </PRE><P>The <CODE>export</CODE> form is valid in a <CODE>foreach</CODE> body. The following function collects just the field names of the map.</P><PRE CLASS="verbatim"> FieldNames(o) = names = o.foreach(v, x) names += $(v) export return $(names) </PRE></LI></UL><P>There is also simpler syntax when the key is a string. The table can be defined using definitions with the form <CODE>$|key|</CODE> (the number of pipe symbols <CODE>|</CODE> is allowed to vary).</P><PRE CLASS="verbatim"> $|key 1| = value1 $||key1|key2|| = value2 # The key is key1|key2 X = $|key 1| # Define X to be the value of field $|key 1| </PRE><P>The usual modifiers are also allowed. The expression <CODE>$`|key|</CODE> represents lazy evaluation of the key, and <CODE>$,|key|</CODE> is normal evaluation.</P><H3 CLASS="subsection"><A NAME="htoc330">12.1.3</A>  Number</H3><P><A NAME="obj:Number"></A><A NAME="object:Number"></A><A NAME="@default346"></A><A NAME="@obj11"></A></P><P>Parent objects: <CODE>Object</CODE>.</P><P>The <CODE>Number</CODE> object is the parent object for integers and floating-point numbers. </P><H3 CLASS="subsection"><A NAME="htoc331">12.1.4</A>  Int</H3><P><A NAME="obj:Int"></A><A NAME="object:Int"></A><A NAME="@default347"></A><A NAME="@obj12"></A></P><P>Parent objects: <CODE>Number</CODE>.</P><P>The <CODE>Int</CODE> object represents integer values. </P><H3 CLASS="subsection"><A NAME="htoc332">12.1.5</A>  Float</H3><P><A NAME="obj:Float"></A><A NAME="object:Float"></A><A NAME="@default348"></A><A NAME="@obj13"></A></P><P>Parent objects: <CODE>Number</CODE>.</P><P>The <CODE>Float</CODE> object represents floating-point numbers. </P><H3 CLASS="subsection"><A NAME="htoc333">12.1.6</A>  Sequence</H3><P><A NAME="obj:Sequence"></A><A NAME="object:Sequence"></A><A NAME="@default349"></A><A NAME="@obj14"></A></P><P>Parent objects: <CODE>Object</CODE>.</P><P>The <CODE>Sequence</CODE> object represents a generic object containing sequential elements. It provides the following methods.</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>$(s.length)</CODE>: the number of elements in the sequence. </LI><LI CLASS="li-itemize"><CODE>$(s.map <fun>)</CODE>: maps a function over the fields in the sequence. The function should take one argument. The result is a new sequence constructed from the values returned by the function. </LI><LI CLASS="li-itemize"><CODE>s.foreach</CODE>: the <CODE>foreach</CODE> form is equivalent to <CODE>map</CODE>, but with altered syntax.<PRE CLASS="verbatim"> s.foreach(<var>) <body> </PRE><P>For example, the following function prints all the elements of the sequence.</P><PRE CLASS="verbatim"> PrintSequence(s) = s.foreach(x) println(Elem = $(x)) </PRE><P>The <CODE>export</CODE> form is valid in a <CODE>foreach</CODE> body. The following function counts the number of zeros in the sequence.</P><PRE CLASS="verbatim"> Zeros(s) = count = $(int 0) s.foreach(v) if $(equal $(v), 0) count = $(add $(count), 1) export export return $(count) </PRE></LI><LI CLASS="li-itemize"><CODE>$(s.forall <fun>)</CODE>: tests whether each element of the sequence satifies a predicate. </LI><LI CLASS="li-itemize"><CODE>$(s.exists <fun>)</CODE>: tests whether the sequence contains an element that satisfies a predicate. </LI><LI CLASS="li-itemize"><CODE>$(s.sort <fun>)</CODE>: sorts a sequence. The <CODE><fun></CODE> is a comparison function. It takes two elements <CODE>(x, y)</CODE> of the sequence, compares them, and returns a negative number if <I>x</I> < <I>y</I>, a positive number if <I>x</I> > <I>y</I>, and zero if the two elements are equal.<PRE CLASS="verbatim"> osh> items = $(int 0 3 -2) osh> items.forall(x => $(gt $x, 0)) - : bool = false osh> items.exists(x => $(gt $x, 0)) - : bool = true osh> items.sort($(compare)) - : Array = -2 3 0 </PRE></LI></UL><H3 CLASS="subsection"><A NAME="htoc334">12.1.7</A>  Array</H3><P><A NAME="obj:Array"></A><A NAME="object:Array"></A><A NAME="@default350"></A><A NAME="@obj15"></A></P><P>Parent objects: <CODE>Sequence</CODE>.</P><P>The <CODE>Array</CODE> is a random-access sequence. It provides the following additional methods.</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>$(s.nth <i>)</CODE>: returns element <CODE>i</CODE> of the sequence. </LI><LI CLASS="li-itemize"><CODE>$(s.rev <i>)</CODE>: returns the reversed sequence. </LI></UL><H3 CLASS="subsection"><A NAME="htoc335">12.1.8</A>  String</H3><P><A NAME="obj:String"></A><A NAME="object:String"></A><A NAME="@default351"></A><A NAME="@obj16"></A></P><P>Parent objects: <CODE>Array</CODE>. </P><H3 CLASS="subsection"><A NAME="htoc336">12.1.9</A>  Fun</H3><P><A NAME="obj:Fun"></A><A NAME="object:Fun"></A><A NAME="@default352"></A><A NAME="@obj17"></A></P><P>Parent objects: <CODE>Object</CODE>.</P><P>The <CODE>Fun</CODE> object provides the following methods. </P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>$(f.arity)</CODE>: the arity if the function. </LI></UL><H3 CLASS="subsection"><A NAME="htoc337">12.1.10</A>  Rule</H3><P><A NAME="obj:Rule"></A><A NAME="object:Rule"></A><A NAME="@default353"></A><A NAME="@obj18"></A></P><P>Parent objects: <CODE>Object</CODE>.</P><P>The <CODE>Rule</CODE> object represents a build rule. It does not currently have any methods. </P><H3 CLASS="subsection"><A NAME="htoc338">12.1.11</A>  Target</H3><P><A NAME="obj:Target"></A><A NAME="object:Target"></A><A NAME="@default354"></A><A NAME="@obj19"></A></P><P>Parent object: <CODE>Object</CODE>.</P><P>The <CODE>Target</CODE> object contains information collected for a specific target file.</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>target</CODE>: the target file. </LI><LI CLASS="li-itemize"><CODE>effects</CODE>: the files that may be modified by a side-effect when this target is built. </LI><LI CLASS="li-itemize"><CODE>scanner_deps</CODE>: static dependencies that must be built before this target can be scanned. </LI><LI CLASS="li-itemize"><CODE>static-deps</CODE>: statically-defined build dependencies of this target. </LI><LI CLASS="li-itemize"><CODE>build-deps</CODE>: all the build dependencies for the target, including static and scanned dependencies. </LI><LI CLASS="li-itemize"><CODE>build-values</CODE>: all the value dependencies associated with the build. </LI><LI CLASS="li-itemize"><CODE>build-commands</CODE>: the commands to build the target. </LI><LI CLASS="li-itemize"><CODE>output-file</CODE>: if output was diverted to a file, with one of the <CODE>--output-*</CODE> options <A HREF="omake-options.html#chapter:options">A</A>, this field names that file. Otherwise it is <CODE>false</CODE>. </LI></UL><P>The object supports the following methods.</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>find(file)</CODE>: returns a Target object for the given file. Raises a <CODE>RuntimeException</CODE> if the specified target is not part of the project. </LI><LI CLASS="li-itemize"><CODE>find-optional(file)</CODE>: returns a <CODE>Target</CODE> object for the given file, or <CODE>false</CODE> if the file is not part of the project. </LI></UL><P>NOTE: the information for a target is constructed dynamically, so it is possible that the <CODE>Target</CODE> object for a node will contain different values in different contexts. The easiest way to make sure that the <CODE>Target</CODE> information is complete is to compute it within a rule body, where the rule depends on the target file, or the dependencies of the target file. </P><H3 CLASS="subsection"><A NAME="htoc339">12.1.12</A>  Node</H3><P><A NAME="obj:Node"></A><A NAME="object:Node"></A><A NAME="@default355"></A><A NAME="@obj20"></A></P><P>Parent objects: <CODE>Object</CODE>.</P><P>The <CODE>Node</CODE> object is the parent object for files and directories. It supports the following operations. </P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>$(node.stat)</CODE>: returns a <CODE>stat</CODE> object for the file. If the file is a symbolic link, the <CODE>stat</CODE> information is for the destination of the link, not the link itself.</LI><LI CLASS="li-itemize"><CODE>$(node.lstat)</CODE>: returns a <CODE>stat</CODE> object for the file or symbolic link. </LI><LI CLASS="li-itemize"><CODE>$(node.unlink)</CODE>: removes the file. </LI><LI CLASS="li-itemize"><CODE>$(node.rename <file>)</CODE>: renames the file. </LI><LI CLASS="li-itemize"><CODE>$(node.link <file>)</CODE>: creates a hard link <CODE><dst></CODE> to this file. </LI><LI CLASS="li-itemize"><CODE>$(node.symlink <file>)</CODE>: create a symbolic link <CODE><dst></CODE> to this file. </LI><LI CLASS="li-itemize"><CODE>$(node.chmod <perm>)</CODE>: change the permission of this file. </LI><LI CLASS="li-itemize"><CODE>$(node.chown <uid>, <gid>)</CODE>: change the owner and group id of this file. </LI></UL><H3 CLASS="subsection"><A NAME="htoc340">12.1.13</A>  File</H3><P><A NAME="obj:File"></A><A NAME="object:File"></A><A NAME="@default356"></A><A NAME="@obj21"></A></P><P>Parent objects: <CODE>Node</CODE>.</P><P>The file object represents the name of a file. </P><H3 CLASS="subsection"><A NAME="htoc341">12.1.14</A>  Dir</H3><P><A NAME="obj:Dir"></A><A NAME="object:Dir"></A><A NAME="@default357"></A><A NAME="@obj22"></A></P><P>Parent objects: <CODE>Node</CODE>.</P><P>The <CODE>Dir</CODE> object represents the name of a directory. </P><H3 CLASS="subsection"><A NAME="htoc342">12.1.15</A>  Channel</H3><P><A NAME="obj:Channel"></A><A NAME="object:Channel"></A><A NAME="@default358"></A><A NAME="@obj23"></A></P><P>Parent objects: <CODE>Object</CODE>.</P><P>A <CODE>Channel</CODE> is a generic IO channel. It provides the following methods. </P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>$(o.close)</CODE>: close the channel. </LI><LI CLASS="li-itemize"><CODE>$(o.name)</CODE>: returns the file name associated with the channel. </LI></UL><H3 CLASS="subsection"><A NAME="htoc343">12.1.16</A>  InChannel</H3><P><A NAME="obj:InChannel"></A><A NAME="object:InChannel"></A><A NAME="@default359"></A><A NAME="@obj24"></A></P><P>Parent objects: <CODE>Channel</CODE>.</P><P>A <CODE>InChannel</CODE> is an input channel. The variable <CODE>stdin</CODE> is the standard input channel.</P><P>It provides the following methods. </P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>$(InChannel.fopen <file>)</CODE>: open a new input channel. </LI><LI CLASS="li-itemize"><CODE>$(InChannel.of-string <string>)</CODE>: open a new input channel, using a string as input. </LI><LI CLASS="li-itemize"><CODE>$(o.read <number>)</CODE>: reads the given number of characters from the channel </LI><LI CLASS="li-itemize"><CODE>$(o.readln)</CODE>: reads a line from the channel </LI></UL><H3 CLASS="subsection"><A NAME="htoc344">12.1.17</A>  OutChannel</H3><P><A NAME="obj:OutChannel"></A><A NAME="object:OutChannel"></A><A NAME="@default360"></A><A NAME="@obj25"></A></P><P>Parent object: <CODE>Channel</CODE>.</P><P>A <CODE>OutChannel</CODE> is an output channel. The variables <CODE>stdout</CODE> and <CODE>stderr</CODE> are the standard output and error channels.</P><P>It provides the following methods. </P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>$(OutChannel.fopen <file>)</CODE>: open a new output channel. </LI><LI CLASS="li-itemize"><CODE>$(OutChannel.string)</CODE>: open a new output channel, writing to a string. </LI><LI CLASS="li-itemize"><CODE>$(OutChannel.to-string)</CODE>: get the current string of output, for an output channel created as <CODE>OutChannel.open-string</CODE>. </LI><LI CLASS="li-itemize"><CODE>$(OutChannel.append <file>)</CODE>: opens a new output channel, appending to the file. </LI><LI CLASS="li-itemize"><CODE>$(c.flush)</CODE>: flush the output channel. </LI><LI CLASS="li-itemize"><CODE>$(c.print <string>)</CODE>: print a string to the channel. </LI><LI CLASS="li-itemize"><CODE>$(c.println <string>)</CODE>: print a string to the channel, followed by a line terminator. </LI></UL><H3 CLASS="subsection"><A NAME="htoc345">12.1.18</A>  Location</H3><P><A NAME="obj:Location"></A><A NAME="object:Location"></A><A NAME="@default361"></A><A NAME="@obj26"></A></P><P>Parent objects: <CODE>Location</CODE>.</P><P>The <CODE>Location</CODE> object represents a location in a file. </P><H3 CLASS="subsection"><A NAME="htoc346">12.1.19</A>  Exception</H3><P><A NAME="obj:Exception"></A><A NAME="object:Exception"></A><A NAME="@default362"></A><A NAME="@obj27"></A></P><P>Parent objects: <CODE>Object</CODE>.</P><P>The <CODE>Exception</CODE> object is used as the base object for exceptions. It has no fields. </P><H3 CLASS="subsection"><A NAME="htoc347">12.1.20</A>  RuntimeException</H3><P><A NAME="obj:RuntimeException"></A><A NAME="object:RuntimeException"></A><A NAME="@default363"></A><A NAME="@obj28"></A></P><P>Parent objects: <CODE>Exception</CODE>.</P><P>The <CODE>RuntimeException</CODE> object represents an exception from the runtime system. It has the following fields.</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>position</CODE>: a string representing the location where the exception was raised. </LI><LI CLASS="li-itemize"><CODE>message</CODE>: a string containing the exception message. </LI></UL><H3 CLASS="subsection"><A NAME="htoc348">12.1.21</A>  UnbuildableException</H3><P><A NAME="obj:UnbuildableException"></A><A NAME="object:UnbuildableException"></A><A NAME="@default364"></A><A NAME="@obj29"></A></P><P>Parent objects: <CODE>Exception</CODE>.</P><P>The <CODE>UnbuildableException</CODE> object should be used to signal that a target is not buildable. It will be caught by functions such as <CODE><A HREF="omake-system.html#fun:target-exists">target-exists</A></CODE>. This exception has the following fields:</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>target</CODE>: indicates which target is not buildable. </LI><LI CLASS="li-itemize"><CODE>message</CODE>: a string containing the exception message. </LI></UL><H3 CLASS="subsection"><A NAME="htoc349">12.1.22</A>  Shell</H3><P><A NAME="obj:Shell"></A><A NAME="object:Shell"></A><A NAME="@default365"></A><A NAME="@obj30"></A></P><P>Parent objects: <CODE>Object</CODE>.</P><P>The <CODE>Shell</CODE> object contains the collection of builtin functions available as shell commands.</P><P>You can define aliases by extending this object with additional methods. All methods in this class are called with one argument: a single array containing an argument list.</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>echo</CODE><P>The <CODE>echo</CODE> function prints its arguments to the standard output channel. </P></LI><LI CLASS="li-itemize"><CODE>jobs</CODE><P>The <CODE>jobs</CODE> method prints the status of currently running commands. </P></LI><LI CLASS="li-itemize"><CODE>cd</CODE><P>The <CODE>cd</CODE> function changes the current directory. Note that the current directory follows the usual scoping rules. For example, the following program lists the files in the <CODE>foo</CODE> directory, but the current directory is not changed.</P><PRE CLASS="verbatim"> section echo Listing files in the foo directory... cd foo ls echo Listing files in the current directory... ls </PRE></LI><LI CLASS="li-itemize"><CODE>bg</CODE><P>The <CODE>bg</CODE> method places a job in the background. The job is resumed if it has been suspended. </P></LI><LI CLASS="li-itemize"><CODE>fg</CODE><P>The <CODE>fg</CODE> method brings a job to the foreground. The job is resumed if it has been suspended. </P></LI><LI CLASS="li-itemize"><CODE>stop</CODE><P>The <CODE>stop</CODE> method suspends a running job. </P></LI><LI CLASS="li-itemize"><CODE>wait</CODE><P>The <CODE>wait</CODE> function waits for a running job to terminate. It is not possible to wait for a suspended job.</P><P>The job is not brought to the foreground. If the <CODE>wait</CODE> is interrupted, the job continues to run in the background. </P></LI><LI CLASS="li-itemize"><CODE>kill</CODE><P>The <CODE>kill</CODE> function signal a job.</P><P><CODE>kill [signal] <pid...></CODE>.</P><P>The signals are either numeric, or symbolic. The symbolic signals are named as follows.</P><P>ABRT, ALRM, HUP, ILL, KILL, QUIT, SEGV, TERM, USR1, USR2, CHLD, STOP, TSTP, TTIN, TTOU, VTALRM, PROF. </P></LI><LI CLASS="li-itemize"><CODE>exit</CODE><P>The <CODE>exit</CODE> function terminates the current session. </P></LI><LI CLASS="li-itemize"><CODE>which</CODE>, <CODE>where</CODE><P>See the documentation for the corresponding functions. </P></LI><LI CLASS="li-itemize"><CODE>rehash</CODE><P>Reset the search path. </P></LI><LI CLASS="li-itemize"><CODE>ln-or-cp</CODE> <EM>src</EM> dst<P>Links or copies <EM>src to </EM>dst, overwriting <EM>dst. Namely, <CODE>ln-or-cp</CODE> would first delete the </EM>dst file (unless it is a directory), if it exists. Next it would try to create a symbolic link <EM>dst poiting to </EM>src (it will make all the necessary adjustmnents of relative paths). If symbolic link can not be created (<EM>e.g.</EM> the OS or the filesystem does not support symbolic links), it will try to create a hard link. If that fails too, it will try to forcibly copy <EM>src to </EM>dst. </P></LI><LI CLASS="li-itemize"><CODE>history</CODE><P>Print the current command-line history. </P></LI><LI CLASS="li-itemize"><CODE>digest</CODE><P>Print the digests of the given files. </P></LI><LI CLASS="li-itemize">Win32 functions.<P>Win32 doesn't provide very many programs for scripting, except for the functions that are builtin to the DOS <CODE>cmd.exe</CODE>. The following functions are defined on Win32 and only on Win32. On other systems, it is expected that these programs already exist.</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>grep</CODE><PRE CLASS="verbatim"> grep [-q] [-n] pattern files... </PRE><P>The <CODE>grep</CODE> function calls the <TT>omake</TT> <CODE>grep</CODE> function. </P></LI></UL></LI><LI CLASS="li-itemize">Internal versions of standard system commands.<P>By default, <TT>omake</TT> uses internal versions of the following commands: <CODE>cp</CODE>, <CODE>mv</CODE>, <CODE>cat</CODE>, <CODE>rm</CODE>, <CODE>mkdir</CODE>, <CODE>chmod</CODE>, <CODE>test</CODE>, <CODE>find</CODE>. If you really want to use the standard system versions of these commands, set the <CODE>USE_SYSTEM_COMMANDS</CODE> as one of the first definitions in your <CODE>OMakeroot</CODE> file.</P><UL CLASS="itemize"><LI CLASS="li-itemize"> <CODE>pwd</CODE><PRE CLASS="verbatim"> pwd </PRE><P>The <CODE>pwd</CODE> alias would print the absolute path to current directory. </P></LI><LI CLASS="li-itemize"><CODE>mkdir</CODE><PRE CLASS="verbatim"> mkdir [-m <mode>] [-p] files </PRE><P>The <CODE>mkdir</CODE> function is used to create directories. The -verb+-m+ option can be used to specify the permission mode of the created directory. If the <CODE>-p</CODE> option is specified, the full path is created. </P></LI><LI CLASS="li-itemize"><CODE>cp</CODE> </LI><LI CLASS="li-itemize"><CODE>mv</CODE><PRE CLASS="verbatim"> cp [-f] [-i] [-v] src dst cp [-f] [-i] [-v] files dst mv [-f] [-i] [-v] src dst mv [-f] [-i] [-v] files dst </PRE><P>The <CODE>cp</CODE> function copies a <CODE>src</CODE> file to a <CODE>dst</CODE> file, overwriting it if it already exists. If more than one source file is specified, the final file must be a directory, and the source files are copied into the directory.</P><DL CLASS="description"><DT CLASS="dt-description"> <B>-f</B></DT><DD CLASS="dd-description"> Copy files forcibly, do not prompt. </DD><DT CLASS="dt-description"><B>-i</B></DT><DD CLASS="dd-description"> Prompt before removing destination files. </DD><DT CLASS="dt-description"><B>-v</B></DT><DD CLASS="dd-description"> Explain what is happening. </DD></DL></LI><LI CLASS="li-itemize"><CODE>rm</CODE><PRE CLASS="verbatim"> rm [-f] [-i] [-v] [-r] files rmdir [-f] [-i] [-v] [-r] dirs </PRE><P>The <CODE>rm</CODE> function removes a set of files. No warnings are issued if the files do not exist, or if they cannot be removed.</P><P>Options: </P><DL CLASS="description"><DT CLASS="dt-description"> <B>-f</B></DT><DD CLASS="dd-description"> Forcibly remove files, do not prompt. </DD><DT CLASS="dt-description"><B>-i</B></DT><DD CLASS="dd-description"> Prompt before removal. </DD><DT CLASS="dt-description"><B>-v</B></DT><DD CLASS="dd-description"> Explain what is happening. </DD><DT CLASS="dt-description"><B>-r</B></DT><DD CLASS="dd-description"> Remove contents of directories recursively. </DD></DL></LI><LI CLASS="li-itemize"><CODE>chmod</CODE><PRE CLASS="verbatim"> chmod [-r] [-v] [-f] mode files </PRE><P>The <CODE>chmod</CODE> function changes the permissions on a set of files or directories. This function does nothing on Win32. The <CODE>mode</CODE> may be specified as an octal number, or in symbolic form <CODE>[ugoa]*[</CODE>-=][rwxXstugo]+. See the man page for <CODE>chmod</CODE> for details.</P><P>Options: </P><DL CLASS="description"><DT CLASS="dt-description"> <B>-r</B></DT><DD CLASS="dd-description"> Change permissions of all files in a directory recursively. </DD><DT CLASS="dt-description"><B>-v</B></DT><DD CLASS="dd-description"> Explain what is happening. </DD><DT CLASS="dt-description"><B>-f</B></DT><DD CLASS="dd-description"> Continue on errors. </DD></DL></LI><LI CLASS="li-itemize"><CODE>cat</CODE><PRE CLASS="verbatim"> cat files... </PRE><P>The <CODE>cat</CODE> function prints the contents of the files to stdout </P></LI><LI CLASS="li-itemize"><CODE>test</CODE><P><CODE>test</CODE> <EM>expression</EM><BR> <CODE>[</CODE> <EM>expression</EM> +]+<BR> <CODE>[ --help</CODE><BR> <CODE>[ --version</CODE><BR> See the documentation for the <A HREF="omake-system.html#fun:test"><CODE>test</CODE> function</A>.</P></LI><LI CLASS="li-itemize"><CODE>find</CODE><P><CODE>find</CODE> <EM>expression</EM></P><P>See the documentation for the <A HREF="omake-system.html#fun:find"><CODE>find</CODE> function</A>.</P></LI></UL></LI></UL> <TABLE CELLSPACING=6 CELLPADDING=0><TR><TD ALIGN=left NOWRAP>Jump to:</TD><TD VALIGN=top ALIGN=center NOWRAP>  </TD><TD ALIGN=left NOWRAP><A HREF="http://omake.metaprl.org/">OMake Home</A> • <A HREF="omake.html">Guide Home</A> • <A HREF="omake-doc.html">Guide (single-page)</A> • <A HREF="omake-toc.html">Contents (short)</A> • <A HREF="omake-contents.html">Contents (long)</A></TD></TR> <TR><TD ALIGN=left NOWRAP>Index:</TD><TD VALIGN=top ALIGN=center NOWRAP>  </TD><TD ALIGN=left NOWRAP><A HREF="omake-all-index.html">All</A> • <A HREF="omake-var-index.html">Variables</A> • <A HREF="omake-fun-index.html">Functions</A> • <A HREF="omake-obj-index.html">Objects</A> • <A HREF="omake-target-index.html">Targets</A> • <A HREF="omake-option-index.html">Options</A></TD></TR> </TABLE> </BODY> </HTML>