Module: Linebook::Os::Posix::Utilities

Included in:
Linebook::Os::Posix
Defined in:
lib/linebook/os/posix/utilities.rb

Instance Method Summary collapse

Instance Method Details

#_basename(*args, &block) ⇒ Object

:nodoc:



15
16
17
18
19
# File 'lib/linebook/os/posix/utilities.rb', line 15

def _basename(*args, &block) # :nodoc:
  str = capture_str { basename(*args, &block) }
  str.strip!
  str
end

#_cat(*args, &block) ⇒ Object

:nodoc:



28
29
30
31
32
# File 'lib/linebook/os/posix/utilities.rb', line 28

def _cat(*args, &block) # :nodoc:
  str = capture_str { cat(*args, &block) }
  str.strip!
  str
end

#_cd(*args, &block) ⇒ Object

:nodoc:



51
52
53
54
55
# File 'lib/linebook/os/posix/utilities.rb', line 51

def _cd(*args, &block) # :nodoc:
  str = capture_str { cd(*args, &block) }
  str.strip!
  str
end

#_chgrp(*args, &block) ⇒ Object

:nodoc:



66
67
68
69
70
# File 'lib/linebook/os/posix/utilities.rb', line 66

def _chgrp(*args, &block) # :nodoc:
  str = capture_str { chgrp(*args, &block) }
  str.strip!
  str
end

#_chmod(*args, &block) ⇒ Object

:nodoc:



86
87
88
89
90
# File 'lib/linebook/os/posix/utilities.rb', line 86

def _chmod(*args, &block) # :nodoc:
  str = capture_str { chmod(*args, &block) }
  str.strip!
  str
end

#_chown(*args, &block) ⇒ Object

:nodoc:



101
102
103
104
105
# File 'lib/linebook/os/posix/utilities.rb', line 101

def _chown(*args, &block) # :nodoc:
  str = capture_str { chown(*args, &block) }
  str.strip!
  str
end

#_cmp(*args, &block) ⇒ Object

:nodoc:



114
115
116
117
118
# File 'lib/linebook/os/posix/utilities.rb', line 114

def _cmp(*args, &block) # :nodoc:
  str = capture_str { cmp(*args, &block) }
  str.strip!
  str
end

#_comm(*args, &block) ⇒ Object

:nodoc:



127
128
129
130
131
# File 'lib/linebook/os/posix/utilities.rb', line 127

def _comm(*args, &block) # :nodoc:
  str = capture_str { comm(*args, &block) }
  str.strip!
  str
end

#_cp(*args, &block) ⇒ Object

:nodoc:



140
141
142
143
144
# File 'lib/linebook/os/posix/utilities.rb', line 140

def _cp(*args, &block) # :nodoc:
  str = capture_str { cp(*args, &block) }
  str.strip!
  str
end

#_cut(*args, &block) ⇒ Object

:nodoc:



153
154
155
156
157
# File 'lib/linebook/os/posix/utilities.rb', line 153

def _cut(*args, &block) # :nodoc:
  str = capture_str { cut(*args, &block) }
  str.strip!
  str
end

#_date(*args, &block) ⇒ Object

:nodoc:



166
167
168
169
170
# File 'lib/linebook/os/posix/utilities.rb', line 166

def _date(*args, &block) # :nodoc:
  str = capture_str { date(*args, &block) }
  str.strip!
  str
end

#_directory?(*args, &block) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


181
182
183
184
185
# File 'lib/linebook/os/posix/utilities.rb', line 181

def _directory?(*args, &block) # :nodoc:
  str = capture_str { directory?(*args, &block) }
  str.strip!
  str
end

#_dirname(*args, &block) ⇒ Object

:nodoc:



194
195
196
197
198
# File 'lib/linebook/os/posix/utilities.rb', line 194

def _dirname(*args, &block) # :nodoc:
  str = capture_str { dirname(*args, &block) }
  str.strip!
  str
end

#_echo(*args, &block) ⇒ Object

:nodoc:



207
208
209
210
211
# File 'lib/linebook/os/posix/utilities.rb', line 207

def _echo(*args, &block) # :nodoc:
  str = capture_str { echo(*args, &block) }
  str.strip!
  str
end

#_executable?(*args, &block) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


