$stderr  –  STDERR of The Last run Command

$stderr contains the output on STDERR of the last executed run command. This variable is only available if run was executed with --separate-stderr.

Examples

Split output of run into STDOUT and STDERR
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
@test "Example" {
  # enable support for flags of the run command
  bats_require_minimum_version 1.5.0
    
  # keep output on STDERR in $stderr and $stderr_lines
  run --separate-stderr cat nonexistent_filename
  echo "Status: $status" >&3
  echo "Output: $stderr" >&3
  echo "First line: ${stderr_lines[0]}" >&3
}
BashSupport Pro is a shell script IDE with support for bats-core’s $stderrtry it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal