[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Kludge for handling REPL arithmetic expressions
From: |
Tapani Tarvainen |
Subject: |
Re: Kludge for handling REPL arithmetic expressions |
Date: |
Tue, 3 Aug 2021 16:53:48 +0300 |
On Tue, Aug 03, 2021 at 09:26:32AM -0400, Chet Ramey (chet.ramey@case.edu)
wrote:
> On 8/3/21 3:05 AM, Tapani Tarvainen wrote:
>
> > Right: command_not_found_handle() is not called when there's a slash
> > in the command.
> >
> > Offhand I can't any reason why it shouldn't, but making that happen
> > would mean modifying bash source code. A wishlist item, then.
>
> It doesn't because there's no point: a slash in the command name means
> the shell doesn't look for it in $PATH. It's a filesystem path.
Well, yes, except when someone wants to (ab)use
command_not_found_handle() to catch things that are not parsed as
command names to handle them in non-standard ways, like the original
poster tried to do here.
Although I observe that it would not actually work in all cases
anyway: there might be a directory "=2" and a command "=2/7" that
could do unexpected things.
> If you're concerned about whether or not a command name containing a
> slash exists, you can check directly.
I don't see any obvious way to do that in the present case.
Not that I see much point in the "=expression" syntax, other than as
an intellectual exercise.
And while I can think of scenarios where triggering
command_not_found_handle() for nonexistent filesystem paths
would make some things a bit easier to do, I can't offhand
think of any realistic ones where it really couldn't be
checked directly.
So while I don't what harm could come from handling nonexistent
paths like that, I don't see it important either, not worth
spending any significant time on.
I am curious though to see if the OP comes up with a workable
solution for his problem.
--
Tapani Tarvainen