223
224
225
226
227
# File 'lib/linebook/os/posix/utilities.rb', line 223

def _executable?(*args, &block) # :nodoc:
  str = capture_str { executable?(*args, &block) }
  str.strip!
  str
end

#_exists?(*args, &block) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


238
239
240
241
242
# File 'lib/linebook/os/posix/utilities.rb', line 238

def _exists?(*args, &block) # :nodoc:
  str = capture_str { exists?(*args, &block) }
  str.strip!
  str
end

#_expand(*args, &block) ⇒ Object

:nodoc:



251
252
253
254
255
# File 'lib/linebook/os/posix/utilities.rb', line 251

def _expand(*args, &block) # :nodoc:
  str = capture_str { expand(*args, &block) }
  str.strip!
  str
end

#_export(*args, &block) ⇒ Object

:nodoc:



275
276
277
278
279
# File 'lib/linebook/os/posix/utilities.rb', line 275

def _export(*args, &block) # :nodoc:
  str = capture_str { export(*args, &block) }
  str.strip!
  str
end

#_file?(*args, &block) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


290
291
292
293
294
# File 'lib/linebook/os/posix/utilities.rb', line 290

def _file?(*args, &block) # :nodoc:
  str = capture_str { file?(*args, &block) }
  str.strip!
  str
end

#_fold(*args, &block) ⇒ Object

:nodoc:



303
304
305
306
307
# File 'lib/linebook/os/posix/utilities.rb', line 303

def _fold(*args, &block) # :nodoc:
  str = capture_str { fold(*args, &block) }
  str.strip!
  str
end

#_grep(*args, &block) ⇒ Object

:nodoc:



316
317
318
319
320
# File 'lib/linebook/os/posix/utilities.rb', line 316

def _grep(*args, &block) # :nodoc:
  str = capture_str { grep(*args, &block) }
  str.strip!
  str
end

#_has_content?(*args, &block) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


331
332
333
334
335
# File 'lib/linebook/os/posix/utilities.rb', line 331

def _has_content?(*args, &block) # :nodoc:
  str = capture_str { has_content?(*args, &block) }
  str.strip!
  str
end

#_head(*args, &block) ⇒ Object

:nodoc:



344
345
346
347
348
# File 'lib/linebook/os/posix/utilities.rb', line 344

def _head(*args, &block) # :nodoc:
  str = capture_str { head(*args, &block) }
  str.strip!
  str
end

#_id(*args, &block) ⇒ Object

:nodoc:



357
358
359
360
361
# File 'lib/linebook/os/posix/utilities.rb', line 357

def _id(*args, &block) # :nodoc:
  str = capture_str { id(*args, &block) }
  str.strip!
  str
end

#_link?(*args, &block) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


372
373
374
375
376
# File 'lib/linebook/os/posix/utilities.rb', line 372

def _link?(*args, &block) # :nodoc:
  str = capture_str { link?(*args, &block) }
  str.strip!
  str
end

#_ln(*args, &block) ⇒ Object

:nodoc:



385
386
387
388
389
# File 'lib/linebook/os/posix/utilities.rb', line 385

def _ln(*args, &block) # :nodoc:
  str = capture_str { ln(*args, &block) }
  str.strip!
  str
end

#_ls(*args, &block) ⇒ Object

:nodoc:



398
399
400
401
402
# File 'lib/linebook/os/posix/utilities.rb', line 398

def _ls(*args, &block) # :nodoc:
  str = capture_str { ls(*args, &block) }
  str.strip!
  str
end

#_mkdir(*args, &block) ⇒ Object

:nodoc:



411
412
413
414
415
# File 'lib/linebook/os/posix/utilities.rb', line 411

def _mkdir(*args, &block) # :nodoc:
  str = capture_str { mkdir(*args, &block) }
  str.strip!
  str
end

#_mv(*args, &block) ⇒ Object

:nodoc:



424
425
426
427
428
# File 'lib/linebook/os/posix/utilities.rb', line 424

def _mv(*args, &block) # :nodoc:
  str = capture_str { mv(*args, &block) }
  str.strip!
  str
end

#_paste(*args, &block) ⇒ Object

:nodoc:



437
438
439
440
441
# File 'lib/linebook/os/posix/utilities.rb', line 437

