[libav-devel] [PATCH] fate: Make oneline comparison ignore CR

Måns Rullgård mans at mansr.com
Tue May 8 01:32:00 CEST 2012

Alex Converse <alex.converse at gmail.com> writes:

> ---
>  tests/fate-run.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> diff --git a/tests/fate-run.sh b/tests/fate-run.sh
> index a45e9a9..2522a21 100755
> --- a/tests/fate-run.sh
> +++ b/tests/fate-run.sh
> @@ -61,7 +61,7 @@ stddev(){
>  }
>  oneline(){
> -    val=$(cat "$2")
> +    val=$(cat "$2" | tr -d '\r')
>      test x"$val" = x"$1" || { r=$?; printf -- '-%s\n+%s\n' "$ref" "$val"; }
>      return ${r:-0}
>  }
> -- 
> Fixes tests on mingw-w64. Feel free to suggest other approaches.

Fix mingw.  This is not a compliant shell.

Quoting POSIX:

  [Base Definitions] 3.238 Newline Character (<newline>)

  A character that in the output stream indicates that printing should
  start at the beginning of the next line. It is the character
  designated by '\n' in the C language. It is unspecified whether this
  character is the exact sequence transmitted to an output device by the
  system to accomplish the movement to the next line.


  [Shell & Utilities] 2.6.3 Command Substitution

  [...] The shell shall expand the command substitution by executing
  command in a subshell environment (see Shell Execution Environment)
  and replacing the command substitution (the text of command plus the
  enclosing "$()" or backquotes) with the standard output of the
  command, removing sequences of one or more <newline> characters at the
  end of the substitution.

It is clear from this that command substitution should strip from the
command whatever '\n' in C translates to on the platform.

Our policy is to not work around OS bugs in ugly ways.

Måns Rullgård
mans at mansr.com

More information about the libav-devel mailing list