politics 1.0.82 → 1.0.88

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CYCLE_OF_HEALTH +9 -15
  3. data/Makefile +1 -1
  4. data/README.md +54 -46
  5. data/VERSION_NUMBER +1 -1
  6. data/bin/append_each +0 -0
  7. data/bin/google_speak +4 -3
  8. data/bin/lines +0 -0
  9. data/bin/nth_word +0 -0
  10. data/bin/prepend_each +0 -0
  11. data/bin/rgsub +0 -0
  12. data/documentation/append_each +3 -0
  13. data/documentation/left_right.exe +1 -1
  14. data/documentation/page +41 -41
  15. data/documentation/prepend_each +3 -0
  16. data/gem_data/VERSION_NUMBER +1 -1
  17. data/index.html +57 -51
  18. data/install.sh +5 -1
  19. data/non_compiled_programs/google_speak +4 -3
  20. data/src/_compilation/abs +38 -19
  21. data/src/_compilation/add +38 -19
  22. data/src/_compilation/append +38 -19
  23. data/src/_compilation/append_each +290 -0
  24. data/src/_compilation/args +38 -19
  25. data/src/_compilation/delete +38 -19
  26. data/src/_compilation/div +38 -19
  27. data/src/_compilation/exp +38 -19
  28. data/src/_compilation/floor +38 -19
  29. data/src/_compilation/gsub +38 -19
  30. data/src/_compilation/gsubip +38 -19
  31. data/src/_compilation/last_nth +38 -19
  32. data/src/_compilation/lines +38 -19
  33. data/src/_compilation/mul +38 -19
  34. data/src/_compilation/nth +38 -19
  35. data/src/_compilation/nth_word +38 -19
  36. data/src/_compilation/prepend +38 -19
  37. data/src/_compilation/prepend_each +290 -0
  38. data/src/_compilation/rip +38 -19
  39. data/src/_compilation/rnip +38 -19
  40. data/src/_compilation/selectlines +38 -19
  41. data/src/_compilation/sub +38 -19
  42. data/src/_compilation/swap +38 -19
  43. data/src/_compilation/trim +38 -19
  44. data/src/programs/append_each +0 -0
  45. data/src/programs/lines +0 -0
  46. data/src/programs/prepend_each +0 -0
  47. data/src/rgsub +0 -0
  48. data/src/rgsub.c +24 -25
  49. data/src/src/Makefile +1 -1
  50. data/src/src/cd +3 -0
  51. data/src/src/code +30 -9
  52. data/src/src/functions.cr +29 -16
  53. data/src/src/mk +6 -8
  54. data/src/src/rm +1 -0
  55. metadata +12 -3
  56. data/src/src/q.cr +0 -9
  57. /data/images/{12.png → 8.png} +0 -0
