help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

option taking optional argument `-u1` with getopts


From: hancooper
Subject: option taking optional argument `-u1` with getopts
Date: Thu, 26 Aug 2021 03:22:45 +0000

Have been using getopts to pass arguments to a function. I would like that the 
option -u takes an optional
argument `-u1`. I wonder how I can implement this thing.

local OPTIND OPTARG
local shortopts="Vuhs"
while getopts $shortopts arg; do
case $arg in
("V")
pfm "V01 Jul 2021 Wk27 Matematiker Christopher Dimech"
return
;;
("u")
pfm -- "-V, -h, -u"
pfm "TITLE ASC"
return
;;
esac
done

reply via email to

[Prev in Thread] Current Thread [Next in Thread]