mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
jw-build-functions.sh: Fix basename for bash scripts
- Add _ytools_check_config_files_readable - Fix basename for bash
This commit is contained in:
parent
5a6127eff6
commit
870066e1b2
1 changed files with 18 additions and 7 deletions
|
|
@ -12,10 +12,20 @@ _ytools_check_config_present()
|
||||||
return 0;
|
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()
|
_ytools_probe_config_paths()
|
||||||
{
|
{
|
||||||
local f new exp dir
|
local f new exp dir
|
||||||
[ ! "$ytools_config_files" ] && ytools_config_files = "
|
[ ! "$ytools_config_files" ] && ytools_config_files="
|
||||||
/etc/opt/$ytools_project/$ytools_basename.conf
|
/etc/opt/$ytools_project/$ytools_basename.conf
|
||||||
$HOME/.$ytools_project/$ytools_basename.conf
|
$HOME/.$ytools_project/$ytools_basename.conf
|
||||||
$HOME/.$ytools_project/$rc
|
$HOME/.$ytools_project/$rc
|
||||||
|
|
@ -23,19 +33,17 @@ _ytools_probe_config_paths()
|
||||||
$HOME/.$ytools_basename/$rc
|
$HOME/.$ytools_basename/$rc
|
||||||
$HOME/.$rc
|
$HOME/.$rc
|
||||||
"
|
"
|
||||||
for f in $ytools_config_files; do
|
_ytools_check_config_files_readable
|
||||||
[ -r "$f" ] && new="$new $f"
|
|
||||||
done
|
|
||||||
|
|
||||||
ytools_config_files="$new"
|
|
||||||
|
|
||||||
# add includes
|
# add includes
|
||||||
new=""
|
new=""
|
||||||
for f in $ytools_config_files; do
|
for f in $ytools_config_files; do
|
||||||
|
|
||||||
exp=`sed '
|
exp=`sed '
|
||||||
/^[ ]*include[ ]/ !d
|
/^[ ]*include[ ]/ !d
|
||||||
s/^[ ]*include[ ]*//g
|
s/^[ ]*include[ ]*//g
|
||||||
' $f`
|
' $f`
|
||||||
|
|
||||||
if [ "$exp" ]; then
|
if [ "$exp" ]; then
|
||||||
if [ "${exp:0:1}" != '/' ]; then
|
if [ "${exp:0:1}" != '/' ]; then
|
||||||
dir=`dirname $f`
|
dir=`dirname $f`
|
||||||
|
|
@ -45,7 +53,10 @@ _ytools_probe_config_paths()
|
||||||
new="$new $f $exp"
|
new="$new $f $exp"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
[ "$new" ] && ytools_config_files="$new"
|
[ "$new" ] && ytools_config_files="$new"
|
||||||
|
|
||||||
|
_ytools_check_config_files_readable
|
||||||
}
|
}
|
||||||
|
|
||||||
_ytools_cat_section()
|
_ytools_cat_section()
|
||||||
|
|
@ -370,7 +381,7 @@ if [ "$ytools_functions_sourced" != "yes" ]; then
|
||||||
|
|
||||||
ytools_functions_sourced="yes"
|
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_project" ] && ytools_project="ytools"
|
||||||
[ -z "$ytools_rc" ] && ytools_rc="$ytools_basename"rc
|
[ -z "$ytools_rc" ] && ytools_rc="$ytools_basename"rc
|
||||||
_ytools_probe_config_paths
|
_ytools_probe_config_paths
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue