Date: Wed, 5 Oct 2022 15:36:55 -0400
From: Chet Ramey <[email protected]>
Message-ID: <[email protected]>
| Other than that, there's no advantage.
There can be. I have, on occasion (not in bash - I don't
write bash scripts) had a need to redefine one of the standard
commands, while executing a particular function (which calls other
more standard functions which run the command) - and define the
same command differently when running a different function, which
runs the same standard functions running the command, but in a
different way.
Kind of like
f1() {
diff() { command diff -u "$@"; }
dostuff
unset -f diff
}
f2() {
diff() { command diff -iw -c "$@"; }
dostuff
unset -f diff
}
where dostuff() does what ever is needed to make "newversion",
and then, somewhere does one (or more) of something like
diff origfile newversion
"dostuff" can also just be run to get the default diff format.
or something like that. Real examples tend to be far more complicated
(this simple case could be done just by having DIFFARGS or something, but
that would mean modifying dostuff() to use that as diff $DIFFARGS ....)
kre