Fixed typo, added function add_to_var

The function for use in setup hooks. The syntax is very simple:

add_to_var varName needDir addDir prefix

If the directory $prefix$needDir exists, directory $prefix$addDir is added to
variable named varName (using PATH_DELIMITER as delimiter). If addDir is "", it
defaults to needDir (this is a most common case).

svn path=/nixpkgs/trunk/; revision=9496
This commit is contained in:
Yury G. Kudryashov 2007-10-19 19:29:36 +00:00
parent 4152053259
commit c4c17a7843

View file

@ -8,6 +8,25 @@ else
PATH_DELIMITER=':'
fi
add_to_var_with_delim() {
local delimiter=$1
local varName=$2
local needDir=$3
local addDir=${4:-$needDir}
local prefix=$5
if [ -d $prefix$needDir ]; then
if [ -z ${!varName} ]; then
eval export ${varName}=${prefix}$addDir
else
eval export ${varName}=${!varName}${delimiter}${prefix}$addDir
fi
fi
}
add_to_var()
{
add_to_var_with_delim "${PATH_DELIMITER}" "$@"
}
# Set up the initial path.
PATH=
@ -739,7 +758,7 @@ fixupW() {
if test -d "$prefix/share/$d"; then
echo "Both $d/ and share/$d/ exists!"
else
echo Fixing location of $dir/ subdirectory
echo Fixing location of $d/ subdirectory
ensureDir $prefix/share
if test -w $prefix/share; then
mv -v $prefix/$d $prefix/share