"역방향 킬 라인"과 "유닉스 라인 폐기"의 차이점

"역방향 킬 라인"과 "유닉스 라인 폐기"의 차이점

나는 bash 매뉴얼 페이지를 읽고 키보드 단축키를 외우고 있습니다. C-x rubout는 에 바인딩 backward kill line되고 C-u은 에 바인딩되지만 unix line discard이러한 명령에 대한 설명은 동일해 보입니다. 이들명령의 차이점은 무엇인가요?

답변1

그들의현재 구현backward-kill-line, 이 두 함수는 접두사 인수를 무시하는 반면 음수 접두사 인수를 사용할 수 있다는 점을 제외하면 거의 동일한 작업을 수행하는 것으로 보입니다 unix-line-discard.

/* Here is C-u doing what Unix does.  You don't *have* to use these
   key-bindings.  We have a choice of killing the entire line, or
   killing from where we are to the start of the line.  We choose the
   latter, because if you are a Unix weenie, then you haven't backspaced
   into the line at all, and if you aren't, then you know what you are
   doing. */
int
rl_unix_line_discard (int count, int key)
{
  if (rl_point == 0)
    rl_ding ();
  else
    {
      rl_kill_text (rl_point, 0);
      rl_point = 0;
      if (rl_editing_mode == emacs_mode)
    rl_mark = rl_point;
    }
  return 0;
}

/* Kill backwards to the start of the line.  If DIRECTION is negative, kill
   forwards to the line end instead. */
int
rl_backward_kill_line (int direction, int key)
{
  int orig_point;

  if (direction < 0)
    return (rl_kill_line (1, key));
  else
    {
      if (rl_point == 0)
    rl_ding ();
      else
    {
      orig_point = rl_point;
      rl_beg_of_line (1, key);
      if (rl_point != orig_point)
        rl_kill_text (orig_point, rl_point);
      if (rl_editing_mode == emacs_mode)
        rl_mark = rl_point;
    }
    }
  return 0;
}

답변2

내가 찾은 내용은 다음과 같습니다.

backward-kill-line (C-x Rubout)
    Kill backward to the beginning of the line.

unix-line-discard (C-u)
    Kill backward from the cursor to the beginning of the current line. 

https://ftp.gnu.org/old-gnu/Manuals/bash-2.05a/html_node/bashref_97.html

       backward-kill-line (C-x Rubout)
              Kill backward to the beginning of the line.
       unix-line-discard (C-u)
              Kill backward from point to the beginning of the line.  The
              killed text is saved on the kill-ring.

https://man7.org/linux/man-pages/man3/readline.3.html#EDITING_COMMANDS

unix-line-discard키링에 저장되는 것 같지만 backward-kill-line그렇지 않습니다. 그러나 이를 확인하는 방법과이맥스 위키그것은 backward-kill-line또한 jeyring에 추가된다고 말합니다

이 용어의 다른 용도:https://github.com/junegunn/fzf/pull/489/files#diff-1fabf11f4aca2d62eb64290f66d25217R180

관련 정보