Module: Bashcov::BashInfo
- Included in:
- Bashcov
- Defined in:
- lib/bashcov/bash_info.rb
Overview
Note:
methods do not cache results because bash_path
can change at runtime
Note:
receiver is expected to implement bash_path
Module exposing information concerning the installed Bash version
Instance Method Summary collapse
-
#bash_xtracefd? ⇒ Boolean
Whether Bash supports
BASH_XTRACEFD
. -
#truncated_ps4?(length = 128) ⇒ Boolean
Whether Bash supports a
PS4
of at least a given number of bytes.
Instance Method Details
#bash_xtracefd? ⇒ Boolean
Returns Whether Bash supports BASH_XTRACEFD
.
10 11 12 |
# File 'lib/bashcov/bash_info.rb', line 10 def bash_xtracefd? BASH_VERSION >= "4.1" end |
#truncated_ps4?(length = 128) ⇒ Boolean
Note:
Item i.
under the bash-4.2-release
to bash-4.3-alpha
change list notes that version 4.2 truncates PS4
if it is greater than 128 bytes.
Returns whether Bash supports a PS4
of at least a given number of bytes.
21 22 23 24 |
# File 'lib/bashcov/bash_info.rb', line 21 def truncated_ps4?(length = 128) ps4 = SecureRandom.base64(length) !`PS4=#{ps4} #{bash_path} 2>&1 1>&- -xc 'echo hello'`.start_with?(ps4) end |