Class: Yast::Execute
- Inherits:
-
Object
- Object
- Yast::Execute
- Extended by:
- Forwardable
- Includes:
- I18n
- Defined in:
- library/system/src/lib/yast2/execute.rb
Overview
A module for executing scripts/programs in a safe way (not prone to shell quoting bugs). It uses Cheetah as the backend, but adds support for chrooting during the installation. It also globally switches the default Cheetah logger to Y2Logger.
To limit logging sensitive input/output/arguments, you can pass a ReducedRecorder as the recorder option.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Execute
constructor
Constructor.
-
#locally(*args) ⇒ Object
Runs without chroot; a failure becomes a popup.
-
#locally!(*args) ⇒ Object
Runs without chroot; a failure becomes an exception.
-
#on_target(*args) ⇒ Object
Runs with chroot; a failure becomes a popup.
-
#on_target!(*args) ⇒ Object
Runs with chroot; a failure becomes an exception.
-
#run_or_chain(args) ⇒ Object, ExecuteClass
protected
Decides either to run the command or to chain the call in case that no argmuments are given.
-
#stdout(*args) ⇒ String
Runs a command described by args and returns its output.
Constructor Details
#initialize(options = {}) ⇒ Execute
Constructor
60 61 62 63 64 |
# File 'library/system/src/lib/yast2/execute.rb', line 60 def initialize( = {}) textdomain "base" @options = end |
Instance Method Details
#locally(*args) ⇒ Object
99 100 101 |
# File 'library/system/src/lib/yast2/execute.rb', line 99 def locally(*args) chaining_object(yast_popup: true).locally!(*args) end |
#locally!(*args) ⇒ Object
Runs without chroot; a failure becomes an exception.
Runs a command described by args,
disregarding a chroot(2)
specified by the installation (WFM.scr_root).
It also globally switches the default Cheetah logger to
Y2Logger.
110 111 112 |
# File 'library/system/src/lib/yast2/execute.rb', line 110 def locally!(*args) run_or_chain(args) end |
#on_target(*args) ⇒ Object
74 75 76 |
# File 'library/system/src/lib/yast2/execute.rb', line 74 def on_target(*args) chaining_object(yast_popup: true).on_target!(*args) end |
#on_target!(*args) ⇒ Object
Runs with chroot; a failure becomes an exception.
Runs a command described by args,
in a chroot(2)
specified by the installation (WFM.scr_root).
It also globally switches the default Cheetah logger to
Y2Logger.
85 86 87 88 89 |
# File 'library/system/src/lib/yast2/execute.rb', line 85 def on_target!(*args) root = Yast::WFM.scr_root chaining_object(chroot: root).run_or_chain(args) end |
#run_or_chain(args) ⇒ Object, ExecuteClass (protected)
Decides either to run the command or to chain the call in case that no argmuments are given.
132 133 134 |
# File 'library/system/src/lib/yast2/execute.rb', line 132 def run_or_chain(args) args.none? ? self : run(*args) end |
#stdout(*args) ⇒ String
Runs a command described by args and returns its output
It also globally switches the default Cheetah logger to Y2Logger.
121 122 123 |
# File 'library/system/src/lib/yast2/execute.rb', line 121 def stdout(*args) chaining_object(yast_stdout: true, stdout: :capture).run_or_chain(args) end |