summaryrefslogtreecommitdiff
path: root/test/system/helpers.bash
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-24 09:50:11 +0000
committerGitHub <noreply@github.com>2020-09-24 09:50:11 +0000
commit08cc91926db1cd17509f8578e2ff00a94747dbd4 (patch)
tree60da5f1fe45554632f80351f5217bf46db2208d7 /test/system/helpers.bash
parent9765619787c494b8cb53ec15e45e0b3c64eee498 (diff)
parente62848752561640ecad72901938d0c0c5c17ed9a (diff)
downloadpodman-08cc91926db1cd17509f8578e2ff00a94747dbd4.tar.gz
podman-08cc91926db1cd17509f8578e2ff00a94747dbd4.tar.bz2
podman-08cc91926db1cd17509f8578e2ff00a94747dbd4.zip
Merge pull request #7763 from edsantiago/bats_better_parse_table
system tests: helpers: safer parse_table
Diffstat (limited to 'test/system/helpers.bash')
-rw-r--r--test/system/helpers.bash7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index 514ba249e..112b73962 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -376,7 +376,12 @@ function parse_table() {
while read col; do
dprint "col=<<$col>>"
row+=("$col")
- done < <(echo "$line" | tr '|' '\012' | sed -e 's/^ *//' -e 's/\\/\\\\/g')
+ done < <(echo "$line" | sed -E -e 's/(^|\s)\|(\s|$)/\n /g' | sed -e 's/^ *//' -e 's/\\/\\\\/g')
+ # the above seds:
+ # 1) Convert '|' to newline, but only if bracketed by spaces or
+ # at beginning/end of line (this allows 'foo|bar' in tests);
+ # 2) then remove leading whitespace;
+ # 3) then double-escape all backslashes
printf "%q " "${row[@]}"
printf "\n"