commit cbeff0f327045c34ed4ea744a981a04224152e3b Author: Simone Basso bassosimone@gmail.com Date: Fri Oct 9 09:38:42 2015 +0200
Make bin/ooniprobe-dev portable
- use a portable recipe to get the absolute path of the toplevel directory where ooni-probe sources are located [1]
- make sure we exit with a meaningful error message if it is not possible to get the toplevel directory name
- while there put quotes around $@ since according to [2] this is the best way to forward shell script arguments
.. [1] http://serverfault.com/questions/40144
.. [2] http://stackoverflow.com/questions/255898/how-to-iterate-over-arguments-in-b... --- bin/ooniprobe-dev | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/bin/ooniprobe-dev b/bin/ooniprobe-dev index b85d3a3..7eaaf40 100755 --- a/bin/ooniprobe-dev +++ b/bin/ooniprobe-dev @@ -2,5 +2,9 @@ # Developer script for running ooniprobe directly from the repository. # We don't automatically add "$PWD" to PYTHONPATH as that is a security risk # when run as /usr/bin/ooniprobe on an end user's computer. -cd "$(realpath "$(dirname "$0")")/.." -PYTHONPATH="$PWD" exec ./bin/ooniprobe $@ +ROOTDIR=$(cd $(dirname $(dirname $0)) && pwd -P) +if [ $? -ne 0 ]; then + echo "$0: cannot determine toplevel directory" 1>&2 + exit 1 +fi +PYTHONPATH="$ROOTDIR" exec ./bin/ooniprobe "$@"
tor-commits@lists.torproject.org