aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Robbins <contact@andrewrobbins.info>2017-06-27 12:21:09 -0400
committerAndrew Robbins <contact@andrewrobbins.info>2017-06-28 00:21:27 -0400
commit9a67491b91bfc476d8c1c30dc2932d1967fb6720 (patch)
tree0744ba4b023a6c70d132db584e36a3cb044af006
parentf1c378c027db012956d5e8a9585004250550d581 (diff)
downloadlibrebootfr-9a67491b91bfc476d8c1c30dc2932d1967fb6720.tar.gz
librebootfr-9a67491b91bfc476d8c1c30dc2932d1967fb6720.zip
Fixed bug in diff_patch_file() filename parsing.
-rwxr-xr-xlibs/common7
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/common b/libs/common
index c5c89483..7898f115 100755
--- a/libs/common
+++ b/libs/common
@@ -86,12 +86,13 @@ diff_patch_file() {
local repository_path="$1"
local patch_file_path="$2"
- local filename_in_diff="$(sed -rne 's/^-{3} {1}(.*)$/\1/p' <"${patch_file_path}")"
+ # TODO: Improve handling of filenames to avoid gotchas w/ \n, \t, etc.
+ local filename_in_diff="$(sed -rne 's/^-{3}\s+([^ \r\n]*).*/\1/p' "${patch_file_path}")"
local source_file_path
- if ! ( grep -E '^-{3}.*/' <"${patch_file_path}" >/dev/null 2>&1 ); then
- source_file_path="${repository_path}/${filename_in_diff##\ }"
+ if ! ( grep -E '^-{3}.*/' "${patch_file_path}" >/dev/null 2>&1 ); then
+ source_file_path="${repository_path}/${filename_in_diff}"
else
source_file_path="${repository_path}/${filename_in_diff##*/}"
fi