John Reiser wrote on Sun, Dec 31, 2023 at 02:52:53PM -0800:
> > Additional paths will be inserted into the search path used for
> > executables on systems which have a compatible CPU.
> 
> Searching $PATH is a slow operation. It is so slow that a shell script which
> typically processes many files using utilities from packages coreutils
> and/or binutils often factors-out the PATH search by using
> shell variables:
> 
>       CP=$(which cp)
>         ...
>       $(CP) $file.in $file.out

(getting slighly off topic, sorry)
That hasn't been needed for as long as I've used a compter, all^W most
shells already do this for you.

(It's obvious in interactive mode when you need to use hash/rehash
built-ins after moving a binary that you ran once, but it's true as well
when running scripts: if you e.g. strace for stat() calls a script that
calls cp twice you'll see it only looks through PATH once. This is true
of at least bash, zsh, dash, and even busybox ash... Interestingly fish
doesn't seem to do it, I'm a bit surpised here)


Anyway, I'm not arguing PATH lookups are fast -- having seen some setups
with 'module's over NFS or networked file systems I know how bad that
can get -- just don't undersell your shells :)

-- 
Dominique Martinet | Asmadeus
--
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to