[Top][All Lists]

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

Re: is it a bug

From: Robert Elz
Subject: Re: is it a bug
Date: Mon, 16 Nov 2020 20:37:05 +0700

    Date:        Mon, 16 Nov 2020 13:52:55 +0100
    From:        Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>

  | small conclusion: . code works, eval "$( < file )" worked, but alias
  | version not without empty newline

Dale's point, with which I agree, is that you shouldn't even be attempting
using aliases for things like that.  If there is some bug there, I don't
care, and I doubt anyone else does either.

Personally I'd go further and suggest that no-one should ever use aliases
for anything, ever ... aliases originated in csh (or perhaps ashell which
preceded it) which had no functions, and lacked the syntactic ability to
really add them - aliases were its mechanism to allow users to define new
commands that affect the state of the shell itself.   ksh apparently copied
that (part of what csh allowed), but then created functions, which are a much
better method to achieve the same goal - aliases should have been deleted
when that happened.  But weren't (it isn't as if ksh/bash (or POSIX) aliases
are powerful enough to actually replace csh aliases in general, whereas
functions are).   The only use for aliases that can't be done with functions
is to create new sh syntax (as some combination of existing syntax) which
is a spectacularly bad idea, and should never be actually used by anyone,
for anything, other than demonstrating just how crazy it really is.

I generally stop reading bash example code as soon as it starts using arrays.

As best I can guess is that you're writing an alias for defining aliases,
if you just used a function instead (as Dale suggested) this would be
much simpler and cleaner.   But once you've done that, you should throw
it away, as you shouldn't be using aliases at all, you really have no
need for some shorthand method of making them.


reply via email to

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