This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-108
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-108 by this push:
new ca50d83 WIP.
ca50d83 is described below
commit ca50d8321b3e30c368296c94c2ad877006a636d8
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Fri Oct 2 23:50:13 2020 -0700
WIP.
---
bin/nlpcraft.sh | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/bin/nlpcraft.sh b/bin/nlpcraft.sh
index ffecba7..50759ba 100755
--- a/bin/nlpcraft.sh
+++ b/bin/nlpcraft.sh
@@ -20,8 +20,43 @@
# NOTE: this script uses ANSI color sequences by default.
#
+#
+# POSIX-complaint implementation for GNU "readlink -f" functionality.
+# Works on Linux/MacOS.
+#
+readlinkf_posix() {
+ [ "${1:-}" ] || return 1
+ max_symlinks=40
+ CDPATH=''
+
+ target=$1
+ [ -e "${target%/}" ] || target=${1%"${1##*[!/]}"}
+ [ -d "${target:-/}" ] && target="$target/"
+
+ cd -P . 2>/dev/null || return 1
+ while [ "$max_symlinks" -ge 0 ] && max_symlinks=$((max_symlinks - 1)); do
+ if [ ! "$target" = "${target%/*}" ]; then
+ case $target in
+ /*) cd -P "${target%/*}/" 2>/dev/null || break ;;
+ *) cd -P "./${target%/*}" 2>/dev/null || break ;;
+ esac
+ target=${target##*/}
+ fi
+
+ if [ ! -L "$target" ]; then
+ target="${PWD%/}${target:+/}${target}"
+ printf '%s\n' "${target:-/}"
+ return 0
+ fi
+
+ link=$(ls -dl -- "$target" 2>/dev/null) || break
+ target=${link#*" $target -> "}
+ done
+ return 1
+}
+
# Absolute directory path of this script.
-SCRIPT_HOME="$(dirname "$(readlink -f "$0")")"
+SCRIPT_HOME="$(dirname $(readlinkf_posix "$0"))"
# Filename of the script.
SCRIPT_NAME="$(basename "$0")"