Wiki source for CommandRequire


Show raw source

======Command require======

====Name====
**require** Checks the current shell for a specified minimum version


====Synopsis====
**require**
**require version**

Checks to see if the supplied version is less then or equal the the current version of xmlsh. (see [[CommandXversion xversion]]).
If the required version is greater then the current version then throws an exception equivalent to the [[CommandSet "throw on error" (-e)]] flag.
require can be trapped with [[ExceptionHandling try/catch ]] or with a conditional same as errors from [[CommandSet "throw on error" (-e)]].

If no arguments are given then require simply is an invalid command for versions prior to the implementation or require (1.0.1).

On failure (if caught or not) prints to standard error "requires version: <require test>"


====Examples====

Example require version 1.0.2. If version is less then 1.0.2 then an exception is thrown (which will abort a script).
%%
require 1.0.1
%%


Check for version 1.0.2 and print an error message but keep going
%%
require 1.0.2 || echo Required verison 1.0.2 ignored
%%

Trap a require or a script calling require with try/catch

%%
try {
require 99
} catch e {
echo Ignored failure of require 99
}
%%



----
[[Commands]]
[[CommandXVersion]]
[[CategoryCommands]]

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki