Esempio n. 1
0
        private static EvaluationResult ExpandEnvironmentVariablesInString(Context context, ModuleLiteral env, EvaluationStackFrame args)
        {
            var unexpandedString = Args.AsString(args, 0);

            if (StringVariableExpander.TryExpandVariablesInString(unexpandedString, context.FrontEndHost.Engine, out string expandedString))
            {
                return(EvaluationResult.Create(expandedString));
            }

            // No expansion occurred
            return(EvaluationResult.Create(unexpandedString));
        }
Esempio n. 2
0
        /// <summary>
        /// Replaces the name of each environment variable embedded in the specified path with the string equivalent of the value of the variable.
        /// Replacement only occurs for environment variables that are set. Unset environment variables are left unexpanded.
        /// </summary>
        private static EvaluationResult ExpandEnvironmentVariablesInPath(Context context, ModuleLiteral env, EvaluationStackFrame args)
        {
            var path         = Args.AsPath(args, 0);
            var pathAsString = path.ToString(context.PathTable);

            if (StringVariableExpander.TryExpandVariablesInString(pathAsString, context.FrontEndHost.Engine, out string expandedPath))
            {
                // The resulting expanded path may not be a valid one. Apply the same validations as when creating an absolute path from a literal
                return(AmbientPath.CreateFromAbsolutePathString(context, expandedPath));
            }

            // No expansion occurred
            return(EvaluationResult.Create(path));
        }