kinow commented on code in PR #607:
URL: https://github.com/apache/opennlp/pull/607#discussion_r1641918499


##########
opennlp-brat-annotator/src/main/bin/brat-annotation-service:
##########
@@ -21,6 +21,28 @@
 #        may be inadvertantly placed in any output files if
 #        output redirection is used.
 
+# determine OPENNLP_HOME - $0 may be a symlink to OpenNLP's home
+PRG="$0"
+
+while [ -h "$PRG" ] ; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG="`dirname "$PRG"`/$link"
+  fi
+done

Review Comment:
   I think `realpath` is available in Debian/Ubuntu for a while (from gnu 
coreutils? I think). And it should be available on macos too (at least I 
remember using it on an old Intel mac).
   
   I think the code above is doing something similar to `realpath`, but using 
`expr` to parse the output of the commands with regex, or use `dirname` 
(although I am not sure if that works if the regex failed but the file is still 
a symlink?).
   
   Is there a reason for not using `realpath` here? Or something else like 
`pushd $PRG ; PRG=pwd -P; popd`  (or in a subshell, etc.)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to