#18612 closed bug (fixed)

whence() in /etc/profile overrides ZSH builtin

Reported by: zdykstra Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

The zsh package sources /etc/profile, which in turn defines whence(). The problems with this are:

  1. ZSH already provides a built-in 'whence' command, so this function definition unnecessarily masks it.
  2. The function as it is currently defined does not even execute correctly under /bin/zsh, as it assumes it's operating under bash, and zsh sources the file while emulating the behavior of ksh.
[master][~/source/haiku/data/etc]$ which zsh
whence:type:30: bad option: -t
whence:type:41: bad option: -t
[master][~/source/haiku/data/etc]$ whence zsh
whence:type:30: bad option: -t
whence:type:41: bad option: -t

Looking back through the history of /etc/profile, it looks like whence() has been there since the file was imported into SVN. There are Bash built-ins that perform everything whence does, so the easiest path forward is to just remove this function from /etc/profile. People can use the equivalent which/type/command functions under bash.

Alternatively, an additional check condition can be added to https://cgit.haiku-os.org/haiku/tree/data/etc/profile#n50 to check if ZSH_VERSION is defined and if it is, to not define whence(). This is obviously more fragile, as it leaves the door open for additional problems of this nature to crop up going forward.

I'm happy to implement either option.

Change History (4)

comment:1 by waddlesplash, 14 months ago

Unless there's some compatibility reason we need it, I'd support removing the function entirely.

comment:2 by pulkomandy, 14 months ago

I don't know why it's there, I think it is safe to remove.

comment:4 by waddlesplash, 14 months ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.