This commit is contained in:
Shelvacu
2025-06-05 16:41:50 -07:00
committed by Shelvacu on fw
parent 11043dc0ab
commit c5eebadff9

View File

@@ -305,3 +305,27 @@ svl_confirm_or_die() {
svl_die "exiting"
fi
}
# svl_count #=> 0
# svl_count a b c #=> 3
# prints the number of arguments on stdout.
svl_count() {
echo $#
return 0
}
svl_count_matches() {
svl_exact_args $# 1
declare nullglob_before
if shopt -q nullglob; then
nullglob_before=enabled
else
nullglob_before=disabled
fi
shopt -s nullglob
svl_count $1
if [[ "$nullglob_before" == "disabled" ]]; then
shopt -u nullglob
fi
return 0
}