@@ -0,0 +1,290 @@
1
+ #!/usr/bin/crystal
2
+
3
+ CORE_UTIL_STRING = "core_utils"
4
+
5
+ def prepend_each(arg)
6
+ STDIN.each_line do |line|
7
+ puts arg + line
8
+ end
9
+ end
10
+
11
+ def append_each(arg)
12
+ STDIN.each_line do |line|
13
+ puts line + arg
14
+ end
15
+ end
16
+
17
+ def delete(arg)
18
+ `find -name #{arg}`.each_line do |i|
19
+ File.delete(i)
20
+ end
21
+ end
22
+
23
+ def nth_word(arg)
24
+ i = arg.to_u64 - 1
25
+ STDIN.each_line do |line|
26
+ puts line.split[i] rescue ""
27
+ end
28
+ end
29
+
30
+ def trim()
31
+ STDIN.each_line do |line|
32
+ puts line.strip
33
+ end
34
+ end
35
+
36
+ def lines(folder = ".")
37
+ if !STDIN.tty?
38
+ puts STDIN.gets_to_end.count('\n')
39
+ else
40
+ res = `find #{folder}`.count('\n') - 1
41
+ puts res
42
+ end
43
+ end
44
+
45
+ def args(arg1)
46
+ sections = Process.parse_arguments(arg1)
47
+ program, args = sections[0], sections[1..]
48
+
49
+ sections = Process.parse_arguments(arg1)
50
+
51
+ program = Process.find_executable(program)
52
+ if program.nil?
53
+ puts "Can't find program #{arg1}"
54
+ raise "Error"
55
+ end
56
+
57
+ lines = STDIN.gets_to_end.strip
58
+ lines = lines.split "\n"
59
+ times = (lines.size % 2000000 == 0) ? 2 : 1
60
+
61
+ times += lines.size // 2000000
62
+ n = 0
63
+ times.times do
64
+ prog_args = args
65
+
66
+ prog_args += lines[n..(n + 2000000 - 1)]; n += 2000000
67
+
68
+ if (p = Process.fork).nil?
69
+ Process.exec(
70
+ program,
71
+ prog_args
72
+ )
73
+ else
74
+ p.wait
75
+ end
76
+ end
77
+ end
78
+
79
+ def mul()
80
+ t = STDIN.read_line.to_f64
81
+
82
+ i = 0f64; STDIN.each_line do |line|
83
+ t *= line.to_f64
84
+ end
85
+
86
+ puts t
87
+ end
88
+
89
+ def add()
90
+ t = STDIN.read_line.to_f64
91
+
92
+ i = 0f64; STDIN.each_line do |line|
93
+ t += line.to_f64
94
+ end
95
+
96
+ puts t
97
+ end
98
+
99
+ def div()
100
+ t = STDIN.read_line.to_f64
101
+
102
+ i = 0f64; STDIN.each_line do |line|
103
+ t /= line.to_f64
104
+ end
105
+
106
+ puts t
107
+ end
108
+
109
+ def sub()
110
+ t = STDIN.read_line.to_f64
111
+
112
+ i = 0f64; STDIN.each_line do |line|
113
+ t -= line.to_f64
114
+ end
115
+
116
+ puts t
117
+ end
118
+
119
+ def floor()
120
+ puts STDIN.read_line.to_f64.to_i64
121
+ end
122
+
123
+ def abs()
124
+ STDIN.each_line do |l|
125
+ l = l.to_f64.abs
126
+ puts l
127
+ end
128
+ end
129
+
130
+ def exp()
131
+ t = STDIN.read_line.to_f64
132
+
133
+ STDIN.each_line do |line|
134
+ t **= line.to_f64
135
+ end
136
+
137
+ puts t
138
+ end
139
+
140
+ def nth(arg1)
141
+ end_ = arg1.to_u64
142
+ i = 0u64; STDIN.each_line do |line|
143
+ i += 1
144
+ if i == end_
145
+ puts line
146
+ break
147
+ end
148
+ end
149
+ end
150
+
151
+ def last_nth(arg1)
152
+ end_ = arg1.to_u64
153
+ i = 0u64
154
+ t = STDIN.gets_to_end
155
+ if t[-1] == '\n'
156
+ t = t[0..-2]
157
+ end
158
+
159
+ t.split("\n").reverse_each do |line|
160
+ i += 1
161
+ if i == end_
162
+ puts line
163
+ break
164
+ end
165
+ end
166
+ end
167
+
168
+ def gsubip(arg1, arg2, arg3)
169
+ regex = Regex.new(arg1)
170
+ text = File.read(arg3).gsub(/#{arg1}/m, arg2)
171
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(arg3).permissions) do |h|
172
+ h.print text
173
+ end
174
+ begin
175
+ File.rename t, arg3
176
+ rescue
177
+ File.delete t
178
+ end
179
+ end
180
+
181
+ def rip(arg1, arg2, arg3)
182
+ text = File.read(arg3).gsub(arg1, arg2)
183
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(arg3).permissions) do |h|
184
+ h.print text
185
+ end
186
+ begin
187
+ File.rename t, arg3
188
+ rescue
189
+ File.delete t
190
+ end
191
+ end
192
+
193
+ def gsub(arg1, arg2)
194
+ print STDIN.gets_to_end.gsub(/#{arg1}/m, arg2)
195
+ end
196
+
197
+ def rnip(arg1, arg2)
198
+ print STDIN.gets_to_end.gsub(arg1, arg2)
199
+ end
200
+
201
+ def selectlines()
202
+ STDIN.each_line do |line|
203
+ if line.strip.size > 0
204
+ puts line
205
+ end
206
+ end
207
+ end
208
+
209
+ def swap(file1, file2)
210
+ [file1, file2].each do |f|
211
+ File.exists?(f) || abort("No file named #{f.dump}")
212
+ end
213
+ t = File.tempname(CORE_UTIL_STRING, "_tmp")
214
+
215
+ File.rename file1, t
216
+ File.rename file2, file1
217
+ File.rename t, file2
218
+ end
219
+
220
+ def prepend(file)
221
+ file_data = File.read(file)
222
+ new_data = STDIN.gets_to_end
223
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(file).permissions) do |h|
224
+ h << new_data + file_data
225
+ end
226
+
227
+ begin
228
+ File.rename t, file
229
+ rescue
230
+ File.delete t
231
+ end
232
+ end
233
+
234
+ def append(file)
235
+ file_data = File.read(file)
236
+ new_data = STDIN.gets_to_end
237
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(file).permissions) do |h|
238
+ h << file_data + new_data
239
+ end
240
+ begin
241
+ File.rename t, file
242
+ rescue
243
+ File.delete t
244
+ end
245
+ end
246
+
247
+ class Funcs
248
+ def self.argument_data(program, usage, long_desc)
249
+ if !(STDOUT.tty?)
250
+ text = "<div style='border-radius: 50px; border: 10px dotted cyan; padding: 30px;'>\n"
251
+ else
252
+ text = ""
253
+ end
254
+
255
+ text += ("NAME") + "\n\t" + program
256
+ text += " - "
257
+ text += program + "\n" * 2 + ("SYNOPSIS") + "\n"
258
+ # tebold_("SYNOPSIS_")# + bold("SYNOPSIS")
259
+ text += "\t"
260
+ text += (program) + " "
261
+ text += usage + "\n\n"
262
+ text += long_desc + "\n\n"
263
+
264
+ if STDOUT.tty? == false
265
+ text = text.gsub("\n", "<br/> ").gsub("\t", "&nbsp;" * 5)
266
+ text += "</div>\n\n"
267
+ end
268
+
269
+ puts text
270
+ end
271
+ end
272
+
273
+
274
+ def main
275
+ size = ARGV.size
276
+
277
+ if size != 1
278
+ Funcs.argument_data("prepend_each", "[prepend_each] [arguments]", "Prepends a string to each line")
279
+ exit 1
280
+ end
281
+
282
+ begin
283
+ prepend_each(ARGV[0]?)
284
+ rescue e : Exception
285
+ puts e
286
+ end
287
+ end
288
+
289
+
290
+ main
data/src/_compilation/rip CHANGED
@@ -1,11 +1,24 @@
1
1
  #!/usr/bin/crystal