def _paste(*args, &block) # :nodoc:
  str = capture_str { paste(*args, &block) }
  str.strip!
  str
end

#_pathchk(*args, &block) ⇒ Object

:nodoc:



450
451
452
453
454
# File 'lib/linebook/os/posix/utilities.rb', line 450

def _pathchk(*args, &block) # :nodoc:
  str = capture_str { pathchk(*args, &block) }
  str.strip!
  str
end

#_pwd(*args, &block) ⇒ Object

:nodoc:



463
464
465
466
467
# File 'lib/linebook/os/posix/utilities.rb', line 463

def _pwd(*args, &block) # :nodoc:
  str = capture_str { pwd(*args, &block) }
  str.strip!
  str
end

#_read(*args, &block) ⇒ Object

:nodoc:



476
477
478
479
480
# File 'lib/linebook/os/posix/utilities.rb', line 476

def _read(*args, &block) # :nodoc:
  str = capture_str { read(*args, &block) }
  str.strip!
  str
end

#_readable?(*args, &block) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


491
492
493
494
495
# File 'lib/linebook/os/posix/utilities.rb', line 491

def _readable?(*args, &block) # :nodoc:
  str = capture_str { readable?(*args, &block) }
  str.strip!
  str
end

#_rm(*args, &block) ⇒ Object

:nodoc:



504
505
506
507
508
# File 'lib/linebook/os/posix/utilities.rb', line 504

def _rm(*args, &block) # :nodoc:
  str = capture_str { rm(*args, &block) }
  str.strip!
  str
end

#_rmdir(*args, &block) ⇒ Object

:nodoc:



517
518
519
520
521
# File 'lib/linebook/os/posix/utilities.rb', line 517

def _rmdir(*args, &block) # :nodoc:
  str = capture_str { rmdir(*args, &block) }
  str.strip!
  str
end

#_sed(*args, &block) ⇒ Object

:nodoc:



530
531
532
533
534
# File 'lib/linebook/os/posix/utilities.rb', line 530

def _sed(*args, &block) # :nodoc:
  str = capture_str { sed(*args, &block) }
  str.strip!
  str
end

#_set(*args, &block) ⇒ Object

:nodoc:



560
561
562
563
564
# File 'lib/linebook/os/posix/utilities.rb', line 560

def _set(*args, &block) # :nodoc:
  str = capture_str { set(*args, &block) }
  str.strip!
  str
end

#_sort(*args, &block) ⇒ Object

:nodoc:



573
574
575
576
577
# File 'lib/linebook/os/posix/utilities.rb', line 573

def _sort(*args, &block) # :nodoc:
  str = capture_str { sort(*args, &block) }
  str.strip!
  str
end

#_split(*args, &block) ⇒ Object

:nodoc:



586
587
588
589
590
# File 'lib/linebook/os/posix/utilities.rb', line 586

def _split(*args, &block) # :nodoc:
  str = capture_str { split(*args, &block) }
  str.strip!
  str
end

#_tail(*args, &block) ⇒ Object

:nodoc:



599
600
601
602
603
# File 'lib/linebook/os/posix/utilities.rb', line 599

def _tail(*args, &block) # :nodoc:
  str = capture_str { tail(*args, &block) }
  str.strip!
  str
end

#_touch(*args, &block) ⇒ Object

:nodoc:



612
613
614
615
616
# File 'lib/linebook/os/posix/utilities.rb', line 612

def _touch(*args, &block) # :nodoc:
  str = capture_str { touch(*args, &block) }
  str.strip!
  str
end

#_tr(*args, &block) ⇒ Object

:nodoc:



625
626
627
628
629
# File 'lib/linebook/os/posix/utilities.rb', line 625

def _tr(*args, &block) # :nodoc:
  str = capture_str { tr(*args, &block) }
  str.strip!
  str
end

#_tsort(*args, &block) ⇒ Object

:nodoc:



638
639
640
641
642
# File 'lib/linebook/os/posix/utilities.rb', line 638

def _tsort(*args, &block) # :nodoc:
  str = capture_str { tsort(*args, &block) }
  str.strip!
  str
end

#_uname(*args, &block) ⇒ Object

:nodoc:



