Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace awk for perl in the bash history widget #3313

Merged
merged 4 commits into from
Sep 22, 2023

Commits on May 30, 2023

  1. replace awk for perl in the bash history widget

    While awk is POSIX, perl isn't pre-installed on all *nix flavors. This
    commit replaces perl with awk to eliminate the dependency on perl.
    
    Related: junegunn#3295, junegunn#3309, junegunn#3310.
    
    Test suite passed:
    * `make error` all test sections 'PASS'
    * `make docker-test` 215 runs, 1884 assertions, 0 failures, 0 errors, 0 skips.
    
    Manually tested in the following environments:
    * Linux amd64 with bash 3.2, 4.4, 5.2; gawk -P, one true awk, mawk, busybox awk.
    * macOS Catalina, bash 3.2, macOS awk 20070501.
    
    **Performance comparison:**
    
    Mawk turned out the fastest, then perl.
    One true awk's implementation should be the closest to macOS awk.
    Test data: 230 KB history, 15102 entries, including multi-line and duplicates.
    Linux, bash 4.4. Times in milliseconds.
    
    | Command                 | Mean | Min  | Max  | Relative |
    | :---                    | ---: | ---: | ---: | -------: |
    | `mawk 1.3.4`            | 22.9 | 22.3 | 25.6 | **1.00** |
    | `perl 5.26.1`           | 34.3 | 33.6 | 35.1 |   1.49   |
    | `one true awk 20221215` | 41.9 | 40.6 | 46.3 |   1.83   |
    | `gawk 5.1.0`            | 46.1 | 44.4 | 50.3 |   2.01   |
    | `busybox awk 1.27.0`    | 64.8 | 63.2 | 70.0 |   2.82   |
    
    **Other Notes**
    
    A bug affects bash, which fails restoring a saved multi-line history entry as a single entry. Bug fixed in version 5.0.[^1]
    
    While developing this PR I discovered two unsubmitted issues affecting the current perl script. The output stream ends with `$'\n\0000'` instead of `$'\0000'`. Because of this, the script does not deduplicate a duplicated entry located at the end of the history list; therefore fzf displays two identical (not necessarily adjacent) entries. A minor point about the first issue is that the top fzf entry ends with a dangling line feed symbol, which is visible in the terminal.
    
    [^1]: https://github.com/bminor/bash/blob/ec8113b9861375e4e17b3307372569d429dec814/CHANGES#L1511
      To enable: `shopt -s cmdhist lithist; HISTTIMEFORMAT='%F %T '`.
    step- committed May 30, 2023
    Configuration menu
    Copy the full SHA
    d9b63ec View commit details
    Browse the repository at this point in the history

Commits on Sep 21, 2023

  1. Cherry pick master file updates

    - [bash] Disable pipefail in command substitution 1894304
    - [shell] Use --scheme=path when appropriate 2bed7d3
    step- committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    5b2b87b View commit details
    Browse the repository at this point in the history

Commits on Sep 22, 2023

  1. Configuration menu
    Copy the full SHA
    0dce53b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    341c13e View commit details
    Browse the repository at this point in the history