I have a function plist that is able to call head and tail commands. But for processing regions I call a different function pregion.
# --- plist ---
("-H"|"--head")
local -r hn="$2" ; shift 2 ;;
("-T"|"--tail")
local -r tm="$2" ; shift 2 ;;
("--FS") # field separator
local fs="$2" ; shift 2 ;;
("--incl")
local incl+=("$2") ; shift 2 ;; # file type suffix
("--excl")
local excl+=("$2") ; shift 2 ;; # file type suffix
("--RP")
local pn=$2 ; shift 2 ;;
("--RQ")
local qn=$2 ; shift 2 ;;
("--dyn"|"--dynamic")
local dyn="1" ; shift 1 ;;
("-C"|"--context")
local ctx=$2 ; shift 2 ;;
("-d"|"--directory")
local fdir=$2 ; shift 2 ;;
(--)
shift; break ;;
...
if [[ -v hn ]]; then
head -v -hn "$n"
elif [[ -v tm ]]; then
tail -v -n "$tm"
elif [[ -v dyn ]]; then
pregion "$@" # requires original options here
fi
With head and tail, I only use options -H, -T', --FS,
and --incl. Because I am using shift when processing options, I need to have a copy ef the original plist input arguments, because I cannot simply pass "$@" to pregion.
This will call head or tail
plist -H 8 ./01cuneus
plist -T 13 ./01cuneus
Examples of calling pregion
plist --dyn -C 8 "Martin" ./01cuneus
plist --incl .texi --incl .org --RP 8 --RQ 13 ./01cuneus
plist --incl .texi --incl .org --dyn -C 8 "Martin" ./01cuneus
shiftin this code. I don't see-H,-Tetc. Why do you think you can't pass the args to pregion? You can make a copy of the incoming params to plist (args=("$@")) and use that to pass to pregion (pregion "${args[@]}")shift. What the problem is in passing"$@"as arg topregion. Everything related to this issue. And rip out the parts that are irrelevant to this, if runningheadis not where the problem is, just remove it or replace with anecho "this is where we'd call head / do this or that"or so.headandtailin functionplist.plist foo bar, then do this, but if called withplist -x -y abcd, then do this.)pregion --dyn -C 8 "Martin" ./01cuneus, etc. if that's what you want.