Optimise basename/dirname operations
authorColin Watson <cjwatson@debian.org>
Thu, 19 Jan 2017 21:22:22 +0000 (21:22 +0000)
committerColin Watson <cjwatson@debian.org>
Thu, 19 Jan 2017 21:22:22 +0000 (21:22 +0000)
Replace basename/dirname with shell string processing (thanks, Hedayat
Vatankhah; part of #694668).

common.sh
debian/changelog
linux-boot-probes/mounted/powerpc/40yaboot
os-probes/mounted/x86/efi/10elilo

index c6d3424..98d39fa 100644 (file)
--- a/common.sh
+++ b/common.sh
@@ -52,7 +52,7 @@ progname=
 cache_progname() {
   case $progname in
     '')
-      progname="$(basename "$0")"
+      progname="${0##*/}"
       ;;
   esac
 }
index f93db02..a96b667 100644 (file)
@@ -21,6 +21,8 @@ os-prober (1.72) UNRELEASED; urgency=medium
     options (thanks, Hedayat Vatankhah; closes: #674561).
   * Disable debugging if OS_PROBER_DISABLE_DEBUG is set (thanks, Hedayat
     Vatankhah; closes: #698598).
+  * Replace basename/dirname with shell string processing (thanks, Hedayat
+    Vatankhah; part of #694668).
 
  -- Colin Watson <cjwatson@debian.org>  Sat, 31 Dec 2016 17:11:49 +0000
 
index 2bb6765..764621c 100755 (executable)
@@ -27,7 +27,7 @@ recordstanza () {
                fi
 
                if [ -z "$title" ]; then
-                       title="$(basename "$kernel")"
+                       title="${kernel##*/}"
                fi
                if [ "$read_only" ]; then
                        parameters="ro $parameters"
index 72dc462..d815b52 100755 (executable)
@@ -9,8 +9,8 @@ found=
 
 elilo=`find $1 -name "elilo.efi"`
 if [ -n "$elilo" ]; then
-       bdir=`dirname $elilo`
-       bdir=`basename $bdir`
+       bdir="${elilo%/*}"
+       bdir="${elilo##*/}"
        long="ELILO Boot Manager"
        short="ELILO"
        path=${bdir}/elilo.efi