Whamcloud - gitweb
Array element access in bash MUST be enclosed with {}.
[fs/lustre-release.git] / build / suse-functions.sh
1 # Readlink is not present on some older distributions: emulate it.
2 readlink() {
3     local path=$1 ll
4
5     if [ -L "$path" ]; then
6         ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" &&
7         echo "${ll/* -> }"
8     else
9         return 1
10     fi
11 }
12 relink() {
13     if [ -h "$2" ]; then
14         local old=$(readlink "$2")
15         [ "$old" = "$1" ] && return 0
16         echo "Changing symlink $2 from $old to $1"
17     elif [ -e "$2" ]; then
18         echo "Replacing file $2 with symlink to $1"
19     fi
20     rm -f "$2" \
21     && ln -s "$1" "$2"
22 }