jw-build-functions.sh: Fix basename for bash scripts

- Add _ytools_check_config_files_readable
  - Fix basename for bash
This commit is contained in:
Jan Lindemann 2011-02-25 10:05:50 +00:00 committed by Jan Lindemann
commit 870066e1b2

View file

@ -12,10 +12,20 @@ _ytools_check_config_present()
return 0;
}
_ytools_check_config_files_readable()
{
local new=""
for f in $ytools_config_files; do
[ -f "$f" -a -r "$f" ] && new="$new $f"
done
ytools_config_files="$new"
}
_ytools_probe_config_paths()
{
local f new exp dir
[ ! "$ytools_config_files" ] && ytools_config_files = "
[ ! "$ytools_config_files" ] && ytools_config_files="
/etc/opt/$ytools_project/$ytools_basename.conf
$HOME/.$ytools_project/$ytools_basename.conf
$HOME/.$ytools_project/$rc
@ -23,19 +33,17 @@ _ytools_probe_config_paths()
$HOME/.$ytools_basename/$rc
$HOME/.$rc
"
for f in $ytools_config_files; do
[ -r "$f" ] && new="$new $f"
done
ytools_config_files="$new"
_ytools_check_config_files_readable
# add includes
new=""
for f in $ytools_config_files; do
exp=`sed '
/^[ ]*include[ ]/ !d
s/^[ ]*include[ ]*//g
' $f`
if [ "$exp" ]; then
if [ "${exp:0:1}" != '/' ]; then
dir=`dirname $f`
@ -45,7 +53,10 @@ _ytools_probe_config_paths()
new="$new $f $exp"
fi
done
[ "$new" ] && ytools_config_files="$new"
_ytools_check_config_files_readable
}
_ytools_cat_section()
@ -370,7 +381,7 @@ if [ "$ytools_functions_sourced" != "yes" ]; then
ytools_functions_sourced="yes"
[ -z "$ytools_basename" ] && ytools_basename=`basename $0 | sed 's/\.sh$//'`
[ -z "$ytools_basename" ] && ytools_basename=`echo "$0" | sed 's/^-*//' | xargs basename | sed 's/\.sh$//'`
[ -z "$ytools_project" ] && ytools_project="ytools"
[ -z "$ytools_rc" ] && ytools_rc="$ytools_basename"rc
_ytools_probe_config_paths