2
2
 
3
- def delete(arg)
4
- `find -name #{arg}`.each_line do |i|
5
- File.delete(i)
6
- end
3
+ CORE_UTIL_STRING = "core_utils"
4
+
5
+ def prepend_each(arg)
6
+ STDIN.each_line do |line|
7
+ puts arg + line
8
+ end
7
9
  end
8
10
 
11
+ def append_each(arg)
12
+ STDIN.each_line do |line|
13
+ puts line + arg
14
+ end
15
+ end
16
+
17
+ def delete(arg)
18
+ `find -name #{arg}`.each_line do |i|
19
+ File.delete(i)
20
+ end
21
+ end
9
22
 
10
23
  def nth_word(arg)
11
24
  i = arg.to_u64 - 1
@@ -20,11 +33,11 @@ def trim()
20
33
  end
21
34
  end
22
35
 
23
- def lines()
36
+ def lines(folder = ".")
24
37
  if !STDIN.tty?
25
- puts STDIN.gets_to_end.count("\n")
38
+ puts STDIN.gets_to_end.count('\n')
26
39
  else
27
- res = `find .`.count("\n") - 1
40
+ res = `find #{folder}`.count('\n') - 1
28
41
  puts res
29
42
  end
30
43
  end
@@ -155,25 +168,25 @@ end
155
168
  def gsubip(arg1, arg2, arg3)
