Class

Shell::CommandProcessor

Inheritance
< Object

Constants

Name   Description
NoDelegateMethods = ["initialize", "expand_path"] initialize of Shell and related classes.

Methods

Class

Visibility Signature
public add_delegate_command_to_shell (id)
public alias_command (ali, command, *opts, &block)
public alias_map ()
public def_builtin_commands (delegation_class, command_specs)
public def_system_command (command, path = command)
public initialize ()
public install_builtin_commands ()
public install_system_commands (pre = "sys_")
public method_added (id)
public new (shell)
public run_config ()
public unalias_command (ali)
public undef_system_command (command)

Instance

Visibility Signature
public [] (command, file1, file2=nil)
public append (to, filter)
public cat (*filenames)
public check_point ()
public concat (*jobs)
public echo (*strings)
public expand_path (path)
public find_system_command (command)
public finish_all_jobs ()
public foreach (path = nil, *rs) {|fn| ...}
public glob (pattern)
public mkdir (*path)
public notify (*opts) {|mes if iterator?| ...}
public open (path, mode)
public out (dev = STDOUT, &block)
public rehash ()
public rmdir (*path)
public system (command, *opts)
public tee (file)
public test (command, file1, file2=nil)
public transact (&block)
public unlink (path)

Class Method Detail

add_delegate_command_to_shell(id)

alias_command(ali, command, *opts, &block)

alias_map()

def_builtin_commands(delegation_class, command_specs)

CommandProcessor.def_builtin_commands(delegation_class, command_specs)

    delegation_class: Class or Module
    command_specs: [[command_name, [argument,...]],...]
       command_name: String
       arguments:      String
          FILENAME?? -> expand_path(filename??)
          *FILENAME?? -> filename??.collect{|f|expand_path(f)}.join(", ")
  define command_name(argument,...) as
      delegation_class.command_name(argument,...)

def_system_command(command, path = command)

CommandProcessor.def_system_command(command, path)

    command:  String
    path:       String
  define 'command()' method as method.

initialize()

install_builtin_commands()

define default builtin commands

install_system_commands(pre = "sys_")

CommandProcessor.install_system_commands(pre)

      pre: String - command name prefix

defines every command which belongs in default_system_path via CommandProcessor.command(). It doesn‘t define already defined methods twice. By default, "pre_" is prefixes to each method name. Characters that may not be used in a method name are all converted to ‘_’. Definition errors are just ignored.

method_added(id)

new(shell)

run_config()

include run file.

unalias_command(ali)

undef_system_command(command)

Instance Method Detail

[](command, file1, file2=nil)

Alias for test

append(to, filter)

cat(*filenames)

check_point()

ProcessCommand#transact

concat(*jobs)

echo(*strings)

expand_path(path)

CommandProcessor#expand_path(path)

    path:     String
    return: String
  returns the absolute path for <path>

find_system_command(command)

finish_all_jobs()

Alias for check_point

foreach(path = nil, *rs) {|fn| ...}

File related commands Shell#foreach Shell#open Shell#unlink Shell#test

-

CommandProcessor#foreach(path, rs)

    path: String
    rs:     String - record separator
    iterator
  Same as:
    File#foreach (when path is file)
    Dir#foreach (when path is directory)
  path is relative to pwd

glob(pattern)

def sort(*filenames)

  Sort.new(self, *filenames)

end

mkdir(*path)

Dir related methods

Shell#mkdir Shell#rmdir

notify(*opts) {|mes if iterator?| ...}

%pwd, %cwd -> @pwd

open(path, mode)

CommandProcessor#open(path, mode)

    path:     String
    mode:     String
    return: File or Dir
  Same as:
    File#open (when path is file)
    Dir#open  (when path is directory)
  mode has an effect only when path is a file

out(dev = STDOUT, &block)

internal commands

rehash()

ProcessCommand#rehash

  clear command hash table.

rmdir(*path)

CommandProcessor#rmdir(*path)

    path: String
  same as Dir.rmdir()

system(command, *opts)

CommandProcessor#system(command, *opts)

    command: String
    opts:      String
    return:  SystemCommand
  Same as system() function
  example:
    print sh.system("ls", "-l")
    sh.system("ls", "-l") | sh.head > STDOUT

tee(file)

test(command, file1, file2=nil)

CommandProcessor#test(command, file1, file2) CommandProcessor#[command, file1, file2]

    command: char or String or Symbol
    file1:   String
    file2:   String(optional)
    return: Boolean
  same as:
    test()     (when command is char or length 1 string or symbol)
    FileTest.command (others)
  example:
    sh[?e, "foo"]
    sh[:e, "foo"]
    sh["e", "foo"]
    sh[:exists?, "foo"]
    sh["exists?", "foo"]

transact(&block)

unlink(path)

CommandProcessor#unlink(path)

  same as:
    Dir#unlink  (when path is directory)
    File#unlink (when path is file)