Wow, there's a libc function that perl doesn't offer access to!
getmntent:
... reads the next line of the filesystem description file from stream and returns a pointer to a structure containing the broken out fields
Not a very fancy function, we can readily re-implement it, OK.
Looks good.
I don't really recommend any changes.
But here are my musings.
# fstab columns: <file system> <mount point> <type> <options> <dump> <pass>
Thank you for the reminder, that's helpful.
Now I have it all on one screen in front of me,
without flipping back and forth to a man page.
# $1 - filter (default: '1').
I confess that I misread this the first time.
We're in a bash context, and I initially didn't understand
that I was reading an idiomatic perl expression for True.
IDK, maybe name it filter_predicate?
Maybe point out that we're using perl?
No biggie, it becomes obvious soon enough.
# $2 - format (default: 'print $_').
Sorry, I tend to think of "format" in terms of sprintf(), distinct from I/O.
Consider making it '$_' and
then your scaffolding always prints the formatted string?
# fstab_list '$fstab[0]=~/UUID/' 'print $fstab[0], " at ", $fstab[1]'
Warning, creeping featurism! Quick, skip to next section.
Your script offers a pretty thin wrapper.
Consider making it fatter,
by replacing inconvenient cryptic integer indexes
with mntent names of {fsname, dir, type, opts, freq, passno}.
Then we can access fstab at a higher level of abstraction.
local format="${2:-'print $_'}"
Consider adding:
local fstab="${3:-'/etc/fstab'}"
and passing that along to perl.
Why?
To make it possible for a maintenance engineer
to write automated test cases,
feeding in some "hard to parse" frozen fstab text.
I like the quoting and the perl parsing, it all looks good.
I imagine this runs cleanly through shellcheck -- kudos.
perl -wnl -e ...
Consider tacking on -Mstrict, just in case.
Couldn't hurt, it's a good habit.
This code appears to achieve its design goals.
I would be willing to delegate or accept maintenance tasks on it.