156
169
  regex = Regex.new(arg1)
157
170
  text = File.read(arg3).gsub(/#{arg1}/m, arg2)
158
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(arg3).permissions) do |h|
171
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(arg3).permissions) do |h|
159
172
  h.print text
160
173
  end
161
174
  begin
162
175
  File.rename t, arg3
163
176
  rescue
164
- rm t
177
+ File.delete t
165
178
  end
166
179
  end
167
180
 
168
181
  def rip(arg1, arg2, arg3)
169
182
  text = File.read(arg3).gsub(arg1, arg2)
170
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(arg3).permissions) do |h|
183
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(arg3).permissions) do |h|
171
184
  h.print text
172
185
  end
173
186
  begin
174
187
  File.rename t, arg3
175
188
  rescue
176
- rm t
189
+ File.delete t
177
190
  end
178
191
  end
179
192
 
@@ -197,7 +210,7 @@ def swap(file1, file2)
197
210
  [file1, file2].each do |f|
198
211
  File.exists?(f) || abort("No file named #{f.dump}")
199
212
  end
200
- t = File.tempname("coreutils", "_tmp")
213
+ t = File.tempname(CORE_UTIL_STRING, "_tmp")
201
214
 
202
215
  File.rename file1, t
203
216
  File.rename file2, file1
@@ -207,27 +220,27 @@ end
207
220
  def prepend(file)
208
221
  file_data = File.read(file)
209
222
  new_data = STDIN.gets_to_end
210
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(file).permissions) do |h|
223
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(file).permissions) do |h|
211
224
  h << new_data + file_data
212
225
  end
213
226
 
214
227
  begin
215
228
  File.rename t, file
216
229
  rescue
217
- rm t
230
+ File.delete t
218
231
  end
219
232
  end
220
233
 
221
234
  def append(file)
222
235
  file_data = File.read(file)
223
236
  new_data = STDIN.gets_to_end
224
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(file).permissions) do |h|
237
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(file).permissions) do |h|
225
238
  h << file_data + new_data
226
239
  end
227
240
  begin
228
241
  File.rename t, file
229
242
  rescue
230
- rm t
243
+ File.delete t
231
244
  end
232
245
  end
233
246
 
@@ -258,13 +271,19 @@ class Funcs
258
271
  end
259
272
 
260
273
 
261
- def main()
262
- if ARGV.size != 3
274
+ def main
275
+ size = ARGV.size
276
+
277
+ if size != 3
263
278
  Funcs.argument_data("rip", "[rip] [arguments]", "Replace In Place\n\nrip tool replaces a string, not a regular expression, with another string\n\nExample\n\nrip cat dog file")
264
279
  exit 1
265
280
  end
266
281
 
267
- rip(ARGV[0], ARGV[1], ARGV[2])
282
+ begin
283
+ rip(ARGV[0]?, ARGV[1]?, ARGV[2]?)
284
+ rescue e : Exception
285
+ puts e
286
+ end
268
287
  end
269
288
 
270
289
 
@@ -1,11 +1,24 @@
1
1
  #!/usr/bin/crystal
2
2
 
3
- def delete(arg)
4
- `find -name #{arg}`.each_line do |i|
5
- File.delete(i)
6
- end
3
+ CORE_UTIL_STRING = "core_utils"
4
+
5
+ def prepend_each(arg)
6
+ STDIN.each_line do |line|
7
+ puts arg + line
8
+ end
7
9
  end
8
10
 
11
+ def append_each(arg)
12
+ STDIN.each_line do |line|
13
+ puts line + arg
14
+ end
15
+ end
16
+
17
+ def delete(arg)
18
+ `find -name #{arg}`.each_line do |i|
19
+ File.delete(i)
20
+ end
21
+ end
9
22
 
10
23
  def nth_word(arg)
11
24
  i = arg.to_u64 - 1
@@ -20,11 +33,11 @@ def trim()
20
33
  end
