]> git.plutz.net Git - shellwiki/blobdiff - tools.sh
speed improvement: save fork when checking mdfile existence
[shellwiki] / tools.sh
index c5545fb92e0cecc8975627514b7d80b32ea16aff..de055fe808049e2afbc3b925a1f19f1f06413d5f 100755 (executable)
--- a/tools.sh
+++ b/tools.sh
@@ -12,15 +12,21 @@ else
 fi
 
 mdfile(){
+  #  Check if page exists, if possible fall
+  #  back to default page from installation
   local page="$(PATH "$1")"
 
   if   [ -f "$_DATA/pages/$page/#page.md" ]; then
     printf %s\\n "$_DATA/pages/$page/#page.md"
+    return 0
   elif [ -f "$_EXEC/pages/$page/#page.md" ]; then
     printf %s\\n "$_EXEC/pages/$page/#page.md"
+    return 0
   else
     return 1
-  fi
+  fi 2>&-
+  #  ^^ suppress error messages produced
+  #     by printf when stdout was closed
 }
 
 size_human(){