Re: pmount could perhaps be of greater utility?
On 06.05.19 09:03, Greg Wooledge wrote:
> On Sat, May 04, 2019 at 01:48:01PM +0200, Jonas Smedegaard wrote:
> > Quoting Erik Christiansen (2019-05-04 08:43:53)
> > > $ which lmount
> > > lmount is a function
> > > lmount ()
> > > {
> > > pmount $1 `e2label $1`
> > > }
> >
> > I recommend to install package shellcheck and run "shellcheck lmount".
>
> My initial reaction was similar, but he might not be using a regular
> shell. At the very least, his "which" command is not the standard
> which(1) utility, because that wouldn't know about shell functions.
>
> So, either he isn't in bash/ksh/dash, or his "which" command has been
> overridden with a function or alias. (On the other hand, his output
> from "which" looks identical to bash's "type" output. So maybe he
> did something like alias which=type.)
Well surmised, good sir. It's more than 30 years since I found "which"
on HP-UX inadequate and "type" meaninglessly mnemonic of "print", thus
the alias. Through SunOS, Solaris, and Linux, the inadequacy has
remained - and so the remedy.
> At the end of the day, if this is supposed to be a bash function, it
> has three quoting errors,
Yep, if the robustness required for users other than an author were
applicable, then I see two absences of double quotes. But it is worth
remembering that there are no robustness requirements when the author is
the only user, and supporting a space in "/dev/xxx" is in any event a
pointless exercise.
> and is using the ancient deprecated command substitution syntax (which
> will work in this case, but is not a good habit).
That does appear to remain opinion. The venerably traditional syntax is
still fully legal supported bash syntax, e.g.:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_03
The recent (late last century, IIRC) introduction of the $(...)
alternative syntax has admittedly brought newer *nix users who know
nothing else, and so delude themselves that there is nothing else. That
is a misapprehension. To each, his own, especially amongst adequately
equivalent alternatives.
HAND
Erik
(Who has used the newfangled syntax on occasion, just to see if it works.)
--
Do not do unto others as you would they should do unto you.
Their tastes may not be the same.
- George Bernard Shaw
Reply to: