[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Call dynamic builtins with 'builtin' command
From: |
Chet Ramey |
Subject: |
Re: Call dynamic builtins with 'builtin' command |
Date: |
Sat, 12 Oct 2024 16:55:31 -0400 |
User-agent: |
Mozilla Thunderbird |
On 10/9/24 7:15 AM, Vadim Nevorotin wrote:
Hello!
I'm trying to do a very simple task: I want to use the 'stat' builtin
from BASH_LOADABLES_PATH without overwriting the current behavior of
the 'stat' command in the current shell (whether it's a binary from
$PATH, or an alias, or a function).
So you want it to override an executable file, since adding a loadable
builtin doesn't change the search order, and aliases and shell functions
are found before builtins.
This does not work:
$ builtin stat
bash: builtin: stat: not a shell builtin
According to 'help enable' this should work, but it also do not:
$ enable stat
$ enable -n stat
$ builtin stat
bash: builtin: stat: not a shell builtin
I'm not sure what you expect -- you just disabled the builtin you loaded,
so it won't be used.
'enable -n' should just disable stat, according to 'help enable', but
it looks like it also removes it.
Why should it not? You'll have to enable it again before you use it, which
will load it again.
So:
1. At least the help for 'enable' should be fixed, but there is
definitely a bug in enable+builtin usage for dynamic builtins.
What is the bug?
2. Can you explain how to load and use e.g. stat builtin without
overwriting the current behavior of stat in the whole existing script?
Is this anything more complicated than doing
enable it
use it
disable it
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature