Bug 203743 - Full screen editing of history with vi is broken in /bin/sh
Summary: Full screen editing of history with vi is broken in /bin/sh
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Jilles Tjoelker
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-13 16:29 UTC by lab
Modified: 2015-10-27 21:39 UTC (History)
1 user (show)

See Also:


Attachments
correctly use buffer sizes (691 bytes, patch)
2015-10-18 20:30 UTC, Jilles Tjoelker
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description lab 2015-10-13 16:29:42 UTC
1) Set shell command line editing mode to vi. 
2) Execute some command (ex: 'ls -l')
3) Use escape to enter command line editing.
4) Use 'k' to view last command.
5) Use ^V to enter full screen vi.
6) Modify old command (ex: change to 'man sh').
7) Use :wq to exit vi
8) Edited command will fail. I saw output of '-sh: ma: not found)
Comment 1 Jilles Tjoelker freebsd_committer freebsd_triage 2015-10-18 20:30:39 UTC
Created attachment 162193 [details]
correctly use buffer sizes

This patch makes libedit read the text into the current buffer correctly. If you make the text much longer in the editor, it will be truncated (and then executed in its truncated form).
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-10-27 21:17:03 UTC
A commit references this bug:

Author: jilles
Date: Tue Oct 27 21:16:30 UTC 2015
New revision: 290065
URL: https://svnweb.freebsd.org/changeset/base/290065

Log:
  libedit: Use correct buffer lengths in vi mode v command.

  Libedit's vi mode provides a v command to edit the current line in vi(1)
  (hard-coded to vi, in fact).

  When Unicode/wide character mode was added, this command started truncating
  and/or corrupting the edited text.

  This commit fixes v if the text fits into the buffer. If the text is longer,
  it is truncated.

  PR:		203743
  Obtained from:	NetBSD (originally submitted by me)

Changes:
  head/lib/libedit/vi.c