tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: sh(1) and ksh(1) default PATH



On Sun, 14 Aug 2022 at 03:13, Robert Elz <kre%munnari.oz.au@localhost> wrote:
>
> The normal default path for sh comes from sysctl user.cs_path
> and if there was a desire to alter that, that would be the place to
> do it (as in, by setting that in /etc/sysctl.conf).

This seems like a critical fulcrum we already have. If so, could we
move towards either having system dotfiles with some form of:
PATH="$(/sbin/sysctl -n user.cs_path)"
or just comment out PATH settings and have sh, ksh, and csh default
PATH to user.cs_path when unset?

In the latter case that would mean the following would have printed
the same PATH outputs
# sysctl -n user.cs_path ; env -i sh -c 'echo $PATH'
/usr/bin:/bin:/usr/sbin:/sbin:/usr/pkg/bin:/usr/pkg/sbin:/usr/local/bin:/usr/local/sbin
/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin

I note that sys_info already sets PATH to user.cs_path
https://nxr.netbsd.org/xref/src/usr.bin/sys_info/sys_info.sh#31

At first glance (which means I've missed something :), this seems like
a very attractive option - it would mean one central place can define
the default PATH for multiple shells

Thanks

David


Home | Main Index | Thread Index | Old Index