Skip to content

Commit 32b7753

Browse files
committed
Safeguard prefix directory operations in SVN testing
Given for some unforeseen error situation DIR is empty, the trap wouldn't operate on the prefix but root. We don't want that under any circumstances und prefer to exit in error. Similarly, we don't want the `cd` operation to take CDPATH into account.
1 parent 824bbf4 commit 32b7753

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test-svn.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/bin/bash
22

3-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
3+
DIR="$( CDPATH='' cd -- "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
4+
[ "$DIR" ] || exit
45

56
svn --help > /dev/null || { echo "Fail: could not find 'svn' executable"; exit 1; }
67
svnadmin --help > /dev/null || { echo "Fail: could not find 'svnadmin' executable"; exit 1; }
78

89
trap cleanup INT ERR
910

1011
function cleanup() {
11-
cd "$DIR/test-data"
12+
cd "$DIR/test-data" || exit
1213
rm -rf proj proj-working svnrepo
1314
}
1415

0 commit comments

Comments
 (0)