Sha256: 12d4e994c516113ed8e48c32bc8255b3a833955143990838cdf659563dcbf380
Contents?: true
Size: 841 Bytes
Versions: 5
Compression:
Stored size: 841 Bytes
Contents
# -*- encoding: utf-8 -*- require 'cgi' require 'tempfile' require 'rbconfig' module Webgen::Tag # Executes the given command and returns the standard output. All special HTML characters are # escaped. class ExecuteCommand include Webgen::Tag::Base BIT_BUCKET = (Config::CONFIG['arch'].include?('mswin32') ? "nul" : "/dev/null") # Execute the command and return the standard output. def call(tag, body, context) command = param('tag.executecommand.command') output = `#{command} 2> #{BIT_BUCKET}` if ($? >> 8) != 0 raise "Command '#{command}' in <#{context.ref_node.absolute_lcn}> has return value != 0: #{output}" end output = CGI::escapeHTML(output) if param('tag.executecommand.escape_html') [output, param('tag.executecommand.process_output')] end end end
Version data entries
5 entries across 5 versions & 3 rubygems