651
652
653
654
655
# File 'lib/linebook/os/posix/utilities.rb', line 651

def _uname(*args, &block) # :nodoc:
  str = capture_str { uname(*args, &block) }
  str.strip!
  str
end

#_unexpand(*args, &block) ⇒ Object

:nodoc:



664
665
666
667
668
# File 'lib/linebook/os/posix/utilities.rb', line 664

def _unexpand(*args, &block) # :nodoc:
  str = capture_str { unexpand(*args, &block) }
  str.strip!
  str
end

#_uniq(*args, &block) ⇒ Object

:nodoc:



677
678
679
680
681
# File 'lib/linebook/os/posix/utilities.rb', line 677

def _uniq(*args, &block) # :nodoc:
  str = capture_str { uniq(*args, &block) }
  str.strip!
  str
end

#_unset(*args, &block) ⇒ Object

:nodoc:



690
691
692
693
694
# File 'lib/linebook/os/posix/utilities.rb', line 690

def _unset(*args, &block) # :nodoc:
  str = capture_str { unset(*args, &block) }
  str.strip!
  str
end

#_wc(*args, &block) ⇒ Object

:nodoc:



703
704
705
706
707
# File 'lib/linebook/os/posix/utilities.rb', line 703

def _wc(*args, &block) # :nodoc:
  str = capture_str { wc(*args, &block) }
  str.strip!
  str
end

#_writable?(*args, &block) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


718
719
720
721
722
# File 'lib/linebook/os/posix/utilities.rb', line 718

def _writable?(*args, &block) # :nodoc:
  str = capture_str { writable?(*args, &block) }
  str.strip!
  str
end

#basename(string, suffix = nil) ⇒ Object

Return non-directory portion of a pathname. If a suffix is provided and present, then it will be removed. [Spec]



10
11
12
13
# File 'lib/linebook/os/posix/utilities.rb', line 10

def basename(string, suffix=nil)
  execute 'basename', string, suffix
  chain_proxy
end

#cat(*files) ⇒ Object

Concatenate and print files. [Spec]



23
24
25
26
# File 'lib/linebook/os/posix/utilities.rb', line 23

def cat(*files)
  execute 'cat', *files
  chain_proxy
end

#cd(directory = nil, options = {}) ⇒ Object

Change the working directory, for the duration of a block if given. [Spec]



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/linebook/os/posix/utilities.rb', line 36

