commit 66ac9466852d11e968f8fd2ad6ffc7386cee49e1
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 1 Mar 2019 01:03:54 +0000 (01:03 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 1 Mar 2019 01:03:54 +0000 (01:03 +0000)
    gotest: avoid using echo inside $()

    The handling of newlines is not portable between bash and ksh.

    Reviewed-on: https://go-review.googlesource.com/c/164597

From-SVN: r269298

gcc/go/gofrontend/MERGE
libgo/testsuite/gotest

index e997df8f36fd8b0abd19fc59aa273ad82458c262..b5e9eedb2b6196d644a670b462d837c0c87b6b33 100644 (file)
@@ -1,4 +1,4 @@
-08f1c400ec95d70a5cf5a08b1600fa5445e42361
+66ac9466852d11e968f8fd2ad6ffc7386cee49e1
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 06000eae60eac8c8f4ab46c23997762482b6c1e5..c9c14652c76ae0490dbeacf219fbe81d8def451f 100755 (executable)
@@ -619,21 +619,25 @@ symtogo() {
                    # Turn pairs of spaces into " \x20", because $() will
                    # drop duplicate spaces.
                    # Drop trailing spaces, and turn newlines into \n.
-                   output="$(sed '1 s/\([Uu]nordered \)\?[Oo]utput:[   ]*//' < example.txt |
+                   # Remove leading and trailing \n.
+                   sed '1 s/\([Uu]nordered \)\?[Oo]utput:[     ]*//' < example.txt |
                                 sed -e 's/\\/\\\\/g' \
                                     -e 's/"/\\"/g' \
                                     -e 's/     /\\t/g' \
                                     -e 's/  / \\x20/g' \
                                     -e 's/[    ]*$/\\n/g' |
-                                tr -d '\n')"
-                   # Remove leading and trailing \n.
-                   output="$(echo "$output" | sed -e 's/^\(\\n\)*//' -e 's/\(\\n\)*$//')"
+                                tr -d '\n' |
+                                sed -e 's/^\(\\n\)*//' \
+                                    -e 's/\(\\n\)*$//' > example2.txt
                    hasoutput=true
                    rm -f example.txt
                    break
                done
                if test x$hasoutput = xtrue; then
-                   echo '      {"'$n'", '$j', "'"$output"'", '$unordered'},'
+                   echo '      {"'$n'", '$j','
+                   sed -e 's/^/                "/' -e 's/$/", /' < example2.txt
+                   echo $unordered'},'
+                   rm -f example2.txt
                fi
        done
        echo '}'