From nobody Thu Oct 05 17:00:07 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S1d8m0H0vz4w43p for ; Thu, 5 Oct 2023 17:00:08 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S1d8l4fMxz3XQG for ; Thu, 5 Oct 2023 17:00:07 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696525207; a=rsa-sha256; cv=none; b=FUhiMDLsazvZEHBzPkRiUhOx4YI+ots/Ea+8M3BNxtSpBsA+hd0FzFkz9jdCoE+UZMv7Zc 0MmfukkQW+sx+MMUOrnFEMhcX9JbsOR3iSDnVndPahU+HsLKUM7OsmFvMomHP9LUiHWLCC fNTr22RHBHmzU37v880wTcVBHszI/7N4Xmnso8LehfmTG9Aw9rF67HFsSShHrBIMxIFH7w byDbppY9T8f3hNC8yHJVtDH3I24GBCL6686rgyIRZXWz0UcE3gft86YSOh0gIFSPsZ+pxb fLPkliuplmLLkUvRm4DTHRvxZ8bgTxdvn5Myn/hD2Y/fpmd76gdwCZYJxmDeTA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696525207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FDuGu3d9Pa/1mZV4uaVGEDuq9J2liEeIu8w6wf5aoBE=; b=q1KbezCMdCqWOprTfdVFnAP7CWhS9yKcq9VIvPg12zAvPq0NBbhn84CAO2WGm8SD+URBlm 2JkB8Wg+BEnrxGw3bxJ2ysjGPLqFUpQXq372zuVUKLYk1H2qX1BfOLGdMMuUpzhYVnPAmT JoGQEf8SMA+ilMCDs5dJ1xj8ktNXCxB7Br2bEggNzgntHxxy05lfvcd7Vn4dORrNfEpe8Y /OrFUVXy8MNIGGKYrGK47E7jx5kExQWgNLSJJUn9MFEj/cETdX/f85l8C9T7wm/9vb5unZ fKwns73oi/I7VukzFXw1mTDt95NzID6WREext5Te3eR9AipsETOqIedt0fYviA== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S1d8l3kl4z1Rrt for ; Thu, 5 Oct 2023 17:00:07 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 395H07EP061584 for ; Thu, 5 Oct 2023 17:00:07 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 395H0714061583 for bugs@FreeBSD.org; Thu, 5 Oct 2023 17:00:07 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 274280] Incompatible default shell configuration Date: Thu, 05 Oct 2023 17:00:07 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: conf X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: tg@mirbsd.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D274280 Bug ID: 274280 Summary: Incompatible default shell configuration Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: conf Assignee: bugs@FreeBSD.org Reporter: tg@mirbsd.org I=E2=80=99m upstream for mksh (shells/mksh in ports), and I=E2=80=99ve had = a user report problems on FreeBSD, which I was able to track down. dot.shrc=C2=B9 contains commands specific to FreeBSD sh which are not POSIX conformant nor compatible with mksh; specifically, the bind commands in lin= es 34ff, although the PS1 is also n=C5=8Dn-standard. The problem is exacerbated by dot.profile=C2=B2 exporting ENV, which makes = mksh look at .shrc in the first place, which it normally would not. Just like PS1, exporting ENV is something that should not be done. For ENV however, there=E2=80=99s the option of writing the designated file in a way= that is compatible with all shells that read it (which is not an option for PS1). My preference would be for FreeBSD to not export ENV. I understand this is = most likely too much; therefore, please add the following lines=E2=80=A6 if test -n "$KSH_VERSION"; then test -e ~/.mkshrc || return 0 . ~/.mkshrc return fi =E2=80=A6 between the comment end on line 8 and the comment beginning on li= ne 11 to fix this problem and MFC that to the active stable branches. The change will defer from .shrc to .mkshrc if it exists (and if so, return= its exit status up the chain), and just return true if it doesn=E2=80=99t exist. The change will make it so that, when mksh (or pdksh, oksh or AT&T ksh93, incidentally, but the stock dot.mkshrc has a whitelist for mksh/lksh and ju= st returns true for all other shells) is run, the remainder of the FreeBSD .sh= rc is ignored and the mksh one is used instead. It might be useful to defer to different files, depending on what shells are ported however this will raise complexity. Looking at your ports tree, I=E2=80=99m surprised to see that 1999 pdksh is= even still present. But that can be mostly lumped together with oksh. A more complete solution would thus be: if test -n "${KSH_VERSION:-}"; then # mksh/lksh? (shells/mksh port) case $KSH_VERSION in *LEGACY\ KSH*|*MIRBSD\ KSH*) test -e ~/.mkshrc || return 0 . ~/.mkshrc return ;; esac # AT&T ksh93? (shells/ast-ksh, shells/ksh, shells/ksh93) if (eval 'x=3D${.sh.version}') >/dev/null 2>&1; then test -e ~/.ksh93rc || return 0 . ~/.ksh93rc return fi # other pdksh variants (shells/oksh, shells/pdksh) test -e ~/.kshrc || return 0 . ~/.kshrc return fi This is assuming users of these shells would create the corresponding dotfi= les. There=E2=80=99s historic evidence for ~/.kshrc, mostly by pdksh/oksh users;= there=E2=80=99s none for ~/.ksh93rc TTBOMK (some, but few, seem to be using ~/.kshrc). This leaves out GNU bash, AT&T ksh88, yash, zsh (if any of these honour $EN= V). From my shell detection utility=C2=B3, they can easily be detected by: if test -n "${BASH_VERSION:-}"; then =E2=80=A6 fi case ${YASH_VERSION:-} in *.*) =E2=80=A6 ;; esac case ${ZSH_VERSION:-} in *[0-9]*) =E2=80=A6 ;; esac case ${VERSION:-} in zsh*) =E2=80=A6 ;; esac (the last one is for old versions of zsh and may not be necessary any more) This leaves out AT&T ksh88, which is sensible as it=E2=80=99s binary-only a= nd only present on old Unic=C4=93s, and other sh variants like NetBSD sh, ash/dash,= etc. There *is* a dash port; dash does not support bind, and it does not set a s= hell parameter to detect it; dash does read $ENV. You=E2=80=99ll have broken das= h users, but that=E2=80=99s probably not a big issue. Unfortunately, FreeBSD /bin/sh doesn=E2=80=99t appear (I don=E2=80=99t have= access to a FreeBSD system at the moment, only a MidnightBSD system, but it seems to share /bin= /sh still) to set a variable to discern it either, so let=E2=80=99s just ignore= dash for now. Note: I don=E2=80=99t advocate for leaving out the bind commands from .shrc= instead. Users of the other shells *will* want to be able to read their shells=E2=80= =99 own startup files (especially considering mksh ships such a rich one predefined= ), so diverting to them is necessary. =E2=91=A0 https://cgit.freebsd.org/src/tree/usr.bin/man/man.sh =E2=91=A1 https://cgit.freebsd.org/src/tree/share/skel/dot.profile =E2=91=A2 http://www.mirbsd.org/cvs.cgi/contrib/code/Snippets/getshver?rev= =3DHEAD --=20 You are receiving this mail because: You are the assignee for the bug.=