[yelp-tools] yelp-build: Fix some broken and non-portable expr usage, #743911



commit 529e23b8bb5357f33fef143564b0dac64186a177
Author: Shaun McCance <shaunm gnome org>
Date:   Sun May 31 23:52:05 2015 -0400

    yelp-build: Fix some broken and non-portable expr usage, #743911
    
    Both `expr index` and `expr substr` are non-portable. What's more,
    my usage of `expr index` was wrong, and there was a bug that nobody
    ever seemed to trip up. Fix it and use portable stuff.
    
    Bug #743911 partially addressed.

 tools/yelp-build.in |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/tools/yelp-build.in b/tools/yelp-build.in
index a38bbf8..aeb8e56 100755
--- a/tools/yelp-build.in
+++ b/tools/yelp-build.in
@@ -295,9 +295,8 @@ yelp_html_db2html () {
                 moutput="$html_out/$mfile"
                 mkdir_p `dirname "$moutput"`
                 if [ ! -f "$minput" -a "x$html_paths" != "x" ]; then
-                    if [ $(expr index "$minput" "$(pwd)/") = 1 ]; then
-                        minput_rel=$(expr substr "$minput" \
-                            $(expr length "$(pwd)//") $(expr length "$minput"))
+                   minput_rel=${minput#"$(pwd)/"}
+                   if [ "x$minput_rel" != "x$minput_src" ]; then
                         for path in $html_paths; do
                             if [ -f "$path/$minput_rel" ]; then
                                 minput="$path/$minput_rel"
@@ -434,9 +433,8 @@ yelp_html_mal2html () {
             line_dest="$html_out/"`echo "$line" | cut -d' ' -f2`
         fi
         if [ ! -f "$line_src" -a "x$html_paths" != "x" ]; then
-            if [ $(expr index "$line_src" "$(pwd)/") = 1 ]; then
-                line_src_rel=$(expr substr "$line_src" \
-                    $(expr length "$(pwd)//") $(expr length "$line_src"))
+           line_src_rel=${line_src#"$(pwd)/"}
+           if [ "x$line_src_rel" != "x$line_src" ]; then
                 for path in $html_paths; do
                     if [ -f "$path/$line_src_rel" ]; then
                         line_src="$path/$line_src_rel"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]