Re: Best way to over-ride a builtin and run the "real" version from /bin
From:
Lawrence Velázquez
Subject:
Re: Best way to over-ride a builtin and run the "real" version from /bin (or wherever)
Date:
Mon, 14 Jul 2025 16:29:26 -0400
On Mon, Jul 14, 2025, at 2:09 PM, Zachary Santer wrote:
> On Mon, Jul 14, 2025 at 1:28 PM Stan Marsh <gazelle@xmission.com> wrote:
>>
>> For example, "false" is a bash builtin, but the version in /bin has better
>> functionality. How best to invoke the "real" version, bypassing the builtin?
>>
>> Obviously, using /bin/false works, but assume that you don't necessarily know
>> the path of the non-builtin version (i.e., don't want to hard-code it).
>>
>> I thought this was done using "command", like:
>>
>> $ command false --help
>>
>> but that still runs the builtin.
>
> env false
> right?
Assuming bash, you can also invoke the output of "type -P" [*].
For example, bash's printf(1) doesn't support numbered argument
conversion specifications, but BSD's does:
$ printf '%2$s %1$s\n' foo bar
bash: printf: `$': invalid format character
$ "$(type -P printf)" '%2$s %1$s\n' foo bar
bar foo
You can also disable the built-in outright, if you don't plan on
using it during that shell process's lifetime:
$ printf '%2$s %1$s\n' foo bar
bash: printf: `$': invalid format character
$ enable -n printf
$ printf '%2$s %1$s\n' foo bar
bar foo
[*]
https://mywiki.wooledge.org/BashFAQ/086#Call_an_external_utility_by_PATH_resolution.2C_bypassing_builtins_and.2For_functions
--
vq