Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: un.rb
#
[0] Fix | Delete
# = un.rb
[1] Fix | Delete
#
[2] Fix | Delete
# Copyright (c) 2003 WATANABE Hirofumi <eban@ruby-lang.org>
[3] Fix | Delete
#
[4] Fix | Delete
# This program is free software.
[5] Fix | Delete
# You can distribute/modify this program under the same terms of Ruby.
[6] Fix | Delete
#
[7] Fix | Delete
# == Utilities to replace common UNIX commands in Makefiles etc
[8] Fix | Delete
#
[9] Fix | Delete
# == SYNOPSIS
[10] Fix | Delete
#
[11] Fix | Delete
# ruby -run -e cp -- [OPTION] SOURCE DEST
[12] Fix | Delete
# ruby -run -e ln -- [OPTION] TARGET LINK_NAME
[13] Fix | Delete
# ruby -run -e mv -- [OPTION] SOURCE DEST
[14] Fix | Delete
# ruby -run -e rm -- [OPTION] FILE
[15] Fix | Delete
# ruby -run -e mkdir -- [OPTION] DIRS
[16] Fix | Delete
# ruby -run -e rmdir -- [OPTION] DIRS
[17] Fix | Delete
# ruby -run -e install -- [OPTION] SOURCE DEST
[18] Fix | Delete
# ruby -run -e chmod -- [OPTION] OCTAL-MODE FILE
[19] Fix | Delete
# ruby -run -e touch -- [OPTION] FILE
[20] Fix | Delete
# ruby -run -e help [COMMAND]
[21] Fix | Delete
[22] Fix | Delete
require "fileutils"
[23] Fix | Delete
require "optparse"
[24] Fix | Delete
[25] Fix | Delete
module FileUtils
[26] Fix | Delete
# @fileutils_label = ""
[27] Fix | Delete
@fileutils_output = $stdout
[28] Fix | Delete
end
[29] Fix | Delete
[30] Fix | Delete
def setup(options = "")
[31] Fix | Delete
ARGV.map! do |x|
[32] Fix | Delete
case x
[33] Fix | Delete
when /^-/
[34] Fix | Delete
x.delete "^-#{options}v"
[35] Fix | Delete
when /[*?\[{]/
[36] Fix | Delete
Dir[x]
[37] Fix | Delete
else
[38] Fix | Delete
x
[39] Fix | Delete
end
[40] Fix | Delete
end
[41] Fix | Delete
ARGV.flatten!
[42] Fix | Delete
ARGV.delete_if{|x| x == "-"}
[43] Fix | Delete
opt_hash = {}
[44] Fix | Delete
OptionParser.new do |o|
[45] Fix | Delete
options.scan(/.:?/) do |s|
[46] Fix | Delete
o.on("-" + s.tr(":", " ")) do |val|
[47] Fix | Delete
opt_hash[s.delete(":").intern] = val
[48] Fix | Delete
end
[49] Fix | Delete
end
[50] Fix | Delete
o.on("-v") do opt_hash[:verbose] = true end
[51] Fix | Delete
o.parse!
[52] Fix | Delete
end
[53] Fix | Delete
yield ARGV, opt_hash
[54] Fix | Delete
end
[55] Fix | Delete
[56] Fix | Delete
##
[57] Fix | Delete
# Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
[58] Fix | Delete
#
[59] Fix | Delete
# ruby -run -e cp -- [OPTION] SOURCE DEST
[60] Fix | Delete
#
[61] Fix | Delete
# -p preserve file attributes if possible
[62] Fix | Delete
# -r copy recursively
[63] Fix | Delete
# -v verbose
[64] Fix | Delete
#
[65] Fix | Delete
[66] Fix | Delete
def cp
[67] Fix | Delete
setup("pr") do |argv, options|
[68] Fix | Delete
cmd = "cp"
[69] Fix | Delete
cmd += "_r" if options.delete :r
[70] Fix | Delete
options[:preserve] = true if options.delete :p
[71] Fix | Delete
dest = argv.pop
[72] Fix | Delete
argv = argv[0] if argv.size == 1
[73] Fix | Delete
FileUtils.send cmd, argv, dest, options
[74] Fix | Delete
end
[75] Fix | Delete
end
[76] Fix | Delete
[77] Fix | Delete
##
[78] Fix | Delete
# Create a link to the specified TARGET with LINK_NAME.
[79] Fix | Delete
#
[80] Fix | Delete
# ruby -run -e ln -- [OPTION] TARGET LINK_NAME
[81] Fix | Delete
#
[82] Fix | Delete
# -s make symbolic links instead of hard links
[83] Fix | Delete
# -f remove existing destination files
[84] Fix | Delete
# -v verbose
[85] Fix | Delete
#
[86] Fix | Delete
[87] Fix | Delete
def ln
[88] Fix | Delete
setup("sf") do |argv, options|
[89] Fix | Delete
cmd = "ln"
[90] Fix | Delete
cmd += "_s" if options.delete :s
[91] Fix | Delete
options[:force] = true if options.delete :f
[92] Fix | Delete
dest = argv.pop
[93] Fix | Delete
argv = argv[0] if argv.size == 1
[94] Fix | Delete
FileUtils.send cmd, argv, dest, options
[95] Fix | Delete
end
[96] Fix | Delete
end
[97] Fix | Delete
[98] Fix | Delete
##
[99] Fix | Delete
# Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
[100] Fix | Delete
#
[101] Fix | Delete
# ruby -run -e mv -- [OPTION] SOURCE DEST
[102] Fix | Delete
#
[103] Fix | Delete
# -v verbose
[104] Fix | Delete
#
[105] Fix | Delete
[106] Fix | Delete
def mv
[107] Fix | Delete
setup do |argv, options|
[108] Fix | Delete
dest = argv.pop
[109] Fix | Delete
argv = argv[0] if argv.size == 1
[110] Fix | Delete
FileUtils.mv argv, dest, options
[111] Fix | Delete
end
[112] Fix | Delete
end
[113] Fix | Delete
[114] Fix | Delete
##
[115] Fix | Delete
# Remove the FILE
[116] Fix | Delete
#
[117] Fix | Delete
# ruby -run -e rm -- [OPTION] FILE
[118] Fix | Delete
#
[119] Fix | Delete
# -f ignore nonexistent files
[120] Fix | Delete
# -r remove the contents of directories recursively
[121] Fix | Delete
# -v verbose
[122] Fix | Delete
#
[123] Fix | Delete
[124] Fix | Delete
def rm
[125] Fix | Delete
setup("fr") do |argv, options|
[126] Fix | Delete
cmd = "rm"
[127] Fix | Delete
cmd += "_r" if options.delete :r
[128] Fix | Delete
options[:force] = true if options.delete :f
[129] Fix | Delete
FileUtils.send cmd, argv, options
[130] Fix | Delete
end
[131] Fix | Delete
end
[132] Fix | Delete
[133] Fix | Delete
##
[134] Fix | Delete
# Create the DIR, if they do not already exist.
[135] Fix | Delete
#
[136] Fix | Delete
# ruby -run -e mkdir -- [OPTION] DIR
[137] Fix | Delete
#
[138] Fix | Delete
# -p no error if existing, make parent directories as needed
[139] Fix | Delete
# -v verbose
[140] Fix | Delete
#
[141] Fix | Delete
[142] Fix | Delete
def mkdir
[143] Fix | Delete
setup("p") do |argv, options|
[144] Fix | Delete
cmd = "mkdir"
[145] Fix | Delete
cmd += "_p" if options.delete :p
[146] Fix | Delete
FileUtils.send cmd, argv, options
[147] Fix | Delete
end
[148] Fix | Delete
end
[149] Fix | Delete
[150] Fix | Delete
##
[151] Fix | Delete
# Remove the DIR.
[152] Fix | Delete
#
[153] Fix | Delete
# ruby -run -e rmdir -- [OPTION] DIR
[154] Fix | Delete
#
[155] Fix | Delete
# -v verbose
[156] Fix | Delete
#
[157] Fix | Delete
[158] Fix | Delete
def rmdir
[159] Fix | Delete
setup do |argv, options|
[160] Fix | Delete
FileUtils.rmdir argv, options
[161] Fix | Delete
end
[162] Fix | Delete
end
[163] Fix | Delete
[164] Fix | Delete
##
[165] Fix | Delete
# Copy SOURCE to DEST.
[166] Fix | Delete
#
[167] Fix | Delete
# ruby -run -e install -- [OPTION] SOURCE DEST
[168] Fix | Delete
#
[169] Fix | Delete
# -p apply access/modification times of SOURCE files to
[170] Fix | Delete
# corresponding destination files
[171] Fix | Delete
# -m set permission mode (as in chmod), instead of 0755
[172] Fix | Delete
# -v verbose
[173] Fix | Delete
#
[174] Fix | Delete
[175] Fix | Delete
def install
[176] Fix | Delete
setup("pm:") do |argv, options|
[177] Fix | Delete
options[:mode] = (mode = options.delete :m) ? mode.oct : 0755
[178] Fix | Delete
options[:preserve] = true if options.delete :p
[179] Fix | Delete
dest = argv.pop
[180] Fix | Delete
argv = argv[0] if argv.size == 1
[181] Fix | Delete
FileUtils.install argv, dest, options
[182] Fix | Delete
end
[183] Fix | Delete
end
[184] Fix | Delete
[185] Fix | Delete
##
[186] Fix | Delete
# Change the mode of each FILE to OCTAL-MODE.
[187] Fix | Delete
#
[188] Fix | Delete
# ruby -run -e chmod -- [OPTION] OCTAL-MODE FILE
[189] Fix | Delete
#
[190] Fix | Delete
# -v verbose
[191] Fix | Delete
#
[192] Fix | Delete
[193] Fix | Delete
def chmod
[194] Fix | Delete
setup do |argv, options|
[195] Fix | Delete
mode = argv.shift.oct
[196] Fix | Delete
FileUtils.chmod mode, argv, options
[197] Fix | Delete
end
[198] Fix | Delete
end
[199] Fix | Delete
[200] Fix | Delete
##
[201] Fix | Delete
# Update the access and modification times of each FILE to the current time.
[202] Fix | Delete
#
[203] Fix | Delete
# ruby -run -e touch -- [OPTION] FILE
[204] Fix | Delete
#
[205] Fix | Delete
# -v verbose
[206] Fix | Delete
#
[207] Fix | Delete
[208] Fix | Delete
def touch
[209] Fix | Delete
setup do |argv, options|
[210] Fix | Delete
FileUtils.touch argv, options
[211] Fix | Delete
end
[212] Fix | Delete
end
[213] Fix | Delete
[214] Fix | Delete
##
[215] Fix | Delete
# Display help message.
[216] Fix | Delete
#
[217] Fix | Delete
# ruby -run -e help [COMMAND]
[218] Fix | Delete
#
[219] Fix | Delete
[220] Fix | Delete
def help
[221] Fix | Delete
setup do |argv,|
[222] Fix | Delete
all = argv.empty?
[223] Fix | Delete
open(__FILE__) do |me|
[224] Fix | Delete
while me.gets("##\n")
[225] Fix | Delete
if help = me.gets("\n\n")
[226] Fix | Delete
if all or argv.delete help[/-e \w+/].sub(/-e /, "")
[227] Fix | Delete
print help.gsub(/^# ?/, "")
[228] Fix | Delete
end
[229] Fix | Delete
end
[230] Fix | Delete
end
[231] Fix | Delete
end
[232] Fix | Delete
end
[233] Fix | Delete
end
[234] Fix | Delete
[235] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function