This file is indexed.

/usr/bin/sow is in ruby-hoe 2.9.4+dfsg1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/ruby

require 'optparse'
require 'rubygems'
require 'hoe'
require 'fileutils'
require 'erb'

XIF = 'FI' + 'X' # prevents extra hits on my TAG reporter

option = {
  :style  => "default",
  :subdir => nil,
}

def check_subdir option
  if option[:subdir] then
    warn "ERROR: you can't specify multiple subdirs"
    abort opts.to_s
  end
end

opts = OptionParser.new do |opts|
  opts.banner = "Usage: sow [options] project_name"

  opts.separator "Standard options:"

  opts.on("-t", "--trunk", "Add project to subdir under 'trunk'.") do
    check_subdir option
    option[:subdir] = "trunk"
  end

  opts.on("-d", "--dev", "Add project to subdir under 'dev'.") do
    check_subdir option
    option[:subdir] = "dev"
  end

  opts.on("-s style", "--style style", String, "Use template <style>.") do |s|
    option[:style] = s
  end

  opts.on("-h", "--help", "Show this message.") do
    puts opts
    exit
  end
end

opts.parse!

include FileUtils::Verbose

# variables for erb:
template_dir  = File.expand_path("~/.hoe_template")
template_path = File.join template_dir, option[:style]
source_path   = File.join(File.dirname(File.dirname(__FILE__)), "share","ruby-hoe","template")
default_dir   = File.join template_dir, "default"

if File.directory? template_dir and not File.directory? default_dir then
  warn "Detected old #{template_dir}"
  warn "Moving to #{default_dir}"
  tmp = "#{template_dir}.#{$$}"
  File.rename template_dir, tmp
  FileUtils.mkdir template_dir
  File.rename tmp, default_dir
end

unless File.directory? template_path then
  warn "Creating missing #{option[:style]} template."
  FileUtils.mkdir_p File.dirname(template_path)
  FileUtils.cp_r source_path, template_path
  paths = (Dir["#{template_path}/**/*"] +
           Dir["#{template_path}/**/.*"]).select { |f| File.file? f }
  FileUtils.chmod 0644, paths
  FileUtils.chmod 0755, paths.grep(/bin\//)
end

project = ARGV.shift

abort opts.to_s unless project
abort "Project #{project} seems to exist" if test ?d, project

project, file_name, klass = Hoe.normalize_names project

FileUtils.cp_r template_path, project

Dir.chdir project do
  dirs = Dir["**/*"].select { |f| File.directory? f }.sort.reverse
  dirs.grep(/file_name$/).each do |file|
    FileUtils.mv file, file.sub(/file_name$/, file_name)
  end

  paths = (Dir["**/*"] + Dir["**/.*"]).select { |f| File.file? f }.sort
  paths.each do |path|
    file = File.read path

    warn "erb: #{path}"

    File.open path, "w" do |f|
      f.puts ERB.new(file).result(binding)
    end
  end

  paths.grep(/file_name|\.erb$/).each do |file|
    new_file = file.sub(/file_name/, file_name).sub(/\.erb$/, '')
    FileUtils.mv file, new_file
  end
end

if option[:subdir] then
  temp_dir = "#{project}.#{$$}"
  FileUtils.mv project, temp_dir
  FileUtils.mkdir project
  FileUtils.mv temp_dir, "#{project}/#{option[:subdir]}"
end

puts
puts "... done, now go fix all occurrences of '#{XIF}':"
if Hoe::WINDOZE then
  puts `findstr /N /S /C:#{XIF} #{project}\\*`
else
  puts `find #{project} -type f | xargs grep -n #{XIF}`.gsub(/\A|\n/, "\n  ")
end