Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2022-11-09 22:31:09 +0300
committerBryan Drewery <bryan@shatow.net>2022-11-10 02:06:20 +0300
commit874616addcc7eafe407fb57fe4354721e5901d4b (patch)
treec7a20d0be19a9097161f8a78fc19f8ddbc61c115
parent48d8ce431d7559338aa626b055c72af0ec1e3c41 (diff)
mapfile sh compat: Fix handling of escapes
-rw-r--r--src/share/poudriere/include/util.sh2
-rw-r--r--test/mapfile.sh14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/share/poudriere/include/util.sh b/src/share/poudriere/include/util.sh
index 657c5a65..a4fc4d34 100644
--- a/src/share/poudriere/include/util.sh
+++ b/src/share/poudriere/include/util.sh
@@ -699,7 +699,7 @@ mapfile_read() {
fi
hash_get mapfile_fd "${handle}" fd || fd=8
- read_blocking "$@" <&${fd}
+ read_blocking -r "$@" <&${fd}
}
mapfile_write() {
diff --git a/test/mapfile.sh b/test/mapfile.sh
index 81054f1a..0d96c6ce 100644
--- a/test/mapfile.sh
+++ b/test/mapfile.sh
@@ -208,6 +208,20 @@ if mapfile_builtin; then
}
fi
+# Test \ handling
+{
+ TMP=$(mktemp -t mapfile)
+
+ expected='\blah\\b\\\\lah'
+ echo "${expected}" >> "${TMP}"
+ assert_ret 0 mapfile handle "${TMP}" "re"
+ unset line
+ assert_ret 0 mapfile_read "${handle}" line
+ assert_ret 0 mapfile_close "${handle}"
+ assert "${expected}" "${line}" "line with backslashes should match"
+ rm -f "${TMP}"
+}
+
# Should only return full lines as read(1) does
{
rm -f "${TMP}"