Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Introspection/UNIX-Shell/introspection-1.sh
Normal file
22
Task/Introspection/UNIX-Shell/introspection-1.sh
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
case ${.sh.version} in
|
||||
*93[[:alpha:]]+*) :;; #this appears to be ksh93, we're OK
|
||||
*) echo "version appears to be too old"
|
||||
exit # otherwise, bail out
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -z ${bloop+bloop has a value} ]]; then
|
||||
print "no bloop variable"
|
||||
elsif (( abs(1) )); then
|
||||
print -- $(( abs(bloop) ))
|
||||
fi
|
||||
|
||||
typeset -a int_vars
|
||||
set | while IFS='=' read -r var value; do
|
||||
if [[ $value == +([[:digit:]]) ]]; then
|
||||
int_vars[n++]=$var
|
||||
let sum += $value
|
||||
fi
|
||||
done
|
||||
print "${int_vars[*]}"
|
||||
print -- $sum
|
||||
26
Task/Introspection/UNIX-Shell/introspection-2.sh
Normal file
26
Task/Introspection/UNIX-Shell/introspection-2.sh
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
if [[ $BASH_VERSION < "4.2" ]]; then
|
||||
echo "version is too old"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ ! -v bloop ]]; then
|
||||
echo "no bloop variable"
|
||||
elif [[ $(type -t abs 2>/dev/null) != function ]]; then
|
||||
echo "abs is not a shell function"
|
||||
else
|
||||
echo $(abs $bloop)
|
||||
fi
|
||||
|
||||
# need to populate the variables and use them within the same subshell in a pipeline.
|
||||
set | {
|
||||
shopt -s extglob
|
||||
int_vars=()
|
||||
while IFS='=' read -r var value; do
|
||||
if [[ $value == +([[:digit:]]) ]]; then
|
||||
int_vars+=($var)
|
||||
(( sum += value ))
|
||||
fi
|
||||
done
|
||||
echo "${int_vars[*]}"
|
||||
echo $sum
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue