Blame | Last modification | View Log | RSS feed
/*Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.SET environment variablesFirst optional parameter:; parameters are considered parts of a path variable, semicolons areappended to each element if not already present-D parameters are properties for Java or Makefile etc., -D will beprepended and the parameters will be separated by a space=D the same as above but equal sign is not required, parameters should be comma separated in the environment variable- parameters should be separated by the next parameterOther values mean that the first parameter is missing and the environmentvariable will be set to the space separated parametersSecond parameter: name of the environment variableNext parameters: values; implies that the equal sign is considered a part of the parameter and isnot interpreted-D requires parameters in the form name=value. If the equal sign is not found,the parameters are changed to name=expanded_nameOther options have optional equal sign. If it is found, only the part afterthe equal sign will be oprionally expanded.If the parameter is the minus sign, the next parameter will not be expanded.If the parameter is a single dot, it will be replaced with the value of theenvironment variable as it existed before envset was invoked.For other parameters the batch looks for the environment variable with thesame name (in uppercase). If it is found, it forms the expanded_name. Ifthe environment variable with such a name does not exist, the expanded_namewill hold the parameter name without case conversion.*/parse arg mode envar argsequal = 0sep = ' '/* Parse command line parameters */selectwhen mode='-' then dosep = envarparse var args envar argsendwhen mode=';' then dosep = ''equal = -1endwhen mode='-D' then equal = 1when mode='=D' then mode = '-D'when mode=',' then sep = ','otherwiseargs = envar argsenvar = modemode = ''endenv = 'OS2ENVIRONMENT'envar = translate(envar)orig = value(envar,,env)newval = ''expand = 1/* for each parameter... */do i = 1 to words(args)if expand > 0 & word(args, i) = '-' then expand = 0else call addval word(args, i)end/* Optionally enclose path variable by quotes */if mode = ';' & pos(' ', newval) > 0 then newval = '"' || newval || '"'/* Set the new value, 'SET' cannot be used since it does not allow '=' */x = value(envar, newval, env)exit 0addval: procedure expose sep equal orig expand newval mode envparse arg varif var = '.' then expvar = origelse doif equal >= 0 then doparse var var name '=' valif val = '' then var = nameelse var = valendif expand = 0 then expvar = varelse expvar = value(translate(var),,env)if expvar = '' then expvar = varif equal >= 0 then doif val = '' then doparse var expvar key '=' valif val <> '' then name = keyelse doif equal > 0 then val = keyelse name = keyendendelse val = expvarif pos(' ', val) > 0 | pos('=', val) > 0 then val = '"' || val || '"'if val = '' then expvar = nameelse expvar = name || '=' || valendif mode = '-D' then expvar = '-D' || expvarif mode = ';' then doif right(expvar, 1) <> ';' then expvar = expvar || ';'endendif newval = '' then newval = expvarelse newval = newval || sep || expvarexpand = 1return