Class: AssLauncher::Support::Shell::Script Private

Inherits:
Command
  • Object
show all
Includes:
Platforms
Defined in:
lib/ass_launcher/support/shell.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

What reason for it? Reason for it:

Fucking 1C binary often unexpected parse cmd arguments if run in shell like ‘1c.exe arguments`. For correction this invented two way run 1C binary: as command see Command or as script see Script. If run 1C as command we can control executing process wait exit or kill 1C binary process. If run 1C as script 1C more correctly parse arguments but we can’t kill subprosess running in cmd.exe

Note:

On default use silient execute 1C binary whit /DisableStartupDialogs, /DisableStartupMessages parameters and capture 1C output /OUT parameter. Read message from /OUT when 1C binary process exit and build instnce of RunAssResult.

Note:

Fucking 1C not work with stdout and stderr For out 1C use /OUT“file” parameter and write message into. Message encoding ‘cp1251’ for windows and ‘utf-8’ for Linux

class Script wraping cmd string in to script tempfile and running as: popen3(‘cmd.exe’, ‘/C’, ‘tempfile’ in cygwin or windows or popen3(‘sh’, ‘tempfile’) in linux

Constant Summary

Constants inherited from Command

Command::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Command

#options, #process_holder

Instance Method Summary collapse

Methods included from Platforms

cygwin?, env, glob, linux?, path, path_class, windows?

Methods inherited from Command

#capture_assout?, #exit_handling, #running?

Constructor Details

#initialize(cmd, options = {}) ⇒ Script

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Script.

Parameters:

  • cmd (String)

    cmd string for executing as cmd.exe or sh script

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :assout_encoding (String)

    encoding for assoutput file. Default ‘cp1251’

  • :capture_assout (Boolean)

    capture assoutput. Default true

  • :silent_mode (Boolean)

    run 1C with /DisableStartupDialogs and /DisableStartupMessages parameters. Default true



227
228
229
# File 'lib/ass_launcher/support/shell.rb', line 227

def initialize(cmd, options = {})
  super cmd, [], options
end

Instance Method Details

#argsArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return args for run shell script

Returns:

  • (Array)


287
288
289
290
291
292
293
# File 'lib/ass_launcher/support/shell.rb', line 287

def args
  if cygwin_or_windows?
    ['/C', make_script.win_string]
  else
    [make_script.to_s]
  end.freeze
end

#cmdString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returm shell binary ‘cmd.exe’ or ‘sh’

Returns:



277
278
279
280
281
282
283
# File 'lib/ass_launcher/support/shell.rb', line 277

def cmd
  if cygwin_or_windows?
    'cmd.exe'
  else
    'sh'
  end
end

#run(options = {}) ⇒ ProcessHolder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run script. Script wait process exit

Parameters:

  • options (Hash) (defaults to: {})

    options for Process.spawn

Returns:



309
310
311
312
# File 'lib/ass_launcher/support/shell.rb', line 309

def run(options = {})
  ph = super
  ph.wait
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

used @cmd and @args variable for reason! In class AssLauncher::Support::Shell::Script methods #cmd and #args returns command and args for run script in sh or cmd.exe but #to_s return content for script



266
267
268
# File 'lib/ass_launcher/support/shell.rb', line 266

def to_s
  "#{@cmd} #{@args.join(' ')}"
end