Emacs editing mode is the default mode in sh. When just using the sh command, it is enabled without using the -E mode. One uses sh -V to enable the vi editing mode instead. However, $ENV points to /home/user/.shrc and .shrc has a redundant line in it: set -o emacs What this does is not only just set default functionality, but overrides a user's command: ``sh -V'' and ``sh -o vi'' and ``sh +o emacs'' don't work as long as this line in .shrc exists, and as long as ENV points to .shrc The solution is to remove that line and the two commented lines above it in .shrc, as sh uses emacs editing by default. This is confirmed both by actual usage and by the sh(1) man page. This was actually noticed all the way back in 2010 as bug 153233 This is a very easy fix.
Created attachment 178844 [details] diff that solves the problem This diff solves the problem by commenting out the line.
A commit references this bug: Author: jilles Date: Sun Jan 15 13:40:15 UTC 2017 New revision: 312230 URL: https://svnweb.freebsd.org/changeset/base/312230 Log: skel: Do not set -o emacs in .shrc. sh has defaulted to 'set -o emacs' since FreeBSD 9.0. Therefore, do not set this again in .shrc, since that only serves to prevent invocations like 'sh -o vi' and 'sh +o emacs' to have the intended effect. PR: 215958 Submitted by: Andras Farkas MFC after: 1 week Changes: head/share/skel/dot.shrc
Fixed in head, thanks.
A commit references this bug: Author: jilles Date: Sun Jan 22 21:31:32 UTC 2017 New revision: 312653 URL: https://svnweb.freebsd.org/changeset/base/312653 Log: MFC r312230: skel: Do not set -o emacs in .shrc. sh has defaulted to 'set -o emacs' since FreeBSD 9.0. Therefore, do not set this again in .shrc, since that only serves to prevent invocations like 'sh -o vi' and 'sh +o emacs' to have the intended effect. PR: 215958 Submitted by: Andras Farkas Changes: _U stable/11/ stable/11/share/skel/dot.shrc
A commit references this bug: Author: jilles Date: Sun Jan 22 21:34:26 UTC 2017 New revision: 312654 URL: https://svnweb.freebsd.org/changeset/base/312654 Log: MFC r312230: skel: Do not set -o emacs in .shrc. sh has defaulted to 'set -o emacs' since FreeBSD 9.0. Therefore, do not set this again in .shrc, since that only serves to prevent invocations like 'sh -o vi' and 'sh +o emacs' to have the intended effect. PR: 215958 Submitted by: Andras Farkas Changes: _U stable/10/ stable/10/share/skel/dot.shrc