def cd(directory=nil, options={})
  if block_given?
    var = _package_.next_variable_name('cd')
    writeln %{#{var}=$(pwd)}
  end

  execute 'cd', directory, options

  if block_given?
    yield
    execute 'cd', "$#{var}"
  end
  chain_proxy
end

#chgrp(group, *files) ⇒ Object

Change the file group ownership [Spec]



59
60
61
62
63
64
# File 'lib/linebook/os/posix/utilities.rb', line 59

def chgrp(group, *files)
  unless group.nil?
    execute 'chgrp', group, *files
  end
  chain_proxy
end

#chmod(mode, *files) ⇒ Object

Change the file modes. The mode may be specified as a String or a Fixnum. If a Fixnum is provided, then it will be formatted into an octal string using sprintf “%o”. [Spec]



76
77
78
79
80
81
82
83
84
# File 'lib/linebook/os/posix/utilities.rb', line 76

def chmod(mode, *files)
  unless mode.nil?
    if mode.kind_of?(Fixnum)
      mode = sprintf("%o", mode)
    end
    execute 'chmod', mode, *files
  end
  chain_proxy
end

#chown(owner, *files) ⇒ Object

Change the file ownership. [Spec]



94
95
96
97
98
99
# File 'lib/linebook/os/posix/utilities.rb', line 94

def chown(owner, *files)
  unless owner.nil?
    execute 'chown', owner, *files
  end
  chain_proxy
end

#cmp(file1, file2, options = {}) ⇒ Object

Compare two files. [Spec]



109
110
111
112
# File 'lib/linebook/os/posix/utilities.rb', line 109

def cmp(file1, file2, options={})
  execute 'cmp', file1, file2, options
  chain_proxy
end

#comm(file1, file2, options = {}) ⇒ Object

Select or reject lines common to two files. [Spec]



122
123
124
125
# File 'lib/linebook/os/posix/utilities.rb', line 122

def comm(file1, file2, options={})
  execute 'comm', file1, file2, options
  chain_proxy
end

#cp(source_file, target_file, options = {}) ⇒ Object

Copy files. [Spec]



135
136
137
138
# File 'lib/linebook/os/posix/utilities.rb', line 135

def cp(source_file, target_file, options={})
  execute 'cp', source_file, target_file, options
  chain_proxy
end

#cut(*files) ⇒ Object

Cut out selected fields of each line of a file. [Spec]



148
149
150
151
# File 'lib/linebook/os/posix/utilities.rb', line 148

def cut(*files)
  execute 'cut', *files
  chain_proxy
end

#date(options = {}) ⇒ Object

Writes the date and time. [Spec]



161
162
163
164
# File 'lib/linebook/os/posix/utilities.rb', line 161

def date(options={})
  execute 'date', options
  chain_proxy
end

#directory?(dir) ⇒ Boolean

Checks that file exists and is a directory.

Returns:

  • (Boolean)


173
174
175
176
177
178
179
# File 'lib/linebook/os/posix/utilities.rb', line 173

def directory?(dir)
  #  [ -d "<%= dir %>" ]
  #  
  write "[ -d \""; write(( dir ).to_s); write "\" ]\n"

  chain_proxy
end

#dirname(string) ⇒ Object

Return the directory portion of a pathname. [Spec]



189
190
191
192
# File 'lib/linebook/os/posix/utilities.rb', line 189

def dirname(string)
  execute 'dirname', string
  chain_proxy
end

#echo(*string) ⇒ Object

Write arguments to standard output. [Spec]



202
203
204
205
# File 'lib/linebook/os/posix/utilities.rb', line 202

def echo(*string)
  execute 'echo', *string
  chain_proxy
end

#executable?(file) ⇒ Boolean

Checks that file exists and is executable, or file is a directory that can be searched.

Returns:

  • (Boolean)


215
216
217
218
219
220
221
# File 'lib/linebook/os/posix/utilities.rb', line 215

def executable?(file)
  #  [ -x "<%= file %>" ]
  #  
  write "[ -x \""; write(( file ).to_s); write "\" ]\n"

  chain_proxy
end

#exists?(file) ⇒ Boolean

Checks that file exists.

Returns:

  • (Boolean)


230
231
232
233
234
235
236
# File 'lib/linebook/os/posix/utilities.rb', line 230

def exists?(file)
  #  [ -e "<%= file %>" ]
  #  
  write "[ -e \""; write(( file ).to_s); write "\" ]\n"

  chain_proxy
end

#expand(*files) ⇒ Object

Convert tabs to spaces. [Spec]



246
247
248
249
# File 'lib/linebook/os/posix/utilities.rb', line 246

def expand(*files)
  execute 'expand', *files
  chain_proxy
end

#export(key, value = nil) ⇒ Object

Set the export attribute for variables. [Spec]



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/linebook/os/posix/utilities.rb', line 259

def export(key, value=nil)
  #  <% if value.nil? %>
  #  export <%= key %>
  #  <% else %>
  #  export <%= key %>=<%= quote(value) %>
  #  <% end %>
  #  
  if value.nil? 
  write "export "; write(( key ).to_s); write "\n"
  else 
  write "export "; write(( key ).to_s); write "="; write(( quote(value) ).to_s); write "\n"
  end 

  chain_proxy
end

#file?(file) ⇒ Boolean

Checks that file exists and is a regular file.

Returns:

  • (Boolean)


282
283
284
285
286
287
288
# File 'lib/linebook/os/posix/utilities.rb', line 282

def file?(file)
  #  [ -f "<%= file %>" ]
  #  
  write "[ -f \""; write(( file ).to_s); write "\" ]\n"

  chain_proxy
end

#fold(*files) ⇒ Object

Filter for folding lines. [Spec]



298
299
300
301
# File 'lib/linebook/os/posix/utilities.rb', line 298

def fold(*files)
  execute 'fold', *files
  chain_proxy
end

#grep(pattern_list, *files) ⇒ Object

Search a file for a pattern. [Spec]



311
312
313
314
# File 'lib/linebook/os/posix/utilities.rb', line 311

def grep(pattern_list, *files)
  execute 'grep', pattern_list, *files
  chain_proxy
end

#has_content?(file) ⇒ Boolean

Checks that file exists and is not empty.

Returns:

  • (Boolean)


323
324
325
326
327
328
329
# File 'lib/linebook/os/posix/utilities.rb', line 323

def has_content?(file)
  #  [ -s "<%= file %>" ]
  #  
  write "[ -s \""; write(( file ).to_s); write "\" ]\n"

  chain_proxy
end

#head(*files) ⇒ Object

Copy the first part of files. [Spec]



339
340
341
342
# File 'lib/linebook/os/posix/utilities.rb', line 339

def head(*files)
  execute 'head', *files
  chain_proxy
end

#id(user, options = {}) ⇒ Object

Return user identity. [Spec]



352
353
354
355
# File 'lib/linebook/os/posix/utilities.rb', line 352

def id(user, options={})
  execute 'id', user, options
  chain_proxy
end

#link?(file) ⇒ Boolean

Checks that file exists and is a symbolic link.

Returns:

  • (Boolean)


364
365
366
367
368
369
370
# File 'lib/linebook/os/posix/utilities.rb', line 364

def link?(file)
  #  [ -L "<%= file %>" ]
  #  
  write "[ -L \""; write(( file ).to_s); write "\" ]\n"

  chain_proxy
end

#ln(source_file, target_file, options = {}) ⇒ Object

Link files. [Spec]



380
381
382
383
# File 'lib/linebook/os/posix/utilities.rb', line 380

def ln(source_file, target_file, options={})
  execute 'ln', source_file, target_file, options
  chain_proxy
end

#ls(*files) ⇒ Object

List directory contents. [Spec]



393
394
395
396
# File 'lib/linebook/os/posix/utilities.rb', line 393

def ls(*files)
  execute 'ls', *files
  chain_proxy
end

#mkdir(*dirs) ⇒ Object

Make directories. [Spec]



406
407
408
409
# File 'lib/linebook/os/posix/utilities.rb', line 406

def mkdir(*dirs)
  execute 'mkdir', *dirs
  chain_proxy
end

#mv(source_file, target_file, options = {}) ⇒ Object

Move files. [Spec]



419
420
421
422
# File 'lib/linebook/os/posix/utilities.rb', line 419

def mv(source_file, target_file, options={})
  execute 'mv', source_file, target_file, options
  chain_proxy
end

#paste(*files) ⇒ Object

Merge corresponding or subsequent lines of files. [Spec]



432
433
434
435
# File 'lib/linebook/os/posix/utilities.rb', line 432

def paste(*files)
  execute 'paste', *files
  chain_proxy
end

#pathchk(*pathnames) ⇒ Object

Check pathnames. [Spec]



445
446
447
448
# File 'lib/linebook/os/posix/utilities.rb', line 445

def pathchk(*pathnames)
  execute 'pathchk', *pathnames
  chain_proxy
end

#pwd(options = {}) ⇒ Object

Return working directory name. [Spec]



458
459
460
461
# File 'lib/linebook/os/posix/utilities.rb', line 458

def pwd(options={})
  execute 'pwd', options
  chain_proxy
end

#read(*vars) ⇒ Object

Read a line from standard input. [Spec]



471
472
473
474
# File 'lib/linebook/os/posix/utilities.rb', line 471

def read(*vars)
  execute 'read', *vars
  chain_proxy
end

#readable?(file) ⇒ Boolean

Checks that file exists and is readable.

Returns:

  • (Boolean)


483
484
485
486
487
488
489
# File 'lib/linebook/os/posix/utilities.rb', line 483

def readable?(file)
  #  [ -r "<%= file %>" ]
  #  
  write "[ -r \""; write(( file ).to_s); write "\" ]\n"

  chain_proxy
end

#rm(*files) ⇒ Object

Remove directory entries. [Spec]



499
500
501
502
# File 'lib/linebook/os/posix/utilities.rb', line 499

def rm(*files)
  execute 'rm', *files
  chain_proxy
end

#rmdir(*dirs) ⇒ Object

Remove directories. [Spec]



512
513
514
515
# File 'lib/linebook/os/posix/utilities.rb', line 512

def rmdir(*dirs)
  execute 'rm', *dirs
  chain_proxy
end

#sed(script, *files) ⇒ Object

Stream editor. [Spec]



525
526
527
528
# File 'lib/linebook/os/posix/utilities.rb', line 525

def sed(script, *files)
  execute 'sed', script, *files
  chain_proxy
end

#set(options) ⇒ Object

Set or unset options as specified. For example:

set 'x' => true, 'v' => false

If a block is given then options will only be reset when the block completes. [Spec]



542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/linebook/os/posix/utilities.rb', line 542

def set(options)
  if block_given?
    var = _package_.next_variable_name('set')
    patterns = options.keys.collect {|key| "-e #{key}" }.sort
    writeln %{#{var}=$(set +o | grep #{patterns.join(' ')})}
  end

  options.keys.sort_by {|opt| opt.to_s }.each do |opt|
    writeln %{set #{options[opt] ? '-' : '+'}o #{opt}}
  end

  if block_given?
    yield
    writeln %{eval "$#{var}"}
  end
  chain_proxy
end

#sort(*files) ⇒ Object

Sort, merge, or sequence check text files. [Spec]



568
569
570
571
# File 'lib/linebook/os/posix/utilities.rb', line 568

def sort(*files)
  execute 'sort', *files
  chain_proxy
end

#split(file, *options) ⇒ Object

Split files into pieces. [Spec]



581
582
583
584
# File 'lib/linebook/os/posix/utilities.rb', line 581

def split(file, *options)
  execute 'split', file, *options
  chain_proxy
end

#tail(file, options = {}) ⇒ Object

Copy the last part of a file. [Spec]



594
595
596
597
# File 'lib/linebook/os/posix/utilities.rb', line 594

def tail(file, options={})
  execute 'tail', file, options
  chain_proxy
end

#touch(*files) ⇒ Object

Change file access and modification times. [Spec]



607
608
609
610
# File 'lib/linebook/os/posix/utilities.rb', line 607

def touch(*files)
  execute 'touch', *files
  chain_proxy
end

#tr(string1, string2 = nil, *options) ⇒ Object

Translate characters. [Spec]



620
621
622
623
# File 'lib/linebook/os/posix/utilities.rb', line 620

def tr(string1, string2=nil, *options)
  execute 'tr', string1, string2, *options
  chain_proxy
end

#tsort(file) ⇒ Object

Topological sort. [Spec]



633
634
635
636
# File 'lib/linebook/os/posix/utilities.rb', line 633

def tsort(file)
  execute 'tsort', file
  chain_proxy
end

#uname(options = {}) ⇒ Object

Return system name. [Spec]



646
647
648
649
# File 'lib/linebook/os/posix/utilities.rb', line 646

def uname(options={})
  execute 'uname', options
  chain_proxy
end

#unexpand(*files) ⇒ Object

Convert spaces to tabs. [Spec]



659
660
661
662
# File 'lib/linebook/os/posix/utilities.rb', line 659

def unexpand(*files)
  execute 'unexpand', *files
  chain_proxy
end

#uniq(*options) ⇒ Object

Report or filter out repeated lines in a file. [Spec]



672
673
674
675
# File 'lib/linebook/os/posix/utilities.rb', line 672

def uniq(*options)
  execute 'uniq', *options
  chain_proxy
end

#unset(*names) ⇒ Object

Unset values and attributes of variables and functions. [Spec]



685
686
687
688
# File 'lib/linebook/os/posix/utilities.rb', line 685

def unset(*names)
  execute 'unset', *names
  chain_proxy
end

#wc(*files) ⇒ Object

Word, line, and byte or character count. [Spec]



698
699
700
701
# File 'lib/linebook/os/posix/utilities.rb', line 698

def wc(*files)
  execute 'wc', *files
  chain_proxy
end

#writable?(file) ⇒ Boolean

Checks that file exists and is writable.

Returns:

  • (Boolean)


710
711
712
713
714
715
716
# File 'lib/linebook/os/posix/utilities.rb', line 710

def writable?(file)
  #  [ -w "<%= file %>" ]
  #  
  write "[ -w \""; write(( file ).to_s); write "\" ]\n"

  chain_proxy
end