From d1e7e7ada924bceda66d6dffa46e559abd919a2b Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Fri, 7 Sep 2018 18:54:30 -0500 Subject: [PATCH] FIXED: Fix PATH in convenience scripts Add the convenience script's directory to PATH, on the assumption that the multimarkdown executable is in the same directory. Remove $PWD from PATH, because there's no reason why we should expect the user's shell to have been changed to the directory that contains multimarkdown. export PATH separately from setting PATH, because older shells can't do both at once. unset CDPATH because if a user had exported it, it could change the behavior of cd. --- scripts/markdown | 12 +++++++++++- scripts/mmd | 12 +++++++++++- scripts/mmd2all | 12 +++++++++++- scripts/mmd2epub | 14 ++++++++++++-- scripts/mmd2fodt | 12 +++++++++++- scripts/mmd2odt | 12 +++++++++++- scripts/mmd2opml | 12 +++++++++++- scripts/mmd2pdf | 12 +++++++++++- scripts/mmd2tex | 12 +++++++++++- 9 files changed, 100 insertions(+), 10 deletions(-) diff --git a/scripts/markdown b/scripts/markdown index f59c5db..19a0d39 100755 --- a/scripts/markdown +++ b/scripts/markdown @@ -8,7 +8,17 @@ # # Be sure to include multimarkdown in our PATH -export PATH="$PWD:/usr/local/bin:$PATH" +unset CDPATH +SCRIPT="$0" +while + DIR="$(cd -P -- "$(dirname -- "$SCRIPT")" && pwd)" + test -h "$SCRIPT" +do + SCRIPT="$(readlink "$SCRIPT")" + [ "$SCRIPT" = "${SCRIPT#/}" ] && SCRIPT="$DIR/$SCRIPT" +done +PATH="$DIR:/usr/local/bin:$PATH" +export PATH which multimarkdown > /dev/null if [ $? = 1 ] diff --git a/scripts/mmd b/scripts/mmd index 6f37362..a1a6aa7 100755 --- a/scripts/mmd +++ b/scripts/mmd @@ -8,7 +8,17 @@ # # Be sure to include multimarkdown in our PATH -export PATH="$PWD:/usr/local/bin:$PATH" +unset CDPATH +SCRIPT="$0" +while + DIR="$(cd -P -- "$(dirname -- "$SCRIPT")" && pwd)" + test -h "$SCRIPT" +do + SCRIPT="$(readlink "$SCRIPT")" + [ "$SCRIPT" = "${SCRIPT#/}" ] && SCRIPT="$DIR/$SCRIPT" +done +PATH="$DIR:/usr/local/bin:$PATH" +export PATH which multimarkdown > /dev/null if [ $? = 1 ] diff --git a/scripts/mmd2all b/scripts/mmd2all index 94b8987..0c12310 100755 --- a/scripts/mmd2all +++ b/scripts/mmd2all @@ -9,7 +9,17 @@ # # Be sure to include multimarkdown in our PATH -export PATH="$PWD:/usr/local/bin:$PATH" +unset CDPATH +SCRIPT="$0" +while + DIR="$(cd -P -- "$(dirname -- "$SCRIPT")" && pwd)" + test -h "$SCRIPT" +do + SCRIPT="$(readlink "$SCRIPT")" + [ "$SCRIPT" = "${SCRIPT#/}" ] && SCRIPT="$DIR/$SCRIPT" +done +PATH="$DIR:/usr/local/bin:$PATH" +export PATH which multimarkdown > /dev/null if [ $? = 1 ] diff --git a/scripts/mmd2epub b/scripts/mmd2epub index 11f7797..7643541 100755 --- a/scripts/mmd2epub +++ b/scripts/mmd2epub @@ -1,6 +1,6 @@ #!/bin/sh # -# mmd2oepub --- MultiMarkdown convenience script +# mmd2epub --- MultiMarkdown convenience script # # Fletcher T. Penney # @@ -8,7 +8,17 @@ # # Be sure to include multimarkdown in our PATH -export PATH="$PWD:/usr/local/bin:$PATH" +unset CDPATH +SCRIPT="$0" +while + DIR="$(cd -P -- "$(dirname -- "$SCRIPT")" && pwd)" + test -h "$SCRIPT" +do + SCRIPT="$(readlink "$SCRIPT")" + [ "$SCRIPT" = "${SCRIPT#/}" ] && SCRIPT="$DIR/$SCRIPT" +done +PATH="$DIR:/usr/local/bin:$PATH" +export PATH which multimarkdown > /dev/null if [ $? = 1 ] diff --git a/scripts/mmd2fodt b/scripts/mmd2fodt index 64258d1..745755b 100755 --- a/scripts/mmd2fodt +++ b/scripts/mmd2fodt @@ -8,7 +8,17 @@ # # Be sure to include multimarkdown in our PATH -export PATH="$PWD:/usr/local/bin:$PATH" +unset CDPATH +SCRIPT="$0" +while + DIR="$(cd -P -- "$(dirname -- "$SCRIPT")" && pwd)" + test -h "$SCRIPT" +do + SCRIPT="$(readlink "$SCRIPT")" + [ "$SCRIPT" = "${SCRIPT#/}" ] && SCRIPT="$DIR/$SCRIPT" +done +PATH="$DIR:/usr/local/bin:$PATH" +export PATH which multimarkdown > /dev/null if [ $? = 1 ] diff --git a/scripts/mmd2odt b/scripts/mmd2odt index a0acc66..f8985c6 100755 --- a/scripts/mmd2odt +++ b/scripts/mmd2odt @@ -8,7 +8,17 @@ # # Be sure to include multimarkdown in our PATH -export PATH="$PWD:/usr/local/bin:$PATH" +unset CDPATH +SCRIPT="$0" +while + DIR="$(cd -P -- "$(dirname -- "$SCRIPT")" && pwd)" + test -h "$SCRIPT" +do + SCRIPT="$(readlink "$SCRIPT")" + [ "$SCRIPT" = "${SCRIPT#/}" ] && SCRIPT="$DIR/$SCRIPT" +done +PATH="$DIR:/usr/local/bin:$PATH" +export PATH which multimarkdown > /dev/null if [ $? = 1 ] diff --git a/scripts/mmd2opml b/scripts/mmd2opml index 7ffa149..c4b9ed6 100755 --- a/scripts/mmd2opml +++ b/scripts/mmd2opml @@ -8,7 +8,17 @@ # # Be sure to include multimarkdown in our PATH -export PATH="$PWD:/usr/local/bin:$PATH" +unset CDPATH +SCRIPT="$0" +while + DIR="$(cd -P -- "$(dirname -- "$SCRIPT")" && pwd)" + test -h "$SCRIPT" +do + SCRIPT="$(readlink "$SCRIPT")" + [ "$SCRIPT" = "${SCRIPT#/}" ] && SCRIPT="$DIR/$SCRIPT" +done +PATH="$DIR:/usr/local/bin:$PATH" +export PATH which multimarkdown > /dev/null if [ $? = 1 ] diff --git a/scripts/mmd2pdf b/scripts/mmd2pdf index 1afe5a5..d8463a6 100755 --- a/scripts/mmd2pdf +++ b/scripts/mmd2pdf @@ -15,7 +15,17 @@ # LaTeX file. # Be sure to include multimarkdown and latex in our PATH -export PATH="$PWD:/usr/local/bin:/usr/texbin:/Library/TeX/texbin:$PATH" +unset CDPATH +SCRIPT="$0" +while + DIR="$(cd -P -- "$(dirname -- "$SCRIPT")" && pwd)" + test -h "$SCRIPT" +do + SCRIPT="$(readlink "$SCRIPT")" + [ "$SCRIPT" = "${SCRIPT#/}" ] && SCRIPT="$DIR/$SCRIPT" +done +PATH="$DIR:/usr/local/bin:/usr/texbin:/Library/TeX/texbin:$PATH" +export PATH which multimarkdown > /dev/null if [ $? = 1 ] diff --git a/scripts/mmd2tex b/scripts/mmd2tex index 2cac18d..317ba75 100755 --- a/scripts/mmd2tex +++ b/scripts/mmd2tex @@ -8,7 +8,17 @@ # # Be sure to include multimarkdown in our PATH -export PATH="$PWD:/usr/local/bin:$PATH" +unset CDPATH +SCRIPT="$0" +while + DIR="$(cd -P -- "$(dirname -- "$SCRIPT")" && pwd)" + test -h "$SCRIPT" +do + SCRIPT="$(readlink "$SCRIPT")" + [ "$SCRIPT" = "${SCRIPT#/}" ] && SCRIPT="$DIR/$SCRIPT" +done +PATH="$DIR:/usr/local/bin:$PATH" +export PATH which multimarkdown > /dev/null if [ $? = 1 ] -- 2.40.0