(identity) add gn_for: send each valid gn to stdin of PROG_AND_ARGS

This commit is contained in:
Corwin Brust 2026-05-09 03:45:58 -04:00
parent deb6f51b57
commit add3204f83

View file

@ -513,18 +513,24 @@ function c4.i.gn_skipped {
done
fi
fi
test 0 -eq "${C4_I_GN_SKIPPED[$gn]}"
test 0 -ne "${C4_I_GN_SKIPPED[$gn]}"
}
## check validity/availability of a node
_c4_is_gn=
function c4.i.gn_for {
for gn in $(seq $( c4.i.gn_min ) $( c4.i.gn_max )) ; do
c4.i.gn_skipped $gn ||\
printf "%s" $gn | $@
done
}
#function c4.i.is_gn {
#seq "$(<.min)" "$(<.max)" | grep -v "$( perl -le 'printf q{\(%s\)}, join q{\|}, map {chomp;$_} <>' <.skip )" | grep "$(hostname -s | tr -d '[[:alpha:]]')" >/dev/null 2>&1 && echo OK
#}
function c4.fa_src {
local src #="$(case $# in 1) $1 ;; *) $( c4.i.of $@ ) ;; esac) 1)"; shift;
local src #="$(case $# in 1) $1 ;; *) $( c4.i.of $@ ) ;; esac)"; shift;
case $# in
1) src=$1 ;;
*) src=$( c4.i.of $@ ) ;;
@ -668,6 +674,32 @@ function c4.i.has {
#c4.i.has "gn" "max" && echo ok || echo nope
#c4.i.has "users" && echo ok || echo nope
C4_TR='H'; ### HEAPS
## fill given array var with lines from STDIN
declare C4_H_FOR_HI=/dev/stdin
#declare -p C4_H_FOR_AO >/dev/null 2>&1 && unset C4_H_FOR_AO;
declare -a C4_H_FOR_AO=()
declare -i C4_H_FOR_CI=-1
declare -i C4_H_FOR_CO=-1
function c4.h.array {
local line=
local IFS=
C4_H_FOR_AO=()
C4_H_FOR_CI=-1
C4_H_FOR_CO=-1
if test -p $C4_H_FOR_HI ; then
while read line ; do
C4_H_FOR_CI=$((C4_H_FOR_CI+1))
test -n "$line" || continue
C4_H_FOR_CO=$((C4_H_FOR_CO+1))
C4_H_FOR_AO+=("$line")
echo "GOT: ${C4_H_FOR_AO[$C4_H_FOR_CO]}"
done <$C4_H_FOR_IH
fi
}
C4_TR='S'; ### SPOKES