linebook 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History +8 -0
- data/HowTo/Setup/Debian +75 -0
- data/HowTo/Setup/SLES +87 -0
- data/HowTo/Setup/Ubuntu +71 -0
- data/HowTo/Setup/openSUSE +75 -0
- data/HowTo/Switch Users +73 -0
- data/lib/linebook/os/linux.rb +24 -199
- data/lib/linebook/os/linux/utilities.rb +226 -0
- data/lib/linebook/os/posix.rb +268 -78
- data/lib/linebook/os/posix/utilities.rb +726 -0
- data/lib/linebook/os/posix/variable.rb +91 -0
- data/lib/linebook/os/ubuntu.rb +1 -1
- data/lib/linebook/shell.rb +3 -3
- data/lib/linebook/version.rb +1 -1
- metadata +24 -12
- data/lib/linebook/os/unix.rb +0 -462
@@ -0,0 +1,726 @@
|
|
1
|
+
# Generated by Linecook
|
2
|
+
|
3
|
+
module Linebook
|
4
|
+
module Os
|
5
|
+
module Posix
|
6
|
+
module Utilities
|
7
|
+
# Return non-directory portion of a pathname. If a suffix is provided and
|
8
|
+
# present, then it will be removed.
|
9
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/basename.html]
|
10
|
+
def basename(string, suffix=nil)
|
11
|
+
execute 'basename', string, suffix
|
12
|
+
chain_proxy
|
13
|
+
end
|
14
|
+
|
15
|
+
def _basename(*args, &block) # :nodoc:
|
16
|
+
str = capture_str { basename(*args, &block) }
|
17
|
+
str.strip!
|
18
|
+
str
|
19
|
+
end
|
20
|
+
|
21
|
+
# Concatenate and print files.
|
22
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cat.html]
|
23
|
+
def cat(*files)
|
24
|
+
execute 'cat', *files
|
25
|
+
chain_proxy
|
26
|
+
end
|
27
|
+
|
28
|
+
def _cat(*args, &block) # :nodoc:
|
29
|
+
str = capture_str { cat(*args, &block) }
|
30
|
+
str.strip!
|
31
|
+
str
|
32
|
+
end
|
33
|
+
|
34
|
+
# Change the working directory, for the duration of a block if given.
|
35
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cd.html]
|
36
|
+
def cd(directory=nil, options={})
|
37
|
+
if block_given?
|
38
|
+
var = _package_.next_variable_name('cd')
|
39
|
+
writeln %{#{var}=$(pwd)}
|
40
|
+
end
|
41
|
+
|
42
|
+
execute 'cd', directory, options
|
43
|
+
|
44
|
+
if block_given?
|
45
|
+
yield
|
46
|
+
execute 'cd', "$#{var}"
|
47
|
+
end
|
48
|
+
chain_proxy
|
49
|
+
end
|
50
|
+
|
51
|
+
def _cd(*args, &block) # :nodoc:
|
52
|
+
str = capture_str { cd(*args, &block) }
|
53
|
+
str.strip!
|
54
|
+
str
|
55
|
+
end
|
56
|
+
|
57
|
+
# Change the file group ownership
|
58
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chgrp.html]
|
59
|
+
def chgrp(group, *files)
|
60
|
+
unless group.nil?
|
61
|
+
execute 'chgrp', group, *files
|
62
|
+
end
|
63
|
+
chain_proxy
|
64
|
+
end
|
65
|
+
|
66
|
+
def _chgrp(*args, &block) # :nodoc:
|
67
|
+
str = capture_str { chgrp(*args, &block) }
|
68
|
+
str.strip!
|
69
|
+
str
|
70
|
+
end
|
71
|
+
|
72
|
+
# Change the file modes. The mode may be specified as a String or a Fixnum. If a
|
73
|
+
# Fixnum is provided, then it will be formatted into an octal string using
|
74
|
+
# sprintf "%o".
|
75
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html]
|
76
|
+
def chmod(mode, *files)
|
77
|
+
unless mode.nil?
|
78
|
+
if mode.kind_of?(Fixnum)
|
79
|
+
mode = sprintf("%o", mode)
|
80
|
+
end
|
81
|
+
execute 'chmod', mode, *files
|
82
|
+
end
|
83
|
+
chain_proxy
|
84
|
+
end
|
85
|
+
|
86
|
+
def _chmod(*args, &block) # :nodoc:
|
87
|
+
str = capture_str { chmod(*args, &block) }
|
88
|
+
str.strip!
|
89
|
+
str
|
90
|
+
end
|
91
|
+
|
92
|
+
# Change the file ownership.
|
93
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chown.html]
|
94
|
+
def chown(owner, *files)
|
95
|
+
unless owner.nil?
|
96
|
+
execute 'chown', owner, *files
|
97
|
+
end
|
98
|
+
chain_proxy
|
99
|
+
end
|
100
|
+
|
101
|
+
def _chown(*args, &block) # :nodoc:
|
102
|
+
str = capture_str { chown(*args, &block) }
|
103
|
+
str.strip!
|
104
|
+
str
|
105
|
+
end
|
106
|
+
|
107
|
+
# Compare two files.
|
108
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cmp.html]
|
109
|
+
def cmp(file1, file2, options={})
|
110
|
+
execute 'cmp', file1, file2, options
|
111
|
+
chain_proxy
|
112
|
+
end
|
113
|
+
|
114
|
+
def _cmp(*args, &block) # :nodoc:
|
115
|
+
str = capture_str { cmp(*args, &block) }
|
116
|
+
str.strip!
|
117
|
+
str
|
118
|
+
end
|
119
|
+
|
120
|
+
# Select or reject lines common to two files.
|
121
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/comm.html]
|
122
|
+
def comm(file1, file2, options={})
|
123
|
+
execute 'comm', file1, file2, options
|
124
|
+
chain_proxy
|
125
|
+
end
|
126
|
+
|
127
|
+
def _comm(*args, &block) # :nodoc:
|
128
|
+
str = capture_str { comm(*args, &block) }
|
129
|
+
str.strip!
|
130
|
+
str
|
131
|
+
end
|
132
|
+
|
133
|
+
# Copy files.
|
134
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html]
|
135
|
+
def cp(source_file, target_file, options={})
|
136
|
+
execute 'cp', source_file, target_file, options
|
137
|
+
chain_proxy
|
138
|
+
end
|
139
|
+
|
140
|
+
def _cp(*args, &block) # :nodoc:
|
141
|
+
str = capture_str { cp(*args, &block) }
|
142
|
+
str.strip!
|
143
|
+
str
|
144
|
+
end
|
145
|
+
|
146
|
+
# Cut out selected fields of each line of a file.
|
147
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cut.html]
|
148
|
+
def cut(*files)
|
149
|
+
execute 'cut', *files
|
150
|
+
chain_proxy
|
151
|
+
end
|
152
|
+
|
153
|
+
def _cut(*args, &block) # :nodoc:
|
154
|
+
str = capture_str { cut(*args, &block) }
|
155
|
+
str.strip!
|
156
|
+
str
|
157
|
+
end
|
158
|
+
|
159
|
+
# Writes the date and time.
|
160
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html]
|
161
|
+
def date(options={})
|
162
|
+
execute 'date', options
|
163
|
+
chain_proxy
|
164
|
+
end
|
165
|
+
|
166
|
+
def _date(*args, &block) # :nodoc:
|
167
|
+
str = capture_str { date(*args, &block) }
|
168
|
+
str.strip!
|
169
|
+
str
|
170
|
+
end
|
171
|
+
|
172
|
+
# Checks that file exists and is a directory.
|
173
|
+
def directory?(dir)
|
174
|
+
# [ -d "<%= dir %>" ]
|
175
|
+
#
|
176
|
+
write "[ -d \""; write(( dir ).to_s); write "\" ]\n"
|
177
|
+
|
178
|
+
chain_proxy
|
179
|
+
end
|
180
|
+
|
181
|
+
def _directory?(*args, &block) # :nodoc:
|
182
|
+
str = capture_str { directory?(*args, &block) }
|
183
|
+
str.strip!
|
184
|
+
str
|
185
|
+
end
|
186
|
+
|
187
|
+
# Return the directory portion of a pathname.
|
188
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/dirname.html]
|
189
|
+
def dirname(string)
|
190
|
+
execute 'dirname', string
|
191
|
+
chain_proxy
|
192
|
+
end
|
193
|
+
|
194
|
+
def _dirname(*args, &block) # :nodoc:
|
195
|
+
str = capture_str { dirname(*args, &block) }
|
196
|
+
str.strip!
|
197
|
+
str
|
198
|
+
end
|
199
|
+
|
200
|
+
# Write arguments to standard output.
|
201
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html]
|
202
|
+
def echo(*string)
|
203
|
+
execute 'echo', *string
|
204
|
+
chain_proxy
|
205
|
+
end
|
206
|
+
|
207
|
+
def _echo(*args, &block) # :nodoc:
|
208
|
+
str = capture_str { echo(*args, &block) }
|
209
|
+
str.strip!
|
210
|
+
str
|
211
|
+
end
|
212
|
+
|
213
|
+
# Checks that file exists and is executable, or file is a directory that can be
|
214
|
+
# searched.
|
215
|
+
def executable?(file)
|
216
|
+
# [ -x "<%= file %>" ]
|
217
|
+
#
|
218
|
+
write "[ -x \""; write(( file ).to_s); write "\" ]\n"
|
219
|
+
|
220
|
+
chain_proxy
|
221
|
+
end
|
222
|
+
|
223
|
+
def _executable?(*args, &block) # :nodoc:
|
224
|
+
str = capture_str { executable?(*args, &block) }
|
225
|
+
str.strip!
|
226
|
+
str
|
227
|
+
end
|
228
|
+
|
229
|
+
# Checks that file exists.
|
230
|
+
def exists?(file)
|
231
|
+
# [ -e "<%= file %>" ]
|
232
|
+
#
|
233
|
+
write "[ -e \""; write(( file ).to_s); write "\" ]\n"
|
234
|
+
|
235
|
+
chain_proxy
|
236
|
+
end
|
237
|
+
|
238
|
+
def _exists?(*args, &block) # :nodoc:
|
239
|
+
str = capture_str { exists?(*args, &block) }
|
240
|
+
str.strip!
|
241
|
+
str
|
242
|
+
end
|
243
|
+
|
244
|
+
# Convert tabs to spaces.
|
245
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expand.html]
|
246
|
+
def expand(*files)
|
247
|
+
execute 'expand', *files
|
248
|
+
chain_proxy
|
249
|
+
end
|
250
|
+
|
251
|
+
def _expand(*args, &block) # :nodoc:
|
252
|
+
str = capture_str { expand(*args, &block) }
|
253
|
+
str.strip!
|
254
|
+
str
|
255
|
+
end
|
256
|
+
|
257
|
+
# Set the export attribute for variables.
|
258
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_22]
|
259
|
+
def export(key, value=nil)
|
260
|
+
# <% if value.nil? %>
|
261
|
+
# export <%= key %>
|
262
|
+
# <% else %>
|
263
|
+
# export <%= key %>=<%= quote(value) %>
|
264
|
+
# <% end %>
|
265
|
+
#
|
266
|
+
if value.nil?
|
267
|
+
write "export "; write(( key ).to_s); write "\n"
|
268
|
+
else
|
269
|
+
write "export "; write(( key ).to_s); write "="; write(( quote(value) ).to_s); write "\n"
|
270
|
+
end
|
271
|
+
|
272
|
+
chain_proxy
|
273
|
+
end
|
274
|
+
|
275
|
+
def _export(*args, &block) # :nodoc:
|
276
|
+
str = capture_str { export(*args, &block) }
|
277
|
+
str.strip!
|
278
|
+
str
|
279
|
+
end
|
280
|
+
|
281
|
+
# Checks that file exists and is a regular file.
|
282
|
+
def file?(file)
|
283
|
+
# [ -f "<%= file %>" ]
|
284
|
+
#
|
285
|
+
write "[ -f \""; write(( file ).to_s); write "\" ]\n"
|
286
|
+
|
287
|
+
chain_proxy
|
288
|
+
end
|
289
|
+
|
290
|
+
def _file?(*args, &block) # :nodoc:
|
291
|
+
str = capture_str { file?(*args, &block) }
|
292
|
+
str.strip!
|
293
|
+
str
|
294
|
+
end
|
295
|
+
|
296
|
+
# Filter for folding lines.
|
297
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/fold.html]
|
298
|
+
def fold(*files)
|
299
|
+
execute 'fold', *files
|
300
|
+
chain_proxy
|
301
|
+
end
|
302
|
+
|
303
|
+
def _fold(*args, &block) # :nodoc:
|
304
|
+
str = capture_str { fold(*args, &block) }
|
305
|
+
str.strip!
|
306
|
+
str
|
307
|
+
end
|
308
|
+
|
309
|
+
# Search a file for a pattern.
|
310
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html]
|
311
|
+
def grep(pattern_list, *files)
|
312
|
+
execute 'grep', pattern_list, *files
|
313
|
+
chain_proxy
|
314
|
+
end
|
315
|
+
|
316
|
+
def _grep(*args, &block) # :nodoc:
|
317
|
+
str = capture_str { grep(*args, &block) }
|
318
|
+
str.strip!
|
319
|
+
str
|
320
|
+
end
|
321
|
+
|
322
|
+
# Checks that file exists and is not empty.
|
323
|
+
def has_content?(file)
|
324
|
+
# [ -s "<%= file %>" ]
|
325
|
+
#
|
326
|
+
write "[ -s \""; write(( file ).to_s); write "\" ]\n"
|
327
|
+
|
328
|
+
chain_proxy
|
329
|
+
end
|
330
|
+
|
331
|
+
def _has_content?(*args, &block) # :nodoc:
|
332
|
+
str = capture_str { has_content?(*args, &block) }
|
333
|
+
str.strip!
|
334
|
+
str
|
335
|
+
end
|
336
|
+
|
337
|
+
# Copy the first part of files.
|
338
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/head.html]
|
339
|
+
def head(*files)
|
340
|
+
execute 'head', *files
|
341
|
+
chain_proxy
|
342
|
+
end
|
343
|
+
|
344
|
+
def _head(*args, &block) # :nodoc:
|
345
|
+
str = capture_str { head(*args, &block) }
|
346
|
+
str.strip!
|
347
|
+
str
|
348
|
+
end
|
349
|
+
|
350
|
+
# Return user identity.
|
351
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/id.html]
|
352
|
+
def id(user, options={})
|
353
|
+
execute 'id', user, options
|
354
|
+
chain_proxy
|
355
|
+
end
|
356
|
+
|
357
|
+
def _id(*args, &block) # :nodoc:
|
358
|
+
str = capture_str { id(*args, &block) }
|
359
|
+
str.strip!
|
360
|
+
str
|
361
|
+
end
|
362
|
+
|
363
|
+
# Checks that file exists and is a symbolic link.
|
364
|
+
def link?(file)
|
365
|
+
# [ -L "<%= file %>" ]
|
366
|
+
#
|
367
|
+
write "[ -L \""; write(( file ).to_s); write "\" ]\n"
|
368
|
+
|
369
|
+
chain_proxy
|
370
|
+
end
|
371
|
+
|
372
|
+
def _link?(*args, &block) # :nodoc:
|
373
|
+
str = capture_str { link?(*args, &block) }
|
374
|
+
str.strip!
|
375
|
+
str
|
376
|
+
end
|
377
|
+
|
378
|
+
# Link files.
|
379
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ln.html]
|
380
|
+
def ln(source_file, target_file, options={})
|
381
|
+
execute 'ln', source_file, target_file, options
|
382
|
+
chain_proxy
|
383
|
+
end
|
384
|
+
|
385
|
+
def _ln(*args, &block) # :nodoc:
|
386
|
+
str = capture_str { ln(*args, &block) }
|
387
|
+
str.strip!
|
388
|
+
str
|
389
|
+
end
|
390
|
+
|
391
|
+
# List directory contents.
|
392
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html]
|
393
|
+
def ls(*files)
|
394
|
+
execute 'ls', *files
|
395
|
+
chain_proxy
|
396
|
+
end
|
397
|
+
|
398
|
+
def _ls(*args, &block) # :nodoc:
|
399
|
+
str = capture_str { ls(*args, &block) }
|
400
|
+
str.strip!
|
401
|
+
str
|
402
|
+
end
|
403
|
+
|
404
|
+
# Make directories.
|
405
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/mkdir.html]
|
406
|
+
def mkdir(*dirs)
|
407
|
+
execute 'mkdir', *dirs
|
408
|
+
chain_proxy
|
409
|
+
end
|
410
|
+
|
411
|
+
def _mkdir(*args, &block) # :nodoc:
|
412
|
+
str = capture_str { mkdir(*args, &block) }
|
413
|
+
str.strip!
|
414
|
+
str
|
415
|
+
end
|
416
|
+
|
417
|
+
# Move files.
|
418
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/mv.html]
|
419
|
+
def mv(source_file, target_file, options={})
|
420
|
+
execute 'mv', source_file, target_file, options
|
421
|
+
chain_proxy
|
422
|
+
end
|
423
|
+
|
424
|
+
def _mv(*args, &block) # :nodoc:
|
425
|
+
str = capture_str { mv(*args, &block) }
|
426
|
+
str.strip!
|
427
|
+
str
|
428
|
+
end
|
429
|
+
|
430
|
+
# Merge corresponding or subsequent lines of files.
|
431
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/paste.html]
|
432
|
+
def paste(*files)
|
433
|
+
execute 'paste', *files
|
434
|
+
chain_proxy
|
435
|
+
end
|
436
|
+
|
437
|
+
def _paste(*args, &block) # :nodoc:
|
438
|
+
str = capture_str { paste(*args, &block) }
|
439
|
+
str.strip!
|
440
|
+
str
|
441
|
+
end
|
442
|
+
|
443
|
+
# Check pathnames.
|
444
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pathchk.html]
|
445
|
+
def pathchk(*pathnames)
|
446
|
+
execute 'pathchk', *pathnames
|
447
|
+
chain_proxy
|
448
|
+
end
|
449
|
+
|
450
|
+
def _pathchk(*args, &block) # :nodoc:
|
451
|
+
str = capture_str { pathchk(*args, &block) }
|
452
|
+
str.strip!
|
453
|
+
str
|
454
|
+
end
|
455
|
+
|
456
|
+
# Return working directory name.
|
457
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pwd.html]
|
458
|
+
def pwd(options={})
|
459
|
+
execute 'pwd', options
|
460
|
+
chain_proxy
|
461
|
+
end
|
462
|
+
|
463
|
+
def _pwd(*args, &block) # :nodoc:
|
464
|
+
str = capture_str { pwd(*args, &block) }
|
465
|
+
str.strip!
|
466
|
+
str
|
467
|
+
end
|
468
|
+
|
469
|
+
# Read a line from standard input.
|
470
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html]
|
471
|
+
def read(*vars)
|
472
|
+
execute 'read', *vars
|
473
|
+
chain_proxy
|
474
|
+
end
|
475
|
+
|
476
|
+
def _read(*args, &block) # :nodoc:
|
477
|
+
str = capture_str { read(*args, &block) }
|
478
|
+
str.strip!
|
479
|
+
str
|
480
|
+
end
|
481
|
+
|
482
|
+
# Checks that file exists and is readable.
|
483
|
+
def readable?(file)
|
484
|
+
# [ -r "<%= file %>" ]
|
485
|
+
#
|
486
|
+
write "[ -r \""; write(( file ).to_s); write "\" ]\n"
|
487
|
+
|
488
|
+
chain_proxy
|
489
|
+
end
|
490
|
+
|
491
|
+
def _readable?(*args, &block) # :nodoc:
|
492
|
+
str = capture_str { readable?(*args, &block) }
|
493
|
+
str.strip!
|
494
|
+
str
|
495
|
+
end
|
496
|
+
|
497
|
+
# Remove directory entries.
|
498
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html]
|
499
|
+
def rm(*files)
|
500
|
+
execute 'rm', *files
|
501
|
+
chain_proxy
|
502
|
+
end
|
503
|
+
|
504
|
+
def _rm(*args, &block) # :nodoc:
|
505
|
+
str = capture_str { rm(*args, &block) }
|
506
|
+
str.strip!
|
507
|
+
str
|
508
|
+
end
|
509
|
+
|
510
|
+
# Remove directories.
|
511
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/rmdir.html]
|
512
|
+
def rmdir(*dirs)
|
513
|
+
execute 'rm', *dirs
|
514
|
+
chain_proxy
|
515
|
+
end
|
516
|
+
|
517
|
+
def _rmdir(*args, &block) # :nodoc:
|
518
|
+
str = capture_str { rmdir(*args, &block) }
|
519
|
+
str.strip!
|
520
|
+
str
|
521
|
+
end
|
522
|
+
|
523
|
+
# Stream editor.
|
524
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html]
|
525
|
+
def sed(script, *files)
|
526
|
+
execute 'sed', script, *files
|
527
|
+
chain_proxy
|
528
|
+
end
|
529
|
+
|
530
|
+
def _sed(*args, &block) # :nodoc:
|
531
|
+
str = capture_str { sed(*args, &block) }
|
532
|
+
str.strip!
|
533
|
+
str
|
534
|
+
end
|
535
|
+
|
536
|
+
# Set or unset options as specified. For example:
|
537
|
+
#
|
538
|
+
# set 'x' => true, 'v' => false
|
539
|
+
#
|
540
|
+
# If a block is given then options will only be reset when the block completes.
|
541
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_25]
|
542
|
+
def set(options)
|
543
|
+
if block_given?
|
544
|
+
var = _package_.next_variable_name('set')
|
545
|
+
patterns = options.keys.collect {|key| "-e #{key}" }.sort
|
546
|
+
writeln %{#{var}=$(set +o | grep #{patterns.join(' ')})}
|
547
|
+
end
|
548
|
+
|
549
|
+
options.keys.sort_by {|opt| opt.to_s }.each do |opt|
|
550
|
+
writeln %{set #{options[opt] ? '-' : '+'}o #{opt}}
|
551
|
+
end
|
552
|
+
|
553
|
+
if block_given?
|
554
|
+
yield
|
555
|
+
writeln %{eval "$#{var}"}
|
556
|
+
end
|
557
|
+
chain_proxy
|
558
|
+
end
|
559
|
+
|
560
|
+
def _set(*args, &block) # :nodoc:
|
561
|
+
str = capture_str { set(*args, &block) }
|
562
|
+
str.strip!
|
563
|
+
str
|
564
|
+
end
|
565
|
+
|
566
|
+
# Sort, merge, or sequence check text files.
|
567
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html]
|
568
|
+
def sort(*files)
|
569
|
+
execute 'sort', *files
|
570
|
+
chain_proxy
|
571
|
+
end
|
572
|
+
|
573
|
+
def _sort(*args, &block) # :nodoc:
|
574
|
+
str = capture_str { sort(*args, &block) }
|
575
|
+
str.strip!
|
576
|
+
str
|
577
|
+
end
|
578
|
+
|
579
|
+
# Split files into pieces.
|
580
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/split.html]
|
581
|
+
def split(file, *options)
|
582
|
+
execute 'split', file, *options
|
583
|
+
chain_proxy
|
584
|
+
end
|
585
|
+
|
586
|
+
def _split(*args, &block) # :nodoc:
|
587
|
+
str = capture_str { split(*args, &block) }
|
588
|
+
str.strip!
|
589
|
+
str
|
590
|
+
end
|
591
|
+
|
592
|
+
# Copy the last part of a file.
|
593
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tail.html]
|
594
|
+
def tail(file, options={})
|
595
|
+
execute 'tail', file, options
|
596
|
+
chain_proxy
|
597
|
+
end
|
598
|
+
|
599
|
+
def _tail(*args, &block) # :nodoc:
|
600
|
+
str = capture_str { tail(*args, &block) }
|
601
|
+
str.strip!
|
602
|
+
str
|
603
|
+
end
|
604
|
+
|
605
|
+
# Change file access and modification times.
|
606
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html]
|
607
|
+
def touch(*files)
|
608
|
+
execute 'touch', *files
|
609
|
+
chain_proxy
|
610
|
+
end
|
611
|
+
|
612
|
+
def _touch(*args, &block) # :nodoc:
|
613
|
+
str = capture_str { touch(*args, &block) }
|
614
|
+
str.strip!
|
615
|
+
str
|
616
|
+
end
|
617
|
+
|
618
|
+
# Translate characters.
|
619
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tr.html]
|
620
|
+
def tr(string1, string2=nil, *options)
|
621
|
+
execute 'tr', string1, string2, *options
|
622
|
+
chain_proxy
|
623
|
+
end
|
624
|
+
|
625
|
+
def _tr(*args, &block) # :nodoc:
|
626
|
+
str = capture_str { tr(*args, &block) }
|
627
|
+
str.strip!
|
628
|
+
str
|
629
|
+
end
|
630
|
+
|
631
|
+
# Topological sort.
|
632
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tsort.html]
|
633
|
+
def tsort(file)
|
634
|
+
execute 'tsort', file
|
635
|
+
chain_proxy
|
636
|
+
end
|
637
|
+
|
638
|
+
def _tsort(*args, &block) # :nodoc:
|
639
|
+
str = capture_str { tsort(*args, &block) }
|
640
|
+
str.strip!
|
641
|
+
str
|
642
|
+
end
|
643
|
+
|
644
|
+
# Return system name.
|
645
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/uname.html]
|
646
|
+
def uname(options={})
|
647
|
+
execute 'uname', options
|
648
|
+
chain_proxy
|
649
|
+
end
|
650
|
+
|
651
|
+
def _uname(*args, &block) # :nodoc:
|
652
|
+
str = capture_str { uname(*args, &block) }
|
653
|
+
str.strip!
|
654
|
+
str
|
655
|
+
end
|
656
|
+
|
657
|
+
# Convert spaces to tabs.
|
658
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/unexpand.html]
|
659
|
+
def unexpand(*files)
|
660
|
+
execute 'unexpand', *files
|
661
|
+
chain_proxy
|
662
|
+
end
|
663
|
+
|
664
|
+
def _unexpand(*args, &block) # :nodoc:
|
665
|
+
str = capture_str { unexpand(*args, &block) }
|
666
|
+
str.strip!
|
667
|
+
str
|
668
|
+
end
|
669
|
+
|
670
|
+
# Report or filter out repeated lines in a file.
|
671
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/uniq.html]
|
672
|
+
def uniq(*options)
|
673
|
+
execute 'uniq', *options
|
674
|
+
chain_proxy
|
675
|
+
end
|
676
|
+
|
677
|
+
def _uniq(*args, &block) # :nodoc:
|
678
|
+
str = capture_str { uniq(*args, &block) }
|
679
|
+
str.strip!
|
680
|
+
str
|
681
|
+
end
|
682
|
+
|
683
|
+
# Unset values and attributes of variables and functions.
|
684
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_29]
|
685
|
+
def unset(*names)
|
686
|
+
execute 'unset', *names
|
687
|
+
chain_proxy
|
688
|
+
end
|
689
|
+
|
690
|
+
def _unset(*args, &block) # :nodoc:
|
691
|
+
str = capture_str { unset(*args, &block) }
|
692
|
+
str.strip!
|
693
|
+
str
|
694
|
+
end
|
695
|
+
|
696
|
+
# Word, line, and byte or character count.
|
697
|
+
# {[Spec]}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/wc.html]
|
698
|
+
def wc(*files)
|
699
|
+
execute 'wc', *files
|
700
|
+
chain_proxy
|
701
|
+
end
|
702
|
+
|
703
|
+
def _wc(*args, &block) # :nodoc:
|
704
|
+
str = capture_str { wc(*args, &block) }
|
705
|
+
str.strip!
|
706
|
+
str
|
707
|
+
end
|
708
|
+
|
709
|
+
# Checks that file exists and is writable.
|
710
|
+
def writable?(file)
|
711
|
+
# [ -w "<%= file %>" ]
|
712
|
+
#
|
713
|
+
write "[ -w \""; write(( file ).to_s); write "\" ]\n"
|
714
|
+
|
715
|
+
chain_proxy
|
716
|
+
end
|
717
|
+
|
718
|
+
def _writable?(*args, &block) # :nodoc:
|
719
|
+
str = capture_str { writable?(*args, &block) }
|
720
|
+
str.strip!
|
721
|
+
str
|
722
|
+
end
|
723
|
+
end
|
724
|
+
end
|
725
|
+
end
|
726
|
+
end
|