From bac1404cf13169d9bdf68105629992b2ecf7d771 Mon Sep 17 00:00:00 2001 From: "Fedor A. Fetisov" Date: Mon, 12 May 2014 18:01:13 +0400 Subject: [PATCH] Make flat_cp tool portable to systems without GNU sed --- src/tools/flat_cp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tools/flat_cp b/src/tools/flat_cp index 2e61b97f..be226a36 100755 --- a/src/tools/flat_cp +++ b/src/tools/flat_cp @@ -23,17 +23,17 @@ # source_file=$1 -cut_from=$(sed -r "s/\/+$//" <<< "$3") +cut_from=$(sed "s/\/\{1,\}$//" <<< "$3") if [ $cut_from ] then - cut_from=$(sed -r "s/\//\\\\\//g" <<< "$cut_from") - target_file_name=$(sed -r "s/^(.*)$cut_from\/(.*)$/\2/" <<< "$source_file") + cut_from=$(sed "s/\//\\\\\//g" <<< "$cut_from") + target_file_name=$(sed "s/^\(.*\)$cut_from\/\(.*\)$/\2/" <<< "$source_file") else target_file_name=$source_file fi -target_file_name=$(sed -r "s/\//_/g" <<< "$target_file_name") -target_file=$(sed -r "s/\/?$//" <<< "$2")"/"$target_file_name +target_file_name=$(sed "s/\//_/g" <<< "$target_file_name") +target_file=$(sed "s/\/\{0,1\}$//" <<< "$2")"/"$target_file_name cp $source_file $target_file \ No newline at end of file