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

Instance Method Details

#bash_xtracefd?Boolean

Returns Whether Bash supports BASH_XTRACEFD.

Returns:

  • (Boolean)

    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.

Parameters:

  • length (Integer) (defaults to: 128)

    the number of bytes to test; default 128

Returns:

  • (Boolean)

    whether Bash supports a PS4 of at least a given number of bytes

See Also:



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