Article 5SQE6 Calling a function with empty argument

Calling a function with empty argument

by
Faki
from LinuxQuestions.org on (#5SQE6)
I want to allow a usage function to be called with an empty variable or with no variable at all.

For instance, being able to use

Code:arg=""
heading-usage $argand

Code:heading-usageHere is the function listing. Is it adequate for calling the `(*)` condition when `arg` is empty or not present? Had noticed that `$#` becomes `1` if `arg` is empty, forcing be to ditch the condition `(( $# == 0 ))` that I initially used for the situation when `arg` is empty.

Code:heading-usage ()
{
case $1 in
(1)
printf '%s\n' " -v VB, -v=VB, -vVB"
printf '%s\n' " -h, --help, -u, --usage"
;;
(2)
printf '%s\n' "Additional Information"
;;
(*)
printf '%s\n' "Display a heading"
;;
esac
}latest?d=yIl2AUoC8zA latest?i=HSXGSfipbEE:mS7Ir1YITAE:F7zBnMy latest?i=HSXGSfipbEE:mS7Ir1YITAE:V_sGLiP latest?d=qj6IDK7rITs latest?i=HSXGSfipbEE:mS7Ir1YITAE:gIN9vFw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments