#973669 ksh: ignores tracked aliases during execution

Package:
ksh
Source:
ksh93u+m
Submitter:
Benjamin Barenblat
Date:
2026-06-19 17:45:02 UTC
Severity:
normal
Tags:
#973669#5
Date:
2020-11-03 00:49:05 UTC
From:
To:
ksh doesn’t pay attention to tracked aliases during execution – it
always does a PATH search:

    $ strace -e signal=none -P /usr/local/bin/ls -P /usr/bin/ls -P /bin/ls ksh +E
    $ ls -a
    stat("/usr/local/bin/ls", 0x7ffde8d749c0) = -1 ENOENT (No such file or directory)
    stat("/usr/bin/ls", 0x7ffde8d749c0)     = -1 ENOENT (No such file or directory)
    stat("/bin/ls", {st_mode=S_IFREG|0755, st_size=138856, ...}) = 0
    lstat("/bin/ls", {st_mode=S_IFREG|0755, st_size=138856, ...}) = 0
    .  ..
    $ whence -a ls
    ls is a tracked alias for /bin/ls
    $ ls -a
    stat("/usr/local/bin/ls", 0x7ffde8d749c0) = -1 ENOENT (No such file or directory)
    stat("/usr/bin/ls", 0x7ffde8d749c0)     = -1 ENOENT (No such file or directory)
    stat("/bin/ls", {st_mode=S_IFREG|0755, st_size=138856, ...}) = 0
    lstat("/bin/ls", {st_mode=S_IFREG|0755, st_size=138856, ...}) = 0
    .  ..

This is inefficient. It’s also surprising, given that tracked aliases
were originally intended to avoid PATH lookups in cases like this.

This appears to have been first noticed in 2011 by Siddhesh Poyarekar.
marc.info has mangled the thread a bit, but I think it’s

https://marc.info/?i=AANLkTinva-vek-y4CrNPdMic9b_HaFMmKVv=+3TnhFcO@mail.gmail.com
    └ https://marc.info/?i=201102161622.p1GGMYvv022111@penguin.research.att.com
      ├ https://marc.info/?i=AANLkTi=ktorzLncFMCK16yxAckRD6RKLjV5ywszfc31P@mail.gmail.com
      │ ├ https://marc.info/?i=AANLkTikiuFzexCRxxKx8CkBGm2-TbWG6F1R2+rOTwmwr@mail.gmail.com
      │ └ https://marc.info/?i=rca1529.4D5D6C3B.0@rightcore.com
      └ https://marc.info/?i=20110307172636.34716a4b@zaphod.usersys.redhat.com