From 08635b658b6d9ec96393b773eea7ac8c012aef5a Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 14 May 2010 17:47:25 +0200 Subject: [PATCH] Make bin/pegjs work when called via a symlink Similar issue exists on Windows too (they have symlinks since Vista), but I could not find how to dereference symlinks from batch files, so I did not fix it. I guess this does not matter much given how little the symlinks are used in the Windows world. Closes #1. --- bin/pegjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/pegjs b/bin/pegjs index 8f63320..276c2b6 100755 --- a/bin/pegjs +++ b/bin/pegjs @@ -1,4 +1,10 @@ #!/bin/sh -DIR=`dirname "$0"` +if [ -L "$0" ]; then + THIS_FILE=`readlink "$0"` +else + THIS_FILE=$0 +fi +DIR=`dirname "$THIS_FILE"` + java -jar "$DIR/../vendor/rhino/js.jar" "$DIR/pegjs-main.js" "$DIR" "$@"