[ https://issues.apache.org/jira/browse/OPENNLP-1568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17855429#comment-17855429 ]
ASF GitHub Bot commented on OPENNLP-1568: ----------------------------------------- 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.)? > opennlp command fails when invoked from outside $OPENNLP_HOME/bin directory > --------------------------------------------------------------------------- > > Key: OPENNLP-1568 > URL: https://issues.apache.org/jira/browse/OPENNLP-1568 > Project: OpenNLP > Issue Type: Bug > Components: Command Line Interface > Affects Versions: 2.3.3 > Environment: Linux/Bash > Reporter: Alexander Veit > Priority: Major > > Try to run the opennlp command from outside $OPENNLP_HOME/bin directory. > It fails with an error message similar to > > {noformat} > 2024-06-15T22:44:04.900344345Z main ERROR Reconfiguration failed: > No configuration found for '4f2410ac' at 'null' in 'null'{noformat} > > The error is caused by the relative path in > {code:java} > -Dlog4j.configurationFile=../conf/log4j2.xml {code} > of the opennlp script. -- This message was sent by Atlassian Jira (v8.20.10#820010)