21
34
  end
22
35
 
23
- def lines()
36
+ def lines(folder = ".")
24
37
  if !STDIN.tty?
25
- puts STDIN.gets_to_end.count("\n")
38
+ puts STDIN.gets_to_end.count('\n')
26
39
  else
27
- res = `find .`.count("\n") - 1
40
+ res = `find #{folder}`.count('\n') - 1
28
41
  puts res
29
42
  end
30
43
  end
@@ -155,25 +168,25 @@ end
155
168
  def gsubip(arg1, arg2, arg3)
156
169
  regex = Regex.new(arg1)
157
170
  text = File.read(arg3).gsub(/#{arg1}/m, arg2)
158
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(arg3).permissions) do |h|
171
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(arg3).permissions) do |h|
159
172
  h.print text
160
173
  end
161
174
  begin
162
175
  File.rename t, arg3
163
176
  rescue
164
- rm t
177
+ File.delete t
165
178
  end
166
179
  end
167
180
 
168
181
  def rip(arg1, arg2, arg3)
169
182
  text = File.read(arg3).gsub(arg1, arg2)
170
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(arg3).permissions) do |h|
183
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(arg3).permissions) do |h|
171
184
  h.print text
172
185
  end
173
186
  begin
174
187
  File.rename t, arg3
175
188
  rescue
176
- rm t
189
+ File.delete t
177
190
  end
178
191
  end
179
192
 
@@ -197,7 +210,7 @@ def swap(file1, file2)
197
210
  [file1, file2].each do |f|
198
211
  File.exists?(f) || abort("No file named #{f.dump}")
199
212
  end
200
- t = File.tempname("coreutils", "_tmp")
213
+ t = File.tempname(CORE_UTIL_STRING, "_tmp")
201
214
 
202
215
  File.rename file1, t
203
216
  File.rename file2, file1
@@ -207,27 +220,27 @@ end
207
220
  def prepend(file)
208
221
  file_data = File.read(file)
209
222
  new_data = STDIN.gets_to_end
210
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(file).permissions) do |h|
223
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(file).permissions) do |h|
211
224
  h << new_data + file_data
212
225
  end
213
226
 
214
227
  begin
215
228
  File.rename t, file
216
229
  rescue
217
- rm t
230
+ File.delete t
218
231
  end
219
232
  end
220
233
 
221
234
  def append(file)
222
235
  file_data = File.read(file)
223
236
  new_data = STDIN.gets_to_end
224
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(file).permissions) do |h|
237
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(file).permissions) do |h|
225
238
  h << file_data + new_data
226
239
  end
227
240
  begin
228
241
  File.rename t, file
229
242
  rescue
230
- rm t
243
+ File.delete t
231
244
  end
232
245
  end
233
246
 
@@ -258,13 +271,19 @@ class Funcs
258
271
  end
259
272
 
260
273
 
261
- def main()
262
- if ARGV.size != 2
274
+ def main
275
+ size = ARGV.size
276
+
277
+ if size != 2
263
278
  Funcs.argument_data("rnip", "[rnip] [arguments]", "Replace Not In Place\n\nThis is like gsub, but for strings, not for regular expressions\n\nExample\n\necho .......... | rnip foo bar\n\nSee also\n\ngsub")
264
279
  exit 1
265
280
  end
266
281
 
267
- rnip(ARGV[0], ARGV[1])
282
+ begin
283
+ rnip(ARGV[0]?, ARGV[1]?)
284
+ rescue e : Exception
285
+ puts e
286
+ end
268
287
  end
269
288
 
270
289
 
@@ -1,11 +1,24 @@
1
1
  #!/usr/bin/crystal
2
2
 
3
- def delete(arg)
4
- `find -name #{arg}`.each_line do |i|
5
- File.delete(i)
6
- end
3
+ CORE_UTIL_STRING = "core_utils"
4
+
5
+ def prepend_each(arg)
6
+ STDIN.each_line do |line|
7
+ puts arg + line
8
+ end
7
9
  end
8
10
 
