История изменений
Исправление vodz, (текущая версия) :
Ну нате, без башизмов:
#!/bin/sh
S1=AAA.BB.CCC
S2="*.sh"
doteq() {
local f1 fold=$- IFS=. s1=$1 s2=$2
set -f
eval "set -- \$$s1"
f1=$#
eval "set -- \$$s2"
if [ $# -lt $f1 ]; then
f1=$((f1-$#))
else
f1=$(($#-f1))
s1=$s2
fi
while [ $f1 -gt 0 ]; do
eval $s1='${'$s1'%.*}'
f1=$((f1-1))
done
[ "${fold#*f}" = "$fold" ] && set +f
}
doteq S1 S2
echo "S1=$S1 S2=$S2"
doteq() {
local -i f1
local fold=$- IFS=. s1=$1 s2=$2
set -f
set -- ${!s1}
f1=$#
set -- ${!s2}
if [ $# -lt $f1 ]; then
f1=f1-$#
else
f1=$#-f1
s1=$s2
fi
while ((f1-->0)); do
eval $s1='${!s1%.*}'
done
[ "${fold#*f}" = "$fold" ] && set +f
}
Исходная версия vodz, :
Ну нате, без башизмов:
#!/bin/sh
S1=AAA.BB.CCC
S2="*.sh"
doteq() {
local f1 fold=$- IFS=. s1=$1 s2=$2
set -f
eval "set -- \$$s1"
f1=$#
eval "set -- \$$s2"
if [ $# -lt $f1 ]; then
f1=$((f1-$#))
else
f1=$(($#-f1))
s1=$s2
fi
while [ $f1 -gt 0 ]; do
eval $s1='${'$s1'%.*}'
f1=$((f1-1))
done
[ "${fold#*f}" = "$fold" ] && set +f
}
doteq S1 S2
echo "S1=$S1 S2=$S2"