Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#65755 - [filesystem] The appendpath function in /etc/profile is not unset POSIX compliantly

Attached to Project: Arch Linux
Opened by ibbem (ibbem) - Monday, 09 March 2020, 13:47 GMT
Last edited by Sébastien Luttringer (seblu) - Tuesday, 19 May 2020, 22:46 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Sébastien Luttringer (seblu)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

In /etc/profile the function appendpath is used to add the default PATH entries.
This function is later unset with 'unset appendpath'.

The problem with this is, that it isn't POSIX compliant to assume, that this will actually unset the function. The relevant part of the POSIX standard reads:
(https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#unset)
> If neither -f nor -v is specified, name refers to a variable; if a variable by that name does not exist, it is unspecified whether a function by that name, if any, shall be unset.

Most shells just unset the function if the variable doesn't exist (bash, dash, ksh), but not zsh.
Therefor every zsh instance started as a login shell has a function appendpath in it's environment (if not unset in a later script).

Fix:
Fixing this is trivial. Just add the -f flag to 'unset appendpath'.
I have verified that this works for bash, dash, ksh and zsh.

Diff of /etc/profile:
19c19
< unset appendpath
---
> unset -f appendpath


Additional info:
* version of the filesystem package: 2019.10-2

Steps to reproduce:
In a shell run:
zsh -l
echo $PATH | grep test --color=always
appendpath test
echo $PATH | grep test --color=always
whence -v appendpath
exit
This task depends upon

Closed by  Sébastien Luttringer (seblu)
Tuesday, 19 May 2020, 22:46 GMT
Reason for closing:  Fixed
Additional comments about closing:  2020.05.20-1

Loading...