I wonder if I may use comments in between POSIX shell script's function name and its body? This appears not to throw any problem in shellcheck and runs in Dash / Bash, but searching for this information found me nothing useful.
Example shell functions:
is_int()
# POSIX [bool] function to test one variable for an integer.
{
case "${1#[+-]}" in
(*[!0123456789]*) return 1 ;;
('') return 1 ;;
(*) return 0 ;;
esac
}
is_uint()
# POSIX [bool] function to test one variable for an unsigned integer.
{
case "$1" in
([+-]*) return 1 ;;
esac
is_int "$1"
}
Would any shell have known problem with this? I would not like if it hurt the portability of some of my scripts.
Attention, I only use this very recently and because VS Codium I started using supports function blocks collapsing like that:
Thank you.
PS: I like the comments describing functions in my shell scripts this way a bit more than having the comment above f()'s name. It is only cosmetic problem and as such please refrain from discussing the Why not above function's name. Thank you!