11
+ def append_each(arg)
12
+ STDIN.each_line do |line|
13
+ puts line + arg
14
+ end
15
+ end
16
+
17
+ def delete(arg)
18
+ `find -name #{arg}`.each_line do |i|
19
+ File.delete(i)
20
+ end
21
+ end
9
22
 
10
23
  def nth_word(arg)
11
24
  i = arg.to_u64 - 1
@@ -20,11 +33,11 @@ def trim()
20
33
  end
21
34
  end
22
35
 
23
- def lines()
36
+ def lines(folder = ".")
24
37
  if !STDIN.tty?
25
- puts STDIN.gets_to_end.count("\n")
38
+ puts STDIN.gets_to_end.count('\n')
26
39
  else
27
- res = `find .`.count("\n") - 1
40
+ res = `find #{folder}`.count('\n') - 1
28
41
  puts res
29
42
  end
30
43
  end
@@ -155,25 +168,25 @@ end
155
168
  def gsubip(arg1, arg2, arg3)
156
169
  regex = Regex.new(arg1)
157
170
  text = File.read(arg3).gsub(/#{arg1}/m, arg2)
158
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(arg3).permissions) do |h|
171
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(arg3).permissions) do |h|
159
172
  h.print text
160
173
  end
161
174
  begin
162
175
  File.rename t, arg3
163
176
  rescue
164
- rm t
177
+ File.delete t
165
178
  end
166
179
  end
167
180
 
168
181
  def rip(arg1, arg2, arg3)
169
182
  text = File.read(arg3).gsub(arg1, arg2)
170
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(arg3).permissions) do |h|
183
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(arg3).permissions) do |h|
171
184
  h.print text
172
185
  end
173
186
  begin
174
187
  File.rename t, arg3
175
188
  rescue
176
- rm t
189
+ File.delete t
177
190
  end
178
191
  end
179
192
 
@@ -197,7 +210,7 @@ def swap(file1, file2)
197
210
  [file1, file2].each do |f|
198
211
  File.exists?(f) || abort("No file named #{f.dump}")
199
212
  end
200
- t = File.tempname("coreutils", "_tmp")
213
+ t = File.tempname(CORE_UTIL_STRING, "_tmp")
201
214
 
202
215
  File.rename file1, t
203
216
  File.rename file2, file1
@@ -207,27 +220,27 @@ end
207
220
  def prepend(file)
208
221
  file_data = File.read(file)
209
222
  new_data = STDIN.gets_to_end
210
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(file).permissions) do |h|
223
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(file).permissions) do |h|
211
224
  h << new_data + file_data
212
225
  end
213
226
 
214
227
  begin
215
228
  File.rename t, file
216
229
  rescue
217
- rm t
230
+ File.delete t
218
231
  end
219
232
  end
220
233
 
221
234
  def append(file)
222
235
  file_data = File.read(file)
223
236
  new_data = STDIN.gets_to_end
224
- File.open(t = File.tempname("coreutils", "_tmp"), "w", File.info(file).permissions) do |h|
237
+ File.open(t = File.tempname(CORE_UTIL_STRING, "_tmp"), "w", File.info(file).permissions) do |h|
225
238
  h << file_data + new_data
226
239
  end
227
240
  begin
228
241
  File.rename t, file
229
242
  rescue
230
- rm t
243
+ File.delete t
231
244
  end
232
245
  end
233
246
 
@@ -258,13 +271,19 @@ class Funcs
258
271
  end
259
272
 
260
273
 
261
- def main()
262
- if ARGV.size != 0
274
+ def main
275
+ size = ARGV.size
276
+
277
+ if size > 0
263
278
  Funcs.argument_data("selectlines", "[selectlines] [arguments]", "selectlines shows all nonblank lines from the input\n\nExample\n\ncat file | selectlines\n\n(echo 2; echo; echo; echo) | selectlines\n\n=> 2\n\nThe result would be 2, with no blank lines after that")
264
279
  exit 1
265
280
  end
266
281
 
267
- selectlines
282
+ begin
283
+ selectlines
284
+ rescue e : Exception
285
+ puts e
286
+ end
268
287
  end
269
288
 
270
289