[test] Avoid unportable echo in Other/lit-quoting.txt

`LLVM :: Other/lit-quoting.txt` currently `FAIL`s on Solaris:

  llvm/test/Other/lit-quoting.txt:8:9: error: CHECK2: expected string not found in input
  CHECK2: {{^a\[b\\c$}}
          ^
  <stdin>:1:1: note: scanning from here
  a[b
  ^

This happens because echo with backslashes or special characters is
unportable, as extensively documented in the Autoconf manual.  In the case
at hand, `echo 'a[b\c'` yields `a[b\c` on Linux, but `a[b` (no newline) on
Solaris.

This patch fixes this by using the portable alternative suggested in the
Autoconf manual.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D108031
This commit is contained in:
Rainer Orth 2021-08-15 00:20:47 +02:00
parent 7aef2e54c8
commit 918dad54bd
1 changed files with 8 additions and 8 deletions

View File

@ -1,14 +1,14 @@
RUN: echo "\"" | FileCheck %s --check-prefix=CHECK1
RUN: echo '"' | FileCheck %s --check-prefix=CHECK1
RUN: echo 'a[b\c' | FileCheck %s --check-prefix=CHECK2
RUN: echo "a[b\\c" | FileCheck %s --check-prefix=CHECK2
RUN: echo 'a\b\\c\\\\d' | FileCheck %s --check-prefix=CHECK3
RUN: echo "a\\b\\\\c\\\\\\\\d" | FileCheck %s --check-prefix=CHECK3
RUN: printf "%%s\n" "\"" | FileCheck %s --check-prefix=CHECK1
RUN: printf "%%s\n" '"' | FileCheck %s --check-prefix=CHECK1
RUN: printf "%%s\n" 'a[b\c' | FileCheck %s --check-prefix=CHECK2
RUN: printf "%%s\n" "a[b\\c" | FileCheck %s --check-prefix=CHECK2
RUN: printf "%%s\n" 'a\b\\c\\\\d' | FileCheck %s --check-prefix=CHECK3
RUN: printf "%%s\n" "a\\b\\\\c\\\\\\\\d" | FileCheck %s --check-prefix=CHECK3
CHECK1: {{^"$}}
CHECK2: {{^a\[b\\c$}}
CHECK3: {{^a\\b\\\\c\\\\\\\\d$}}
On Windows, with MSYS based tools, the following commands fail though:
RUNX: echo 'a[b\c\\d' | FileCheck %s --check-prefix=CHECK4
RUNX: echo "a[b\\c\\\\d" | FileCheck %s --check-prefix=CHECK4
RUNX: printf "%%s\n" 'a[b\c\\d' | FileCheck %s --check-prefix=CHECK4
RUNX: printf "%%s\n" "a[b\\c\\\\d" | FileCheck %s --check-prefix=CHECK4
CHECK4: {{^a\[b\\c\\\\d$}}