Compare commits
No commits in common. "master" and "Integration_3.3.1" have entirely different histories.
master
...
Integratio
|
|
@ -22,4 +22,4 @@ tasks:
|
|||
ninja
|
||||
- test: |
|
||||
cd fish/build
|
||||
env ninja test
|
||||
env SHOW_INTERACTIVE_LOG=1 ninja test
|
||||
|
|
|
|||
|
|
@ -19,4 +19,4 @@ tasks:
|
|||
ninja
|
||||
- test: |
|
||||
cd fish/build
|
||||
env ninja test
|
||||
env SHOW_INTERACTIVE_LOG=1 ninja test
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ tasks:
|
|||
gmake -j2
|
||||
- test: |
|
||||
cd fish/build
|
||||
gmake test
|
||||
gmake test SHOW_INTERACTIVE_LOG=1
|
||||
|
|
|
|||
118
.cirrus.yml
118
.cirrus.yml
|
|
@ -1,118 +0,0 @@
|
|||
env:
|
||||
CIRRUS_CLONE_DEPTH: 1
|
||||
CI: 1
|
||||
|
||||
linux_task:
|
||||
matrix:
|
||||
- name: alpine
|
||||
container: &step
|
||||
image: ghcr.io/fish-shell/fish-ci/alpine:latest
|
||||
memory: 4GB
|
||||
- name: bionic
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/bionic:latest
|
||||
- name: bionic-asan-clang
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/bionic-asan-clang:latest
|
||||
- name: bionic-tsan
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/bionic-tsan:latest
|
||||
- name: bionic-tsan-clang
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/bionic-tsan-clang:latest
|
||||
- name: centos7
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/centos7:latest
|
||||
- name: centos8
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/centos8:latest
|
||||
- name: focal-32bit
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/focal-32bit:latest
|
||||
- name: xenial
|
||||
container:
|
||||
<<: *step
|
||||
image: ghcr.io/fish-shell/fish-ci/xenial:latest
|
||||
|
||||
tests_script:
|
||||
# cirrus at times gives us 32 procs and 2 GB of RAM
|
||||
# Unrestriced parallelism results in OOM
|
||||
- lscpu || true
|
||||
- (cat /proc/meminfo | grep MemTotal) || true
|
||||
- mkdir build && cd build
|
||||
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCTEST_PARALLEL_LEVEL=6 ..
|
||||
- ninja -j 6 fish fish_tests
|
||||
- ninja fish_run_tests
|
||||
|
||||
# CI task disabled during RIIR transition
|
||||
only_if: false && $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
|
||||
linux_arm_task:
|
||||
matrix:
|
||||
- name: focal-arm64
|
||||
arm_container:
|
||||
image: ghcr.io/fish-shell/fish-ci/focal-arm64
|
||||
only_if: $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
- name: jammy-armv7-32bit
|
||||
arm_container:
|
||||
image: ghcr.io/fish-shell/fish-ci/jammy-armv7-32bit
|
||||
|
||||
tests_script:
|
||||
# cirrus at times gives us 32 procs and 2 GB of RAM
|
||||
# Unrestriced parallelism results in OOM
|
||||
- lscpu || true
|
||||
- (cat /proc/meminfo | grep MemTotal) || true
|
||||
- mkdir build && cd build
|
||||
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCTEST_PARALLEL_LEVEL=6 ..
|
||||
- ninja -j 6 fish fish_tests
|
||||
- file ./fish
|
||||
- ninja fish_run_tests
|
||||
|
||||
# CI task disabled during RIIR transition
|
||||
only_if: false && $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
|
||||
freebsd_task:
|
||||
matrix:
|
||||
# - name: FreeBSD 14
|
||||
# freebsd_instance:
|
||||
# image_family: freebsd-14-0-snap
|
||||
- name: FreeBSD 13
|
||||
freebsd_instance:
|
||||
image: freebsd-13-1-release-amd64
|
||||
- name: FreeBSD 12.3
|
||||
freebsd_instance:
|
||||
image: freebsd-12-3-release-amd64
|
||||
tests_script:
|
||||
- pkg install -y cmake-core devel/pcre2 devel/ninja misc/py-pexpect git-lite
|
||||
# libclang.so is a required build dependency for rust-c++ ffi bridge
|
||||
- pkg install -y llvm
|
||||
# BSDs have the following behavior: root may open or access files even if
|
||||
# the mode bits would otherwise disallow it. For example root may open()
|
||||
# a file with write privileges even if the file has mode 400. This breaks
|
||||
# our tests for e.g. cd and path. So create a new unprivileged user to run tests.
|
||||
- pw user add -n fish-user -s /bin/csh -d /home/fish-user
|
||||
- mkdir -p /home/fish-user
|
||||
- chown -R fish-user /home/fish-user
|
||||
- mkdir build && cd build
|
||||
- chown -R fish-user ..
|
||||
- sudo -u fish-user -s whoami
|
||||
# FreeBSD's pkg currently has rust 1.66.0 while we need rust 1.67.0+. Use rustup to install
|
||||
# the latest, but note that it only installs rust per-user.
|
||||
- sudo -u fish-user -s fetch -qo - https://sh.rustup.rs > rustup.sh
|
||||
- sudo -u fish-user -s sh ./rustup.sh -y --profile=minimal
|
||||
# `sudo -s ...` does not invoke a login shell so we need a workaround to make sure the
|
||||
# rustup environment is configured for subsequent `sudo -s ...` commands.
|
||||
# For some reason, this doesn't do the job:
|
||||
# - sudo -u fish-user sh -c 'echo source \$HOME/.cargo/env >> $HOME/.cshrc'
|
||||
- sudo -u fish-user -s cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCTEST_PARALLEL_LEVEL=1 ..
|
||||
- sudo -u fish-user sh -c '. $HOME/.cargo/env; ninja -j 6 fish fish_tests'
|
||||
- sudo -u fish-user sh -c '. $HOME/.cargo/env; ninja fish_run_tests'
|
||||
|
||||
only_if: $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-valist.Uninitialized,cert-*,performance-*,portability-*,-modernize-use-auto,modernize-loop-convert,modernize-use-bool-literals,modernize-use-using,hicpp-uppercase-literal-suffix,readability-make-member-function-const,readability-redundant-string-init,readability-inconsistent-declaration-parameter-name,readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-cert-dcl21-cpp,-cert-dcl37-c,-cert-dcl50-cpp,-cert-dcl51-cpp,-cert-str34-c,-cert-env33-c,misc-static-assert,readability-use-anyofallof,readability-simplify-*,readability-redundant-*,modernize-redundant-void-arg,modernize-make-shared,modernize-make-unique,modernize-loop-convert,'
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-valist.Uninitialized,cert-*,performance-*,portability-*,-modernize-use-auto,modernize-loop-convert,modernize-use-bool-literals,modernize-use-using,hicpp-uppercase-literal-suffix,readability-make-member-function-const,readability-redundant-string-init,readability-inconsistent-declaration-parameter-name,readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-cert-dcl37-c,-cert-dcl50-cpp,-cert-dcl51-cpp,-cert-str34-c,-cert-env33-c'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
AnalyzeTemporaryDtors: false
|
||||
|
|
|
|||
|
|
@ -20,9 +20,3 @@ indent_size = 2
|
|||
|
||||
[Dockerfile]
|
||||
indent_size = 2
|
||||
|
||||
[share/{completions,functions}/**.fish]
|
||||
max_line_length = none
|
||||
|
||||
[{COMMIT_EDITMSG,git-revise-todo}]
|
||||
max_line_length = 80
|
||||
|
|
|
|||
|
|
@ -21,13 +21,11 @@
|
|||
/.github/* export-ignore
|
||||
/.builds export-ignore
|
||||
/.builds/* export-ignore
|
||||
/.travis.yml export-ignore
|
||||
|
||||
# for linguist; let github identify our project as C++ instead of C due to pcre2
|
||||
pcre2/** linguist-vendored
|
||||
/pcre2/* linguist-vendored
|
||||
angular.js linguist-vendored
|
||||
angular-*.js linguist-vendored
|
||||
doc_src/** linguist-documentation
|
||||
/doc_src/* linguist-documentation
|
||||
*.fish linguist-language=fish
|
||||
src/*.h linguist-language=c++
|
||||
src/builtins/*.h linguist-language=c++
|
||||
share/completions/*.fish linguist-documentation
|
||||
/tests/*.in linguist-language=fish
|
||||
|
|
|
|||
|
|
@ -12,5 +12,3 @@ Please tell us if you tried fish without third-party customizations by executing
|
|||
|
||||
Tell us how to reproduce the problem. Including an asciinema.org recording is useful for problems that involve the visual display of fish output such as its prompt.
|
||||
-->
|
||||
|
||||
**YOUR TEXT HERE**
|
||||
|
|
|
|||
|
|
@ -2,24 +2,15 @@ name: 'Lock threads'
|
|||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 18 * * 1'
|
||||
# │ │ │ │ │
|
||||
# min 0-59 ┘ │ │ │ └ weekday 0-6
|
||||
# hour 0-23 ┘ │ └ month 1-12
|
||||
# └ day 1-31
|
||||
permissions:
|
||||
contents: read
|
||||
- cron: '0 18 * * *'
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
permissions:
|
||||
issues: write # for dessant/lock-threads to lock issues
|
||||
pull-requests: write # for dessant/lock-threads to lock PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v4
|
||||
- uses: dessant/lock-threads@v2
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-inactive-days: '365'
|
||||
pr-inactive-days: '365'
|
||||
exclude-any-issue-labels: 'question, needs more info'
|
||||
issue-lock-inactive-days: '180'
|
||||
pr-lock-inactive-days: '180'
|
||||
issue-exclude-labels: 'question'
|
||||
|
|
|
|||
|
|
@ -1,31 +1,18 @@
|
|||
name: make test
|
||||
name: C/C++ CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
CTEST_PARALLEL_LEVEL: "1"
|
||||
CMAKE_BUILD_PARALLEL_LEVEL: "4"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
ubuntu:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: 1.67
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
sudo pip3 install pexpect
|
||||
# Generate a locale that uses a comma as decimal separator.
|
||||
sudo locale-gen fr_FR.UTF-8
|
||||
- name: cmake
|
||||
env:
|
||||
# Some warnings upgraded to errors to match Open Build Service platforms
|
||||
|
|
@ -40,17 +27,12 @@ jobs:
|
|||
run: |
|
||||
make test
|
||||
|
||||
ubuntu-32bit-fetched-pcre2:
|
||||
ubuntu-32bit-vendored-pcre2:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: 1.67
|
||||
targets: "i686-unknown-linux-gnu" # setup-rust wants this space-separated
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt update
|
||||
|
|
@ -62,10 +44,10 @@ jobs:
|
|||
CFLAGS: "-m32"
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake -DFISH_USE_SYSTEM_PCRE2=OFF -DRust_CARGO_TARGET=i686-unknown-linux-gnu ..
|
||||
cmake -DFISH_USE_SYSTEM_PCRE2=OFF ..
|
||||
- name: make
|
||||
run: |
|
||||
make VERBOSE=1
|
||||
make
|
||||
- name: make test
|
||||
run: |
|
||||
make test
|
||||
|
|
@ -73,24 +55,9 @@ jobs:
|
|||
ubuntu-asan:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# Rust has two different memory sanitizers of interest; they can't be used at the same time:
|
||||
# * AddressSanitizer detects out-of-bound access, use-after-free, use-after-return,
|
||||
# use-after-scope, double-free, invalid-free, and memory leaks.
|
||||
# * MemorySanitizer detects uninitialized reads.
|
||||
#
|
||||
RUSTFLAGS: "-Zsanitizer=address"
|
||||
# RUSTFLAGS: "-Zsanitizer=memory -Zsanitizer-memory-track-origins"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
# All -Z options require running nightly
|
||||
rust-version: nightly
|
||||
# ASAN uses `cargo build -Zbuild-std` which requires the rust-src component
|
||||
components: rust-src
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
|
|
@ -99,72 +66,50 @@ jobs:
|
|||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
CXXFLAGS: "-fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address -DFISH_CI_SAN"
|
||||
CXXFLAGS: "-fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address"
|
||||
ASAN_OPTIONS: check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1
|
||||
UBSAN_OPTIONS: print_stacktrace=1:report_error_type=1
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
# Rust's ASAN requires the build system to explicitly pass a --target triple. We read that
|
||||
# value from CMake variable Rust_CARGO_TARGET (shared with corrosion).
|
||||
cmake .. -DASAN=1 -DRust_CARGO_TARGET=x86_64-unknown-linux-gnu -DCMAKE_BUILD_TYPE=Debug
|
||||
cmake ..
|
||||
- name: make
|
||||
run: |
|
||||
make
|
||||
- name: make test
|
||||
env:
|
||||
FISH_CI_SAN: 1
|
||||
ASAN_OPTIONS: check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1
|
||||
UBSAN_OPTIONS: print_stacktrace=1:report_error_type=1
|
||||
# use_tls=0 is a workaround for LSAN crashing with "Tracer caught signal 11" (SIGSEGV),
|
||||
# which seems to be an issue with TLS support in newer glibc versions under virtualized
|
||||
# environments. Follow https://github.com/google/sanitizers/issues/1342 and
|
||||
# https://github.com/google/sanitizers/issues/1409 to track this issue.
|
||||
LSAN_OPTIONS: verbosity=0:log_threads=0:use_tls=0
|
||||
run: |
|
||||
make test
|
||||
|
||||
# Our clang++ tsan builds are not recognizing safe rust patterns (such as the fact that Drop
|
||||
# cannot be called while a thread is using the object in question). Rust has its own way of
|
||||
# running TSAN, but for the duration of the port from C++ to Rust, we'll keep this disabled.
|
||||
ubuntu-threadsan:
|
||||
|
||||
# ubuntu-threadsan:
|
||||
#
|
||||
# runs-on: ubuntu-latest
|
||||
#
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
# - name: SetupRust
|
||||
# uses: ATiltedTree/setup-rust@v1
|
||||
# with:
|
||||
# rust-version: 1.67
|
||||
# - name: Install deps
|
||||
# run: |
|
||||
# sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
# sudo pip3 install pexpect
|
||||
# - name: cmake
|
||||
# env:
|
||||
# FISH_CI_SAN: 1
|
||||
# CC: clang
|
||||
# CXX: clang++
|
||||
# CXXFLAGS: "-fsanitize=thread"
|
||||
# run: |
|
||||
# mkdir build && cd build
|
||||
# cmake ..
|
||||
# - name: make
|
||||
# run: |
|
||||
# make
|
||||
# - name: make test
|
||||
# run: |
|
||||
# make test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
sudo pip3 install pexpect
|
||||
- name: cmake
|
||||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
CXXFLAGS: "-fsanitize=thread"
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
- name: make
|
||||
run: |
|
||||
make
|
||||
- name: make test
|
||||
run: |
|
||||
make test
|
||||
|
||||
macos:
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: 1.67
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo pip3 install pexpect
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
name: Rust checks
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
rustfmt:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: stable
|
||||
- name: cargo fmt
|
||||
run: |
|
||||
cd fish-rust
|
||||
cargo fmt --check --all
|
||||
|
||||
clippy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: SetupRust
|
||||
uses: ATiltedTree/setup-rust@v1
|
||||
with:
|
||||
rust-version: stable
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip tmux
|
||||
sudo pip3 install pexpect
|
||||
- name: cmake
|
||||
run: |
|
||||
cmake -B build
|
||||
- name: cargo clippy
|
||||
run: |
|
||||
cd fish-rust
|
||||
cargo clippy --workspace --all-targets -- --deny=warnings
|
||||
|
|
@ -89,16 +89,3 @@ __pycache__
|
|||
/tags
|
||||
xcuserdata/
|
||||
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# Generated by clangd
|
||||
/.cache
|
||||
|
|
|
|||
680
CHANGELOG.rst
680
CHANGELOG.rst
|
|
@ -1,675 +1,3 @@
|
|||
fish 3.7.0 (released ???)
|
||||
===================================
|
||||
|
||||
.. ignore: 9439 9440 9442 9452 9469 9480 9482
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- ``abbr --erase`` now also erases the universal variables used by the old abbr function. That means::
|
||||
abbr --erase (abbr --list)
|
||||
|
||||
can now be used to clean out all old abbreviations (:issue:`9468`).
|
||||
- ``abbr --add --universal`` now warns about --universal being non-functional, to make it easier to detect old-style ``abbr`` calls (:issue:`9475`).
|
||||
- ``functions --handlers-type caller-exit`` once again lists functions defined as ``function --on-job-exit caller``, rather than them being listed by ``functions --handlers-type process-exit``.
|
||||
|
||||
Deprecations and removed features
|
||||
---------------------------------
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
- ``abbr --list`` no longer escapes the abbr name, which is necessary to be able to pass it to ``abbr --erase`` (:issue:`9470`).
|
||||
- ``read`` will now print an error if told to set a read-only variable instead of silently doing nothing (:issue:`9346`).
|
||||
- ``functions`` and ``type`` now show where a function was copied and where it originally was instead of saying ``Defined interactively``.
|
||||
- Stack trace now shows line numbers for copied functions.
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- Using ``fish_vi_key_bindings`` in combination with fish's ``--no-config`` mode works without locking up the shell (:issue:`9443`).
|
||||
- The history pager now uses more screen space, usually half the screen (:issue:`9458`).
|
||||
- The history pager now shows fuzzy (subsequence) matches in the absence of exact substring matches (:issue:`9476`).
|
||||
- Variables that were set while the locale was C (i.e. ASCII) will now properly be encoded if the locale is switched (:issue:`2613`, :issue:`9473`).
|
||||
- Escape during history search restores the original commandline again (regressed in 3.6.0).
|
||||
- Using ``--help`` on builtins now respects the $MANPAGER variable in preference to $PAGER (:issue:`9488`).
|
||||
- Command-specific tab completions may now offer results whose first character is a period. For example, it is now possible to tab-complete ``git add`` for files with leading periods. The default file completions hide these files, unless the token itself has a leading period (:issue:`3707`).
|
||||
- A new variable, :envvar:`fish_cursor_external`, can be used to specify to cursor shape when a command is launched. When unspecified, the value defaults to the value of :envvar:`fish_cursor_default` (:issue:`4656`).
|
||||
|
||||
New or improved bindings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Improved prompts
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
- Added completions for:
|
||||
|
||||
- ``otool``
|
||||
- ``mix phx``
|
||||
- ``neovim``
|
||||
- ``stow``
|
||||
- ``trash`` and helper utilities ``trash-empty``, ``trash-list``, ``trash-put``, ``trash-restore``
|
||||
- ``apkanalyzer``
|
||||
- ``scrypt``
|
||||
- ``fastboot``
|
||||
|
||||
- git's completion for ``git-foo``-style commands was fixed (:issue:`9457`)
|
||||
- File completion now offers ``../`` and ``./`` again (:issue:`9477`)
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Other improvements
|
||||
------------------
|
||||
|
||||
|
||||
For distributors
|
||||
----------------
|
||||
- *Placeholder to fix Sphinx warning*
|
||||
|
||||
--------------
|
||||
|
||||
|
||||
fish 3.6.0 (released January 7, 2023)
|
||||
=====================================
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- By default, :kbd:`Control-R` now opens the command history in the pager (:issue:`602`). This is fully searchable and syntax-highlighted, as an alternative to the incremental search seen in other shells. The new special input function ``history-pager`` has been added for custom bindings.
|
||||
- Abbrevations are more flexible (:issue:`9313`, :issue:`5003`, :issue:`2287`):
|
||||
|
||||
- They may optionally replace tokens anywhere on the command line, instead of only commands
|
||||
- Matching tokens may be described using a regular expression instead of a literal word
|
||||
- The replacement text may be produced by a fish function, instead of a literal word
|
||||
- They may position the cursor anywhere in the expansion, instead of at the end
|
||||
|
||||
For example::
|
||||
|
||||
function multicd
|
||||
echo cd (string repeat -n (math (string length -- $argv[1]) - 1) ../)
|
||||
end
|
||||
|
||||
abbr --add dotdot --regex '^\.\.+$' --function multicd
|
||||
|
||||
This expands ``..`` to ``cd ../``, ``...`` to ``cd ../../`` and ``....`` to ``cd ../../../`` and so on.
|
||||
|
||||
Or::
|
||||
|
||||
function last_history_item; echo $history[1]; end
|
||||
abbr -a !! --position anywhere --function last_history_item
|
||||
|
||||
which expands ``!!`` to the last history item, anywhere on the command line, mimicking other shells' history expansion.
|
||||
|
||||
See :ref:`the documentation <cmd-abbr>` for more.
|
||||
- ``path`` gained a new ``mtime`` subcommand to print the modification time stamp for files. For example, this can be used to handle cache file ages (:issue:`9057`)::
|
||||
|
||||
> touch foo
|
||||
> sleep 10
|
||||
> path mtime --relative foo
|
||||
10
|
||||
|
||||
- ``string`` gained a new ``shorten`` subcommand to shorten strings to a given visible width (:issue:`9156`)::
|
||||
|
||||
> string shorten --max 10 "Hello this is a long string"
|
||||
Hello thi…
|
||||
|
||||
- ``test`` (aka ``[``) gained ``-ot`` (older than) and ``-nt`` (newer than) operators to compare file modification times, and ``-ef`` to compare whether the arguments are the same file (:issue:`3589`).
|
||||
- fish will now mark the extent of many errors with a squiggly line, instead of just a caret (``^``) at the beginning (:issue:`9130`). For example::
|
||||
|
||||
checks/set.fish (line 471): for: a,b: invalid variable name. See `help identifiers`
|
||||
for a,b in y 1 z 3
|
||||
^~^
|
||||
- A new function, ``fish_delta``, shows changes that have been made in fish's configuration from the defaults (:issue:`9255`).
|
||||
- ``set --erase`` can now be used with multiple scopes at once, like ``set -efglU foo`` (:issue:`7711`, :issue:`9280`).
|
||||
- ``status`` gained a new subcommand, ``current-commandline``, which retrieves the entirety of the currently-executing command line when called from a function during execution. This allows easier job introspection (:issue:`8905`, :issue:`9296`).
|
||||
|
||||
Deprecations and removed features
|
||||
---------------------------------
|
||||
- The ``\x`` and ``\X`` escape syntax is now equivalent. ``\xAB`` previously behaved the same as ``\XAB``, except that it would error if the value "AB" was larger than "7f" (127 in decimal, the highest ASCII value) (:issue:`9247`, :issue:`9245`, :issue:`1352`).
|
||||
- The ``fish_git_prompt`` will now only turn on features if the appropriate variable has been set to a true value (of "1", "yes" or "true") instead of just checking if it is defined. This allows specifically turning features *off* without having to erase variables, such as via universal variables. If you have defined a variable to a different value and expect it to count as true, you need to change it (:issue:`9274`).
|
||||
For example, ``set -g __fish_git_prompt_show_informative_status 0`` previously would have enabled informative status (because any value would have done so), but now it turns it off.
|
||||
- Abbreviations are no longer stored in universal variables. Existing universal abbreviations are still imported, but new abbreviations should be added to ``config.fish``.
|
||||
- The short option ``-r`` for abbreviations has changed from ``rename`` to ``regex``, for consistency with ``string``.
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
- ``argparse`` can now be used without option specifications, to allow using ``--min-args``, ``--max-args`` or for commands that take no options (but might in future) (:issue:`9006`)::
|
||||
|
||||
function my_copy
|
||||
argparse --min-args 2 -- $argv
|
||||
or return
|
||||
|
||||
cp $argv
|
||||
end
|
||||
|
||||
- ``set --show`` now shows when a variable was inherited from fish's parent process, which should help with debugging (:issue:`9029`)::
|
||||
|
||||
> set --show XDG_DATA_DIRS
|
||||
$XDG_DATA_DIRS: set in global scope, exported, a path variable with 4 elements
|
||||
$XDG_DATA_DIRS[1]: |/home/alfa/.local/share/flatpak/exports/share|
|
||||
$XDG_DATA_DIRS[2]: |/var/lib/flatpak/exports/share|
|
||||
$XDG_DATA_DIRS[3]: |/usr/local/share|
|
||||
$XDG_DATA_DIRS[4]: |/usr/share|
|
||||
$XDG_DATA_DIRS: originally inherited as |/home/alfa/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/|
|
||||
|
||||
- The read limit is now restored to the default when :envvar:`fish_read_limit` is unset (:issue:`9129`).
|
||||
- ``math`` produces an error for division-by-zero, as well as augmenting some errors with their extent (:issue:`9190`). This changes behavior in some limited cases, such as::
|
||||
|
||||
math min 1 / 0, 5
|
||||
|
||||
which would previously print "5" (because in floating point division "1 / 0" yields infinite, and 5 is smaller than infinite) but will now return an error.
|
||||
- ``fish_clipboard_copy`` and ``fish_clipboard_paste`` can now be used in pipes (:issue:`9271`)::
|
||||
|
||||
git rev-list 3.5.1 | fish_clipboard_copy
|
||||
|
||||
fish_clipboard_paste | string join + | math
|
||||
|
||||
- ``status fish-path`` returns a fully-normalised path, particularly noticeable on NetBSD (:issue:`9085`).
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- If the terminal definition for :envvar:`TERM` can't be found, fish now tries using the "xterm-256color" and "xterm" definitions before "ansi" and "dumb". As the majority of terminal emulators in common use are now more or less xterm-compatible (often even explicitly claiming the xterm-256color entry), this should often result in a fully or almost fully usable terminal (:issue:`9026`).
|
||||
- A new variable, :envvar:`fish_cursor_selection_mode`, can be used to configure whether the command line selection includes the character under the cursor (``inclusive``) or not (``exclusive``). The new default is ``exclusive``; use ``set fish_cursor_selection_mode inclusive`` to get the previous behavior back (:issue:`7762`).
|
||||
- fish's completion pager now fills half the terminal on first tab press instead of only 4 rows, which should make results visible more often and save key presses, without constantly snapping fish to the top of the terminal (:issue:`9105`, :issue:`2698`).
|
||||
- The ``complete-and-search`` binding, used with :kbd:`Shift-Tab` by default, selects the first item in the results immediately (:issue:`9080`).
|
||||
- ``bind`` output is now syntax-highlighted when used interacively.
|
||||
- :kbd:`Alt-H` (the default ``__fish_man_page`` binding) does a better job of showing the manual page of the command under cursor (:issue:`9020`).
|
||||
- If :envvar:`fish_color_valid_path` contains an actual color instead of just modifiers, those will be used for valid paths even if the underlying color isn't "normal" (:issue:`9159`).
|
||||
- The key combination for the QUIT terminal sequence, often :kbd:`Control-Backslash` (``\x1c``), can now be sused as a binding (:issue:`9234`).
|
||||
- fish's vi mode uses normal xterm-style sequences to signal cursor change, instead of using the iTerm's proprietary escape sequences. This allows for a blinking cursor and makes it work in complicated scenarios with nested terminals. (:issue:`3741`, :issue:`9172`)
|
||||
- When running fish on a remote system (such as inside SSH or a container), :kbd:`Control-X` now copies to the local client system's clipboard if the terminal supports OSC 52.
|
||||
- ``commandline`` gained two new options, ``--selection-start`` and ``--selection-end``, to set the start/end of the current selection (:issue:`9197`, :issue:`9215`).
|
||||
- fish's builtins now handle keyboard interrupts (:kbd:`Control-C`) correctly (:issue:`9266`).
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
- Added completions for:
|
||||
|
||||
- ``ark``
|
||||
- ``asciinema`` (:issue:`9257`)
|
||||
- ``clojure`` (:issue:`9272`)
|
||||
- ``csh``
|
||||
- ``direnv`` (:issue:`9268`)
|
||||
- ``dive`` (:issue:`9082`)
|
||||
- ``dolphin``
|
||||
- ``dua`` (:issue:`9277`)
|
||||
- ``efivar`` (:issue:`9318`)
|
||||
- ``eg``
|
||||
- ``es`` (:issue:`9388`)
|
||||
- ``firefox-developer-edition`` and ``firefox`` (:issue:`9090`)
|
||||
- ``fortune`` (:issue:`9177`)
|
||||
- ``kb``
|
||||
- ``kind`` (:issue:`9110`)
|
||||
- ``konsole``
|
||||
- ``ksh``
|
||||
- ``loadkeys`` (:issue:`9312`)
|
||||
- ``okular``
|
||||
- ``op`` (:issue:`9300`)
|
||||
- ``ouch`` (:issue:`9405`)
|
||||
- ``pix``
|
||||
- ``readelf`` (:issue:`8746`, :issue:`9386`)
|
||||
- ``qshell``
|
||||
- ``rc``
|
||||
- ``sad`` (:issue:`9145`)
|
||||
- ``tcsh``
|
||||
- ``toot``
|
||||
- ``tox`` (:issue:`9078`)
|
||||
- ``wish``
|
||||
- ``xed``
|
||||
- ``xonsh`` (:issue:`9389`)
|
||||
- ``xplayer``
|
||||
- ``xreader``
|
||||
- ``xviewer``
|
||||
- ``yash`` (:issue:`9391`)
|
||||
- ``zig`` (:issue:`9083`)
|
||||
|
||||
- Improvements to many completions, including making ``cd`` completion much faster (:issue:`9220`).
|
||||
- Completion of tilde (``~``) works properly even when the file name contains an escaped character (:issue:`9073`).
|
||||
- fish no longer loads completions if the command is used via a relative path and is not in :envvar:`PATH` (:issue:`9133`).
|
||||
- fish no longer completes inside of comments (:issue:`9320`).
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- Opening ``help`` on WSL now uses PowerShell to open the browser if available, removing some awkward UNC path errors (:issue:`9119`).
|
||||
|
||||
Other improvements
|
||||
------------------
|
||||
- The Web-based configuration tool now works on systems with IPv6 disabled (:issue:`3857`).
|
||||
- Aliases can ignore arguments by ending them with ``#`` (:issue:`9199`).
|
||||
- ``string`` is now faster when reading large strings from stdin (:issue:`9139`).
|
||||
- ``string repeat`` uses less memory and is faster. (:issue:`9124`)
|
||||
- Builtins are much faster when writing to a pipe or file. (:issue:`9229`).
|
||||
- Performance improvements to highlighting (:issue:`9180`) should make using fish more pleasant on slow systems.
|
||||
- On 32-bit systems, globs like ``*`` will no longer fail to return some files, as large file support has been enabled.
|
||||
|
||||
Fixed bugs
|
||||
----------
|
||||
- The history search text for a token search is now highlighted correctly if the line contains multiple instances of that text (:issue:`9066`).
|
||||
- ``process-exit`` and ``job-exit`` events are now generated for all background jobs, including those launched from event handlers (:issue:`9096`).
|
||||
- A crash when completing a token that contained both a potential glob and a quoted variable expansion was fixed (:issue:`9137`).
|
||||
- ``prompt_pwd`` no longer accidentally overwrites a global or universal ``$fish_prompt_pwd_full_dirs`` when called with the ``-d`` or ``--full-length-dirs`` option (:issue:`9123`).
|
||||
- A bug which caused fish to freeze or exit after running a command which does not preserve the foreground process group was fixed (:issue:`9181`).
|
||||
- The "Disco" sample prompt no longer prints an error in some working directories (:issue:`9164`). If you saved this prompt, you should run ``fish_config prompt save disco`` again.
|
||||
- fish launches external commands via the given path again, rather than always using an absolute path. This behaviour was inadvertently changed in 3.5.0 and is visible, for example, when launching a bash script which checks ``$0`` (:issue:`9143`).
|
||||
- ``printf`` no longer tries to interpret the first argument as an option (:issue:`9132`).
|
||||
- Interactive ``read`` in scripts will now have the correct keybindings again (:issue:`9227`).
|
||||
- A possible stack overflow when recursively evaluating substitutions has been fixed (:issue:`9302`).
|
||||
- A crash with relative $CDPATH has been fixed (:issue:`9407`).
|
||||
- ``printf`` now properly fills extra ``%d`` specifiers with 0 even on macOS and BSD (:issue:`9321`).
|
||||
- ``fish_key_reader`` now correctly exits when receiving a SIGHUP (like after closing the terminal) (:issue:`9309`).
|
||||
- ``fish_config theme save`` now works as documented instead of erroring out (:issue:`9088`, :issue:`9273`).
|
||||
- fish no longer triggers prompts to install command line tools when first run on macOS (:issue:`9343`).
|
||||
- ``fish_git_prompt`` now quietly fails on macOS if the xcrun cache is not yet populated (:issue:`6625`), working around a potential hang.
|
||||
|
||||
For distributors
|
||||
----------------
|
||||
- The vendored PCRE2 sources have been removed. It is recommended to declare PCRE2 as a dependency when packaging fish. If the CMake variable FISH_USE_SYSTEM_PCRE2 is false, fish will now download and build PCRE2 from the official repo (:issue:`8355`, :issue:`8363`). Note this variable defaults to true if PCRE2 is found installed on the system.
|
||||
|
||||
--------------
|
||||
|
||||
fish 3.5.1 (released July 20, 2022)
|
||||
===================================
|
||||
|
||||
This release of fish introduces the following small enhancements:
|
||||
|
||||
- Cursor shaping for Vi mode is enabled by default in tmux, and will be used if the outer terminal is capable (:issue:`8981`).
|
||||
- ``printf`` returns a better error when used with arguments interpreted as octal numbers (:issue:`9035`).
|
||||
- ``history merge`` when in private mode is now an error, rather than wiping out other sessions' history (:issue:`9050`).
|
||||
- The error message when launching a command that is built for the wrong architecture on macOS is more helpful (:issue:`9052`).
|
||||
- Added completions for:
|
||||
|
||||
- ``choose`` (:issue:`9065`)
|
||||
- ``expect`` (:issue:`9060`)
|
||||
- ``navi`` (:issue:`9064`)
|
||||
- ``qdbus`` (:issue:`9031`)
|
||||
- ``reflector`` (:issue:`9027`)
|
||||
|
||||
- Improvements to some completions.
|
||||
|
||||
This release also fixes a number of problems identified in fish 3.5.0.
|
||||
|
||||
- Completing ``git blame`` or ``git -C`` works correctly (:issue:`9053`).
|
||||
- On terminals that emit a ``CSI u`` sequence for :kbd:`Shift-Space`, fish inserts a space instead of printing an error. (:issue:`9054`).
|
||||
- ``status fish-path`` on Linux-based platforms could print the path with a " (deleted)" suffix (such as ``/usr/bin/fish (deleted)``), which is now removed (:issue:`9019`).
|
||||
- Cancelling an initial command (from fish's ``--init-command`` option) with :kbd:`Control-C` no longer prevents configuration scripts from running (:issue:`9024`).
|
||||
- The job summary contained extra blank lines if the prompt used multiple lines, which is now fixed (:issue:`9044`).
|
||||
- Using special input functions in bindings, in combination with ``and``/``or`` conditionals, no longer crashes (:issue:`9051`).
|
||||
|
||||
--------------
|
||||
|
||||
fish 3.5.0 (released June 16, 2022)
|
||||
===================================
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- A new ``path`` builtin command to filter and transform paths (:issue:`7659`, :issue:`8958`). For example, to list all the separate extensions used on files in /usr/share/man (after removing one extension, commonly a ".gz")::
|
||||
|
||||
path filter -f /usr/share/man/** | path change-extension '' | path extension | path sort -u
|
||||
- Tab (or any key bound to ``complete``) now expands wildcards instead of invoking completions, if there is a wildcard in the path component under the cursor (:issue:`954`, :issue:`8593`).
|
||||
- Scripts can now catch and handle the SIGINT and SIGTERM signals, either via ``function --on-signal`` or with ``trap`` (:issue:`6649`).
|
||||
|
||||
Deprecations and removed features
|
||||
---------------------------------
|
||||
- The ``stderr-nocaret`` feature flag, introduced in fish 3.0 and enabled by default in fish 3.1, has been made read-only.
|
||||
That means it is no longer possible to disable it, and code supporting the ``^`` redirection has been removed (:issue:`8857`, :issue:`8865`).
|
||||
|
||||
To recap: fish used to support ``^`` to redirect stderr, so you could use commands like::
|
||||
|
||||
test "$foo" -gt 8 ^/dev/null
|
||||
|
||||
to ignore error messages. This made the ``^`` symbol require escaping and quoting, and was a bit of a weird shortcut considering ``2>`` already worked, which is only one character longer.
|
||||
|
||||
So the above can simply become::
|
||||
|
||||
test "$foo" -gt 8 2>/dev/null
|
||||
|
||||
- The following feature flags have been enabled by default:
|
||||
|
||||
- ``regex-easyesc``, which makes ``string replace -r`` not do a superfluous round of unescaping in the replacement expression.
|
||||
That means e.g. to escape any "a" or "b" in an argument you can use ``string replace -ra '([ab])' '\\\\$1' foobar`` instead of needing 8 backslashes.
|
||||
|
||||
This only affects the *replacement* expression, not the *match* expression (the ``'([ab])'`` part in the example).
|
||||
A survey of plugins on GitHub did not turn up any affected code, so we do not expect this to affect many users.
|
||||
|
||||
This flag was introduced in fish 3.1.
|
||||
- ``ampersand-nobg-in-token``, which means that ``&`` will not create a background job if it occurs in the middle of a word. For example, ``echo foo&bar`` will print "foo&bar" instead of running ``echo foo`` in the background and then starting ``bar`` as a second job.
|
||||
|
||||
Reformatting with ``fish_indent`` would already introduce spaces, turning ``echo foo&bar`` into ``echo foo & bar``.
|
||||
|
||||
This flag was introduced in fish 3.4.
|
||||
|
||||
To turn off these flags, add ``no-regex-easyesc`` or ``no-ampersand-nobg-in-token`` to :envvar:`fish_features` and restart fish::
|
||||
|
||||
set -Ua fish_features no-regex-easyesc
|
||||
|
||||
Like ``stderr-nocaret``, they will eventually be made read-only.
|
||||
- Most ``string`` subcommands no longer append a newline to their input if the input didn't have one (:issue:`8473`, :issue:`3847`)
|
||||
- Fish's escape sequence removal (like for ``string length --visible`` or to figure out how wide the prompt is) no longer has special support for non-standard color sequences like from Data General terminals, e.g. the Data General Dasher D220 from 1984. This removes a bunch of work in the common case, allowing ``string length --visible`` to be much faster with unknown escape sequences. We don't expect anyone to have ever used fish with such a terminal (:issue:`8769`).
|
||||
- Code to upgrade universal variables from fish before 3.0 has been removed. Users who upgrade directly from fish versions 2.7.1 or before will have to set their universal variables & abbreviations again. (:issue:`8781`)
|
||||
- The meaning of an empty color variable has changed (:issue:`8793`). Previously, when a variable was set but empty, it would be interpreted as the "normal" color. Now, empty color variables cause the same effect as unset variables - the general highlighting variable for that type is used instead. For example::
|
||||
|
||||
set -g fish_color_command blue
|
||||
set -g fish_color_keyword
|
||||
|
||||
would previously make keywords "normal" (usually white in a dark terminal). Now it'll make them blue. To achieve the previous behavior, use the normal color explicitly: ``set -g fish_color_keyword normal``.
|
||||
|
||||
This makes it easier to make self-contained color schemes that don't accidentally use color that was set before.
|
||||
``fish_config`` has been adjusted to set known color variables that a theme doesn't explicitly set to empty.
|
||||
- ``eval`` is now a reserved keyword, so it can't be used as a function name. This follows ``set`` and ``read``, and is necessary because it can't be cleanly shadowed by a function - at the very least ``eval set -l argv foo`` breaks. Fish will ignore autoload files for it, so left over ``eval.fish`` from previous fish versions won't be loaded.
|
||||
- The git prompt in informative mode now defaults to skipping counting untracked files, as this was extremely slow. To turn it on, set :envvar:`__fish_git_prompt_showuntrackedfiles` or set the git config value "bash.showuntrackedfiles" to ``true`` explicitly (which can be done for individual repositories). The "informative+vcs" sample prompt already skipped display of untracked files, but didn't do so in a way that skipped the computation, so it should be quite a bit faster in many cases (:issue:`8980`).
|
||||
- The ``__terlar_git_prompt`` function, used by the "Terlar" sample prompt, has been rebuilt as a configuration of the normal ``fish_git_prompt`` to ease maintenance, improve performance and add features (like reading per-repo git configuration). Some slight changes remain; users who absolutely must have the same behavior are encouraged to copy the old function (:issue:`9011`, :issue:`7918`, :issue:`8979`).
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
- Quoted command substitution that directly follow a variable expansion (like ``echo "$var$(echo x)"``) no longer affect the variable expansion (:issue:`8849`).
|
||||
- Fish now correctly expands command substitutions that are preceded by an escaped dollar (like ``echo \$(echo)``). This regressed in version 3.4.0.
|
||||
- ``math`` can now handle underscores (``_``) as visual separators in numbers (:issue:`8611`, :issue:`8496`)::
|
||||
|
||||
math 5 + 2_123_252
|
||||
|
||||
- ``math``'s ``min`` and ``max`` functions now take a variable number of arguments instead of always requiring 2 (:issue:`8644`, :issue:`8646`)::
|
||||
|
||||
> math min 8,2,4
|
||||
2
|
||||
|
||||
- ``read`` is now faster as the last process in a pipeline (:issue:`8552`).
|
||||
- ``string join`` gained a new ``--no-empty`` flag to skip empty arguments (:issue:`8774`, :issue:`8351`).
|
||||
- ``read`` now only triggers the ``fish_read`` event, not the ``fish_prompt`` event (:issue:`8797`). It was supposed to work this way in fish 3.2.0 and later, but both events were emitted.
|
||||
- The TTY modes are no longer restored when non-interactive shells exit. This fixes wrong tty modes in pipelines with interactive commands. (:issue:`8705`).
|
||||
- Some functions shipped with fish printed error messages to standard output, but they now they rightly go to standard error (:issue:`8855`).
|
||||
- ``jobs`` now correctly reports CPU usage as a percentage, instead of as a number of clock ticks (:issue:`8919`).
|
||||
- ``process-exit`` events now fire when the process exits even if the job has not yet exited, fixing a regression in 3.4.1 (:issue:`8914`).
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- Fish now reports a special error if a command wasn't found and there is a non-executable file by that name in :envvar:`PATH` (:issue:`8804`).
|
||||
- ``less`` and other interactive commands would occasionally be stopped when run in a pipeline with fish functions; this has been fixed (:issue:`8699`).
|
||||
- Case-changing autosuggestions generated mid-token now correctly append only the suffix, instead of duplicating the token (:issue:`8820`).
|
||||
- ``ulimit`` learned a number of new options for the resource limits available on Linux, FreeBSD ande NetBSD, and returns a specific warning if the limit specified is not available on the active operating system (:issue:`8823`, :issue:`8786`).
|
||||
- The ``vared`` command can now successfully edit variables named "tmp" or "prompt" (:issue:`8836`, :issue:`8837`).
|
||||
- ``time`` now emits an error if used after the first command in a pipeline (:issue:`8841`).
|
||||
- ``fish_add_path`` now prints a message for skipped non-existent paths when using the ``-v`` flag (:issue:`8884`).
|
||||
- Since fish 3.2.0, pressing :kbd:`Control-D` while a command is running would end up inserting a space into the next commandline, which has been fixed (:issue:`8871`).
|
||||
- A bug that caused multi-line prompts to be moved down a line when pasting or switching modes has been fixed (:issue:`3481`).
|
||||
- The Web-based configuration system no longer strips too many quotes in the abbreviation display (:issue:`8917`, :issue:`8918`).
|
||||
- Fish started with ``--no-config`` will now use the default keybindings (:issue:`8493`)
|
||||
- When fish inherits a :envvar:`USER` environment variable value that doesn't correspond to the current effective user ID, it will now correct it in all cases (:issue:`8879`, :issue:`8583`).
|
||||
- Fish sets a new :envvar:`EUID` variable containing the current effective user id (:issue:`8866`).
|
||||
- ``history search`` no longer interprets the search term as an option (:issue:`8853`)
|
||||
- The status message when a job terminates should no longer be erased by a multiline prompt (:issue:`8817`)
|
||||
|
||||
New or improved bindings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- The :kbd:`Alt-S` binding will now insert ``doas`` instead of ``sudo`` if necessary (:issue:`8942`).
|
||||
- The ``kill-whole-line`` special input function now kills the newline preceeding the last line. This makes ``dd`` in vi-mode clear the last line properly.
|
||||
- The new ``kill-inner-line`` special input function kills the line without any newlines, allowing ``cc`` in vi-mode to clear the line while preserving newlines (:issue:`8983`).
|
||||
- On terminals that emit special sequences for these combinations, :kbd:`Shift-Space` is bound like :kbd:`Space`, and :kbd:`Ctrl-Return` is bound like :kbd:`Return` (:issue:`8874`).
|
||||
|
||||
Improved prompts
|
||||
^^^^^^^^^^^^^^^^
|
||||
- A new ``Astronaut`` prompt (:issue:`8775`), a multi-line prompt using plain text reminiscent of the Starship.rs prompt.
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
- Added completions for:
|
||||
|
||||
- ``archlinux-java`` (:issue:`8911`)
|
||||
- ``apk`` (:issue:`8951`)
|
||||
- ``brightnessctl`` (:issue:`8758`)
|
||||
- ``efibootmgr`` (:issue:`9010`)
|
||||
- ``fastboot`` (:issue:`8904`)
|
||||
- ``optimus-manager`` (:issue:`8913`)
|
||||
- ``rclone`` (:issue:`8819`)
|
||||
- ``sops`` (:issue:`8821`)
|
||||
- ``tuned-adm`` (:issue:`8760`)
|
||||
- ``wg-quick`` (:issue:`8687`)
|
||||
|
||||
- ``complete`` can now be given multiple ``--condition`` options. They will be attempted in the order they were given, and only if all succeed will the completion be made available (as if they were connected with ``&&``). This helps with caching - fish's complete system stores the return value of each condition as long as the commandline doesn't change, so this can reduce the number of conditions that need to be evaluated (:issue:`8536`, :issue:`8967`).
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- Working directory reporting is enabled for kitty (:issue:`8806`).
|
||||
- Changing the cursor shape is now enabled by default in iTerm2 (:issue:`3696`).
|
||||
|
||||
For distributors
|
||||
----------------
|
||||
- libatomic is now correctly detected as necessary when building on RISC-V (:issue:`8850`, :issue:`8851`).
|
||||
- In some cases, the build process found the wrong libintl on macOS. This has been corrected (:issue:`5244`).
|
||||
- The paths for completions, functions, and configuration snippets now include
|
||||
subdirectories ``fish/vendor_completions.d``, ``fish/vendor_functions.d``, and
|
||||
``fish/vendor_conf.d`` (respectively) within ``XDG_DATA_HOME`` (or ``~/.local/share``
|
||||
if not defined) (:issue:`8887`, :issue:`7816`).
|
||||
|
||||
--------------
|
||||
|
||||
fish 3.4.1 (released March 25, 2022)
|
||||
====================================
|
||||
|
||||
This release of fish fixes the following problems identified in fish 3.4.0:
|
||||
|
||||
- An error printed after upgrading, where old instances could pick up a newer version of the ``fish_title`` function, has been fixed (:issue:`8778`)
|
||||
- fish builds correctly on NetBSD (:issue:`8788`) and OpenIndiana (:issue:`8780`).
|
||||
- ``nextd-or-forward-word``, bound to :kbd:`Alt-Right Arrow` by default, was inadvertently changed to move like ``forward-bigword``. This has been corrected (:issue:`8790`).
|
||||
- ``funcsave -q`` and ``funcsave --quiet`` now work correctly (:issue:`8830`).
|
||||
- Issues with the ``csharp`` and ``nmcli`` completions were corrected.
|
||||
|
||||
If you are upgrading from version 3.3.1 or before, please also review the release notes for 3.4.0 (included below).
|
||||
|
||||
--------------
|
||||
|
||||
fish 3.4.0 (released March 12, 2022)
|
||||
====================================
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- fish's command substitution syntax has been extended: ``$(cmd)`` now has the same meaning as ``(cmd)`` but it can be used inside double quotes, to prevent line splitting of the results (:issue:`159`)::
|
||||
|
||||
foo (bar | string collect)
|
||||
# can now be written as
|
||||
foo "$(bar)"
|
||||
|
||||
# and
|
||||
|
||||
foo (bar)
|
||||
# can now be written as
|
||||
foo $(bar)
|
||||
# this will still split on newlines only.
|
||||
|
||||
- Complementing the ``prompt`` command in 3.3.0, ``fish_config`` gained a ``theme`` subcommand to show and pick from the sample themes (meaning color schemes) directly in the terminal, instead of having to open a Web browser. For example ``fish_config theme choose Nord`` loads the Nord theme in the current session (:issue:`8132`). The current theme can be saved with ``fish_config theme dump``, and custom themes can be added by saving them in ``~/.config/fish/themes/``.
|
||||
- ``set`` and ``read`` learned a new option, ``--function``, to set a variable in the function's top scope. This should be a more familiar way of scoping variables and avoids issues with ``--local``, which is actually block-scoped (:issue:`565`, :issue:`8145`)::
|
||||
|
||||
function demonstration
|
||||
if true
|
||||
set --function foo bar
|
||||
set --local baz banana
|
||||
end
|
||||
echo $foo # prints "bar" because $foo is still valid
|
||||
echo $baz # prints nothing because $baz went out of scope
|
||||
end
|
||||
|
||||
- ``string pad`` now excludes escape sequences like colors that fish knows about, and a new ``--visible`` flag to ``string length`` makes it use that kind of visible width. This is useful to get the number of terminal cells an already colored string would occupy, like in a prompt. (:issue:`8182`, :issue:`7784`, :issue:`4012`)::
|
||||
|
||||
> string length --visible (set_color red)foo
|
||||
3
|
||||
|
||||
- Performance improvements to globbing, especially on systems using glibc. In some cases (large directories with files with many numbers in the names) this almost halves the time taken to expand the glob.
|
||||
- Autosuggestions can now be turned off by setting ``$fish_autosuggestion_enabled`` to 0, and (almost) all highlighting can be turned off by choosing the new "None" theme. The exception is necessary colors, like those which distinguish autosuggestions from the actual command line. (:issue:`8376`)
|
||||
- The ``fish_git_prompt`` function, which is included in the default prompts, now overrides ``git`` to avoid running commands set by per-repository configuration. This avoids a potential security issue in some circumstances, and has been assigned CVE-2022-20001 (:issue:`8589`).
|
||||
|
||||
Deprecations and removed features
|
||||
---------------------------------
|
||||
- A new feature flag, ``ampersand-nobg-in-token`` makes ``&`` only act as background operator if followed by a separator. In combination with ``qmark-noglob``, this allows entering most URLs at the command line without quoting or escaping (:issue:`7991`). For example::
|
||||
|
||||
> echo foo&bar # will print "foo&bar", instead of running "echo foo" in the background and executing "bar"
|
||||
> echo foo & bar # will still run "echo foo" in the background and then run "bar"
|
||||
# with both ampersand-nobg-in-token and qmark-noglob, this argument has no special characters anymore
|
||||
> open https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtu.be
|
||||
|
||||
As a reminder, feature flags can be set on startup with ``fish --features ampersand-nobg-in-token,qmark-noglob`` or with a universal variable called ``fish_features``::
|
||||
|
||||
> set -Ua fish_features ampersand-nobg-in-token
|
||||
|
||||
- ``$status`` is now forbidden as a command, to prevent a surprisingly common error among new users: Running ``if $status`` (:issue:`8171`). This applies *only* to ``$status``, other variables are still allowed.
|
||||
- ``set --query`` now returns an exit status of 255 if given no variable names. This means ``if set -q $foo`` will not enter the if-block if ``$foo`` is empty or unset. To restore the previous behavior, use ``if not set -q foo; or set -q $foo`` - but this is unlikely to be desireable (:issue:`8214`).
|
||||
- ``_`` is now a reserved keyword (:issue:`8342`).
|
||||
- The special input functions ``delete-or-exit``, ``nextd-or-forward-word`` and ``prevd-or-backward-word`` replace fish functions of the same names (:issue:`8538`).
|
||||
- Mac OS X 10.9 is no longer supported. The minimum Mac version is now 10.10 "Yosemite."
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
- ``string collect`` supports a new ``--allow-empty`` option, which will output one empty argument in a command substitution that has no output (:issue:`8054`). This allows commands like ``test -n (echo -n | string collect --allow-empty)`` to work more reliably. Note this can also be written as ``test -n "$(echo -n)"`` (see above).
|
||||
- ``string match`` gained a ``--groups-only`` option, which makes it only output capturing groups, excluding the full match. This allows ``string match`` to do simple transformations (:issue:`6056`)::
|
||||
|
||||
> string match -r --groups-only '(.*)fish' 'catfish' 'twofish' 'blue fish' | string escape
|
||||
cat
|
||||
two
|
||||
'blue '
|
||||
|
||||
- ``$fish_user_paths`` is now automatically deduplicated to fix a common user error of appending to it in config.fish when it is universal (:issue:`8117`). :ref:`fish_add_path <cmd-fish_add_path>` remains the recommended way to add to $PATH.
|
||||
- ``return`` can now be used outside functions. In scripts, it does the same thing as ``exit``. In interactive mode,it sets ``$status`` without exiting (:issue:`8148`).
|
||||
- An oversight prevented all syntax checks from running on commands given to ``fish -c`` (:issue:`8171`). This includes checks such as ``exec`` not being allowed in a pipeline, and ``$$`` not being a valid variable. Generally, another error was generated anyway.
|
||||
- ``fish_indent`` now correctly reformats tokens that end with a backslash followed by a newline (:issue:`8197`).
|
||||
- ``commandline`` gained an ``--is-valid`` option to check if the command line is syntactically valid and complete. This allows basic implementation of transient prompts (:issue:`8142`).
|
||||
- ``commandline`` gained a ``--paging-full-mode`` option to check if the pager is showing all the possible lines (no "7 more rows" message) (:issue:`8485`).
|
||||
- List expansion correctly reports an error when used with all zero indexes (:issue:`8213`).
|
||||
- Running ``fish`` with a directory instead of a script as argument (eg ``fish .``) no longer leads to an infinite loop. Instead it errors out immediately (:issue:`8258`)
|
||||
- Some error messages occuring after fork, like "text file busy" have been replaced by bespoke error messages for fish (like "File is currently open for writing"). This also restores error messages with current glibc versions that removed sys_errlist (:issue:`8234`, :issue:`4183`).
|
||||
- The ``realpath`` builtin now also squashes leading slashes with the ``--no-symlinks`` option (:issue:`8281`).
|
||||
- When trying to ``cd`` to a dangling (broken) symbolic link, fish will print an error noting that the target is a broken link (:issue:`8264`).
|
||||
- On MacOS terminals that are not granted permissions to access a folder, ``cd`` would print a spurious "rotten symlink" error, which has been corrected to "permission denied" (:issue:`8264`).
|
||||
- Since fish 3.0, ``for`` loops would trigger a variable handler function before the loop was entered. As the variable had not actually changed or been set, this was a spurious event and has been removed (:issue:`8384`).
|
||||
- ``math`` now correctly prints negative values and values larger than ``2**31`` when in hex or octal bases (:issue:`8417`).
|
||||
- ``dirs`` always produces an exit status of 0, instead of sometimes returning 1 (:issue:`8211`).
|
||||
- ``cd ""`` no longer crashes fish (:issue:`8147`).
|
||||
- ``set --query`` can now query whether a variable is a path variable via ``--path`` or ``--unpath`` (:issue:`8494`).
|
||||
- Tilde characters (``~``) produced by custom completions are no longer escaped when applied to the command line, making it easier to use the output of a recursive ``complete -C`` in completion scripts (:issue:`4570`).
|
||||
- ``set --show`` reports when a variable is read-only (:issue:`8179`).
|
||||
- Erasing ``$fish_emoji_width`` will reset fish to the default guessed emoji width (:issue:`8274`).
|
||||
- The ``la`` function no longer lists entries for "." and "..", matching other systems defaults (:issue:`8519`).
|
||||
- ``abbr -q`` returns the correct exit status when given multiple abbreviation names as arguments (:issue:`8431`).
|
||||
- ``command -v`` returns an exit status of 127 instead of 1 if no command was found (:issue:`8547`).
|
||||
- ``argparse`` with ``--ignore-unknown`` no longer breaks with multiple unknown options in a short option group (:issue:`8637`).
|
||||
- Comments inside command substitutions or brackets now correctly ignore parentheses, quotes, and brackets (:issue:`7866`, :issue:`8022`, :issue:`8695`).
|
||||
- ``complete -C`` supports a new ``--escape`` option, which turns on escaping in returned completion strings (:issue:`3469`).
|
||||
- Invalid byte or unicode escapes like ``\Utest`` or ``\xNotHex`` are now a tokenizer error instead of causing the token to be truncated (:issue:`8545`).
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- Vi mode cursors are now set properly after :kbd:`Control-C` (:issue:`8125`).
|
||||
- ``funced`` will try to edit the whole file containing a function definition, if there is one (:issue:`391`).
|
||||
- Running a command line consisting of just spaces now deletes an ephemeral (starting with space) history item again (:issue:`8232`).
|
||||
- Command substitutions no longer respect job control, instead running inside fish's own process group (:issue:`8172`). This more closely matches other shells, and improves :kbd:`Control-C` reliability inside a command substitution.
|
||||
- ``history`` and ``__fish_print_help`` now properly support ``less`` before version 530, including the version that ships with macOS. (:issue:`8157`).
|
||||
- ``help`` now knows which section is in which document again (:issue:`8245`).
|
||||
- fish's highlighter will now color options (starting with ``-`` or ``--``) with the color given in the new $fish_color_option, up to the first ``--``. It falls back on $fish_color_param, so nothing changes for existing setups (:issue:`8292`).
|
||||
- When executing a command, abbreviations are no longer expanded when the cursor is separated from the command by spaces, making it easier to suppress abbreviation expansion of commands without arguments. (:issue:`8423`).
|
||||
- ``fish_key_reader``'s output was simplified. By default, it now only prints a bind statement. The previous per-character timing information can be seen with a new ``--verbose`` switch (:issue:`8467`).
|
||||
- Custom completions are now also loaded for commands that contain tildes or variables like ``~/bin/fish`` or ``$PWD/fish`` (:issue:`8442`).
|
||||
- Command lines spanning multiple lines will not be overwritten by the completion pager when it fills the entire terminal (:issue:`8509`, :issue:`8405`).
|
||||
- When redrawing a multiline prompt, the old prompt is now properly cleared (:issue:`8163`).
|
||||
- Interactive completion would occasionally ignore the last word on the command line due to a race condition. This has been fixed (:issue:`8175`).
|
||||
- Propagation of universal variables from a fish process that is closing is faster (:issue:`8209`).
|
||||
- The command line is drawn in the correct place if the prompt ends with a newline (:issue:`8298`).
|
||||
- ``history`` learned a new subcommand ``clear-session`` to erase all history from the current session (:issue:`5791`).
|
||||
- Pressing :kbd:`Control-C` in ``fish_key_reader`` will no longer print the incorrect "Press [ctrl-C] again to exit" message (:issue:`8510`).
|
||||
- The default command-not-found handler for Fedora/PackageKit now passes the whole command line, allowing for functionality such as running the suggested command directly (:issue:`8579`).
|
||||
- When looking for locale information, the Debian configuration is now used when available (:issue:`8557`).
|
||||
- Pasting text containing quotes from the clipboard trims spaces more appropriately (:issue:`8550`).
|
||||
- The clipboard bindings ignore X-based clipboard programs if the ``DISPLAY`` environment variable is not set, which helps prefer the Windows clipboard when it is available (such as on WSL).
|
||||
- ``funcsave`` will remove a saved copy of a function that has been erased with ``functions --erase``.
|
||||
- The Web-based configuration tool gained a number of improvements, including the ability to set pager colors.
|
||||
- The default ``fish_title`` prints a shorter title with shortened $PWD and no more redundant "fish" (:issue:`8641`).
|
||||
- Holding down an arrow key won't freeze the terminal with long periods of flashing (:issue:`8610`).
|
||||
- Multi-char bindings are no longer interrupted if a signal handler enqueues an event. (:issue:`8628`).
|
||||
|
||||
New or improved bindings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- :kbd:`Escape` can now bound without breaking arrow key bindings (:issue:`8428`).
|
||||
- The :kbd:`Alt-H` binding (to open a command’s manual page) now also ignores ``command`` (:issue:`8447`).
|
||||
|
||||
Improved prompts
|
||||
^^^^^^^^^^^^^^^^
|
||||
- The ``fish_status_to_signal`` helper function returns the correct signal names for the current platform, rather than Linux (:issue:`8530`).
|
||||
- The ``prompt_pwd`` helper function learned a ``--full-length-dirs N`` option to keep the last N directory components unshortened. In addition the number of characters to shorten each component should be shortened to can now be given as ``-d N`` or ``--dir-length N``. (:issue:`8208`)::
|
||||
|
||||
> prompt_pwd --full-length-dirs 2 -d 1 ~/dev/fish-shell/share/tools/web_config
|
||||
~/d/f/s/tools/web_config
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
- Added completions for:
|
||||
|
||||
- Apple's ``shortcuts``
|
||||
- ``argparse`` (:issue:`8434`)
|
||||
- ``asd`` (:issue:`8759`)
|
||||
- ``az`` (:issue:`8141`)
|
||||
- ``black`` (:issue:`8123`)
|
||||
- ``clasp`` (:issue:`8373`)
|
||||
- ``cpupower`` (:issue:`8302`)
|
||||
- ``dart`` (:issue:`8315`)
|
||||
- ``dscacheutil``
|
||||
- ``elvish`` (:issue:`8416`)
|
||||
- ``ethtool`` (:issue:`8283`)
|
||||
- ``exif`` (:issue:`8246`)
|
||||
- ``findstr`` (:issue:`8481`)
|
||||
- ``git-sizer`` (:issue:`8156`)
|
||||
- ``gnome-extensions`` (:issue:`8732`)
|
||||
- ``gping`` (:issue:`8181`)
|
||||
- ``isatty`` (:issue:`8609`)
|
||||
- ``istioctl`` (:issue:`8343`)
|
||||
- ``kmutil``
|
||||
- ``kubectl`` (:issue:`8734`)
|
||||
- ``matlab`` (:issue:`8505`)
|
||||
- ``mono`` (:issue:`8415`) and related tools ``csharp``, ``gacutil``, ``gendarme``, ``ikdasm``, ``ilasm``, ``mkbundle``, ``monodis``, ``monop``, ``sqlsharp`` and ``xsp`` (:issue:`8452`)
|
||||
- Angular's ``ng`` (:issue:`8111`)
|
||||
- ``nodeenv`` (:issue:`8533`)
|
||||
- ``octave`` (:issue:`8505`)
|
||||
- ``pabcnet_clear`` (:issue:`8421`)
|
||||
- ``qmk`` (:issue:`8180`)
|
||||
- ``rakudo`` (:issue:`8113`)
|
||||
- ``rc-status`` (:issue:`8757`)
|
||||
- ``roswell`` (:issue:`8330`)
|
||||
- ``sbcl`` (:issue:`8330`)
|
||||
- ``starship`` (:issue:`8520`)
|
||||
- ``topgrade`` (:issue:`8651`)
|
||||
- ``wine``, ``wineboot`` and ``winemaker`` (:issue:`8411`)
|
||||
- Windows Subsystem for Linux (WSL)'s ``wslpath`` (:issue:`8364`)
|
||||
- Windows' ``color`` (:issue:`8483`), ``attrib``, ``attributes``, ``choice``, ``clean``, ``cleanmgr``, ``cmd``, ``cmdkey``, ``comp``, ``forfiles``, ``powershell``, ``reg``, ``schtasks``, ``setx`` (:issue:`8486`)
|
||||
- ``zef`` (:issue:`8114`)
|
||||
|
||||
- Improvements to many completions, especially for ``git`` aliases (:issue:`8129`), subcommands (:issue:`8134`) and submodules (:issue:`8716`).
|
||||
- Many adjustments to complete correct options for system utilities on BSD and macOS.
|
||||
- When evaluating custom completions, the command line state no longer includes variable overrides (``var=val``). This unbreaks completions that read ``commandline -op``.
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- Dynamic terminal titles are enabled on WezTerm (:issue:`8121`).
|
||||
- Directory history navigation works out of the box with Apple Terminal's default key settings (:issue:`2330`).
|
||||
- fish now assumes Unicode 9+ widths for emoji under iTerm 2 (:issue:`8200`).
|
||||
- Skin-tone emoji modifiers (U+1F3FB through U+1F3FF) are now measured as width 0 (:issue:`8275`).
|
||||
- fish's escape sequence removal now also knows Tmux's wrapped escapes.
|
||||
- Vi mode cursors are enabled in Apple Terminal.app (:issue:`8167`).
|
||||
- Vi cursor shaping and $PWD reporting is now also enabled on foot (:issue:`8422`).
|
||||
- ``ls`` will use colors also on newer versions of Apple Terminal.app (:issue:`8309`).
|
||||
- The :kbd:`Delete` and :kbd:`Shift-Tab` keys work more reliably under ``st`` (:issue:`8352`, :issue:`8354`).
|
||||
|
||||
Other improvements
|
||||
------------------
|
||||
- Fish's test suite now uses ``ctest``, and has become much faster to run. It is now also possible to run only specific tests with targets named ``test_$filename`` - ``make test_set.fish`` only runs the set.fish test. (:issue:`7851`)
|
||||
- The HTML version of the documentation now includes copy buttons for code examples (:issue:`8218`).
|
||||
- The HTML version of the documentation and the web-based configuration tool now pick more modern system fonts instead of falling back to Arial and something like Courier New most of the time (:issue:`8632`).
|
||||
- The Debian & Ubuntu package linked from fishshell.com is now a single package, rather than split into ``fish`` and ``fish-common`` (:issue:`7845`).
|
||||
- The macOS installer does not assert that Rosetta is required to install fish on machines with Apple Silicon (:issue:`8566`).
|
||||
- The macOS installer now cleans up previous .pkg installations when upgrading. (:issue:`2963`).
|
||||
|
||||
For distributors
|
||||
----------------
|
||||
- The minimum version of CMake required to build fish is now 3.5.0.
|
||||
- The CMake installation supports absolute paths for ``CMAKE_INSTALL_DATADIR`` (:issue:`8150`).
|
||||
- Building using NetBSD curses works on any platform (:issue:`8087`).
|
||||
- The build system now uses the default linker instead of forcing use of the gold or lld linker (:issue:`8152`).
|
||||
|
||||
--------------
|
||||
|
||||
fish 3.3.1 (released July 6, 2021)
|
||||
==================================
|
||||
|
||||
|
|
@ -685,11 +13,10 @@ A number of improvements to the documentation, and fixes for completions, are in
|
|||
If you are upgrading from version 3.2.2 or before, please also review the release notes for 3.3.0 (included below).
|
||||
|
||||
--------------
|
||||
|
||||
|
||||
fish 3.3.0 (released June 28, 2021)
|
||||
===================================
|
||||
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- ``fish_config`` gained a ``prompt`` subcommand to show and pick from the sample prompts directly in the terminal, instead of having to open a webbrowser. For example ``fish_config prompt choose default`` loads the default prompt in the current session (:issue:`7958`).
|
||||
|
|
@ -699,7 +26,7 @@ Deprecations and removed features
|
|||
---------------------------------
|
||||
- The ``$fish_history`` value "default" is no longer special. It used to be treated the same as "fish" (:issue:`7650`).
|
||||
- Redirection to standard error with the ``^`` character has been disabled by default. It can be turned back on using the ``stderr-nocaret`` feature flag, but will eventually be disabled completely (:issue:`7105`).
|
||||
- Specifying an initial tab to ``fish_config`` now only works with ``fish_config browse`` (eg ``fish_config browse variables``), otherwise it would interfere with the new ``prompt`` subcommand (see below) (:issue:`7958`).
|
||||
- Specifying an initial tab to ``fish_config`` now only works with ``fish_config browse`` (e.g. ``fish_config browse variables``), otherwise it would interfere with the new ``prompt`` subcommand (see below) (:issue:`7958`).
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
|
|
@ -2192,7 +1519,6 @@ Interactive improvements
|
|||
key both on its own and as part of a control sequence, was applied to
|
||||
all control characters; this has been reduced to just the escape key.
|
||||
- Completing a function shows the description properly (:issue:`5206`).
|
||||
- `commandline` can now be used to set the commandline for the next command, restoring a behavior in 3.4.1 (:issue:`8807`).
|
||||
- Added completions for
|
||||
|
||||
- ``ansible``, including ``ansible-galaxy``, ``ansible-playbook``
|
||||
|
|
@ -3809,5 +3135,3 @@ to call ttyname() on OS X.
|
|||
|
||||
We’ve got some work to do to be as lean as bash, but we’re on the right
|
||||
track.
|
||||
|
||||
.. vim: ft=rst : tw=0 :
|
||||
|
|
|
|||
120
CMakeLists.txt
120
CMakeLists.txt
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
if(POLICY CMP0066)
|
||||
cmake_policy(SET CMP0066 OLD)
|
||||
|
|
@ -16,16 +16,20 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(DEFAULT_BUILD_TYPE "RelWithDebInfo")
|
||||
|
||||
# Generate Xcode schemas (but not for tests).
|
||||
set(CMAKE_XCODE_GENERATE_SCHEME 1)
|
||||
# Use the default flags (#6296) but remove -DNDEBUG so that asserts remain enabled.
|
||||
string(REPLACE "-DNDEBUG" ""
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
|
||||
string(REPLACE "-DNDEBUG" ""
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
"${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to default '${DEFAULT_BUILD_TYPE}'")
|
||||
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}")
|
||||
endif()
|
||||
|
||||
include(cmake/Rust.cmake)
|
||||
|
||||
# Error out when linking statically, it doesn't work.
|
||||
if (CMAKE_EXE_LINKER_FLAGS MATCHES ".*-static.*")
|
||||
message(FATAL_ERROR "Fish does not support static linking")
|
||||
|
|
@ -37,43 +41,44 @@ if (CMAKE_GENERATOR STREQUAL "Ninja" AND
|
|||
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)))
|
||||
add_compile_options(-fdiagnostics-color=always)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
||||
endif()
|
||||
|
||||
# Enable a whole bunch of warnings, but turn off:
|
||||
# - comment because we use a bunch of those, and they're not really all that harmful.
|
||||
# - address, because that occurs for our mkostemp check (weak-linking requires us to compare `&mkostemp == nullptr`).
|
||||
add_compile_options(-Wall -Wextra -Wno-comment -Wno-address)
|
||||
|
||||
# Get extra C++ files from Rust.
|
||||
get_property(FISH_EXTRA_SOURCES TARGET fish-rust PROPERTY fish_extra_cpp_files)
|
||||
|
||||
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
|
||||
add_compile_options(-Wunused-template -Wunused-local-typedef -Wunused-macros)
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra \
|
||||
-Wno-comment \
|
||||
-Wno-address \
|
||||
")
|
||||
|
||||
# Disable exception handling.
|
||||
add_compile_options(-fno-exceptions)
|
||||
|
||||
# Undefine NDEBUG to keep assert() in release builds.
|
||||
add_definitions(-UNDEBUG)
|
||||
|
||||
# Allow including Rust headers in normal (not bindgen) builds.
|
||||
add_definitions(-DINCLUDE_RUST_HEADERS)
|
||||
|
||||
# Enable large files on GNU.
|
||||
add_definitions(-D_LARGEFILE_SOURCE
|
||||
-D_LARGEFILE64_SOURCE
|
||||
-D_FILE_OFFSET_BITS=64
|
||||
-D_ATFILE_SOURCE)
|
||||
# Prefer lld or the gold linker because they don't emit useless warnings about sys_nerr and
|
||||
# _sys_errlist. They're also faster (significantly so in the case of lld).
|
||||
if (UNIX)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version
|
||||
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
||||
if ("${LD_VERSION}" MATCHES "LLD ")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
|
||||
elseif (NOT APPLE)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
|
||||
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
||||
if ("${LD_VERSION}" MATCHES "GNU gold")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Hide the CMake Rules directories in Xcode projects.
|
||||
source_group("CMake Rules" REGULAR_EXPRESSION "^$")
|
||||
|
||||
# Put source and header files at top level under targets.
|
||||
source_group("Source Files" REGULAR_EXPRESSION ".*\\.cpp")
|
||||
source_group("Header Files" REGULAR_EXPRESSION ".*\\.h")
|
||||
source_group("Builtins" "builtins/")
|
||||
source_group("Source Files" REGULAR_EXPRESSION "^$")
|
||||
source_group("Header Files" REGULAR_EXPRESSION "^$")
|
||||
source_group("Builtins" REGULAR_EXPRESSION "builtin_.*")
|
||||
|
||||
# Support folders.
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
|
@ -97,36 +102,34 @@ if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
|
|||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
endif()
|
||||
|
||||
# List of sources for builtin functions.
|
||||
set(FISH_BUILTIN_SRCS
|
||||
src/builtin.cpp src/builtins/argparse.cpp src/builtins/bind.cpp
|
||||
src/builtins/builtin.cpp src/builtins/cd.cpp src/builtins/command.cpp
|
||||
src/builtins/commandline.cpp src/builtins/complete.cpp
|
||||
src/builtins/disown.cpp
|
||||
src/builtins/eval.cpp src/builtins/fg.cpp
|
||||
src/builtins/function.cpp src/builtins/functions.cpp src/builtins/history.cpp
|
||||
src/builtins/jobs.cpp src/builtins/math.cpp src/builtins/printf.cpp src/builtins/path.cpp
|
||||
src/builtins/read.cpp src/builtins/set.cpp
|
||||
src/builtins/set_color.cpp src/builtins/source.cpp src/builtins/status.cpp
|
||||
src/builtins/string.cpp src/builtins/test.cpp src/builtins/type.cpp src/builtins/ulimit.cpp
|
||||
)
|
||||
|
||||
# List of other sources.
|
||||
# All objects that the system needs to build fish, except fish.cpp
|
||||
set(FISH_SRCS
|
||||
src/ast.cpp src/autoload.cpp src/color.cpp src/common.cpp src/complete.cpp
|
||||
src/env.cpp src/env_dispatch.cpp src/env_universal_common.cpp src/event.cpp
|
||||
src/exec.cpp src/expand.cpp src/fallback.cpp src/fish_version.cpp
|
||||
src/flog.cpp src/function.cpp src/highlight.cpp
|
||||
src/ast.cpp src/autoload.cpp src/builtin.cpp src/builtin_argparse.cpp
|
||||
src/builtin_bg.cpp src/builtin_bind.cpp src/builtin_block.cpp
|
||||
src/builtin_builtin.cpp src/builtin_cd.cpp src/builtin_command.cpp
|
||||
src/builtin_commandline.cpp src/builtin_complete.cpp src/builtin_contains.cpp
|
||||
src/builtin_disown.cpp src/builtin_echo.cpp src/builtin_emit.cpp
|
||||
src/builtin_eval.cpp src/builtin_exit.cpp src/builtin_fg.cpp
|
||||
src/builtin_function.cpp src/builtin_functions.cpp src/builtin_history.cpp
|
||||
src/builtin_jobs.cpp src/builtin_math.cpp src/builtin_printf.cpp
|
||||
src/builtin_pwd.cpp src/builtin_random.cpp src/builtin_read.cpp
|
||||
src/builtin_realpath.cpp src/builtin_return.cpp src/builtin_set.cpp
|
||||
src/builtin_set_color.cpp src/builtin_source.cpp src/builtin_status.cpp
|
||||
src/builtin_string.cpp src/builtin_test.cpp src/builtin_type.cpp src/builtin_ulimit.cpp
|
||||
src/builtin_wait.cpp src/color.cpp src/common.cpp src/complete.cpp src/env.cpp
|
||||
src/env_dispatch.cpp src/env_universal_common.cpp src/event.cpp src/exec.cpp
|
||||
src/expand.cpp src/fallback.cpp src/fd_monitor.cpp src/fish_version.cpp
|
||||
src/flog.cpp src/function.cpp src/future_feature_flags.cpp src/highlight.cpp
|
||||
src/history.cpp src/history_file.cpp src/input.cpp src/input_common.cpp
|
||||
src/io.cpp src/iothread.cpp src/kill.cpp
|
||||
src/intern.cpp src/io.cpp src/iothread.cpp src/job_group.cpp src/kill.cpp
|
||||
src/null_terminated_array.cpp src/operation_context.cpp src/output.cpp
|
||||
src/pager.cpp src/parse_execution.cpp src/parse_tree.cpp src/parse_util.cpp
|
||||
src/parser.cpp src/parser_keywords.cpp src/path.cpp src/postfork.cpp
|
||||
src/proc.cpp src/re.cpp src/reader.cpp src/screen.cpp
|
||||
src/signals.cpp src/termsize.cpp src/tinyexpr.cpp
|
||||
src/trace.cpp src/utf8.cpp
|
||||
src/wait_handle.cpp src/wcstringutil.cpp src/wgetopt.cpp src/wildcard.cpp
|
||||
src/wutil.cpp src/fds.cpp src/rustffi.cpp
|
||||
src/proc.cpp src/reader.cpp src/redirection.cpp src/sanity.cpp src/screen.cpp
|
||||
src/signal.cpp src/termsize.cpp src/timer.cpp src/tinyexpr.cpp
|
||||
src/tokenizer.cpp src/topic_monitor.cpp src/trace.cpp src/utf8.cpp src/util.cpp
|
||||
src/wait_handle.cpp src/wcstringutil.cpp src/wgetopt.cpp src/wildcard.cpp
|
||||
src/wutil.cpp src/fds.cpp
|
||||
)
|
||||
|
||||
# Header files are just globbed.
|
||||
|
|
@ -139,11 +142,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config_cmake.h.in
|
|||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Pull in our src directory for headers searches, but only quoted ones.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -iquote ${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
|
||||
|
||||
|
||||
# Set up standard directories.
|
||||
include(GNUInstallDirs)
|
||||
add_definitions(-D_UNICODE=1
|
||||
|
|
@ -183,13 +181,11 @@ function(FISH_LINK_DEPS_AND_SIGN target)
|
|||
endfunction(FISH_LINK_DEPS_AND_SIGN)
|
||||
|
||||
# Define libfish.a.
|
||||
add_library(fishlib STATIC ${FISH_SRCS} ${FISH_BUILTIN_SRCS})
|
||||
add_library(fishlib STATIC ${FISH_SRCS})
|
||||
target_sources(fishlib PRIVATE ${FISH_HEADERS})
|
||||
target_link_libraries(fishlib
|
||||
fish-rust
|
||||
${CURSES_LIBRARY} ${CURSES_EXTRA_LIBRARY} Threads::Threads ${CMAKE_DL_LIBS}
|
||||
${PCRE2_LIB} ${Intl_LIBRARIES} ${ATOMIC_LIBRARY}
|
||||
"fish-rust")
|
||||
${PCRE2_LIB} ${Intl_LIBRARIES} ${ATOMIC_LIBRARY})
|
||||
target_include_directories(fishlib PRIVATE
|
||||
${CURSES_INCLUDE_DIRS})
|
||||
|
||||
|
|
|
|||
126
CONTRIBUTING.rst
126
CONTRIBUTING.rst
|
|
@ -10,40 +10,8 @@ In short:
|
|||
- Be conservative in what you need (``C++11``, few dependencies)
|
||||
- Use automated tools to help you (including ``make test``, ``build_tools/style.fish`` and ``make lint``)
|
||||
|
||||
Contributing completions
|
||||
------------------------
|
||||
|
||||
Completion scripts are the most common contribution to fish, and they are very welcome.
|
||||
|
||||
In general, we'll take all well-written completion scripts for a command that is publically available.
|
||||
This means no private tools or personal scripts, and we do reserve the right to reject for other reasons.
|
||||
|
||||
Before you try to contribute them to fish, consider if the authors of the tool you are completing want to maintain the script instead.
|
||||
Often that makes more sense, specifically because they can add new options to the script immediately once they add them,
|
||||
and don't have to maintain one completion script for multiple versions. If the authors no longer wish to maintain the script,
|
||||
they can of course always contact the fish maintainers to hand it over, preferably by opening a PR.
|
||||
This isn't a requirement - if the authors don't want to maintain it, or you simply don't want to contact them,
|
||||
you can contribute your script to fish.
|
||||
|
||||
Completion scripts should
|
||||
|
||||
1. Use as few dependencies as possible - try to use fish's builtins like ``string`` instead of ``grep`` and ``awk``,
|
||||
use ``python`` to read json instead of ``jq`` (because it's already a soft dependency for fish's tools)
|
||||
2. If it uses a common unix tool, use posix-compatible invocations - ideally it would work on GNU/Linux, macOS, the BSDs and other systems
|
||||
3. Option and argument descriptions should be kept short.
|
||||
The shorter the description, the more likely it is that fish can use more columns.
|
||||
4. Function names should start with ``__fish``, and functions should be kept in the completion file unless they're used elsewhere.
|
||||
5. Run ``fish_indent`` on your script.
|
||||
6. Try not to use minor convenience features right after they are available in fish - we do try to keep completion scripts backportable.
|
||||
If something has a real impact on the correctness or performance, feel free to use it,
|
||||
but if it is just a shortcut, please leave it.
|
||||
|
||||
Put your completion script into share/completions/name-of-command.fish. If you have multiple commands, you need multiple files.
|
||||
|
||||
If you want to add tests, you probably want to add a littlecheck test. See below for details.
|
||||
|
||||
Contributing to fish's C++ core
|
||||
-------------------------------
|
||||
General
|
||||
-------
|
||||
|
||||
Fish uses C++11. Newer C++ features should not be used to make it possible to use on older systems.
|
||||
|
||||
|
|
@ -53,23 +21,37 @@ Don't introduce new dependencies unless absolutely necessary, and if you do,
|
|||
please make it optional with graceful failure if possible.
|
||||
Add any new dependencies to the README.rst under the *Running* and/or *Building* sections.
|
||||
|
||||
Linters
|
||||
-------
|
||||
This also goes for completion scripts and functions - if at all possible, they should only use
|
||||
POSIX-compatible invocations of any tools, and no superfluous dependencies.
|
||||
|
||||
Automated analysis tools like cppcheck can point out
|
||||
E.g. some completions deal with JSON data. In those it's preferable to use python to handle it,
|
||||
as opposed to ``jq``, because fish already optionally uses python elsewhere. (It also happens to be quite a bit *faster*)
|
||||
|
||||
Lint Free Code
|
||||
--------------
|
||||
|
||||
Automated analysis tools like cppcheck and oclint can point out
|
||||
potential bugs or code that is extremely hard to understand. They also
|
||||
help ensure the code has a consistent style and that it avoids patterns
|
||||
that tend to confuse people.
|
||||
|
||||
To make linting the code easy there are two make targets: ``lint``,
|
||||
to lint any modified but not committed ``*.cpp`` files, and
|
||||
``lint-all`` to lint all files.
|
||||
To make linting the code easy there are two make targets: ``lint`` and
|
||||
``lint-all``. The latter does exactly what the name implies. The former
|
||||
will lint any modified but not committed ``*.cpp`` files. If there is no
|
||||
uncommitted work it will lint the files in the most recent commit.
|
||||
|
||||
Fish has custom cppcheck rules in the file ``.cppcheck.rule``. These
|
||||
help catch mistakes such as using ``wcwidth()`` rather than
|
||||
``fish_wcwidth()``. Please add a new rule if you find similar mistakes
|
||||
being made.
|
||||
|
||||
Dealing With Lint Warnings
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You are strongly encouraged to address a lint warning by refactoring the
|
||||
code, changing variable names, or whatever action is implied by the
|
||||
warning.
|
||||
|
||||
Suppressing Lint Warnings
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -91,20 +73,24 @@ following:
|
|||
|
||||
[src/complete.cpp:1727]: warning (nullPointerRedundantCheck): Either the condition 'cmd_node' is redundant or there is possible null pointer dereference: cmd_node.
|
||||
|
||||
Code Style
|
||||
----------
|
||||
Suppressing oclint warnings is more complicated to describe so I’ll
|
||||
refer you to the `OCLint
|
||||
HowTo <http://docs.oclint.org/en/latest/howto/suppress.html#annotations>`__
|
||||
on the topic.
|
||||
|
||||
To ensure your changes conform to the style rules run
|
||||
Ensuring Your Changes Conform to the Style Guides
|
||||
-------------------------------------------------
|
||||
|
||||
The following sections discuss the specific rules for the style that
|
||||
should be used when writing fish code. To ensure your changes conform to
|
||||
the style rules you simply need to run
|
||||
|
||||
::
|
||||
|
||||
build_tools/style.fish
|
||||
|
||||
before committing your change. That will run our autoformatters:
|
||||
|
||||
- ``git-clang-format`` for c++
|
||||
- ``fish_indent`` (shipped with fish) for fish script
|
||||
- ``black`` for python
|
||||
before committing your change. That will run ``git-clang-format`` to
|
||||
rewrite only the lines you’re modifying.
|
||||
|
||||
If you’ve already committed your changes that’s okay since it will then
|
||||
check the files in the most recent commit. This can be useful after
|
||||
|
|
@ -122,6 +108,31 @@ If you want to check the style of the entire code base run
|
|||
That command will refuse to restyle any files if you have uncommitted
|
||||
changes.
|
||||
|
||||
Configuring Your Editor for Fish C++ Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Vim
|
||||
^^^
|
||||
|
||||
As of Vim 7.4 it does not recognize triple-slash comments as used by
|
||||
Doxygen and the OS X Xcode IDE to flag comments that explain the
|
||||
following C symbol. This means the ``gq`` key binding to reformat such
|
||||
comments doesn’t behave as expected. You can fix that by adding the
|
||||
following to your vimrc:
|
||||
|
||||
::
|
||||
|
||||
autocmd Filetype c,cpp setlocal comments^=:///
|
||||
|
||||
If you use Vim I recommend the `vim-clang-format
|
||||
plugin <https://github.com/rhysd/vim-clang-format>`__ by
|
||||
[@rhysd](https://github.com/rhysd).
|
||||
|
||||
Emacs
|
||||
^^^^^
|
||||
|
||||
If you use Emacs: TBD
|
||||
|
||||
Configuring Your Editor for Fish Scripts
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -158,6 +169,18 @@ made to run fish_indent via e.g.
|
|||
(add-hook 'fish-mode-hook (lambda ()
|
||||
(add-hook 'before-save-hook 'fish_indent-before-save)))
|
||||
|
||||
Suppressing Reformatting of C++ Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can tell ``clang-format`` to not reformat a block by enclosing it in
|
||||
comments like this:
|
||||
|
||||
::
|
||||
|
||||
// clang-format off
|
||||
code to ignore
|
||||
// clang-format on
|
||||
|
||||
Fish Script Style Guide
|
||||
-----------------------
|
||||
|
||||
|
|
@ -314,6 +337,8 @@ To install the lint checkers on Mac OS X using Homebrew:
|
|||
|
||||
::
|
||||
|
||||
brew tap oclint/formulae
|
||||
brew install oclint
|
||||
brew install cppcheck
|
||||
|
||||
To install the lint checkers on Debian-based Linux distributions:
|
||||
|
|
@ -321,6 +346,7 @@ To install the lint checkers on Debian-based Linux distributions:
|
|||
::
|
||||
|
||||
sudo apt-get install clang
|
||||
sudo apt-get install oclint
|
||||
sudo apt-get install cppcheck
|
||||
|
||||
Installing the Formatting Tools
|
||||
|
|
@ -420,8 +446,8 @@ Include What You Use
|
|||
You should not depend on symbols being visible to a ``*.cpp`` module
|
||||
from ``#include`` statements inside another header file. In other words
|
||||
if your module does ``#include "common.h"`` and that header does
|
||||
``#include "signals.h"`` your module should not assume the sub-include is
|
||||
present. It should instead directly ``#include "signals.h"`` if it needs
|
||||
``#include "signal.h"`` your module should not assume the sub-include is
|
||||
present. It should instead directly ``#include "signal.h"`` if it needs
|
||||
any symbol from that header. That makes the actual dependencies much
|
||||
clearer. It also makes it easy to modify the headers included by a
|
||||
specific header file without having to worry that will break any module
|
||||
|
|
|
|||
2
COPYING
2
COPYING
|
|
@ -1,7 +1,7 @@
|
|||
Fish is a smart and user-friendly command line shell.
|
||||
|
||||
Copyright (C) 2005-2009 Axel Liljencrantz
|
||||
Copyright (C) 2009-2023 fish-shell contributors
|
||||
Copyright (C) 2009-2021 fish-shell contributors
|
||||
|
||||
fish is free software.
|
||||
|
||||
|
|
|
|||
40
README.rst
40
README.rst
|
|
@ -1,8 +1,4 @@
|
|||
.. |Cirrus CI| image:: https://api.cirrus-ci.com/github/fish-shell/fish-shell.svg?branch=master
|
||||
:target: https://cirrus-ci.com/github/fish-shell/fish-shell
|
||||
:alt: Cirrus CI Build Status
|
||||
|
||||
`fish <https://fishshell.com/>`__ - the friendly interactive shell |Build Status| |Cirrus CI|
|
||||
`fish <https://fishshell.com/>`__ - the friendly interactive shell |Build Status|
|
||||
=================================================================================
|
||||
|
||||
fish is a smart and user-friendly command line shell for macOS, Linux,
|
||||
|
|
@ -10,7 +6,8 @@ and the rest of the family. fish includes features like syntax
|
|||
highlighting, autosuggest-as-you-type, and fancy tab completions that
|
||||
just work, with no configuration required.
|
||||
|
||||
For downloads, screenshots and more, go to https://fishshell.com/.
|
||||
For more on fish’s design philosophy, see the `design
|
||||
document <https://fishshell.com/docs/current/design.html>`__.
|
||||
|
||||
Quick Start
|
||||
-----------
|
||||
|
|
@ -37,8 +34,6 @@ fish can be installed:
|
|||
- using the `installer from fishshell.com <https://fishshell.com/>`__
|
||||
- as a `standalone app from fishshell.com <https://fishshell.com/>`__
|
||||
|
||||
Note: The minimum supported macOS version is 10.10 "Yosemite".
|
||||
|
||||
Packages for Linux
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
@ -53,8 +48,8 @@ and can be installed using the following commands:
|
|||
::
|
||||
|
||||
sudo apt-add-repository ppa:fish-shell/release-3
|
||||
sudo apt update
|
||||
sudo apt install fish
|
||||
sudo apt-get update
|
||||
sudo apt-get install fish
|
||||
|
||||
Instructions for other distributions may be found at
|
||||
`fishshell.com <https://fishshell.com>`__.
|
||||
|
|
@ -100,7 +95,7 @@ Running fish requires:
|
|||
The following optional features also have specific requirements:
|
||||
|
||||
- builtin commands that have the ``--help`` option or print usage
|
||||
messages require ``nroff`` or ``mandoc`` for
|
||||
messages require ``ul`` and either ``nroff`` or ``mandoc`` for
|
||||
display
|
||||
- automated completion generation from manual pages requires Python 3.5+
|
||||
- the ``fish_config`` web configuration tool requires Python 3.5+ and a web browser
|
||||
|
|
@ -109,8 +104,7 @@ The following optional features also have specific requirements:
|
|||
``wl-copy``/``wl-paste`` or ``pbcopy``/``pbpaste`` utilities
|
||||
- full completions for ``yarn`` and ``npm`` require the
|
||||
``all-the-package-names`` NPM module
|
||||
- ``colorls`` is used, if installed, to add color when running ``ls`` on platforms
|
||||
that do not have color support (such as OpenBSD)
|
||||
- ``colorls`` is used, if its installed, to add color when running ``ls``
|
||||
|
||||
Switching to fish
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -148,11 +142,10 @@ Dependencies
|
|||
|
||||
Compiling fish requires:
|
||||
|
||||
- Rust (version 1.67 or later)
|
||||
- a C++11 compiler (g++ 4.8 or later, or clang 3.3 or later)
|
||||
- CMake (version 3.5 or later)
|
||||
- CMake (version 3.2 or later)
|
||||
- a curses implementation such as ncurses (headers and libraries)
|
||||
- PCRE2 (headers and libraries) - optional, this will be downloaded if missing
|
||||
- PCRE2 (headers and libraries) - a copy is included with fish
|
||||
- gettext (headers and libraries) - optional, for translation support
|
||||
|
||||
Sphinx is also optionally required to build the documentation from a
|
||||
|
|
@ -178,8 +171,6 @@ The install directory can be changed using the
|
|||
Building from source (macOS) - Xcode
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Note: The minimum supported macOS version is 10.10 "Yosemite".
|
||||
|
||||
.. code:: bash
|
||||
|
||||
mkdir build; cd build
|
||||
|
|
@ -220,7 +211,7 @@ On Debian or Ubuntu you want:
|
|||
|
||||
::
|
||||
|
||||
sudo apt install build-essential cmake ncurses-dev libncurses5-dev libpcre2-dev gettext
|
||||
sudo apt-get install build-essential cmake ncurses-dev libncurses5-dev libpcre2-dev gettext
|
||||
|
||||
On RedHat, CentOS, or Amazon EC2:
|
||||
|
||||
|
|
@ -239,12 +230,15 @@ Contact Us
|
|||
Questions, comments, rants and raves can be posted to the official fish
|
||||
mailing list at https://lists.sourceforge.net/lists/listinfo/fish-users
|
||||
or join us on our `gitter.im
|
||||
channel <https://gitter.im/fish-shell/fish-shell>`__. Or use the `fish tag
|
||||
on Unix & Linux Stackexchange <https://unix.stackexchange.com/questions/tagged/fish>`__.
|
||||
There is also a fish tag on Stackoverflow, but it is typically a poor fit.
|
||||
channel <https://gitter.im/fish-shell/fish-shell>`__. Or use the `fish
|
||||
tag on
|
||||
Stackoverflow <https://stackoverflow.com/questions/tagged/fish>`__ for
|
||||
questions related to fish script and the `fish tag on
|
||||
Superuser <https://superuser.com/questions/tagged/fish>`__ for all other
|
||||
questions (e.g., customizing colors, changing key bindings).
|
||||
|
||||
Found a bug? Have an awesome idea? Please `open an
|
||||
issue <https://github.com/fish-shell/fish-shell/issues/new>`__.
|
||||
|
||||
.. |Build Status| image:: https://github.com/fish-shell/fish-shell/workflows/make%20test/badge.svg
|
||||
.. |Build Status| image:: https://github.com/fish-shell/fish-shell/workflows/C/C++%20CI/badge.svg
|
||||
:target: https://github.com/fish-shell/fish-shell/actions
|
||||
|
|
|
|||
|
|
@ -1089,3 +1089,4 @@ alias alias1020='something --arg1020'
|
|||
alias alias1021='something --arg1021'
|
||||
alias alias1022='something --arg1022'
|
||||
alias alias1023='something --arg1023'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
for i in (seq 1000)
|
||||
for i in (seq 2000)
|
||||
command true
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
# Glob fish's source directory.
|
||||
# This timing is bound to change if the repo does,
|
||||
# so it's best to build two fishes, check out one version of the repo,
|
||||
# and then run this script with both.
|
||||
set -l dir (dirname (status current-filename))
|
||||
for i in (seq 1 10)
|
||||
echo $dir/../../**
|
||||
end
|
||||
|
|
@ -9,35 +9,21 @@ FISH_PATH=$1
|
|||
FISH2_PATH=$2
|
||||
BENCHMARKS_DIR=$(dirname "$0")/benchmarks
|
||||
|
||||
quote() {
|
||||
# Single-quote the given string for a POSIX shell, except in common cases that don't need it.
|
||||
printf %s "$1" |
|
||||
sed "/[^[:alnum:]\/.-]/ {
|
||||
s/'/'\\\''/g
|
||||
s/^/'/
|
||||
s/\$/'/
|
||||
}"
|
||||
}
|
||||
|
||||
for benchmark in "$BENCHMARKS_DIR"/*; do
|
||||
basename "$benchmark"
|
||||
# If we have hyperfine, use it first to warm up the cache
|
||||
if command -v hyperfine >/dev/null 2>&1; then
|
||||
cmd1="$(quote "${FISH_PATH}") --no-config $(quote "$benchmark")"
|
||||
if [ -n "$FISH2_PATH" ]; then
|
||||
cmd2="$(quote "${FISH2_PATH}") --no-config $(quote "$benchmark")"
|
||||
hyperfine --warmup 3 "$cmd1" "$cmd2"
|
||||
else
|
||||
hyperfine --warmup 3 "$cmd1"
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -n "$FISH2_PATH" ] && echo "$FISH_PATH"
|
||||
"${FISH_PATH}" --print-rusage-self "$benchmark" > /dev/null
|
||||
${FISH_PATH} --print-rusage-self "$benchmark" > /dev/null
|
||||
if [ -n "$FISH2_PATH" ]; then
|
||||
echo "$FISH2_PATH"
|
||||
"${FISH2_PATH}" --print-rusage-self "$benchmark" > /dev/null
|
||||
${FISH2_PATH} --print-rusage-self "$benchmark" > /dev/null
|
||||
fi
|
||||
|
||||
if command -v hyperfine >/dev/null 2>&1; then
|
||||
if [ -n "$FISH2_PATH" ]; then
|
||||
hyperfine "${FISH_PATH} $benchmark > /dev/null" "${FISH2_PATH} $benchmark > /dev/null"
|
||||
else
|
||||
hyperfine "${FISH_PATH} $benchmark > /dev/null"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
mac_xar_116 is http://mackyle.github.io/xar/, compiled for Mac. It is used by mac_sign_package.sh as a replacement for productsign.
|
||||
Binary file not shown.
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
cppcheck --std=c++11 --quiet \
|
||||
cppcheck --std=posix --quiet \
|
||||
--suppressions-list=build_tools/cppcheck.suppressions --inline-suppr \
|
||||
--rule-file=build_tools/cppcheck.rules \
|
||||
--force \
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env fish
|
||||
# Build a list of all sections in the html sphinx docs, separately by page,
|
||||
# so it can be added to share/functions/help.fish
|
||||
# Use like
|
||||
# fish extract_help_sections.fish user_doc/html/{fish_for_bash_users.html,faq.html,interactive.html,language.html,tutorial.html}
|
||||
# TODO: Currently `help` uses variable names we can't generate, so it needs to be touched up manually.
|
||||
# Also this could easily be broken by changes in sphinx, ideally we'd have a way to let it print the section titles.
|
||||
#
|
||||
|
||||
for file in $argv
|
||||
set -l varname (string replace -r '.*/(.*).html' '$1' -- $file | string escape --style=var)pages
|
||||
# Technically we can use any id in the document as an anchor, but listing them all is probably too much.
|
||||
# Sphinx stores section titles (in a slug-ized form) in the id,
|
||||
# and stores explicit section links in a `span` tag like
|
||||
# `<span id="identifiers"></span>`
|
||||
# We extract both separately.
|
||||
set -l sections (string replace -rf '.*class="headerlink" href="#([^"]*)".*' '$1' <$file)
|
||||
# Sections titled "id5" and such are internal cruft and shouldn't be offered.
|
||||
set -a sections (string replace -rf '.*span id="([^"]*)".*' '$1' <$file | string match -rv 'id\d+')
|
||||
|
||||
set sections (printf '%s\n' $sections | sort -u)
|
||||
echo set -l $varname $sections
|
||||
end
|
||||
|
|
@ -14,7 +14,8 @@ set -g whitelist \
|
|||
# unclear what this is \
|
||||
l_constinit \
|
||||
# hacks to work around missing ncurses strings on mac \
|
||||
sitm_esc ritm_esc dim_esc
|
||||
sitm_esc ritm_esc dim_esc \
|
||||
|
||||
|
||||
# In our nm regex, we are interested in data (dD) and bss (bB) segments.
|
||||
set -g nm_regex '^([^ ]+) ([dDbB])'
|
||||
|
|
@ -23,7 +24,8 @@ set -l total_globals 0
|
|||
set -l boring_files \
|
||||
fish_key_reader.cpp.o \
|
||||
fish_tests.cpp.o \
|
||||
fish_indent.cpp.o
|
||||
fish_indent.cpp.o \
|
||||
|
||||
|
||||
# return if we should ignore the given symbol name
|
||||
function should_ignore
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Finds potential ODR violations due to weak symbols.
|
||||
# For example, if you have two different structs with the same name in different files,
|
||||
# their inline constructors may collide.
|
||||
# This works only on Linux. It is designed to be run from the cmake build directory.
|
||||
# clang seems more willing to emit non-inlined ctors. Of course perform a Debug build.
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
output = subprocess.check_output(
|
||||
"nm --radix=d -g --demangle -l --print-size CMakeFiles/fishlib.dir/src/*.o",
|
||||
shell=True,
|
||||
universal_newlines=True,
|
||||
)
|
||||
files_by_name = {} # Symbol to set of paths
|
||||
sizes_by_name = {} # Symbol to set of int sizes
|
||||
|
||||
for line in output.split("\n"):
|
||||
# Keep only weak symbols with default values (e.g. emitted inline functions).
|
||||
# Example line: "0000000000000000 0000000000000107 W symbol_name"
|
||||
# First number is offset, second is size.
|
||||
# Note this is decimal because of radix=d.
|
||||
m = re.match(r"\d+ (\d+) W (.*)\t(.*)", line)
|
||||
if not m:
|
||||
continue
|
||||
size, name, filename = m.groups()
|
||||
files_by_name.setdefault(name, set()).add(filename)
|
||||
sizes_by_name.setdefault(name, set()).add(int(size))
|
||||
|
||||
odr_violations = 0
|
||||
for name, sizes in sizes_by_name.items():
|
||||
if len(sizes) == 1:
|
||||
continue
|
||||
files = files_by_name[name]
|
||||
# Ignore symbols that only appear in one file.
|
||||
# These are typically headers - unclear why they get different sizes but it appears benign.
|
||||
if len(files) == 1:
|
||||
continue
|
||||
# Multiple sizes for this symbol name.
|
||||
odr_violations += 1
|
||||
print("Multiple sizes for symbol: " + name)
|
||||
print("\t%s" % ", ".join([str(x) for x in sizes]))
|
||||
print("\tFound in files:")
|
||||
for filename in files:
|
||||
print("\t\t%s" % filename)
|
||||
|
||||
if odr_violations == 0:
|
||||
print("No ODR violations found, hooray\n")
|
||||
|
||||
# Show potential weak symbols.
|
||||
suspicious_odrs = 0
|
||||
for (name, files) in files_by_name.items():
|
||||
if len(files) != 1:
|
||||
continue
|
||||
(filename,) = files
|
||||
if ".cpp" in filename:
|
||||
if suspicious_odrs == 0:
|
||||
print("Some suspicious singles:")
|
||||
suspicious_odrs += 1
|
||||
print("\t%s" % name)
|
||||
print("\t\tIn file %s" % filename)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env sh
|
||||
# Originally from the git sources (GIT-VERSION-GEN)
|
||||
# Presumably (C) Junio C Hamano <junkio@cox.net>
|
||||
# Reused under GPL v2.0
|
||||
|
|
@ -9,26 +9,14 @@ set -e
|
|||
# Find the fish directory as two levels up from script directory.
|
||||
FISH_BASE_DIR="$( cd "$( dirname "$( dirname "$0" )" )" && pwd )"
|
||||
DEF_VER=unknown
|
||||
git_permission_failed=0
|
||||
|
||||
# First see if there is a version file (included in release tarballs),
|
||||
# then try git-describe, then default.
|
||||
if test -f version
|
||||
then
|
||||
VN=$(cat version) || VN="$DEF_VER"
|
||||
else
|
||||
if VN=$(git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
|
||||
:
|
||||
else
|
||||
if test $? = 128; then
|
||||
# Current git versions return status 128
|
||||
# when run in a repo owned by another user.
|
||||
# Even for describe and everything.
|
||||
# This occurs for `sudo make install`.
|
||||
git_permission_failed=1
|
||||
fi
|
||||
VN="$DEF_VER"
|
||||
fi
|
||||
elif ! VN=$(git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
|
||||
VN="$DEF_VER"
|
||||
fi
|
||||
|
||||
# If the first param is --stdout, then output to stdout and exit.
|
||||
|
|
@ -40,20 +28,11 @@ fi
|
|||
|
||||
# Set the output directory as either the first param or cwd.
|
||||
test -n "$1" && OUTPUT_DIR=$1/ || OUTPUT_DIR=
|
||||
FBVF="${OUTPUT_DIR}FISH-BUILD-VERSION-FILE"
|
||||
FBVF=${OUTPUT_DIR}FISH-BUILD-VERSION-FILE
|
||||
|
||||
if test "$VN" = unknown && test -r "$FBVF" && test "$git_permission_failed" = 1
|
||||
if test -r $FBVF
|
||||
then
|
||||
# HACK: Git failed, so we keep the current version file.
|
||||
# This helps in case you built fish as a normal user
|
||||
# and then try to `sudo make install` it.
|
||||
date +%s > ${OUTPUT_DIR}fish-build-version-witness.txt
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -r "$FBVF"
|
||||
then
|
||||
VC=$(grep -v '^#' "$FBVF" | tr -d '"' | sed -e 's/^FISH_BUILD_VERSION=//')
|
||||
VC=$(grep -v '^#' $FBVF | tr -d '"' | sed -e 's/^FISH_BUILD_VERSION=//')
|
||||
else
|
||||
VC="unset"
|
||||
fi
|
||||
|
|
@ -62,7 +41,7 @@ fi
|
|||
# It looks like FISH_BUILD_VERSION="2.7.1-621-ga2f065e6"
|
||||
test "$VN" = "$VC" || {
|
||||
echo >&2 "FISH_BUILD_VERSION=$VN"
|
||||
echo "FISH_BUILD_VERSION=\"$VN\"" >"$FBVF"
|
||||
echo "FISH_BUILD_VERSION=\"$VN\"" >${FBVF}
|
||||
}
|
||||
|
||||
# Output the fish-build-version-witness.txt
|
||||
|
|
|
|||
|
|
@ -2,27 +2,10 @@
|
|||
# the version installed by HomeBrew doesn't have useful mappings for the
|
||||
# system provided headers. This also has mappings for FreeBSD.
|
||||
[
|
||||
{ include: ["<__functional_base>", private, "<functional>", public ] },
|
||||
{ include: ["<__mutex_base>", private, "<mutex>", public ] },
|
||||
{ include: ["@<__algorithm/.*>", "private", "<algorithm>", "public"] },
|
||||
{ include: ["@<__iterator/.*>", "private", "<iterator>", "public"] },
|
||||
{ include: ["@<__functional/.*>", "private", "<functional>", "public"] },
|
||||
{ include: ["@<__memory/.*>", "private", "<memory>", "public"] },
|
||||
{ include: ["@<__utility/.*>", "private", "<utility>", "public"] },
|
||||
{ include: ["@<__chrono/.*>", "private", "<chrono>", "public"] },
|
||||
{ include: ["@<__numeric/.*>", "private", "<numeric>", "public"] },
|
||||
{ include: ["@<__random/.*>", "private", "<random>", "public"] },
|
||||
{ include: ["@<__locale/.*>", "private", "<locale>", "public"] },
|
||||
{ include: ["@<xlocale/.*>", "private", "<xlocale.h>", "public"] },
|
||||
# ratio false positive. See https://groups.google.com/g/include-what-you-use/c/OKVkkWUlx44
|
||||
{ include: ["<ratio>", "public", "<chrono>", "public"] },
|
||||
{ include: ["<__locale>", "private", "<locale>", "public"] },
|
||||
{ include: ["<_ctype.h>", "private", "<ctype.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_once_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_mutex_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_rwlock_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_mutexattr_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_attr_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_cond_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_t.h>", "private", "<pthread.h>", "public"] },
|
||||
{ include: ["<sys/_pthread/_pthread_key_t.h>", "private", "<pthread.h>", "public"] },
|
||||
|
|
@ -37,7 +20,7 @@
|
|||
{ include: ["<sys/fcntl.h>", "private", "<fcntl.h>", "public"] },
|
||||
{ include: ["<sys/_types/_seek_set.h>", "private", "<fcntl.h>", "public"] },
|
||||
{ include: ["<sys/_types/_mbstate_t.h>", "private", "<wchar.h>", "public"] },
|
||||
{ include: ["<iosfwd>", "public", "<string>", "public"] },
|
||||
{ include: ["<iosfwd>", "private", "<string>", "public"] },
|
||||
{ include: ["<sys/_stdint.h>", "private", "<stdint.h>", "public"] },
|
||||
{ include: ["<sys/_types/_s_ifmt.h>", "private", "<sys/types.h>", "public"] },
|
||||
{ include: ["<sys/_types/_size_t.h>", "private", "<sys/types.h>", "public"] },
|
||||
|
|
@ -68,6 +51,7 @@
|
|||
{ include: ["<sys/_types/_va_list.h>", "private", "<sys/types.h>", "public"] },
|
||||
{ include: ["<sys/_types/_sigset_t.h>", "private", "<signal.h>", "public"] },
|
||||
{ include: ["<sys/signal.h>", "private", "<signal.h>", "public"] },
|
||||
{ include: ["<strings.h>", "private", "<string.h>", "public"] },
|
||||
{ include: ["<sys/termios.h>", "private", "<termios.h>", "public"] },
|
||||
{ include: ["<sys/_termios.h>", "private", "<termios.h>", "public"] },
|
||||
{ include: ["<sys/ttycom.h>", "private", "<termios.h>", "public"] },
|
||||
|
|
@ -77,7 +61,7 @@
|
|||
{ include: ["<sys/_types/_wint_t.h>", "private", "<stddef.h>", "public"] },
|
||||
{ include: ["<sys/_select.h>", "private", "<select.h>", "public"] },
|
||||
{ include: ["<sys/cdefs.h>", "private", "<unistd.h>", "public"] },
|
||||
{ include: ["<istream>", "public", "<iostream>", "public"] },
|
||||
{ include: ["<istream>", "private", "<iostream>", "public"] },
|
||||
{ include: ["<sys/_endian.h>", "private", "<netinet/in.h>", "public"] },
|
||||
{ include: ["<sys/_types/_timespec.h>", "private", "<time.h>", "public"] },
|
||||
{ include: ["<sys/_timespec.h>", "private", "<time.h>", "public"] },
|
||||
|
|
@ -86,30 +70,22 @@
|
|||
{ include: ["<__mutex_base>", "private", "<mutex>", "public"] },
|
||||
{ include: ["<__hash_table>", "private", "<unordered_map>", "public"] },
|
||||
{ include: ["<__hash_table>", "private", "<unordered_set>", "public"] },
|
||||
{ include: ['"../common.h"', "public", '"common.h"', "public"] },
|
||||
# We provide our own assert. including assert.h/cassert spoils it and redefines the macro
|
||||
{ symbol: ["assert", "private", '"common.h"', "public"] },
|
||||
{ symbol: ["assert", "private", '"../common.h"', "public"] },
|
||||
{ symbol: ["wcstring", "private", '"common.h"', "public"] },
|
||||
{ symbol: ["wcstring", "private", '"../common.h"', "public"] },
|
||||
{ symbol: ["wcstring_list_t", "private", '"common.h"', "public"] },
|
||||
{ symbol: ["wcstring_list_t", "private", '"../common.h"', "public"] },
|
||||
{ symbol: ["wcstring", "private", '"flog.h"', "public"] },
|
||||
{ symbol: ["wcstring_list_t", "private", '"flog.h"', "public"] },
|
||||
# { include: ["<>", "private", "<>", "public"] },
|
||||
|
||||
{ symbol: ["size_t", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["mutex", "private", "<mutex>", "public"] },
|
||||
{ symbol: ["sig_atomic_t", "private", "<csignal>", "public"] },
|
||||
{ symbol: ["va_end", "private", "<stdarg.h>", "public"] },
|
||||
{ symbol: ["va_list", "private", "<stdarg.h>", "public"] },
|
||||
{ symbol: ["va_start", "private", "<stdarg.h>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<stddef.h>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<stdlib.h>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<stdio.h>", "public"] },
|
||||
{ symbol: ["NULL", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["off_t", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["off_t", "private", "<sys/types.h>", "public"] },
|
||||
{ symbol: ["size_t", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["ssize_t", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["size_t", "private", "<stddef.h>", "public"] },
|
||||
{ symbol: ["ssize_t", "private", "<stddef.h>", "public"] },
|
||||
{ symbol: ["intptr_t", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["gid_t", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["uid_t", "private", "<unistd.h>", "public"] },
|
||||
|
|
@ -118,54 +94,16 @@
|
|||
{ symbol: ["uid_t", "private", "<sys/types.h>", "public"] },
|
||||
{ symbol: ["gid_t", "private", "<sys/types.h>", "public"] },
|
||||
{ symbol: ["timeval", "private", "<sys/time.h>", "public"] },
|
||||
{ symbol: ["__uint32_t", "private", "<cstdint>", "public"] },
|
||||
{ symbol: ["uint32_t", "private", "<cstdint>", "public"] },
|
||||
{ symbol: ["intptr_t", "private", "<cstdint>", "public"] },
|
||||
{ symbol: ["__uint32_t", "private", "<stdint.h>", "public"] },
|
||||
{ symbol: ["uint32_t", "private", "<stdint.h>", "public"] },
|
||||
{ symbol: ["intptr_t", "private", "<stdint.h>", "public"] },
|
||||
{ symbol: ["tparm", "private", "<ncurses.h>", "public"] },
|
||||
{ symbol: ["tigetflag", "private", "<ncurses.h>", "public"] },
|
||||
{ symbol: ["ERR", "private", "<ncurses.h>", "public"] },
|
||||
{ symbol: ["OK", "private", "<ncurses.h>", "public"] },
|
||||
{ symbol: ["select", "private", "<sys/select.h>", "public"] },
|
||||
{ symbol: ["_LIBCPP_VERSION", "private", "<cstddef>", "public"] },
|
||||
{ symbol: ["_LIBCPP_VERSION", "private", "<stddef.h>", "public"] },
|
||||
{ symbol: ["_LIBCPP_VERSION", "private", "<unistd.h>", "public"] },
|
||||
{ symbol: ["MB_CUR_MAX", "private", "<cstdlib>", "public"] },
|
||||
{ symbol: ["MB_LEN_MAX", "private", "<cstdlib>", "public"] },
|
||||
{ symbol: ["WEOF", "private", "<cwctype>", "public"] },
|
||||
{ symbol: [ "std::declval", private, "<utility>", public ] },
|
||||
{ symbol: [ "std::forward", private, "<utility>", public ] },
|
||||
{ symbol: [ "std::move", private, "<utility>", public ] },
|
||||
{ symbol: [ "std::nullptr_t", private, "<cstddef>", public ] },
|
||||
{ symbol: [ "std::string", private, "<string>", public ] },
|
||||
{ symbol: [ "std::isalnum", private, "<locale>", public ] },
|
||||
{ symbol: [ "std::toupper", private, "<locale>", public ] },
|
||||
{ symbol: [ "sem_t", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "sem_post", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "sem_wait", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "sem_init", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "sem_destroy", private, "<semaphore.h>", public ] },
|
||||
{ symbol: [ "FD_SETSIZE", private, "<sys/select.h>", public ] },
|
||||
{ symbol: [ "locale_t", private, "<locale>", public ] },
|
||||
{ include: [ "<assert.h>", public, "<cassert>", public ] },
|
||||
{ include: [ "<complex.h>", public, "<ccomplex>", public ] },
|
||||
{ include: [ "<ctype.h>", public, "<cctype>", public ] },
|
||||
{ include: [ "<errno.h>", public, "<cerrno>", public ] },
|
||||
{ include: [ "<fenv.h>", public, "<cfenv>", public ] },
|
||||
{ include: [ "<float.h>", public, "<cfloat>", public ] },
|
||||
{ include: [ "<inttypes.h>", public, "<cinttypes>", public ] },
|
||||
{ include: [ "<iso646.h>", public, "<ciso646>", public ] },
|
||||
{ include: [ "<limits.h>", public, "<climits>", public ] },
|
||||
{ include: [ "<locale.h>", public, "<clocale>", public ] },
|
||||
{ include: [ "<math.h>", public, "<cmath>", public ] },
|
||||
{ include: [ "<setjmp.h>", public, "<csetjmp>", public ] },
|
||||
{ include: [ "<signal.h>", public, "<csignal>", public ] },
|
||||
{ include: [ "<stdalign.h>", public, "<cstdalign>", public ] },
|
||||
{ include: [ "<stdarg.h>", public, "<cstdarg>", public ] },
|
||||
{ include: [ "<stdbool.h>", public, "<cstdbool>", public ] },
|
||||
{ include: [ "<stddef.h>", public, "<cstddef>", public ] },
|
||||
{ include: [ "<stdlib.h>", public, "<cstdlib>", public ] },
|
||||
{ include: [ "<string.h>", public, "<cstring>", public ] },
|
||||
{ include: [ "<tgmath.h>", public, "<ctgmath>", public ] },
|
||||
{ include: [ "<time.h>", public, "<ctime>", public ] },
|
||||
{ include: [ "<uchar.h>", public, "<cuchar>", public ] },
|
||||
{ include: [ "<wchar.h>", public, "<cwchar>", public ] },
|
||||
{ include: [ "<wctype.h>", public, "<cwctype>", public ] },
|
||||
{ include: [ "<_xlocale.h>", private, "<xlocale.h>", public ] },
|
||||
|
||||
{ symbol: ["MB_CUR_MAX", "private", "<xlocale.h>", "public"] },
|
||||
{ symbol: ["MB_CUR_MAX", "private", "<stdlib.h>", "public"] },
|
||||
]
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
|||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
from collections import deque
|
||||
import datetime
|
||||
import io
|
||||
import re
|
||||
|
|
@ -96,6 +97,8 @@ def esc(m):
|
|||
map = {
|
||||
"\n": "\\n",
|
||||
"\\": "\\\\",
|
||||
"'": "\\'",
|
||||
'"': '\\"',
|
||||
"\a": "\\a",
|
||||
"\b": "\\b",
|
||||
"\f": "\\f",
|
||||
|
|
@ -200,7 +203,6 @@ class TestFailure(object):
|
|||
self.diff = diff
|
||||
self.lines = lines
|
||||
self.checks = checks
|
||||
self.signal = None
|
||||
|
||||
def message(self):
|
||||
fields = self.testrun.config.colors()
|
||||
|
|
@ -225,11 +227,6 @@ class TestFailure(object):
|
|||
)
|
||||
filemsg = "" if self.testrun.config.progress else " in {name}"
|
||||
fmtstrs = ["{RED}Failure{RESET}" + filemsg + ":", ""]
|
||||
if self.signal:
|
||||
fmtstrs += [
|
||||
" Process was killed by signal {BOLD}" + self.signal + "{RESET}",
|
||||
""
|
||||
]
|
||||
if self.line and self.check:
|
||||
fmtstrs += [
|
||||
" The {check_type} on line {input_lineno} wants:",
|
||||
|
|
@ -302,11 +299,11 @@ class TestFailure(object):
|
|||
)
|
||||
if b:
|
||||
bstr = (
|
||||
"on line "
|
||||
+ str(b.line.number)
|
||||
+ ": {BLUE}"
|
||||
"'{BLUE}"
|
||||
+ b.line.escaped_text(for_formatting=True)
|
||||
+ "{RESET}"
|
||||
+ "{RESET}'"
|
||||
+ " on line "
|
||||
+ str(b.line.number)
|
||||
)
|
||||
lastcheckline = b.line.number
|
||||
|
||||
|
|
@ -437,12 +434,6 @@ class TestRun(object):
|
|||
for i in checkq[::-1]:
|
||||
usedchecks.append(i)
|
||||
|
||||
# If we have no more output, there's no reason to give
|
||||
# SCREENFULS of text.
|
||||
# So we truncate the check list.
|
||||
if len(usedchecks) > len(usedlines):
|
||||
usedchecks = usedchecks[:len(usedlines) + 5]
|
||||
|
||||
# Do a SequenceMatch! This gives us a diff-like thing.
|
||||
diff = SequenceMatcher(a=usedlines, b=usedchecks, autojunk=False)
|
||||
# If there's a mismatch or still lines or checkers, we have a failure.
|
||||
|
|
@ -477,6 +468,7 @@ class TestRun(object):
|
|||
"""
|
||||
return [s + "\n" for s in s.decode("utf-8").split("\n")]
|
||||
|
||||
PIPE = subprocess.PIPE
|
||||
if self.config.verbose:
|
||||
print(self.subbed_command)
|
||||
proc = runproc(self.subbed_command)
|
||||
|
|
@ -511,34 +503,7 @@ class TestRun(object):
|
|||
# Trim a trailing newline
|
||||
if outfail.error_annotation_lines[-1].text == "\n":
|
||||
del outfail.error_annotation_lines[-1]
|
||||
failure = outfail if outfail else errfail
|
||||
|
||||
if failure and status < 0:
|
||||
# Process was killed by a signal and failed,
|
||||
# add a message.
|
||||
import signal
|
||||
# Unfortunately strsignal only exists in python 3.8+,
|
||||
# and signal.signals is 3.5+.
|
||||
if hasattr(signal, "Signals"):
|
||||
try:
|
||||
sig = signal.Signals(-status)
|
||||
failure.signal = sig.name + " (" + signal.strsignal(sig.value) + ")"
|
||||
except ValueError:
|
||||
failure.signal = str(-status)
|
||||
else:
|
||||
# No easy way to get the full list,
|
||||
# make up a dict.
|
||||
signals = {
|
||||
signal.SIGABRT: "SIGABRT",
|
||||
signal.SIGBUS: "SIGBUS",
|
||||
signal.SIGFPE: "SIGFPE",
|
||||
signal.SIGILL: "SIGILL",
|
||||
signal.SIGSEGV: "SIGSEGV",
|
||||
signal.SIGTERM: "SIGTERM",
|
||||
}
|
||||
failure.signal = signals.get(-status, str(-status))
|
||||
|
||||
return failure
|
||||
return outfail if outfail else errfail
|
||||
|
||||
|
||||
class CheckCmd(object):
|
||||
|
|
@ -628,13 +593,13 @@ class Checker(object):
|
|||
|
||||
# Find run commands.
|
||||
self.runcmds = [RunCmd.parse(sl) for sl in group1s(RUN_RE)]
|
||||
self.shebang_cmd = None
|
||||
if not self.runcmds:
|
||||
# If no RUN command has been given, fall back to the shebang.
|
||||
if lines[0].text.startswith("#!"):
|
||||
# Remove the "#!" at the beginning, and the newline at the end.
|
||||
cmd = lines[0].text[2:-1]
|
||||
self.shebang_cmd = cmd
|
||||
if not find_command(cmd):
|
||||
raise CheckerError("Command could not be found: " + cmd)
|
||||
self.runcmds = [RunCmd(cmd + " %s", lines[0])]
|
||||
else:
|
||||
raise CheckerError("No runlines ('# RUN') found")
|
||||
|
|
@ -662,13 +627,11 @@ def check_file(input_file, name, subs, config, failure_handler):
|
|||
proc = runproc(
|
||||
perform_substitution(reqcmd.args, subs)
|
||||
)
|
||||
proc.communicate()
|
||||
stdout, stderr = proc.communicate()
|
||||
status = proc.returncode
|
||||
if proc.returncode > 0:
|
||||
return SKIP
|
||||
|
||||
if checker.shebang_cmd is not None and not find_command(checker.shebang_cmd):
|
||||
raise CheckerError("Command could not be found: " + checker.shebang_cmd)
|
||||
|
||||
# Only then run the RUN lines.
|
||||
for runcmd in checker.runcmds:
|
||||
failure = TestRun(name, runcmd, checker, subs, config).run()
|
||||
|
|
@ -725,13 +688,6 @@ def get_argparse():
|
|||
help="Show the files to be checked",
|
||||
default=False,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--force-color",
|
||||
action="store_true",
|
||||
dest="force_color",
|
||||
help="Force usage of color even if not connected to a terminal",
|
||||
default=False,
|
||||
)
|
||||
parser.add_argument("file", nargs="+", help="File to check")
|
||||
return parser
|
||||
|
||||
|
|
@ -742,16 +698,13 @@ def main():
|
|||
def_subs = {"%": "%"}
|
||||
def_subs.update(parse_subs(args.substitute))
|
||||
|
||||
tests_count = 0
|
||||
failed = False
|
||||
skip_count = 0
|
||||
failure_count = 0
|
||||
config = Config()
|
||||
config.colorize = args.force_color or sys.stdout.isatty()
|
||||
config.colorize = sys.stdout.isatty()
|
||||
config.progress = args.progress
|
||||
fields = config.colors()
|
||||
|
||||
for path in args.file:
|
||||
tests_count += 1
|
||||
fields["path"] = path
|
||||
if config.progress:
|
||||
print("Testing file {path} ... ".format(**fields), end="")
|
||||
|
|
@ -760,10 +713,8 @@ def main():
|
|||
subs["s"] = path
|
||||
starttime = datetime.datetime.now()
|
||||
ret = check_path(path, subs, config, TestFailure.print_message)
|
||||
if ret is SKIP:
|
||||
skip_count += 1
|
||||
if not ret:
|
||||
failed = True
|
||||
failure_count += 1
|
||||
elif config.progress:
|
||||
endtime = datetime.datetime.now()
|
||||
duration_ms = round((endtime - starttime).total_seconds() * 1000)
|
||||
|
|
@ -777,15 +728,7 @@ def main():
|
|||
duration=duration_ms, reason=reason, **fields
|
||||
)
|
||||
)
|
||||
|
||||
# To facilitate integration with testing frameworks, use exit code 125 to indicate that all
|
||||
# tests have been skipped (primarily for use when tests are run one at a time). Exit code 125 is
|
||||
# used to indicate to automated `git bisect` runs that a revision has been skipped; we use it
|
||||
# for the same reasons git does.
|
||||
if skip_count > 0 and skip_count == tests_count:
|
||||
sys.exit(125)
|
||||
|
||||
sys.exit(1 if failed else 0)
|
||||
sys.exit(failure_count)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -1,22 +1,80 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Helper to notarize an .app.zip or .pkg file.
|
||||
# Based on https://www.logcg.com/en/archives/3222.html
|
||||
|
||||
set -e
|
||||
|
||||
die() { echo "$*" 1>&2 ; exit 1; }
|
||||
|
||||
check_status() {
|
||||
echo "STATUS" $1
|
||||
}
|
||||
|
||||
test "$#" -ge 1 || die "No paths specified."
|
||||
get_req_uuid() {
|
||||
RESPONSE=$(</dev/stdin)
|
||||
if echo "$RESPONSE" | egrep -q "RequestUUID"; then
|
||||
echo "$RESPONSE" | egrep RequestUUID | awk '{print $3'}
|
||||
elif echo "$RESPONSE" | egrep -q "The upload ID is "; then
|
||||
echo "$RESPONSE" | egrep -p "The upload ID is [-a-z0-9]+" | awk '{print $5}'
|
||||
else
|
||||
die "Could not get Request UUID"
|
||||
fi
|
||||
}
|
||||
|
||||
for INPUT in "$@"; do
|
||||
echo "Processing $INPUT"
|
||||
test -f "$INPUT" || die "Not a file: $INPUT"
|
||||
ext="${INPUT##*.}"
|
||||
(test "$ext" = "zip" || test "$ext" = "pkg") || die "Unrecognized extension: $ext"
|
||||
INPUT=$1
|
||||
AC_USER=$2
|
||||
|
||||
xcrun notarytool submit "$INPUT" --keychain-profile AC_PASSWORD --wait
|
||||
test -z "$AC_USER" && die "AC_USER not specified as second param"
|
||||
test -z "$INPUT" && die "No path specified"
|
||||
test -f "$INPUT" || die "Not a file: $INPUT"
|
||||
|
||||
ext="${INPUT##*.}"
|
||||
(test "$ext" = "zip" || test "$ext" = "pkg") || die "Unrecognized extension: $ext"
|
||||
|
||||
LOGFILE=$(mktemp -t mac_notarize_log)
|
||||
AC_PASS="@keychain:AC_PASSWORD"
|
||||
echo "Logs at $LOGFILE"
|
||||
|
||||
NOTARIZE_UUID=$(xcrun altool --notarize-app \
|
||||
--primary-bundle-id "com.ridiculousfish.fish-shell" \
|
||||
--username "$AC_USER" \
|
||||
--password "$AC_PASS" \
|
||||
--file "$INPUT" 2>&1 |
|
||||
tee -a "$LOGFILE" |
|
||||
get_req_uuid)
|
||||
|
||||
test -z "$NOTARIZE_UUID" && cat "$LOGFILE" && die "Could not get RequestUUID"
|
||||
echo "RequestUUID: $NOTARIZE_UUID"
|
||||
|
||||
# notarization-info doesn't always know about our request immediately.
|
||||
echo "Giving notarization-info a chance to catch up..."
|
||||
sleep 15
|
||||
|
||||
success=0
|
||||
for i in $(seq 20); do
|
||||
echo "Checking progress..."
|
||||
PROGRESS=$(xcrun altool --notarization-info "${NOTARIZE_UUID}" \
|
||||
-u "$AC_USER" \
|
||||
-p "$AC_PASS" 2>&1 |
|
||||
tee -a "$LOGFILE")
|
||||
echo "${PROGRESS}" | tail -n 1
|
||||
|
||||
if [ $? -ne 0 ] || [[ "${PROGRESS}" =~ "Invalid" ]] ; then
|
||||
echo "Error with notarization. Exiting"
|
||||
break
|
||||
fi
|
||||
|
||||
if ! [[ "${PROGRESS}" =~ "in progress" ]]; then
|
||||
success=1
|
||||
break
|
||||
else
|
||||
echo "Not completed yet. Sleeping for 30 seconds."
|
||||
fi
|
||||
sleep 30
|
||||
done
|
||||
|
||||
if [ $success -eq 1 ] ; then
|
||||
if test "$ext" = "zip"; then
|
||||
TMPDIR=$(mktemp -d)
|
||||
echo "Extracting to $TMPDIR"
|
||||
|
|
@ -37,9 +95,9 @@ for INPUT in "$@"; do
|
|||
cd "$(dirname "$STAPLE_TARGET")"
|
||||
zip -r -q "$INPUT_FULL" $(basename "$STAPLE_TARGET")
|
||||
fi
|
||||
echo "Processed $INPUT"
|
||||
fi
|
||||
echo "Processed $INPUT"
|
||||
|
||||
if test "$ext" = "zip"; then
|
||||
spctl -a -v "$STAPLE_TARGET"
|
||||
fi
|
||||
done
|
||||
if test "$ext" = "zip"; then
|
||||
spctl -a -v "$STAPLE_TARGET"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This codesigns a Mac .pkg (installer) file.
|
||||
# Normally we could use `productsign` but that no longer produces
|
||||
# installers compatible with 10.11.
|
||||
# See https://github.com/fish-shell/fish-shell/issues/7656
|
||||
#
|
||||
# So instead we use the flow described here:
|
||||
# http://users.wfu.edu/cottrell/productsign/productsign_linux.html
|
||||
#
|
||||
# This script expects the following:
|
||||
#
|
||||
# 1. A variable $MAC_PRODUCTSIGN_CERTS_DIR pointing at a directory containing files cert00, cert01, cert02
|
||||
# 2. A variable $MAC_PRODUCTSIGN_P12_FILE containing the "Mac Developer ID Installer" keychain item, exported as p12. See below.
|
||||
|
||||
die() { echo "$*" 1>&2 ; exit 1; }
|
||||
|
||||
# Exit on error.
|
||||
set -e
|
||||
|
||||
# Our input package file.
|
||||
INPUT_PKG=$(realpath $1)
|
||||
test -f "$INPUT_PKG" || die "${INPUT_PKG} not a valid package"
|
||||
|
||||
# Find where our mac_xar_116 binary is.
|
||||
XAR_116="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/bin/mac_xar_116
|
||||
|
||||
# Here's what we need to be set.
|
||||
test -f "${MAC_PRODUCTSIGN_P12_FILE}" || die "MAC_PRODUCTSIGN_P12_FILE not set or not a p12 file"
|
||||
test -d "${MAC_PRODUCTSIGN_CERTS_DIR}" || die "MAC_PRODUCTSIGN_CERTS_DIR not set or not a directory"
|
||||
test -f "${MAC_PRODUCTSIGN_CERTS_DIR}/cert00" \
|
||||
&& test -f "${MAC_PRODUCTSIGN_CERTS_DIR}/cert01" \
|
||||
&& test -f "${MAC_PRODUCTSIGN_CERTS_DIR}/cert02" \
|
||||
|| die "MAC_PRODUCTSIGN_CERTS_DIR does not contain cert00, cert01, cert02"
|
||||
test -x "${XAR_116}" || die "mac_xar_116 binary not found or executable at ${XAR_116}"
|
||||
|
||||
TMP=$(mktemp -d)
|
||||
KEYFILE="${TMP}/key.pem"
|
||||
DIGFILE="${TMP}/digestinfo.dat"
|
||||
SIGFILE="${TMP}/signature.dat"
|
||||
|
||||
set -x
|
||||
|
||||
openssl pkcs12 -in "${MAC_PRODUCTSIGN_P12_FILE}" -nodes | openssl rsa -out "${KEYFILE}"
|
||||
test -f "${KEYFILE}" || die "openssl did not create key.pem"
|
||||
SIGSIZE=$(openssl dgst -sign "${KEYFILE}" -binary < /dev/null | wc -c | xargs)
|
||||
|
||||
# Prepare data for signing.
|
||||
${XAR_116} --sign -f ${INPUT_PKG} --digestinfo-to-sign "${DIGFILE}" \
|
||||
--sig-size "${SIGSIZE}" \
|
||||
--cert-loc "${MAC_PRODUCTSIGN_CERTS_DIR}/cert00" \
|
||||
--cert-loc "${MAC_PRODUCTSIGN_CERTS_DIR}/cert01" \
|
||||
--cert-loc "${MAC_PRODUCTSIGN_CERTS_DIR}/cert02"
|
||||
|
||||
# Create the signature.
|
||||
openssl rsautl -sign -inkey "${KEYFILE}" -in "${DIGFILE}" -out "${SIGFILE}"
|
||||
|
||||
# Add it to the archive, in place, then move it back.
|
||||
${XAR_116} --inject-sig "${SIGFILE}" -f "${INPUT_PKG}"
|
||||
|
||||
# Remove all our junk.
|
||||
rm -rf "${TMP}"
|
||||
|
||||
# Check the signature!
|
||||
pkgutil --check-signature "${INPUT_PKG}"
|
||||
|
||||
# The following is taken from http://users.wfu.edu/cottrell/productsign/productsign_linux.html
|
||||
# Saved here for posterity.
|
||||
|
||||
# Signing a Mac OS X package on Linux
|
||||
|
||||
# Premises
|
||||
|
||||
# You are a software developer who's at home on Linux but you want to produce builds of your software for other platforms, including Mac OS X.
|
||||
# You've already figured out cross-compilation. And in regard to OS X you've figured out how to build a (flat) pkg file on Linux – or if not, you can do so quite quickly by looking at the bomutils doc: https://github.com/hogliux/bomutils.
|
||||
# You are grudgingly willing to pay the Apple tax (the fee for becoming a registered developer) so that you can get a certificate with which to sign your package, in order that your gentle users don't get off-putting messages from Gatekeeper.
|
||||
# But you're wondering how to sign your package without having to use Apple's productsign on a Mac.
|
||||
# If you match on all points, we're in business! Here's the drill as I have figured it out. You will need: openssl, recent xar (see below), and one-time access to an actual Mac.
|
||||
|
||||
# Procedure
|
||||
|
||||
# Step 0: Build your program and create an OS X pkg file (xar archive). This you will do (on Linux) whenever you want to create a new release or snapshot.
|
||||
|
||||
# Step 1: This is a one-time step to be performed on a Mac. There may be a way around it, but I'm not aware of one. Please let me know if you're cleverer than I when it comes to certificates and all that. But anyway, follow the Apple directions for installing your developer certificate(s) on OS X, and use productsign to sign your package on the Mac – just this once! (Copy it across from Linux.) And then, before leaving the Mac, open Keychain Access and find your developer cert, the one with "Developer ID Installer" in its title (it should have a private key tucked under it). Highlight it and select "Export items" under the File menu to save as a p12 file. Copy your signed package and the exported p12 file (let's say it's called certs.p12) to your Linux box.
|
||||
|
||||
# Step 2: Back on Linux you're going to need a reasonably recent version of xar, specifically 1.6.1 or higher to support signing. Arch Linux installs xar 1.6.1 if you do pacman -S xar. Fedora's dnf install xar gets version 1.5, which won't do the job. I don't know about other distros, but if need be you can find the source for xar 1.6.1 at http://mackyle.github.io/xar/. Anyway, here's another one-time step: you'll extract the certs you need from the pkg file that you signed on the Mac, and the private key from the p12 file you exported from Keychain Access. (You'll need the passphrase that you set on the p12 when exporting it, so I hope you haven't forgotten that.)
|
||||
|
||||
# I'll assume (unimaginatively) that your package is called foo.pkg.
|
||||
|
||||
# # extract the certs from signed foo.pkg
|
||||
# mkdir certs
|
||||
# xar -f foo.pkg --extract-certs certs
|
||||
# You should find certs00, certs01 and probably certs02 in the certs directory. Perhaps more.
|
||||
|
||||
# # extract the private key from certs.p12 (requires passphrase)
|
||||
# openssl pkcs12 -in certs.p12 -nodes | openssl rsa -out key.pem
|
||||
# At this point you have the materials to sign future versions of your package natively on Linux. I'll now assume that a new unsigned foo.pkg is sitting in a directory containing the key.pem generated above and also the certs subdirectory created above. So now (with many thanks to mackyle!) you do:
|
||||
|
||||
# PKG=foo.pkg
|
||||
|
||||
# # determine the size of the signature
|
||||
# : | openssl dgst -sign key.pem -binary | wc -c > siglen.txt
|
||||
|
||||
# # prepare data for signing -- may have to adjust depending
|
||||
# # on the contents of the certs subdir in your case
|
||||
# xar --sign -f $PKG --digestinfo-to-sign digestinfo.dat \
|
||||
# --sig-size `cat siglen.txt` \
|
||||
# --cert-loc certs/cert00 \
|
||||
# --cert-loc certs/cert01 \
|
||||
# --cert-loc certs/cert02
|
||||
|
||||
# # create the signature
|
||||
# openssl rsautl -sign -inkey key.pem -in digestinfo.dat \
|
||||
# -out signature.dat
|
||||
|
||||
# # stuff it into the archive
|
||||
# xar --inject-sig signature.dat -f $PKG
|
||||
|
||||
# # and clean up
|
||||
# rm -f signature.dat digestinfo.dat siglen.txt
|
||||
# From this point on, just build your package on Linux and sign it on Linux using xar along with the certs and key that you got from the Mac.
|
||||
|
||||
|
|
@ -27,17 +27,21 @@ SRC_DIR=$PWD
|
|||
OUTPUT_PATH=${FISH_ARTEFACT_PATH:-~/fish_built}
|
||||
|
||||
mkdir -p "$PKGDIR/build" "$PKGDIR/root" "$PKGDIR/intermediates" "$PKGDIR/dst"
|
||||
|
||||
# Pass FISH_USE_SYSTEM_PCRE2=OFF because a system PCRE2 on macOS will not be signed by fish,
|
||||
# and will probably not be built universal, so the package will fail to validate/run on other systems.
|
||||
{ cd "$PKGDIR/build" && cmake -DMAC_INJECT_GET_TASK_ALLOW=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_GETTEXT=OFF -DFISH_USE_SYSTEM_PCRE2=OFF -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DMAC_CODESIGN_ID="${MAC_CODESIGN_ID}" "$SRC_DIR" && make VERBOSE=1 -j 12 && env DESTDIR="$PKGDIR/root/" make install; }
|
||||
{ cd "$PKGDIR/build" && cmake -DMAC_INJECT_GET_TASK_ALLOW=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_GETTEXT=OFF -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DMAC_CODESIGN_ID="${MAC_CODESIGN_ID}" "$SRC_DIR" && make VERBOSE=1 -j 12 && env DESTDIR="$PKGDIR/root/" make install; }
|
||||
pkgbuild --scripts "$SRC_DIR/build_tools/osx_package_scripts" --root "$PKGDIR/root/" --identifier 'com.ridiculousfish.fish-shell-pkg' --version "$VERSION" "$PKGDIR/intermediates/fish.pkg"
|
||||
productbuild --package-path "$PKGDIR/intermediates" --distribution "$SRC_DIR/build_tools/osx_distribution.xml" --resources "$SRC_DIR/build_tools/osx_package_resources/" "$OUTPUT_PATH/fish-$VERSION.pkg"
|
||||
|
||||
MAC_PRODUCTSIGN_ID=${MAC_PRODUCTSIGN_ID:--}
|
||||
productsign --sign "${MAC_PRODUCTSIGN_ID}" "$OUTPUT_PATH/fish-$VERSION.pkg" "$OUTPUT_PATH/fish-$VERSION-signed.pkg" && mv "$OUTPUT_PATH/fish-$VERSION-signed.pkg" "$OUTPUT_PATH/fish-$VERSION.pkg"
|
||||
# Here is the historical way to sign the installer package.
|
||||
# But when run on macOS 11.1, the resulting installers don't work on 10.11.
|
||||
# So we have our own script instead. See issue #7656.
|
||||
# Also see https://developer.apple.com/forums/thread/664842
|
||||
# If/when productsign is fixed to support 10.11, we can switch back to this.
|
||||
# MAC_PRODUCTSIGN_ID=${MAC_PRODUCTSIGN_ID:--}
|
||||
# productsign --sign "${MAC_PRODUCTSIGN_ID}" "$OUTPUT_PATH/fish-$VERSION.pkg" "$OUTPUT_PATH/fish-$VERSION-signed.pkg" && mv "$OUTPUT_PATH/fish-$VERSION-signed.pkg" "$OUTPUT_PATH/fish-$VERSION.pkg"
|
||||
|
||||
"$SRC_DIR/build_tools/mac_sign_package.sh" "$OUTPUT_PATH/fish-$VERSION.pkg"
|
||||
|
||||
# Make the app
|
||||
{ cd "$PKGDIR/build" && make -j 12 signed_fish_macapp && zip -r "$OUTPUT_PATH/fish-$VERSION.app.zip" fish.app; }
|
||||
{ cd "$PKGDIR/build" && make signed_fish_macapp && zip -r "$OUTPUT_PATH/fish-$VERSION.app.zip" fish.app; }
|
||||
|
||||
rm -rf "$PKGDIR"
|
||||
rm -r "$PKGDIR"
|
||||
|
|
|
|||
|
|
@ -14,14 +14,6 @@ set -e
|
|||
# but to get the documentation in, we need to make a symlink called "fish-VERSION"
|
||||
# and tar from that, so that the documentation gets the right prefix
|
||||
|
||||
# Use Ninja if available, as it automatically paralellises
|
||||
BUILD_TOOL="make"
|
||||
BUILD_GENERATOR="Unix Makefiles"
|
||||
if command -v ninja >/dev/null; then
|
||||
BUILD_TOOL="ninja"
|
||||
BUILD_GENERATOR="Ninja"
|
||||
fi
|
||||
|
||||
# We need GNU tar as that supports the --mtime and --transform options
|
||||
TAR=notfound
|
||||
for try in tar gtar gnutar; do
|
||||
|
|
@ -59,8 +51,8 @@ git archive --format=tar --prefix="$prefix"/ HEAD > "$path"
|
|||
PREFIX_TMPDIR=$(mktemp -d)
|
||||
cd "$PREFIX_TMPDIR"
|
||||
echo "$VERSION" > version
|
||||
cmake -G "$BUILD_GENERATOR" "$wd"
|
||||
$BUILD_TOOL doc
|
||||
cmake "$wd"
|
||||
make doc
|
||||
|
||||
TAR_APPEND="$TAR --append --file=$path --mtime=now --owner=0 --group=0 \
|
||||
--mode=g+w,a+rX --transform s/^/$prefix\//"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<installer-gui-script minSpecVersion="1">
|
||||
<title>fish shell</title>
|
||||
<welcome file="welcome.html" mime-type="text/html"/>
|
||||
<welcome file="welcome.rtf"/>
|
||||
<background file="terminal_logo.png" scaling="proportional" alignment="bottomleft"/>
|
||||
<pkg-ref id="com.ridiculousfish.fish-shell-pkg"/>
|
||||
<options hostArchitectures="arm64,x86_64" rootVolumeOnly="true"/>
|
||||
<options customize="never" require-scripts="true"/>
|
||||
<options customize="never" require-scripts="false"/>
|
||||
<choices-outline>
|
||||
<line choice="default">
|
||||
<line choice="com.ridiculousfish.fish-shell-pkg"/>
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: system-ui, -apple-system, "Helvetica Neue", sans-serif;
|
||||
font-size: 10pt;
|
||||
}
|
||||
code, tt {
|
||||
font-family: ui-monospace, Menlo, monospace;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<strong>fish</strong> is a smart and user-friendly command line shell. For more information, visit <a href="https://fishshell.com">fishshell.com</a>.
|
||||
</p>
|
||||
<p>
|
||||
<strong>fish</strong> will be installed into <tt>/usr/local/</tt>, and its path will be added to <wbr><tt>/etc/shells</tt> if necessary.
|
||||
</p>
|
||||
<p>
|
||||
Your default shell will <em>not</em> be changed. To make <strong>fish</strong> your login shell after the installation, run:
|
||||
</p>
|
||||
<p>
|
||||
<code>chsh -s /usr/local/bin/fish</code>
|
||||
</p>
|
||||
<p>Enjoy! Bugs can be reported on <a href="https://github.org/fish-shell/fish-shell/">GitHub</a>.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
{\rtf1\ansi\ansicpg1252\cocoartf1485\cocoasubrtf410
|
||||
{\fonttbl\f0\fnil\fcharset0 HelveticaNeue;\f1\fnil\fcharset0 Menlo-Regular;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
{\*\expandedcolortbl;\csgenericrgb\c100000\c100000\c100000;}
|
||||
{\info
|
||||
{\author dlkfjslfjsfdlkfk}}\margl1440\margr1440\vieww10800\viewh8400\viewkind0
|
||||
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
|
||||
|
||||
\f0\fs30 \cf0 Fish is a smart and user friendly command line shell. For more information, visit {\field{\*\fldinst{HYPERLINK "https://fishshell.com"}}{\fldrslt https://fishshell.com}}\
|
||||
\
|
||||
fish will be installed into
|
||||
\f1\fs26 /usr/local/
|
||||
\f0\fs30 , and fish will be added to
|
||||
\f1\fs26 /etc/shells
|
||||
\f0\fs30 if necessary.\
|
||||
\
|
||||
Your default shell will
|
||||
\i not
|
||||
\i0 be changed. To make fish your default, run:\
|
||||
\
|
||||
|
||||
\f1 chsh -s /usr/local/bin/fish
|
||||
\f0 \
|
||||
\
|
||||
Enjoy!\
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh -x
|
||||
|
||||
./add-shell ${DSTVOLUME}usr/local/bin/fish
|
||||
./add-shell /usr/local/bin/fish > /tmp/fish_postinstall_output.log
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/sh -x
|
||||
|
||||
echo "Removing any previous installation"
|
||||
pkgutil --pkg-info ${INSTALL_PKG_SESSION_ID} && pkgutil --only-files --files ${INSTALL_PKG_SESSION_ID} | while read installed
|
||||
do rm -v ${DSTVOLUME}${installed}
|
||||
done
|
||||
echo "... removed"
|
||||
|
|
@ -28,9 +28,8 @@ TIMEOUT_SECS = 5
|
|||
|
||||
UNEXPECTED_SUCCESS = object()
|
||||
|
||||
|
||||
def get_prompt_re(counter):
|
||||
"""Return a regular expression for matching a with a given prompt counter."""
|
||||
""" Return a regular expression for matching a with a given prompt counter. """
|
||||
return re.compile(
|
||||
r"""(?:\r\n?|^) # beginning of line
|
||||
(?:\x1b[\d\[KB(m]*)* # optional colors
|
||||
|
|
@ -45,21 +44,16 @@ def get_prompt_re(counter):
|
|||
|
||||
|
||||
def get_callsite():
|
||||
"""Return a triple (filename, line_number, line_text) of the call site location."""
|
||||
""" Return a triple (filename, line_number, line_text) of the call site location. """
|
||||
callstack = inspect.getouterframes(inspect.currentframe())
|
||||
for f in callstack:
|
||||
# Skip call sites from this file.
|
||||
if inspect.getmodule(f.frame) is Message.MODULE:
|
||||
continue
|
||||
# Skip functions which have a truthy callsite_skip attribute.
|
||||
if getattr(f.function, "callsite_skip", False):
|
||||
continue
|
||||
return (os.path.basename(f.filename), f.lineno, f.code_context)
|
||||
if inspect.getmodule(f.frame) is not Message.MODULE:
|
||||
return (os.path.basename(f.filename), f.lineno, f.code_context)
|
||||
return ("Unknown", -1, "")
|
||||
|
||||
|
||||
def escape(s):
|
||||
"""Escape the string 's' to make it human-understandable."""
|
||||
""" Escape the string 's' to make it human-understandable. """
|
||||
res = []
|
||||
for c in s:
|
||||
if c == "\n":
|
||||
|
|
@ -76,7 +70,7 @@ def escape(s):
|
|||
|
||||
|
||||
def pexpect_error_type(err):
|
||||
"""Return a human-readable description of a pexpect error type."""
|
||||
""" Return a human-readable description of a pexpect error type. """
|
||||
if isinstance(err, pexpect.EOF):
|
||||
return "EOF"
|
||||
elif isinstance(err, pexpect.TIMEOUT):
|
||||
|
|
@ -106,7 +100,7 @@ class Message(object):
|
|||
MODULE = sys.modules[__name__]
|
||||
|
||||
def __init__(self, dir, text, when):
|
||||
"""Construct from a direction, message text and timestamp."""
|
||||
""" Construct from a direction, message text and timestamp. """
|
||||
self.dir = dir
|
||||
self.filename, self.lineno, _ = get_callsite()
|
||||
self.text = text
|
||||
|
|
@ -114,12 +108,12 @@ class Message(object):
|
|||
|
||||
@staticmethod
|
||||
def sent_input(text, when):
|
||||
"""Return an input message with the given text."""
|
||||
""" Return an input message with the given text. """
|
||||
return Message(Message.DIR_INPUT, text, when)
|
||||
|
||||
@staticmethod
|
||||
def received_output(text, when):
|
||||
"""Return a output message with the given text."""
|
||||
""" Return a output message with the given text. """
|
||||
return Message(Message.DIR_OUTPUT, text, when)
|
||||
|
||||
|
||||
|
|
@ -135,9 +129,7 @@ class SpawnedProc(object):
|
|||
function to ensure that each printed prompt is distinct.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, name="fish", timeout=TIMEOUT_SECS, env=os.environ.copy(), **kwargs
|
||||
):
|
||||
def __init__(self, name="fish", timeout=TIMEOUT_SECS, env=os.environ.copy(), **kwargs):
|
||||
"""Construct from a name, timeout, and environment.
|
||||
|
||||
Args:
|
||||
|
|
@ -151,17 +143,15 @@ class SpawnedProc(object):
|
|||
if name not in env:
|
||||
raise ValueError("'%s' variable not found in environment" % name)
|
||||
exe_path = env.get(name)
|
||||
self.colorize = sys.stdout.isatty() or env.get("FISH_FORCE_COLOR", "0") == "1"
|
||||
self.colorize = sys.stdout.isatty()
|
||||
self.messages = []
|
||||
self.start_time = None
|
||||
self.spawn = pexpect.spawn(
|
||||
exe_path, env=env, encoding="utf-8", timeout=timeout, **kwargs
|
||||
)
|
||||
self.spawn = pexpect.spawn(exe_path, env=env, encoding="utf-8", timeout=timeout, **kwargs)
|
||||
self.spawn.delaybeforesend = None
|
||||
self.prompt_counter = 0
|
||||
|
||||
def time_since_first_message(self):
|
||||
"""Return a delta in seconds since the first message, or 0 if this is the first."""
|
||||
""" Return a delta in seconds since the first message, or 0 if this is the first. """
|
||||
now = time.monotonic()
|
||||
if not self.start_time:
|
||||
self.start_time = now
|
||||
|
|
@ -217,7 +207,7 @@ class SpawnedProc(object):
|
|||
self.report_exception_and_exit(pat_desc, unmatched, err)
|
||||
|
||||
def expect_str(self, s, **kwargs):
|
||||
"""Cover over expect_re() which accepts a literal string."""
|
||||
""" Cover over expect_re() which accepts a literal string. """
|
||||
return self.expect_re(re.escape(s), **kwargs)
|
||||
|
||||
def expect_prompt(self, *args, increment=True, **kwargs):
|
||||
|
|
@ -273,11 +263,16 @@ class SpawnedProc(object):
|
|||
print("{CYAN}Escaped buffer:{RESET}".format(**colors))
|
||||
print(escape(self.spawn.before))
|
||||
print("")
|
||||
print("{CYAN}When written to the tty, this looks like:{RESET}".format(**colors))
|
||||
print("{CYAN}<-------{RESET}".format(**colors))
|
||||
sys.stdout.write(self.spawn.before)
|
||||
sys.stdout.flush()
|
||||
print("{RESET}\n{CYAN}------->{RESET}".format(**colors))
|
||||
if sys.stdout.isatty():
|
||||
print(
|
||||
"{CYAN}When written to the tty, this looks like:{RESET}".format(
|
||||
**colors
|
||||
)
|
||||
)
|
||||
print("{CYAN}<-------{RESET}".format(**colors))
|
||||
sys.stdout.write(self.spawn.before)
|
||||
sys.stdout.flush()
|
||||
print("{RESET}\n{CYAN}------->{RESET}".format(**colors))
|
||||
|
||||
print("")
|
||||
|
||||
|
|
@ -310,14 +305,14 @@ class SpawnedProc(object):
|
|||
sys.exit(1)
|
||||
|
||||
def sleep(self, secs):
|
||||
"""Cover over time.sleep()."""
|
||||
""" Cover over time.sleep(). """
|
||||
time.sleep(secs)
|
||||
|
||||
def colors(self):
|
||||
"""Return a dictionary mapping color names to ANSI escapes"""
|
||||
""" Return a dictionary mapping color names to ANSI escapes """
|
||||
|
||||
def ansic(n):
|
||||
"""Return either an ANSI escape sequence for a color, or empty string."""
|
||||
""" Return either an ANSI escape sequence for a color, or empty string. """
|
||||
return "\033[%dm" % n if self.colorize else ""
|
||||
|
||||
return {
|
||||
|
|
@ -341,25 +336,3 @@ class SpawnedProc(object):
|
|||
"LIGHTCYAN": ansic(96),
|
||||
"WHITE": ansic(97),
|
||||
}
|
||||
|
||||
|
||||
def control(char: str) -> str:
|
||||
""" Returns the char sent when control is pressed along the given key. """
|
||||
assert len(char) == 1
|
||||
char = char.lower()
|
||||
if ord("a") <= ord(char) <= ord("z"):
|
||||
return chr(ord(char) - ord("a") + 1)
|
||||
return chr({
|
||||
"@": 0,
|
||||
"`": 0,
|
||||
"[": 27,
|
||||
"{": 27,
|
||||
"\\": 28,
|
||||
"|": 28,
|
||||
"]": 29,
|
||||
"}": 29,
|
||||
"^": 30,
|
||||
"~": 30,
|
||||
"_": 31,
|
||||
"?": 127,
|
||||
}[char])
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ if test $all = yes
|
|||
set -l files (git status --porcelain --short --untracked-files=all | sed -e 's/^ *[^ ]* *//')
|
||||
if set -q files[1]
|
||||
echo
|
||||
echo 'You have uncommitted changes. Are you sure you want to restyle?'
|
||||
read -P 'y/N? ' -n1 -l ans
|
||||
if not string match -qi "y" -- $ans
|
||||
exit 1
|
||||
end
|
||||
echo You have uncommitted changes. Cowardly refusing to restyle the entire code base.
|
||||
echo
|
||||
exit 1
|
||||
end
|
||||
set c_files src/*.h src/*.cpp src/*.c
|
||||
set fish_files share/**.fish
|
||||
|
|
@ -74,20 +72,13 @@ if set -q c_files[1]
|
|||
else if type -q clang-format
|
||||
echo === Running "$red"clang-format"$normal"
|
||||
for file in $c_files
|
||||
if clang-format --dry-run -Werror $file
|
||||
# file was clean, remove it from the list
|
||||
set -e c_files[(contains -i $file $c_files)]
|
||||
end
|
||||
end
|
||||
if set -q c_files[1]
|
||||
printf "Reformat those %d files?\n" (count $c_files)
|
||||
read -P 'y/N? ' -n1 -l ans
|
||||
if string match -qi "y" -- $ans
|
||||
clang-format -i --verbose $c_files
|
||||
else if string match -qi "n" -- $ans
|
||||
echo Skipping
|
||||
else # like they ctrl-C'd or something.
|
||||
exit 1
|
||||
cp $file $file.new # preserves mode bits
|
||||
clang-format $file >$file.new
|
||||
if cmp --quiet $file $file.new
|
||||
rm $file.new
|
||||
else
|
||||
echo $file was NOT correctly formatted
|
||||
mv $file.new $file
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
# This is the case for at least Cygwin and Newlib.
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1)
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(CMakePushCheckState)
|
||||
|
||||
if(APPLE)
|
||||
check_cxx_compiler_flag("-Werror=unguarded-availability" REQUIRES_UNGUARDED_AVAILABILITY)
|
||||
|
|
@ -32,32 +31,6 @@ if (HAS_REDUNDANT_MOVE)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wredundant-move")
|
||||
endif()
|
||||
|
||||
# Defeat bogus warnings about missing field initializers for `var{}` initialization.
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
cmake_push_check_state()
|
||||
list(APPEND CMAKE_REQUIRED_FLAGS "-W")
|
||||
check_cxx_source_compiles("
|
||||
struct sr_t { int x; };
|
||||
int main(void) {
|
||||
sr_t sr{};
|
||||
return sr.x;
|
||||
}"
|
||||
EMPTY_VALUE_INIT_ACCEPTED
|
||||
FAIL_REGEX "-Wmissing-field-initializers"
|
||||
)
|
||||
if (NOT EMPTY_VALUE_INIT_ACCEPTED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
|
||||
# Disable static destructors if we can.
|
||||
check_cxx_compiler_flag("-fno-c++-static-destructors" DISABLE_STATIC_DESTRUCTORS)
|
||||
if (DISABLE_STATIC_DESTRUCTORS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-c++-static-destructors")
|
||||
endif()
|
||||
|
||||
|
||||
# Try using CMake's own logic to locate curses/ncurses
|
||||
find_package(Curses)
|
||||
if(NOT ${CURSES_FOUND})
|
||||
|
|
@ -83,6 +56,10 @@ endif()
|
|||
|
||||
# Get threads.
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
# FindThreads < 3.4.0 doesn't work for C++-only projects
|
||||
if(CMAKE_VERSION VERSION_LESS 3.4.0)
|
||||
enable_language(C)
|
||||
endif()
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
# Detect WSL. Does not match against native Windows/WIN32.
|
||||
|
|
@ -99,22 +76,19 @@ include(CheckIncludeFiles)
|
|||
include(CheckStructHasMember)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckTypeSize)
|
||||
include(CMakePushCheckState)
|
||||
check_cxx_symbol_exists(backtrace_symbols execinfo.h HAVE_BACKTRACE_SYMBOLS)
|
||||
|
||||
# workaround for lousy mtime precision on a Linux kernel
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
|
||||
check_cxx_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
|
||||
check_cxx_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
|
||||
if ((HAVE_CLOCK_GETTIME) AND (HAVE_FUTIMENS))
|
||||
set(UVAR_FILE_SET_MTIME_HACK 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
check_cxx_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
|
||||
check_cxx_symbol_exists(ctermid_r stdio.h HAVE_CTERMID_R)
|
||||
check_struct_has_member("struct dirent" d_type dirent.h HAVE_STRUCT_DIRENT_D_TYPE LANGUAGE CXX)
|
||||
check_cxx_symbol_exists(dirfd "sys/types.h;dirent.h" HAVE_DIRFD)
|
||||
check_include_file_cxx(execinfo.h HAVE_EXECINFO_H)
|
||||
check_cxx_symbol_exists(flock sys/file.h HAVE_FLOCK)
|
||||
# futimens is new in OS X 10.13 but is a weak symbol.
|
||||
# Don't assume it exists just because we can link - it may be null.
|
||||
check_cxx_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
|
||||
check_cxx_symbol_exists(futimes sys/time.h HAVE_FUTIMES)
|
||||
check_cxx_symbol_exists(getifaddrs ifaddrs.h HAVE_GETIFADDRS)
|
||||
check_cxx_symbol_exists(getpwent pwd.h HAVE_GETPWENT)
|
||||
check_cxx_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
|
||||
check_cxx_symbol_exists(gettext libintl.h HAVE_GETTEXT)
|
||||
|
|
@ -138,26 +112,29 @@ check_struct_has_member("struct stat" st_mtimespec.tv_nsec "sys/stat.h"
|
|||
HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC LANGUAGE CXX)
|
||||
check_struct_has_member("struct stat" st_mtim.tv_nsec "sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
|
||||
LANGUAGE CXX)
|
||||
check_cxx_symbol_exists(sys_errlist stdio.h HAVE_SYS_ERRLIST)
|
||||
check_include_file_cxx(sys/ioctl.h HAVE_SYS_IOCTL_H)
|
||||
check_include_file_cxx(sys/select.h HAVE_SYS_SELECT_H)
|
||||
|
||||
# glibc 2.30 deprecated <sys/sysctl.h> because that's what glibc does.
|
||||
# Checking for that here rather than hardcoding a check on the glibc
|
||||
# version in the C++ sources at point of use makes more sense.
|
||||
SET(OLD_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
||||
check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYS_SYSCTL_H)
|
||||
SET(CMAKE_C_FLAGS "${OLD_CMAKE_C_FLAGS}")
|
||||
check_include_file_cxx(termios.h HAVE_TERMIOS_H) # Needed for TIOCGWINSZ
|
||||
|
||||
check_cxx_symbol_exists(eventfd sys/eventfd.h HAVE_EVENTFD)
|
||||
check_cxx_symbol_exists(pipe2 unistd.h HAVE_PIPE2)
|
||||
check_cxx_symbol_exists(wcscasecmp wchar.h HAVE_WCSCASECMP)
|
||||
check_cxx_symbol_exists(wcsdup wchar.h HAVE_WCSDUP)
|
||||
check_cxx_symbol_exists(wcslcpy wchar.h HAVE_WCSLCPY)
|
||||
check_cxx_symbol_exists(wcsncasecmp wchar.h HAVE_WCSNCASECMP)
|
||||
check_cxx_symbol_exists(wcsndup wchar.h HAVE_WCSNDUP)
|
||||
|
||||
# These are for compatibility with Solaris 10, which places the following
|
||||
# in the std namespace.
|
||||
if(NOT HAVE_WCSNCASECMP)
|
||||
check_cxx_symbol_exists(std::wcscasecmp wchar.h HAVE_STD__WCSCASECMP)
|
||||
endif()
|
||||
if(NOT HAVE_WCSDUP)
|
||||
check_cxx_symbol_exists(std::wcsdup wchar.h HAVE_STD__WCSDUP)
|
||||
endif()
|
||||
if(NOT HAVE_WCSNCASECMP)
|
||||
check_cxx_symbol_exists(std::wcsncasecmp wchar.h HAVE_STD__WCSNCASECMP)
|
||||
endif()
|
||||
|
||||
|
|
@ -170,12 +147,13 @@ endif()
|
|||
list(APPEND WCSTOD_L_INCLUDES "wchar.h")
|
||||
check_cxx_symbol_exists(wcstod_l "${WCSTOD_L_INCLUDES}" HAVE_WCSTOD_L)
|
||||
|
||||
check_cxx_symbol_exists(uselocale "locale.h;xlocale.h" HAVE_USELOCALE)
|
||||
check_cxx_symbol_exists(_sys_errs stdlib.h HAVE__SYS__ERRS)
|
||||
|
||||
cmake_push_check_state()
|
||||
check_struct_has_member("struct winsize" ws_row "termios.h;sys/ioctl.h" _HAVE_WINSIZE)
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES termios.h sys/ioctl.h)
|
||||
check_type_size("struct winsize" STRUCT_WINSIZE LANGUAGE CXX)
|
||||
check_cxx_symbol_exists("TIOCGWINSZ" "termios.h;sys/ioctl.h" HAVE_TIOCGWINSZ)
|
||||
if(_HAVE_WINSIZE EQUAL 1 AND HAVE_TIOCGWINSZ EQUAL 1)
|
||||
if(STRUCT_WINSIZE GREATER -1 AND HAVE_TIOCGWINSZ EQUAL 1)
|
||||
set(HAVE_WINSIZE 1)
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
|
|
@ -197,9 +175,9 @@ elseif(HAVE_NCURSES_TERM_H)
|
|||
set(TPARM_INCLUDES "${TPARM_INCLUDES}#include <ncurses/term.h>\n")
|
||||
endif()
|
||||
|
||||
# Solaris and X/Open-conforming systems have a fixed-args tparm
|
||||
cmake_push_check_state()
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
|
||||
# Solaris and X/Open-conforming systems have a fixed-args tparm
|
||||
check_cxx_source_compiles("
|
||||
#define TPARM_VARARGS
|
||||
${TPARM_INCLUDES}
|
||||
|
|
@ -211,23 +189,6 @@ int main () {
|
|||
TPARM_TAKES_VARARGS
|
||||
)
|
||||
|
||||
|
||||
# Check if tputs needs a function reading an int or char.
|
||||
# The only curses I can find that needs a char is OpenIndiana.
|
||||
check_cxx_source_compiles("
|
||||
#include <curses.h>
|
||||
#include <term.h>
|
||||
|
||||
static int writer(int b) {
|
||||
return b;
|
||||
}
|
||||
|
||||
int main() {
|
||||
return tputs(\"foo\", 5, writer);
|
||||
}"
|
||||
TPUTS_USES_INT_ARG
|
||||
)
|
||||
|
||||
if(TPARM_TAKES_VARARGS)
|
||||
set(TPARM_VARARGS 1)
|
||||
else()
|
||||
|
|
@ -267,29 +228,16 @@ int main () {
|
|||
check_cxx_source_compiles("
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
std::atomic<uint8_t> n8 (0);
|
||||
std::atomic<uint64_t> n64 (0);
|
||||
std::atomic<uint64_t> x (0);
|
||||
int main() {
|
||||
uint8_t i = n8.load(std::memory_order_relaxed);
|
||||
uint64_t j = n64.load(std::memory_order_relaxed);
|
||||
return std::atomic_is_lock_free(&n8)
|
||||
& std::atomic_is_lock_free(&n64);
|
||||
uint64_t i = x.load(std::memory_order_relaxed);
|
||||
return std::atomic_is_lock_free(&x);
|
||||
}"
|
||||
LIBATOMIC_NOT_NEEDED)
|
||||
IF (NOT LIBATOMIC_NOT_NEEDED)
|
||||
set(ATOMIC_LIBRARY "atomic")
|
||||
endif()
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <sys/wait.h>
|
||||
|
||||
int main() {
|
||||
static_assert(WEXITSTATUS(0x007f) == 0x7f, \"This is our message we need to add because C++ is terrible\");
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
HAVE_WAITSTATUS_SIGNAL_RET)
|
||||
|
||||
IF (APPLE)
|
||||
# Check if mbrtowc implementation attempts to encode invalid UTF-8 sequences
|
||||
# Known culprits: at least some versions of macOS (confirmed Snow Leopard and Yosemite)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ include(FeatureSummary)
|
|||
set(SPHINX_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc_src")
|
||||
set(SPHINX_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/user_doc")
|
||||
set(SPHINX_BUILD_DIR "${SPHINX_ROOT_DIR}/build")
|
||||
set(SPHINX_CACHE_DIR "${SPHINX_ROOT_DIR}/doctrees")
|
||||
set(SPHINX_HTML_DIR "${SPHINX_ROOT_DIR}/html")
|
||||
set(SPHINX_MANPAGE_DIR "${SPHINX_ROOT_DIR}/man")
|
||||
|
||||
|
|
@ -18,10 +19,9 @@ add_custom_target(sphinx-docs
|
|||
mkdir -p ${SPHINX_HTML_DIR}/_static/
|
||||
COMMAND env PATH="$<TARGET_FILE_DIR:fish_indent>:$$PATH"
|
||||
${SPHINX_EXECUTABLE}
|
||||
-j auto
|
||||
-q -b html
|
||||
-c "${SPHINX_SRC_DIR}"
|
||||
-d "${SPHINX_ROOT_DIR}/.doctrees-html"
|
||||
-d "${SPHINX_CACHE_DIR}"
|
||||
"${SPHINX_SRC_DIR}"
|
||||
"${SPHINX_HTML_DIR}"
|
||||
DEPENDS ${SPHINX_SRC_DIR}/fish_indent_lexer.py fish_indent
|
||||
|
|
@ -31,10 +31,9 @@ add_custom_target(sphinx-docs
|
|||
add_custom_target(sphinx-manpages
|
||||
env PATH="$<TARGET_FILE_DIR:fish_indent>:$$PATH"
|
||||
${SPHINX_EXECUTABLE}
|
||||
-j auto
|
||||
-q -b man
|
||||
-c "${SPHINX_SRC_DIR}"
|
||||
-d "${SPHINX_ROOT_DIR}/.doctrees-man"
|
||||
-d "${SPHINX_CACHE_DIR}"
|
||||
"${SPHINX_SRC_DIR}"
|
||||
# TODO: This only works if we only have section 1 manpages.
|
||||
"${SPHINX_MANPAGE_DIR}/man1"
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ set(bindir ${CMAKE_INSTALL_BINDIR})
|
|||
set(sysconfdir ${CMAKE_INSTALL_SYSCONFDIR})
|
||||
set(mandir ${CMAKE_INSTALL_MANDIR})
|
||||
|
||||
set(rel_datadir ${CMAKE_INSTALL_DATADIR})
|
||||
set(datadir ${CMAKE_INSTALL_FULL_DATADIR})
|
||||
file(RELATIVE_PATH rel_datadir ${CMAKE_INSTALL_PREFIX} ${datadir})
|
||||
|
||||
set(docdir ${CMAKE_INSTALL_DOCDIR})
|
||||
|
||||
|
|
@ -91,9 +91,7 @@ fish_create_dirs(${rel_datadir}/fish ${rel_datadir}/fish/completions
|
|||
${rel_datadir}/fish/tools/web_config
|
||||
${rel_datadir}/fish/tools/web_config/js
|
||||
${rel_datadir}/fish/tools/web_config/partials
|
||||
${rel_datadir}/fish/tools/web_config/sample_prompts
|
||||
${rel_datadir}/fish/tools/web_config/themes
|
||||
)
|
||||
${rel_datadir}/fish/tools/web_config/sample_prompts)
|
||||
|
||||
configure_file(share/__fish_build_paths.fish.in share/__fish_build_paths.fish)
|
||||
install(FILES share/config.fish
|
||||
|
|
@ -149,7 +147,6 @@ install(DIRECTORY share/tools/web_config
|
|||
PATTERN "*.html"
|
||||
PATTERN "*.py"
|
||||
PATTERN "*.js"
|
||||
PATTERN "*.theme"
|
||||
PATTERN "*.fish")
|
||||
|
||||
# Building the man pages is optional: if Sphinx isn't installed, they're not built
|
||||
|
|
@ -158,6 +155,8 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/user_doc/html/ # Trailing slash is
|
|||
DESTINATION ${docdir} OPTIONAL)
|
||||
install(FILES CHANGELOG.rst DESTINATION ${docdir})
|
||||
|
||||
install(FILES share/lynx.lss DESTINATION ${rel_datadir}/fish/)
|
||||
|
||||
# These files are built by cmake/gettext.cmake, but using GETTEXT_PROCESS_PO_FILES's
|
||||
# INSTALL_DESTINATION leads to them being installed as ${lang}.gmo, not fish.mo
|
||||
# The ${languages} array comes from cmake/gettext.cmake
|
||||
|
|
@ -168,14 +167,13 @@ if(GETTEXT_FOUND)
|
|||
endforeach()
|
||||
endif()
|
||||
|
||||
if (NOT APPLE)
|
||||
install(FILES fish.desktop DESTINATION ${rel_datadir}/applications)
|
||||
install(FILES ${SPHINX_SRC_DIR}/python_docs_theme/static/fish.png DESTINATION ${rel_datadir}/pixmaps)
|
||||
endif()
|
||||
install(FILES fish.desktop DESTINATION ${rel_datadir}/applications)
|
||||
install(FILES fish.png DESTINATION ${rel_datadir}/pixmaps)
|
||||
|
||||
# Group install targets into a InstallTargets folder
|
||||
set_property(TARGET build_fish_pc CHECK-FISH-BUILD-VERSION-FILE
|
||||
tests_buildroot_target
|
||||
test_fishscript
|
||||
test_prep tests_buildroot_target
|
||||
PROPERTY FOLDER cmake/InstallTargets)
|
||||
|
||||
# Make a target build_root that installs into the buildroot directory, for testing.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Minimum OS X deployment version")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
|
||||
|
||||
# Code signing ID on Mac.
|
||||
# If this is falsey, codesigning is disabled.
|
||||
|
|
|
|||
|
|
@ -28,50 +28,16 @@ else()
|
|||
endif()
|
||||
|
||||
set(FISH_USE_SYSTEM_PCRE2 ${USE_SYS_PCRE2_DEFAULT} CACHE BOOL
|
||||
"Use PCRE2 from the system, instead of fetching and building it")
|
||||
"Use PCRE2 from the system, instead of bundled with fish")
|
||||
|
||||
if(FISH_USE_SYSTEM_PCRE2)
|
||||
set(PCRE2_LIB "${SYS_PCRE2_LIB}")
|
||||
set(PCRE2_INCLUDE_DIR "${SYS_PCRE2_INCLUDE_DIR}")
|
||||
message(STATUS "Using system PCRE2 library ${PCRE2_INCLUDE_DIR}")
|
||||
else()
|
||||
include(FetchContent RESULT_VARIABLE HAVE_FetchContent)
|
||||
if (${HAVE_FetchContent} STREQUAL "NOTFOUND")
|
||||
message(FATAL_ERROR "Please install PCRE2 headers, or CMake >= 3.11 so I can download PCRE")
|
||||
endif()
|
||||
set(CMAKE_TLS_VERIFY true)
|
||||
set(PCRE2_REPO "https://github.com/PCRE2Project/pcre2.git")
|
||||
|
||||
message(STATUS "Fetching and configuring PCRE2 from ${PCRE2_REPO}")
|
||||
Set(FETCHCONTENT_QUIET FALSE)
|
||||
FetchContent_Declare(
|
||||
pcre2
|
||||
GIT_REPOSITORY ${PCRE2_REPO}
|
||||
GIT_TAG "72669190cb947f0cac1d038a8bb1820da59ef447" # tag: pcre2-10.36
|
||||
GIT_SHALLOW ON
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
# Don't try FetchContent_MakeAvailable, there's no way to add EXCLUDE_FROM_ALL
|
||||
# so we end up installing all of PCRE2 including its headers, man pages, etc.
|
||||
FetchContent_GetProperties(pcre2)
|
||||
if (NOT pcre2_POPULATED)
|
||||
# If GIT_WORK_TREE is set (by user or by git itself with e.g. git rebase), it
|
||||
# will override the git directory which CMake tries to apply in FetchContent_Populate,
|
||||
# resulting in a failed checkout.
|
||||
# Ensure it is not set.
|
||||
unset(ENV{GIT_WORK_TREE})
|
||||
unset(ENV{GIT_DIR})
|
||||
FetchContent_Populate(pcre2)
|
||||
add_subdirectory(${pcre2_SOURCE_DIR} ${pcre2_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
set(PCRE2_INCLUDE_DIR ${pcre2_BINARY_DIR})
|
||||
message(STATUS "Using bundled PCRE2 library")
|
||||
add_subdirectory(pcre2 EXCLUDE_FROM_ALL)
|
||||
set(PCRE2_INCLUDE_DIR ${CMAKE_BINARY_DIR}/pcre2)
|
||||
set(PCRE2_LIB pcre2-${PCRE2_WIDTH})
|
||||
|
||||
# Disable -Wunused-macros inside PCRE2, as it is noisy.
|
||||
get_target_property(PCRE2_COMPILE_OPTIONS ${PCRE2_LIB} COMPILE_OPTIONS)
|
||||
list(REMOVE_ITEM PCRE2_COMPILE_OPTIONS "-Wunused-macros")
|
||||
set_property(TARGET ${PCRE2_LIB} PROPERTY COMPILE_OPTIONS ${PCRE2_COMPILE_OPTIONS})
|
||||
|
||||
endif(FISH_USE_SYSTEM_PCRE2)
|
||||
include_directories(${PCRE2_INCLUDE_DIR})
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
include(FetchContent)
|
||||
|
||||
# Don't let Corrosion's tests interfere with ours.
|
||||
set(CORROSION_TESTS OFF CACHE BOOL "" FORCE)
|
||||
|
||||
FetchContent_Declare(
|
||||
Corrosion
|
||||
GIT_REPOSITORY https://github.com/mqudsi/corrosion
|
||||
GIT_TAG fish
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(Corrosion)
|
||||
|
||||
set(fish_rust_target "fish-rust")
|
||||
|
||||
set(fish_autocxx_gen_dir "${CMAKE_BINARY_DIR}/fish-autocxx-gen/")
|
||||
|
||||
if(NOT DEFINED CARGO_FLAGS)
|
||||
# Corrosion doesn't like an empty string as FLAGS. This is basically a no-op alternative.
|
||||
# See https://github.com/corrosion-rs/corrosion/issues/356
|
||||
set(CARGO_FLAGS "--config" "foo=0")
|
||||
endif()
|
||||
if(DEFINED ASAN)
|
||||
list(APPEND CARGO_FLAGS "-Z" "build-std")
|
||||
endif()
|
||||
|
||||
corrosion_import_crate(
|
||||
MANIFEST_PATH "${CMAKE_SOURCE_DIR}/fish-rust/Cargo.toml"
|
||||
FEATURES "fish-ffi-tests"
|
||||
FLAGS "${CARGO_FLAGS}"
|
||||
)
|
||||
|
||||
# We need the build dir because cxx puts our headers in there.
|
||||
# Corrosion doesn't expose the build dir, so poke where we shouldn't.
|
||||
if (Rust_CARGO_TARGET)
|
||||
set(rust_target_dir "${CMAKE_BINARY_DIR}/cargo/build/${_CORROSION_RUST_CARGO_TARGET}")
|
||||
else()
|
||||
set(rust_target_dir "${CMAKE_BINARY_DIR}/cargo/build/${_CORROSION_RUST_CARGO_HOST_TARGET}")
|
||||
corrosion_set_hostbuild(${fish_rust_target})
|
||||
endif()
|
||||
|
||||
# Tell Cargo where our build directory is so it can find config.h.
|
||||
corrosion_set_env_vars(${fish_rust_target} "FISH_BUILD_DIR=${CMAKE_BINARY_DIR}" "FISH_AUTOCXX_GEN_DIR=${fish_autocxx_gen_dir}" "FISH_RUST_TARGET_DIR=${rust_target_dir}")
|
||||
|
||||
target_include_directories(${fish_rust_target} INTERFACE
|
||||
"${rust_target_dir}/cxxbridge/${fish_rust_target}/src/"
|
||||
"${fish_autocxx_gen_dir}/include/"
|
||||
)
|
||||
|
||||
# Tell fish what extra C++ files to compile.
|
||||
define_property(
|
||||
TARGET PROPERTY fish_extra_cpp_files
|
||||
BRIEF_DOCS "Extra C++ files to compile for fish."
|
||||
FULL_DOCS "Extra C++ files to compile for fish."
|
||||
)
|
||||
|
||||
set_property(TARGET ${fish_rust_target} PROPERTY fish_extra_cpp_files
|
||||
"${fish_autocxx_gen_dir}/cxx/gen0.cxx"
|
||||
)
|
||||
|
|
@ -1,56 +1,4 @@
|
|||
# This adds ctest support to the project
|
||||
enable_testing()
|
||||
|
||||
# By default, ctest runs tests serially
|
||||
if(NOT CTEST_PARALLEL_LEVEL)
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(CORES)
|
||||
set(CTEST_PARALLEL_LEVEL ${CORES})
|
||||
endif()
|
||||
|
||||
# Put in a tests folder to reduce the top level targets in IDEs.
|
||||
set(CMAKE_FOLDER tests)
|
||||
|
||||
# We will use 125 as a reserved exit code to indicate that a test has been skipped, i.e. it did not
|
||||
# pass but it should not be considered a failed test run, either.
|
||||
set(SKIP_RETURN_CODE 125)
|
||||
|
||||
# Even though we are using CMake's ctest for testing, we still define our own `make test` target
|
||||
# rather than use its default for many reasons:
|
||||
# * CMake doesn't run tests in-proc or even add each tests as an individual node in the ninja
|
||||
# dependency tree, instead it just bundles all tests into a target called `test` that always just
|
||||
# shells out to `ctest`, so there are no build-related benefits to not doing that ourselves.
|
||||
# * CMake devs insist that it is appropriate for `make test` to never depend on `make all`, i.e.
|
||||
# running `make test` does not require any of the binaries to be built before testing.
|
||||
# * The only way to have a test depend on a binary is to add a fake test with a name like
|
||||
# "build_fish" that executes CMake recursively to build the `fish` target.
|
||||
# * It is not possible to set top-level CTest options/settings such as CTEST_PARALLEL_LEVEL from
|
||||
# within the CMake configuration file.
|
||||
# * Circling back to the point about individual tests not being actual Makefile targets, CMake does
|
||||
# not offer any way to execute a named test via the `make`/`ninja`/whatever interface; the only
|
||||
# way to manually invoke test `foo` is to to manually run `ctest` and specify a regex matching
|
||||
# `foo` as an argument, e.g. `ctest -R ^foo$`... which is really crazy.
|
||||
|
||||
# The top-level test target is "fish_run_tests".
|
||||
add_custom_target(fish_run_tests
|
||||
COMMAND env CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL} FISH_FORCE_COLOR=1
|
||||
FISH_SOURCE_DIR=${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_CTEST_COMMAND} --force-new-ctest-process # --verbose
|
||||
--output-on-failure --progress
|
||||
DEPENDS fish_tests tests_buildroot_target
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
# If CMP0037 is available, also make an alias "test" target.
|
||||
# Note that this policy may not be available, in which case definining such a target silently fails.
|
||||
cmake_policy(PUSH)
|
||||
if(POLICY CMP0037)
|
||||
cmake_policy(SET CMP0037 OLD)
|
||||
add_custom_target(test DEPENDS fish_run_tests)
|
||||
endif()
|
||||
cmake_policy(POP)
|
||||
|
||||
# Build the low-level tests code
|
||||
# Define fish_tests.
|
||||
add_executable(fish_tests EXCLUDE_FROM_ALL
|
||||
src/fish_tests.cpp)
|
||||
fish_link_deps_and_sign(fish_tests)
|
||||
|
|
@ -58,43 +6,24 @@ fish_link_deps_and_sign(fish_tests)
|
|||
# The "test" directory.
|
||||
set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test)
|
||||
|
||||
# CMake doesn't really support dynamic test discovery where a test harness is executed to list the
|
||||
# tests it contains, making fish_tests.cpp's tests opaque to CMake (whereas littlecheck tests can be
|
||||
# enumerated from the filesystem). We used to compile fish_tests.cpp without linking against
|
||||
# anything (-Wl,-undefined,dynamic_lookup,--unresolved-symbols=ignore-all) to get it to print its
|
||||
# tests at configuration time, but that's a little too much dark CMake magic.
|
||||
#
|
||||
# We now identify tests by checking against a magic regex that's #define'd as a no-op C-side.
|
||||
file(READ "${CMAKE_SOURCE_DIR}/src/fish_tests.cpp" FISH_TESTS_CPP)
|
||||
string(REGEX MATCHALL "TEST_GROUP\\( *\"([^\"]+)\"" "LOW_LEVEL_TESTS" "${FISH_TESTS_CPP}")
|
||||
string(REGEX REPLACE "TEST_GROUP\\( *\"([^\"]+)\"" "\\1" "LOW_LEVEL_TESTS" "${LOW_LEVEL_TESTS}")
|
||||
list(REMOVE_DUPLICATES LOW_LEVEL_TESTS)
|
||||
|
||||
# The directory into which fish is installed.
|
||||
set(TEST_INSTALL_DIR ${TEST_DIR}/buildroot)
|
||||
|
||||
# The directory where the tests expect to find the fish root (./bin, etc)
|
||||
set(TEST_ROOT_DIR ${TEST_DIR}/root)
|
||||
|
||||
# Copy needed directories for out-of-tree builds
|
||||
if(NOT FISH_IN_TREE_BUILD)
|
||||
add_custom_target(funcs_dir)
|
||||
add_custom_command(TARGET funcs_dir
|
||||
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/share
|
||||
# Don't run ln twice or it will create a new link in the link.
|
||||
COMMAND test -e ${CMAKE_BINARY_DIR}/share/functions || ln -sf
|
||||
${CMAKE_SOURCE_DIR}/share/functions/ ${CMAKE_BINARY_DIR}/share/functions
|
||||
COMMENT "Symlinking fish functions to binary dir"
|
||||
VERBATIM)
|
||||
# Copy tests files.
|
||||
file(GLOB TESTS_FILES tests/*)
|
||||
add_custom_target(tests_dir DEPENDS tests)
|
||||
|
||||
add_custom_target(tests_dir DEPENDS tests)
|
||||
add_custom_command(TARGET tests_dir
|
||||
if(NOT FISH_IN_TREE_BUILD)
|
||||
add_custom_command(TARGET tests_dir
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_SOURCE_DIR}/tests/ ${CMAKE_BINARY_DIR}/tests/
|
||||
COMMENT "Copying test files to binary dir"
|
||||
VERBATIM)
|
||||
|
||||
add_dependencies(fish_tests tests_dir funcs_dir)
|
||||
add_dependencies(fish_tests tests_dir)
|
||||
endif()
|
||||
|
||||
# Copy littlecheck.py
|
||||
|
|
@ -103,106 +32,119 @@ configure_file(build_tools/littlecheck.py littlecheck.py COPYONLY)
|
|||
# Copy pexpect_helper.py
|
||||
configure_file(build_tools/pexpect_helper.py pexpect_helper.py COPYONLY)
|
||||
|
||||
# Suppress generating Xcode schemes for all tests, there's too many.
|
||||
set(CMAKE_XCODE_GENERATE_SCHEME 0)
|
||||
|
||||
# CMake being CMake, you can't just add a DEPENDS argument to add_test to make it depend on any of
|
||||
# your binaries actually being built before `make test` is executed (requiring `make all` first),
|
||||
# and the only dependency a test can have is on another test. So we make building fish and
|
||||
# `fish_tests` prerequisites to our entire top-level `test` target.
|
||||
function(add_test_target NAME)
|
||||
string(REPLACE "/" "-" NAME ${NAME})
|
||||
add_custom_target("test_${NAME}" COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -R "^${NAME}$$"
|
||||
DEPENDS fish_tests tests_buildroot_target USES_TERMINAL )
|
||||
endfunction()
|
||||
|
||||
# Make the directory in which to run tests.
|
||||
# Also symlink fish to where the tests expect it to be.
|
||||
# Lastly put fish_test_helper there too.
|
||||
add_custom_target(tests_buildroot_target
|
||||
# Make the directory in which to run tests:
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_INSTALL_DIR}
|
||||
COMMAND env DESTDIR=${TEST_INSTALL_DIR} ${CMAKE_COMMAND}
|
||||
COMMAND DESTDIR=${TEST_INSTALL_DIR} ${CMAKE_COMMAND}
|
||||
--build ${CMAKE_CURRENT_BINARY_DIR} --target install
|
||||
# Put fish_test_helper there too:
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/fish_test_helper
|
||||
${TEST_INSTALL_DIR}/${CMAKE_INSTALL_PREFIX}/bin
|
||||
# Also symlink fish to where the tests expect it to be:
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
${TEST_INSTALL_DIR}/${CMAKE_INSTALL_PREFIX}
|
||||
${TEST_ROOT_DIR}
|
||||
DEPENDS fish fish_test_helper)
|
||||
|
||||
# CMake less than 3.9.0 "fully supports" setting an exit code to denote a skipped test, but then
|
||||
# it just goes ahead and reports it as failed. Really?
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.9.0")
|
||||
set(CMAKE_SKIPPED_HACK "env" "CMAKE_SKIPPED_HACK=1")
|
||||
if(NOT FISH_IN_TREE_BUILD)
|
||||
# We need to symlink share/functions for the tests.
|
||||
# This should be simplified.
|
||||
add_custom_target(symlink_functions
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/share/functions
|
||||
${CMAKE_CURRENT_BINARY_DIR}/share/functions)
|
||||
add_dependencies(tests_buildroot_target symlink_functions)
|
||||
else()
|
||||
set(CMAKE_SKIPPED_HACK)
|
||||
add_custom_target(symlink_functions)
|
||||
endif()
|
||||
|
||||
foreach(LTEST ${LOW_LEVEL_TESTS})
|
||||
add_test(
|
||||
NAME ${LTEST}
|
||||
COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_env.sh
|
||||
${CMAKE_BINARY_DIR}/fish_tests ${LTEST}
|
||||
# Prep the environment for running the unit tests.
|
||||
add_custom_target(test_prep
|
||||
# Add directories hard-coded into the tests
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/data
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/data
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/temp
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/temp
|
||||
|
||||
# Add the XDG_* directories
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/xdg_data
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/xdg_data
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/xdg_config
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/xdg_config
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/xdg_runtime
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/xdg_runtime
|
||||
|
||||
DEPENDS tests_buildroot_target tests_dir
|
||||
USES_TERMINAL)
|
||||
|
||||
# Define our individual tests.
|
||||
# Each test is conceptually independent.
|
||||
# However when running all tests, we want to run them serially for sanity's sake.
|
||||
# So define both a normal target, and a serial variant which enforces ordering.
|
||||
foreach(TESTTYPE test serial_test)
|
||||
add_custom_target(${TESTTYPE}_low_level
|
||||
COMMAND env XDG_DATA_DIRS=
|
||||
XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_data
|
||||
XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_config
|
||||
XDG_RUNTIME_DIR=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_runtime
|
||||
./fish_tests
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
set_tests_properties(${LTEST} PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
||||
add_test_target("${LTEST}")
|
||||
endforeach(LTEST)
|
||||
DEPENDS fish_tests
|
||||
USES_TERMINAL)
|
||||
|
||||
FILE(GLOB FISH_CHECKS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/checks/*.fish)
|
||||
foreach(CHECK ${FISH_CHECKS})
|
||||
get_filename_component(CHECK_NAME ${CHECK} NAME)
|
||||
get_filename_component(CHECK ${CHECK} NAME_WE)
|
||||
add_test(NAME ${CHECK_NAME}
|
||||
COMMAND ${CMAKE_SKIPPED_HACK} sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/test.fish ${CHECK}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
|
||||
)
|
||||
set_tests_properties(${CHECK_NAME} PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
||||
set_tests_properties(${CHECK_NAME} PROPERTIES ENVIRONMENT FISH_FORCE_COLOR=1)
|
||||
add_test_target("${CHECK_NAME}")
|
||||
endforeach(CHECK)
|
||||
add_custom_target(${TESTTYPE}_fishscript
|
||||
COMMAND
|
||||
cd tests &&
|
||||
env XDG_DATA_DIRS=
|
||||
XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_data
|
||||
XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_config
|
||||
XDG_RUNTIME_DIR=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_runtime
|
||||
${TEST_ROOT_DIR}/bin/fish test.fish
|
||||
DEPENDS test_prep
|
||||
USES_TERMINAL)
|
||||
|
||||
FILE(GLOB PEXPECTS CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tests/pexpects/*.py)
|
||||
foreach(PEXPECT ${PEXPECTS})
|
||||
get_filename_component(PEXPECT ${PEXPECT} NAME)
|
||||
add_test(NAME ${PEXPECT}
|
||||
COMMAND ${CMAKE_SKIPPED_HACK} sh ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.sh
|
||||
${CMAKE_CURRENT_BINARY_DIR}/tests/interactive.fish ${PEXPECT}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
|
||||
)
|
||||
set_tests_properties(${PEXPECT} PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
||||
set_tests_properties(${PEXPECT} PROPERTIES ENVIRONMENT FISH_FORCE_COLOR=1)
|
||||
add_test_target("${PEXPECT}")
|
||||
endforeach(PEXPECT)
|
||||
add_custom_target(${TESTTYPE}_interactive
|
||||
COMMAND cd tests &&
|
||||
env XDG_DATA_DIRS=
|
||||
XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_data
|
||||
XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_config
|
||||
XDG_RUNTIME_DIR=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_runtime
|
||||
${TEST_ROOT_DIR}/bin/fish interactive.fish
|
||||
DEPENDS test_prep
|
||||
USES_TERMINAL)
|
||||
endforeach(TESTTYPE)
|
||||
|
||||
# Rust stuff.
|
||||
if(DEFINED ASAN)
|
||||
# Rust w/ -Zsanitizer=address requires explicitly specifying the --target triple or else linker
|
||||
# errors pertaining to asan symbols will ensue.
|
||||
if(NOT DEFINED Rust_CARGO_TARGET)
|
||||
message(FATAL_ERROR "ASAN requires defining the CMake variable Rust_CARGO_TARGET to the
|
||||
intended target triple")
|
||||
endif()
|
||||
set(cargo_target_opt "--target" ${Rust_CARGO_TARGET})
|
||||
# Now add a dependency chain between the serial versions.
|
||||
# This ensures they run in order.
|
||||
add_dependencies(serial_test_low_level test_prep)
|
||||
add_dependencies(serial_test_fishscript serial_test_low_level)
|
||||
add_dependencies(serial_test_interactive serial_test_fishscript)
|
||||
|
||||
|
||||
add_custom_target(serial_test_high_level
|
||||
DEPENDS serial_test_interactive serial_test_fishscript)
|
||||
|
||||
# Create the 'test' target.
|
||||
# Set a policy so CMake stops complaining about the name 'test'.
|
||||
cmake_policy(PUSH)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.11.0 AND POLICY CMP0037)
|
||||
cmake_policy(SET CMP0037 OLD)
|
||||
endif()
|
||||
add_custom_target(test)
|
||||
cmake_policy(POP)
|
||||
add_dependencies(test serial_test_high_level)
|
||||
|
||||
# cargo-test is failing to link w/ ASAN enabled. For some reason it is picking up autocxx ffi
|
||||
# dependencies, even though `carg test` is supposed to be for rust-only code w/ no ffi dependencies.
|
||||
# TODO: Figure this out and fix it.
|
||||
if(NOT DEFINED ASAN)
|
||||
add_test(
|
||||
NAME "cargo-test"
|
||||
COMMAND cargo test ${CARGO_FLAGS} --target-dir target ${cargo_target_opt}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/fish-rust"
|
||||
)
|
||||
set_tests_properties("cargo-test" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
||||
add_test_target("cargo-test")
|
||||
endif()
|
||||
|
||||
add_test(
|
||||
NAME "cargo-test-widestring"
|
||||
COMMAND cargo test ${CARGO_FLAGS} --target-dir target ${cargo_target_opt}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/fish-rust/widestring-suffix/"
|
||||
)
|
||||
add_test_target("cargo-test-widestring")
|
||||
# Group test targets into a TestTargets folder
|
||||
set_property(TARGET test tests_dir
|
||||
test_low_level
|
||||
test_fishscript
|
||||
test_interactive
|
||||
test_fishscript test_prep
|
||||
tests_buildroot_target
|
||||
serial_test_high_level
|
||||
serial_test_low_level
|
||||
serial_test_fishscript
|
||||
serial_test_interactive
|
||||
symlink_functions
|
||||
PROPERTY FOLDER cmake/TestTargets)
|
||||
|
|
|
|||
|
|
@ -1,25 +1,15 @@
|
|||
set(languages de en fr pl pt_BR sv zh_CN)
|
||||
set(languages de en fr nb nn pl pt_BR sv zh_CN)
|
||||
|
||||
include(FeatureSummary)
|
||||
|
||||
option(WITH_GETTEXT "translate messages if gettext is available" ON)
|
||||
if(WITH_GETTEXT)
|
||||
if(APPLE)
|
||||
# Fix for https://github.com/fish-shell/fish-shell/issues/5244
|
||||
# via https://gitlab.kitware.com/cmake/cmake/-/issues/18921
|
||||
set(CMAKE_FIND_FRAMEWORK_OLD ${CMAKE_FIND_FRAMEWORK})
|
||||
set(CMAKE_FIND_FRAMEWORK NEVER)
|
||||
endif()
|
||||
find_package(Intl QUIET)
|
||||
find_package(Gettext)
|
||||
if(GETTEXT_FOUND)
|
||||
set(HAVE_GETTEXT 1)
|
||||
include_directories(${Intl_INCLUDE_DIR})
|
||||
endif()
|
||||
if(APPLE)
|
||||
set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_OLD})
|
||||
unset(CMAKE_FIND_FRAMEWORK_OLD)
|
||||
endif()
|
||||
endif()
|
||||
add_feature_info(gettext GETTEXT_FOUND "translate messages with gettext")
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
/* Define to 1 if compiled on WSL */
|
||||
#cmakedefine WSL 1
|
||||
|
||||
/* Define to 1 if you have the `clock_gettime' function. */
|
||||
#cmakedefine HAVE_CLOCK_GETTIME 1
|
||||
|
||||
/* Define to 1 if you have the `ctermid_r' function. */
|
||||
#cmakedefine HAVE_CTERMID_R 1
|
||||
|
||||
|
|
@ -19,6 +22,15 @@
|
|||
/* Define to 1 if you have the `flock' function. */
|
||||
#cmakedefine HAVE_FLOCK 1
|
||||
|
||||
/* Define to 1 if you have the `futimens' function. */
|
||||
#cmakedefine HAVE_FUTIMENS 1
|
||||
|
||||
/* Define to 1 if you have the `futimes' function. */
|
||||
#cmakedefine HAVE_FUTIMES 1
|
||||
|
||||
/* Define to 1 if you have the `getifaddrs' function. */
|
||||
#cmakedefine HAVE_GETIFADDRS 1
|
||||
|
||||
/* Define to 1 if you have the `getpwent' function. */
|
||||
#cmakedefine HAVE_GETPWENT 1
|
||||
|
||||
|
|
@ -61,6 +73,9 @@
|
|||
/* Define to 1 if you have the `std::wcscasecmp' function. */
|
||||
#cmakedefine HAVE_STD__WCSCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `std::wcsdup' function. */
|
||||
#cmakedefine HAVE_STD__WCSDUP 1
|
||||
|
||||
/* Define to 1 if you have the `std::wcsncasecmp' function. */
|
||||
#cmakedefine HAVE_STD__WCSNCASECMP 1
|
||||
|
||||
|
|
@ -76,6 +91,9 @@
|
|||
/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */
|
||||
#cmakedefine HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
|
||||
|
||||
/* Define to 1 if the sys_errlist array is available. */
|
||||
#cmakedefine HAVE_SYS_ERRLIST 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#cmakedefine HAVE_SYS_IOCTL_H 1
|
||||
|
||||
|
|
@ -85,21 +103,30 @@
|
|||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#cmakedefine HAVE_SYS_SYSCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#cmakedefine HAVE_TERMIOS_H 1
|
||||
|
||||
/* Define to 1 if you have the <term.h> header file. */
|
||||
#cmakedefine HAVE_TERM_H 1
|
||||
|
||||
/* Define to 1 if you have the `wcscasecmp' function. */
|
||||
#cmakedefine HAVE_WCSCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `wcsdup' function. */
|
||||
#cmakedefine HAVE_WCSDUP 1
|
||||
|
||||
/* Define to 1 if you have the `wcslcpy' function. */
|
||||
#cmakedefine HAVE_WCSLCPY 1
|
||||
|
||||
/* Define to 1 if you have the `wcsncasecmp' function. */
|
||||
#cmakedefine HAVE_WCSNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `wcsndup' function. */
|
||||
#cmakedefine HAVE_WCSNDUP 1
|
||||
|
||||
/* Define to 1 if you have the `wcstod_l' function. */
|
||||
#cmakedefine HAVE_WCSTOD_L 1
|
||||
|
||||
/* Define to 1 if the status that wait returns and WEXITSTATUS expects is signal and then ret instead of the other way around. */
|
||||
#cmakedefine HAVE_WAITSTATUS_SIGNAL_RET 1
|
||||
|
||||
/* Define to 1 if the winsize struct and TIOCGWINSZ macro exist */
|
||||
#cmakedefine HAVE_WINSIZE 1
|
||||
|
||||
|
|
@ -109,8 +136,8 @@
|
|||
/* Define to 1 if std::make_unique is available. */
|
||||
#cmakedefine HAVE_STD__MAKE_UNIQUE 1
|
||||
|
||||
/* Define to use clock_gettime and futimens to hack around Linux mtime issue */
|
||||
#cmakedefine UVAR_FILE_SET_MTIME_HACK 1
|
||||
/* Define to 1 if the _sys_errs array is available. */
|
||||
#cmakedefine HAVE__SYS__ERRS 1
|
||||
|
||||
/* Define to 1 to disable ncurses macros that conflict with the STL */
|
||||
#define NCURSES_NOMACROS 1
|
||||
|
|
@ -127,9 +154,6 @@
|
|||
/* Use a variadic tparm on NetBSD curses. */
|
||||
#cmakedefine TPARM_VARARGS 1
|
||||
|
||||
/* The parameter type for the last tputs parameter */
|
||||
#cmakedefine TPUTS_USES_INT_ARG 1
|
||||
|
||||
/* Define to 1 if tparm accepts a fixed amount of parameters. */
|
||||
#cmakedefine TPARM_SOLARIS_KLUDGE 1
|
||||
|
||||
|
|
@ -144,9 +168,6 @@
|
|||
/* Define if xlocale.h is required for locale_t or wide character support */
|
||||
#cmakedefine HAVE_XLOCALE_H 1
|
||||
|
||||
/* Define if uselocale is available */
|
||||
#cmakedefine HAVE_USELOCALE 1
|
||||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
10
|
||||
9
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ Section: shells
|
|||
Priority: optional
|
||||
Maintainer: ridiculous_fish <corydoras@ridiculousfish.com>
|
||||
Uploaders: David Adam <zanchey@ucc.gu.uwa.edu.au>
|
||||
# Debhelper should be bumped to >= 10 once Ubuntu Xenial is no longer supported
|
||||
Build-Depends: debhelper (>= 9.20160115), libncurses5-dev, cmake (>= 3.5.0), gettext, libpcre2-dev,
|
||||
Build-Depends: debhelper (>= 9.20151004), libncurses5-dev, cmake (>= 3.2.0), gettext,
|
||||
# Test dependencies
|
||||
locales-all, python3, rustc (>= 1.67) | rustc-mozilla (>= 1.67)
|
||||
locales-all, python3
|
||||
# When libpcre2-dev is available on all supported Debian versions, add a dependency on that.
|
||||
Standards-Version: 4.1.5
|
||||
Homepage: https://fishshell.com/
|
||||
Vcs-Git: https://github.com/fish-shell/fish-shell.git
|
||||
|
|
@ -14,12 +14,34 @@ Vcs-Browser: https://github.com/fish-shell/fish-shell
|
|||
|
||||
Package: fish
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, passwd (>= 4.0.3-10), gettext-base, man-db,
|
||||
procps, python3 (>=3.5)
|
||||
Conflicts: fish-common
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, fish-common (= ${source:Version}), passwd (>= 4.0.3-10), gettext-base, man-db
|
||||
Recommends: xsel (>=1.2.0)
|
||||
Suggests: xdg-utils
|
||||
Description: friendly interactive shell
|
||||
Fish is a command-line shell for modern systems, focusing on user-friendliness,
|
||||
sensibility and discoverability in interactive use. The syntax is simple, but
|
||||
not POSIX compliant.
|
||||
|
||||
Package: fish-common
|
||||
Architecture: all
|
||||
Multi-Arch: foreign
|
||||
Depends: ${misc:Depends}
|
||||
Recommends: fish, python3 (>= 3.5)
|
||||
Suggests: xdg-utils
|
||||
Replaces: fish (<= 2.1.1.dfsg-2)
|
||||
Description: friendly interactive shell (architecture-independent files)
|
||||
Fish is a command-line shell for modern systems, focusing on user-friendliness,
|
||||
sensibility and discoverability in interactive use. The syntax is simple, but
|
||||
not POSIX compliant.
|
||||
.
|
||||
This package contains the common fish files shared by all architectures.
|
||||
|
||||
Package: fish-dbg
|
||||
Architecture: any
|
||||
Section: debug
|
||||
Depends: fish (= ${binary:Version}), ${misc:Depends}
|
||||
Description: debugging symbols for friendly interactive shell
|
||||
Fish is a command-line shell for modern systems, focusing on user-friendliness,
|
||||
sensibility and discoverability in interactive use. The syntax is simple, but
|
||||
not POSIX compliant.
|
||||
.
|
||||
This package contains the debugging symbols for fish.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
debian/tmp/etc
|
||||
debian/tmp/usr/share
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# These directories are intentionally empty.
|
||||
fish-common: package-contains-empty-directory usr/share/fish/vendor_completions.d/
|
||||
fish-common: package-contains-empty-directory usr/share/fish/vendor_conf.d/
|
||||
fish-common: package-contains-empty-directory usr/share/fish/vendor_functions.d/
|
||||
|
|
@ -0,0 +1 @@
|
|||
debian/tmp/usr/bin
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/sh
|
||||
# postrm script for fish
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
# summary of how this script can be called:
|
||||
# * <postrm> `remove'
|
||||
# * <postrm> `purge'
|
||||
# * <old-postrm> `upgrade' <new-version>
|
||||
# * <new-postrm> `failed-upgrade' <old-version>
|
||||
# * <new-postrm> `abort-install'
|
||||
# * <new-postrm> `abort-install' <old-version>
|
||||
# * <new-postrm> `abort-upgrade' <old-version>
|
||||
# * <disappearer's-postrm> `disappear' <overwriter>
|
||||
# <overwriter-version>
|
||||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
|
||||
case "$1" in
|
||||
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postrm called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
# These directories are intentionally empty.
|
||||
fish: package-contains-empty-directory usr/share/fish/vendor_completions.d/
|
||||
fish: package-contains-empty-directory usr/share/fish/vendor_conf.d/
|
||||
fish: package-contains-empty-directory usr/share/fish/vendor_functions.d/
|
||||
|
|
@ -9,9 +9,12 @@ export DH_VERBOSE=1
|
|||
|
||||
# Setting the build system is still required, because otherwise the GNUmakefile gets picked up
|
||||
override_dh_auto_configure:
|
||||
dh_auto_configure --buildsystem=cmake
|
||||
dh_auto_configure --buildsystem=cmake --parallel
|
||||
|
||||
# On CMake 3.5 (and possibly 3.6), the test target does not pick up its dependencies properly
|
||||
# Build fish_tests/tests_buildroot_target by hand (remove this once Ubuntu Xenial is out of support)
|
||||
override_dh_auto_build:
|
||||
dh_auto_build -- all fish_tests tests_buildroot_target
|
||||
override_dh_installdocs:
|
||||
dh_installdocs --link-doc=fish
|
||||
|
||||
# Still needed until all platforms have debhelper 9.20151219
|
||||
# Consider transitioning https://wiki.debian.org/DebugPackage
|
||||
override_dh_strip:
|
||||
dh_strip --dbg-package=fish-dbg
|
||||
|
|
|
|||
|
|
@ -1,79 +0,0 @@
|
|||
These is a proposed port of fish-shell from C++ to Rust, and from CMake to cargo or related. This document is high level - see the [Development Guide] for more details.
|
||||
|
||||
## Why Port
|
||||
|
||||
- Gain access to more contributors and enable easier contributions. C++ is becoming a legacy language.
|
||||
- Free us from the annoyances of C++/CMake, and old toolchains.
|
||||
- Ensure fish continues to be perceived as modern and relevant.
|
||||
- Unlock concurrent mode (see below).
|
||||
|
||||
## Why Rust
|
||||
|
||||
- Rust is a systems programming language with broad platform support, a large community, and a relatively high probability of still being relevant in a decade.
|
||||
- Rust has a unique strength in its thread safety features, which is the missing piece to enable concurrent mode - see below.
|
||||
- Other languages considered:
|
||||
- Java, Python and the scripting family are ruled out for startup latency and memory usage reasons.
|
||||
- Go would be an awkward fit. fork is [quite the problem](https://stackoverflow.com/questions/28370646/how-do-i-fork-a-go-process/28371586#28371586) in Go.
|
||||
- Other system languages (D, Nim, Zig...) are too niche: fewer contributors, higher risk of the language becoming irrelevant.
|
||||
|
||||
## Risks
|
||||
|
||||
- Large amount of work with possible introduction of new bugs.
|
||||
- Long period of complicated builds.
|
||||
- Existing contributors will have to learn Rust.
|
||||
- As of yet unknown compatibility story for Tier 2+ platforms (Cygwin, etc).
|
||||
|
||||
## Approach
|
||||
|
||||
We will do an **incremental port** in the span of one release. We will have a period of using both C++ and Rust, and both cargo and CMake, leveraging FFI tools (see below).
|
||||
|
||||
The work will **proceed on master**: no long-lived branches. Tests and CI continue to pass at every commit for recent Linux and Mac. Centos7, \*BSD, etc may be temporarily disabled if they prove problematic.
|
||||
|
||||
The Rust code will initially resemble the replaced C++. Fidelity to existing code is more important than Rust idiomaticity, to aid review and bisecting. But don't take this to extremes - use judgement.
|
||||
|
||||
The port will proceed "outside in." We'll start with leaf components (e.g. builtins) and proceed towards the core. Some components will have both a Rust and C++ implementation (e.g. FLOG), in other cases we'll change the existing C++ to invoke the new Rust implementations (builtins).
|
||||
|
||||
After porting the C++, we'll replace CMake.
|
||||
|
||||
We will continue to use wide chars, locales, gettext, printf format strings, and PCRE2. We will not change the fish scripting language at all. We will _not_ use this as an opportunity to fix existing design flaws, with a few carefully chosen exceptions. See [Strings](#strings).
|
||||
|
||||
We will not use tokio, serde, async, or other fancy Rust frameworks initially.
|
||||
|
||||
### FFI
|
||||
|
||||
Rust/C++ interop will use [autocxx](https://github.com/google/autocxx), [Cxx](https://cxx.rs), and possibly [bindgen](https://rust-lang.github.io/rust-bindgen/). I've forked these for fish (see the [Development Guide]). Once the port is done, we will stop using them, except perhaps bindgen for PCRE2.
|
||||
|
||||
We will use [corrosion](https://github.com/corrosion-rs/corrosion) for CMake integration.
|
||||
|
||||
Inefficiencies (e.g. extra string copying) at the FFI layer are fine, since it will all get thrown away.
|
||||
|
||||
Tests can stay in fish_tests.cpp or be moved into Rust .rs files; either is fine.
|
||||
|
||||
### Strings
|
||||
|
||||
Rust's `String` / `&str` types cannot represent non-UTF8 filenames or data using the default encoding scheme. That's why all string conversions must go through fish's encoding scheme (using the private-use area to encode invalid sequences). For example, fish cannot use `File::open` with a `&str` because the decoding will be incorrect.
|
||||
|
||||
So instead of `String`, fish will use its own string type, and manage encoding and decoding as it does today. However we will make some specific changes:
|
||||
|
||||
1. Drop the nul-terminated requirement. When passing `const wchar_t*` back to C++, we will allocate and copy into a nul-terminated buffer.
|
||||
2. Drop support for 16-bit wchar. fish will use UTF32 on all platforms, and manage conversions itself.
|
||||
|
||||
After the port we can consider moving to UTF-8, for memory usage reasons.
|
||||
|
||||
See the [Rust Development Guide][Development Guide] for more on strings.
|
||||
|
||||
### Thread Safety
|
||||
|
||||
Allowing [background functions](https://github.com/fish-shell/fish-shell/issues/238) and concurrent functions has been a goal for many years. I have been nursing [a long-lived branch](https://github.com/ridiculousfish/fish-shell/tree/concurrent_even_simpler) which allows full threaded execution. But though the changes are small, I have been reluctant to propose them, because they will make reasoning about the shell internals too complex: it is difficult in C++ to check and enforce what crosses thread boundaries.
|
||||
|
||||
This is Rust's bread and butter: we will encode thread requirements into our types, making it explicit and compiler-checked, via Send and Sync. Rust will allow turning on concurrent mode in a safe way, with a manageable increase in complexity, finally enabling this feature.
|
||||
|
||||
## Timeline
|
||||
|
||||
Handwaving, 6 months? Frankly unknown - there's 102 remaining .cpp files of various lengths. It'll go faster as we get better at it. Peter (ridiculous_fish) is motivated to work on this, other current contributors have some Rust as well, and we may also get new contributors from the Rust community. Part of the point is to make contribution easier.
|
||||
|
||||
## Links
|
||||
|
||||
- [Packaging Rust projects](https://wiki.archlinux.org/title/Rust_package_guidelines) from Arch Linux
|
||||
|
||||
[Development Guide]: rust-devel.md
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
# fish-shell Rust Development Guide
|
||||
|
||||
This describes how to get started building fish-shell in its partial Rust state, and how to contribute to the port.
|
||||
|
||||
## Overview
|
||||
|
||||
fish is in the process of transitioning from C++ to Rust. The fish project has a Rust crate embedded at path `fish-rust`. This crate builds a Rust library `libfish_rust.a` which is linked with the C++ `libfish.a`. Existing C++ code will be incrementally migrated to this crate; then CMake will be replaced with cargo and other Rust-native tooling.
|
||||
|
||||
Important tools used during this transition:
|
||||
|
||||
1. [Corrosion](https://github.com/corrosion-rs/corrosion) to invoke cargo from CMake.
|
||||
2. [cxx](http://cxx.rs) for basic C++ <-> Rust interop.
|
||||
3. [autocxx](https://google.github.io/autocxx/) for using C++ types in Rust.
|
||||
|
||||
We use forks of the last two - see the [FFI section](#ffi) below. No special action is required to obtain these packages. They're downloaded by cargo.
|
||||
|
||||
## Building
|
||||
|
||||
### Build Dependencies
|
||||
|
||||
fish-shell currently depends on Rust 1.67 or later. To install Rust, follow https://rustup.rs.
|
||||
|
||||
### Build via CMake
|
||||
|
||||
It is recommended to build inside `fish-shell/build`. This will make it easier for Rust to find the `config.h` file.
|
||||
|
||||
Build via CMake as normal (use any generator, here we use Ninja):
|
||||
|
||||
```shell
|
||||
$ cd fish-shell
|
||||
$ mkdir build && cd build
|
||||
$ cmake -G Ninja ..
|
||||
$ ninja
|
||||
```
|
||||
|
||||
This will create the usual fish executables.
|
||||
|
||||
### Build just libfish_rust.a with Cargo
|
||||
|
||||
The directory `fish-rust` contains the Rust sources. These require that CMake has been run to produce `config.h` which is necessary for autocxx to succeed.
|
||||
|
||||
Follow the "Build from CMake" steps above, and then:
|
||||
|
||||
```shell
|
||||
$ cd fish-shell/fish-rust
|
||||
$ cargo build
|
||||
```
|
||||
|
||||
This will build only the library, not a full working fish, but it allows faster iteration for Rust development. That is, after running `cmake` you can open the `fish-rust` as the root of a Rust crate, and tools like rust-analyzer will work.
|
||||
|
||||
## Development
|
||||
|
||||
The basic development loop for this port:
|
||||
|
||||
1. Pick a .cpp (or in some cases .h) file to port, say `util.cpp`.
|
||||
2. Add the corresponding `util.rs` file to `fish-rust/`.
|
||||
3. Reimplement it in Rust, along with its dependencies as needed. Match the existing C++ code where practical, including propagating any relevant comments.
|
||||
- Do this even if it results in less idiomatic Rust, but avoid being super-dogmatic either way.
|
||||
- One technique is to paste the C++ into the Rust code, commented out, and go line by line.
|
||||
4. Decide whether any existing C++ callers should invoke the Rust implementation, or whether we should keep the C++ one.
|
||||
- Utility functions may have both a Rust and C++ implementation. An example is `FLOG` where interop is too hard.
|
||||
- Major components (e.g. builtin implementations) should _not_ be duplicated; instead the Rust should call C++ or vice-versa.
|
||||
5. Remember to run `cargo fmt` and `cargo clippy` to keep the codebase somewhat clean (otherwise CI will fail). If you use rust-analyzer, you can run clippy automatically by setting `rust-analyzer.checkOnSave.command = "clippy"`.
|
||||
|
||||
You will likely run into limitations of [`autocxx`](https://google.github.io/autocxx/) and to a lesser extent [`cxx`](https://cxx.rs/). See the [FFI sections](#ffi) below.
|
||||
|
||||
## Type Mapping
|
||||
|
||||
### Constants & Type Aliases
|
||||
|
||||
The FFI does not support constants (`#define` or `static const`) or type aliases (`typedef`, `using`). Duplicate them using their Rust equivalent (`pub const` and `type`/`struct`/`enum`).
|
||||
|
||||
### Non-POD types
|
||||
|
||||
Many types cannot currently be passed across the language boundary by value or occur in shared structs. As a workaround, use references, raw pointers or smart pointers (`cxx` provides `SharedPtr` and `UniquePtr`). Try to keep workarounds on the C++ side and the FFI layer of the Rust code. This ensures we will get rid of the workarounds as we peel off the FFI layer.
|
||||
|
||||
### Strings
|
||||
|
||||
Fish will mostly _not_ use Rust's `String/&str` types as these cannot represent non-UTF8 data using the default encoding.
|
||||
|
||||
fish's primary string types will come from the [`widestring` crate](https://docs.rs/widestring). The two main string types are `WString` and `&wstr`, which are renamed [Utf32String](https://docs.rs/widestring/latest/widestring/utfstring/struct.Utf32String.html) and [Utf32Str](https://docs.rs/widestring/latest/widestring/utfstr/struct.Utf32Str.html). `WString` is an owned, heap-allocated UTF32 string, `&wstr` a borrowed UTF32 slice.
|
||||
|
||||
In general, follow this mapping when porting from C++:
|
||||
|
||||
- `wcstring` -> `WString`
|
||||
- `const wcstring &` -> `&wstr`
|
||||
- `const wchar_t *` -> `&wstr`
|
||||
|
||||
None of the Rust string types are nul-terminated. We're taking this opportunity to drop the nul-terminated aspect of wide string handling.
|
||||
|
||||
#### Creating strings
|
||||
|
||||
One may create a `&wstr` from a string literal using the `wchar::L!` macro:
|
||||
|
||||
```rust
|
||||
use crate::wchar::{wstr, L!}
|
||||
|
||||
fn get_shell_name() -> &'static wstr {
|
||||
L!("fish")
|
||||
}
|
||||
```
|
||||
|
||||
There is also a `widestrs` proc-macro which enables L as a _suffix_, to reduce the noise. This can be applied to any block, including modules and individual functions:
|
||||
|
||||
```rust
|
||||
use crate::wchar::{wstr, widestrs}
|
||||
|
||||
#[widestrs]
|
||||
fn get_shell_name() -> &'static wstr {
|
||||
"fish"L // equivalent to L!("fish")
|
||||
}
|
||||
```
|
||||
|
||||
### Strings for FFI
|
||||
|
||||
`WString` and `&wstr` are the common strings used by Rust components. At the FII boundary there are some additional strings for interop. _All of these are temporary for the duration of the port._
|
||||
|
||||
- `CxxWString` is the Rust binding of `std::wstring`. It is the wide-string analog to [`CxxString`](https://cxx.rs/binding/cxxstring.html) and is [added in our fork of cxx](https://github.com/ridiculousfish/cxx/blob/fish/src/cxx_wstring.rs). This is useful for functions which return e.g. `const wcstring &`.
|
||||
- `W0String` is renamed [U32CString](https://docs.rs/widestring/latest/widestring/ucstring/struct.U32CString.html). This is basically `WString` except it _is_ nul-terminated. This is useful for getting a nul-terminated `const wchar_t *` to pass to C++ implementations.
|
||||
- `wcharz_t` is an annoying C++ struct which merely wraps a `const wchar_t *`, used for passing these pointers from C++ to Rust. We would prefer to use `const wchar_t *` directly but `autocxx` refuses to generate bindings for types such as `std::vector<const wchar_t *>` so we wrap it in this silly struct.
|
||||
|
||||
Note C++ `wchar_t`, Rust `char`, and `u32` are effectively interchangeable: you can cast pointers to them back and forth (except we check upon u32->char conversion). However be aware of which types are nul-terminated.
|
||||
|
||||
These types should be confined to the FFI modules, in particular `wchar_ffi`. They should not "leak" into other modules. See the `wchar_ffi` module.
|
||||
|
||||
### Format strings
|
||||
|
||||
Rust's builtin `std::fmt` modules do not accept runtime-provided format strings, so we mostly won't use them, except perhaps for FLOG / other non-translated text.
|
||||
|
||||
Instead we'll continue to use printf-style strings, with a Rust printf implementation.
|
||||
|
||||
### Vectors
|
||||
|
||||
See [`Vec`](https://cxx.rs/binding/vec.html) and [`CxxVector`](https://cxx.rs/binding/cxxvector.html).
|
||||
|
||||
In many cases, `autocxx` refuses to allow vectors of certain types. For example, autocxx supports `std::vector` and `std::shared_ptr` but NOT `std::vector<std::shared_ptr<...>>`. To work around this one can create a helper (pointer, length) struct. Example:
|
||||
|
||||
```cpp
|
||||
struct RustFFIJobList {
|
||||
std::shared_ptr<job_t> *jobs;
|
||||
size_t count;
|
||||
};
|
||||
```
|
||||
|
||||
This is just a POD (plain old data) so autocxx can generate bindings for it. Then it is trivial to convert it to a Rust slice:
|
||||
|
||||
```
|
||||
pub fn get_jobs(ffi_jobs: &ffi::RustFFIJobList) -> &[SharedPtr<job_t>] {
|
||||
unsafe { slice::from_raw_parts(ffi_jobs.jobs, ffi_jobs.count) }
|
||||
}
|
||||
```
|
||||
|
||||
Another workaround is to define a struct that contains the shared pointer, and create a vector of that struct.
|
||||
|
||||
## Development Tooling
|
||||
|
||||
The [autocxx guidance](https://google.github.io/autocxx/workflow.html#how-can-i-see-what-bindings-autocxx-has-generated) is helpful:
|
||||
|
||||
1. Install cargo expand (`cargo install cargo-expand`). Then you can use `cargo expand` to see the generated Rust bindings for C++. In particular this is useful for seeing failed expansions for C++ types that autocxx cannot handle.
|
||||
2. In rust-analyzer, enable Proc Macro and Proc Macro Attributes.
|
||||
|
||||
## FFI
|
||||
|
||||
The boundary between Rust and C++ is referred to as the Foreign Function Interface, or FFI.
|
||||
|
||||
`autocxx` and `cxx` both are designed for long-term interop: C++ and Rust coexisting for years. To this end, both emphasize safety: requiring lots of `unsafe`, `Pin`, etc.
|
||||
|
||||
fish plans to use them only temporarily, with a focus on getting things working. To this end, both cxx and autocxx have been forked to support fish:
|
||||
|
||||
1. Relax the requirement that all functions taking pointers are `unsafe` (this just added noise).
|
||||
2. Add support for `wchar_t` as a recognized type, and `CxxWString` analogous to `CxxString`.
|
||||
|
||||
See the `Cargo.toml` file for the locations of the forks.
|
||||
|
|
@ -6,9 +6,9 @@ _ - call fish's translations
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
_ STRING
|
||||
_ STRING...
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -19,17 +19,19 @@ It is equivalent to ``gettext fish STRING``, meaning it can only be used to look
|
|||
|
||||
It requires fish to be built with gettext support. If that support is disabled, or there is no translation it will simply echo the argument back.
|
||||
|
||||
The language depends on the current locale, set with :envvar:`LANG` and :envvar:`LC_MESSAGES`.
|
||||
The language depends on the current locale, set with ``$LANG`` and ``$LC_MESSAGES``.
|
||||
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
``_`` takes no options.
|
||||
``_`` has no options.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
> _ File
|
||||
|
|
|
|||
|
|
@ -6,152 +6,105 @@ abbr - manage fish abbreviations
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
abbr --add NAME [--position command | anywhere] [-r | --regex PATTERN]
|
||||
[--set-cursor[=MARKER]] ([-f | --function FUNCTION] | EXPANSION)
|
||||
abbr --erase NAME ...
|
||||
abbr --rename OLD_WORD NEW_WORD
|
||||
abbr --add [SCOPE] WORD EXPANSION
|
||||
abbr --erase WORD...
|
||||
abbr --rename [SCOPE] OLD_WORD NEW_WORD
|
||||
abbr --show
|
||||
abbr --list
|
||||
abbr --query NAME ...
|
||||
abbr --query WORD...
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``abbr`` manages abbreviations - user-defined words that are replaced with longer phrases when entered.
|
||||
``abbr`` manages abbreviations - user-defined words that are replaced with longer phrases after they are entered.
|
||||
|
||||
.. note::
|
||||
Only typed-in commands use abbreviations. Abbreviations are not expanded in scripts.
|
||||
For example, a frequently-run command like ``git checkout`` can be abbreviated to ``gco``. After entering ``gco`` and pressing :kbd:`Space` or :kbd:`Enter`, the full text ``git checkout`` will appear in the command line.
|
||||
|
||||
For example, a frequently-run command like ``git checkout`` can be abbreviated to ``gco``.
|
||||
After entering ``gco`` and pressing :kbd:`Space` or :kbd:`Enter`, the full text ``git checkout`` will appear in the command line.
|
||||
To avoid expanding something that looks like an abbreviation, the default :kbd:`Control`\ +\ :kbd:`Space` binding inserts a space without expanding.
|
||||
Options
|
||||
-------
|
||||
|
||||
An abbreviation may match a literal word, or it may match a pattern given by a regular expression. When an abbreviation matches a word, that word is replaced by new text, called its *expansion*. This expansion may be a fixed new phrase, or it can be dynamically created via a fish function. This expansion occurs after pressing space or enter.
|
||||
The following options are available:
|
||||
|
||||
Combining these features, it is possible to create custom syntaxes, where a regular expression recognizes matching tokens, and the expansion function interprets them. See the `Examples`_ section.
|
||||
- ``-a WORD EXPANSION`` or ``--add WORD EXPANSION`` Adds a new abbreviation, causing WORD to be expanded to EXPANSION.
|
||||
|
||||
.. versionchanged:: 3.6.0
|
||||
Previous versions of this allowed saving abbreviations in universal variables.
|
||||
That's no longer possible. Existing variables will still be imported and ``abbr --erase`` will also erase the variables.
|
||||
We recommend adding abbreviations to :ref:`config.fish <configuration>` by just adding the ``abbr --add`` command.
|
||||
When you run ``abbr``, you will see output like this
|
||||
- ``-r OLD_WORD NEW_WORD`` or ``--rename OLD_WORD NEW_WORD`` Renames an abbreviation, from OLD_WORD to NEW_WORD.
|
||||
|
||||
::
|
||||
- ``-s`` or ``--show`` Show all abbreviations in a manner suitable for export and import.
|
||||
|
||||
> abbr
|
||||
abbr -a -- foo bar # imported from a universal variable, see `help abbr`
|
||||
- ``-l`` or ``--list`` Lists all abbreviated words.
|
||||
|
||||
In that case you should take the part before the ``#`` comment and save it in :ref:`config.fish <configuration>`,
|
||||
then you can run ``abbr --erase`` to remove the universal variable::
|
||||
- ``-e WORD`` or ``--erase WORD...`` Erase the given abbreviations.
|
||||
|
||||
> abbr >> ~/.config/fish/config.fish
|
||||
> abbr --erase (abbr --list)
|
||||
|
||||
- ``-q`` or ``--query`` Return 0 (true) if one of the WORDs is an abbreviation.
|
||||
|
||||
"add" subcommand
|
||||
--------------------
|
||||
In addition, when adding or renaming abbreviations:
|
||||
|
||||
.. synopsis::
|
||||
|
||||
abbr [-a | --add] NAME [--position command | anywhere] [-r | --regex PATTERN]
|
||||
[--set-cursor[=MARKER]] ([-f | --function FUNCTION] | EXPANSION)
|
||||
|
||||
``abbr --add`` creates a new abbreviation. With no other options, the string **NAME** is replaced by **EXPANSION**.
|
||||
|
||||
With **--position command**, the abbreviation will only expand when it is positioned as a command, not as an argument to another command. With **--position anywhere** the abbreviation may expand anywhere in the command line. The default is **command**.
|
||||
|
||||
With **--regex**, the abbreviation matches using the regular expression given by **PATTERN**, instead of the literal **NAME**. The pattern is interpreted using PCRE2 syntax and must match the entire token. If multiple abbreviations match the same token, the last abbreviation added is used.
|
||||
|
||||
With **--set-cursor=MARKER**, the cursor is moved to the first occurrence of **MARKER** in the expansion. The **MARKER** value is erased. The **MARKER** may be omitted (i.e. simply ``--set-cursor``), in which case it defaults to ``%``.
|
||||
|
||||
With **-f FUNCTION** or **--function FUNCTION**, **FUNCTION** is treated as the name of a fish function instead of a literal replacement. When the abbreviation matches, the function will be called with the matching token as an argument. If the function's exit status is 0 (success), the token will be replaced by the function's output; otherwise the token will be left unchanged. No **EXPANSION** may be given separately.
|
||||
- ``-g`` or ``--global`` to use a global variable.
|
||||
- ``-U`` or ``--universal`` to use a universal variable (default).
|
||||
|
||||
See the "Internals" section for more on them.
|
||||
|
||||
Examples
|
||||
########
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
abbr --add gco git checkout
|
||||
|
||||
Add a new abbreviation where ``gco`` will be replaced with ``git checkout``.
|
||||
|
||||
::
|
||||
|
||||
abbr -a --position anywhere -- -C --color
|
||||
|
||||
Add a new abbreviation where ``-C`` will be replaced with ``--color``. The ``--`` allows ``-C`` to be treated as the name of the abbreviation, instead of an option.
|
||||
|
||||
::
|
||||
|
||||
abbr -a L --position anywhere --set-cursor "% | less"
|
||||
|
||||
Add a new abbreviation where ``L`` will be replaced with ``| less``, placing the cursor before the pipe.
|
||||
|
||||
|
||||
::
|
||||
|
||||
function last_history_item
|
||||
echo $history[1]
|
||||
abbr -a -g gco git checkout
|
||||
|
||||
Add a new abbreviation where ``gco`` will be replaced with ``git checkout`` global to the current shell. This abbreviation will not be automatically visible to other shells unless the same command is run in those shells (such as when executing the commands in config.fish).
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
abbr -a -U l less
|
||||
|
||||
Add a new abbreviation where ``l`` will be replaced with ``less`` universal so all shells. Note that you omit the ``-U`` since it is the default.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
abbr -r gco gch
|
||||
|
||||
Renames an existing abbreviation from ``gco`` to ``gch``.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
abbr -e gco
|
||||
|
||||
Erase the ``gco`` abbreviation.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
ssh another_host abbr -s | source
|
||||
|
||||
Import the abbreviations defined on another_host over SSH.
|
||||
|
||||
Internals
|
||||
---------
|
||||
Each abbreviation is stored in its own global or universal variable. The name consists of the prefix ``_fish_abbr_`` followed by the WORD after being transformed by ``string escape style=var``. The WORD cannot contain a space but all other characters are legal.
|
||||
|
||||
Defining an abbreviation with global scope is slightly faster than universal scope (which is the default). But in general you'll only want to use the global scope when defining abbreviations in a startup script like ``~/.config/fish/config.fish`` like this:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
if status --is-interactive
|
||||
abbr --add --global first 'echo my first abbreviation'
|
||||
abbr --add --global second 'echo my second abbreviation'
|
||||
abbr --add --global gco git checkout
|
||||
# etcetera
|
||||
end
|
||||
abbr -a !! --position anywhere --function last_history_item
|
||||
|
||||
This first creates a function ``last_history_item`` which outputs the last entered command. It then adds an abbreviation which replaces ``!!`` with the result of calling this function. Taken together, this is similar to the ``!!`` history expansion feature of bash.
|
||||
|
||||
::
|
||||
|
||||
function vim_edit
|
||||
echo vim $argv
|
||||
end
|
||||
abbr -a vim_edit_texts --position command --regex ".+\.txt" --function vim_edit
|
||||
|
||||
This first creates a function ``vim_edit`` which prepends ``vim`` before its argument. It then adds an abbreviation which matches commands ending in ``.txt``, and replaces the command with the result of calling this function. This allows text files to be "executed" as a command to open them in vim, similar to the "suffix alias" feature in zsh.
|
||||
|
||||
::
|
||||
|
||||
abbr 4DIRS --set-cursor=! "$(string join \n -- 'for dir in */' 'cd $dir' '!' 'cd ..' 'end')"
|
||||
|
||||
This creates an abbreviation "4DIRS" which expands to a multi-line loop "template." The template enters each directory and then leaves it. The cursor is positioned ready to enter the command to run in each directory, at the location of the ``!``, which is itself erased.
|
||||
|
||||
Other subcommands
|
||||
--------------------
|
||||
|
||||
|
||||
::
|
||||
|
||||
abbr --rename OLD_NAME NEW_NAME
|
||||
|
||||
Renames an abbreviation, from *OLD_NAME* to *NEW_NAME*
|
||||
|
||||
::
|
||||
|
||||
abbr [-s | --show]
|
||||
|
||||
Show all abbreviations in a manner suitable for import and export
|
||||
|
||||
::
|
||||
|
||||
abbr [-l | --list]
|
||||
|
||||
Prints the names of all abbreviation
|
||||
|
||||
::
|
||||
|
||||
abbr [-e | --erase] NAME
|
||||
|
||||
Erases the abbreviation with the given name
|
||||
|
||||
::
|
||||
|
||||
abbr -q or --query [NAME...]
|
||||
|
||||
Return 0 (true) if one of the *NAME* is an abbreviation.
|
||||
|
||||
::
|
||||
|
||||
abbr -h or --help
|
||||
|
||||
Displays help for the `abbr` command.
|
||||
|
||||
You can create abbreviations interactively and they will be visible to other fish sessions if you use the ``-U`` or ``--universal`` flag or don't explicitly specify the scope and the abbreviation isn't already defined with global scope. If you want it to be visible only to the current shell use the ``-g`` or ``--global`` flag.
|
||||
|
|
|
|||
|
|
@ -6,40 +6,38 @@ alias - create a function
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
alias
|
||||
alias [--save] NAME DEFINITION
|
||||
alias [--save] NAME=DEFINITION
|
||||
alias [OPTIONS] NAME DEFINITION
|
||||
alias [OPTIONS] NAME=DEFINITION
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``alias`` is a simple wrapper for the ``function`` builtin, which creates a function wrapping a command. It has similar syntax to POSIX shell ``alias``. For other uses, it is recommended to define a :doc:`function <function>`.
|
||||
|
||||
If you want to ease your interactive use, to save typing, consider using an :doc:`abbreviation <abbr>` instead.
|
||||
``alias`` is a simple wrapper for the ``function`` builtin, which creates a function wrapping a command. It has similar syntax to POSIX shell ``alias``. For other uses, it is recommended to define a :ref:`function <cmd-function>`.
|
||||
|
||||
``fish`` marks functions that have been created by ``alias`` by including the command used to create them in the function description. You can list ``alias``-created functions by running ``alias`` without arguments. They must be erased using ``functions -e``.
|
||||
|
||||
- ``NAME`` is the name of the alias
|
||||
- ``DEFINITION`` is the actual command to execute. ``alias`` automatically appends ``$argv``, so that all parameters used with the alias are passed to the actual command.
|
||||
- ``DEFINITION`` is the actual command to execute. The string ``$argv`` will be appended.
|
||||
|
||||
You cannot create an alias to a function with the same name. Note that spaces need to be escaped in the call to ``alias`` just like at the command line, *even inside quoted parts*.
|
||||
|
||||
The following options are available:
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
- ``-h`` or ``--help`` displays help about using this command.
|
||||
|
||||
**-s** or **--save**
|
||||
Saves the function created by the alias into your fish configuration directory using :doc:`funcsave <funcsave>`.
|
||||
- ``-s`` or ``--save`` Automatically save the function created by the alias into your fish configuration directory using :ref:`funcsave <cmd-funcsave>`.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
The following code will create ``rmi``, which runs ``rm`` with additional arguments on every invocation.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
alias rmi="rm -i"
|
||||
|
|
@ -57,6 +55,6 @@ The following code will create ``rmi``, which runs ``rm`` with additional argume
|
|||
See more
|
||||
--------
|
||||
|
||||
1. The :doc:`function <function>` command this builds on.
|
||||
1. The :ref:`function <cmd-function>` builtin this builds on.
|
||||
2. :ref:`Functions <syntax-function>`.
|
||||
3. :ref:`Defining aliases <syntax-aliases>`.
|
||||
3. :ref:`Function wrappers <syntax-function-wrappers>`.
|
||||
|
|
|
|||
|
|
@ -6,21 +6,19 @@ and - conditionally execute a command
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
PREVIOUS; and COMMAND
|
||||
COMMAND1; and COMMAND2
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``and`` is used to execute a command if the previous command was successful (returned a status of 0).
|
||||
|
||||
``and`` statements may be used as part of the condition in an :doc:`while <while>` or :doc:`if <if>` block.
|
||||
``and`` statements may be used as part of the condition in an :ref:`while <cmd-while>` or :ref:`if <cmd-if>` block.
|
||||
|
||||
``and`` does not change the current exit status itself, but the command it runs most likely will. The exit status of the last foreground command to exit can always be accessed using the :ref:`$status <variables-status>` variable.
|
||||
|
||||
The **-h** or **--help** option displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
|
@ -33,5 +31,4 @@ The following code runs the ``make`` command to build a program. If the build su
|
|||
See Also
|
||||
--------
|
||||
|
||||
- :doc:`or <or>` command
|
||||
- :doc:`not <not>` command
|
||||
- :ref:`or <cmd-or>` command
|
||||
|
|
|
|||
|
|
@ -6,69 +6,63 @@ argparse - parse options passed to a fish script or function
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
argparse [OPTIONS] OPTION_SPEC ... -- [ARG ...]
|
||||
argparse [OPTIONS] OPTION_SPEC... -- [ARG...]
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
This command makes it easy for fish scripts and functions to handle arguments. You pass arguments that define the known options, followed by a literal **--**, then the arguments to be parsed (which might also include a literal **--**). ``argparse`` then sets variables to indicate the passed options with their values, and sets ``$argv`` to the remaining arguments. See the :ref:`usage <cmd-argparse-usage>` section below.
|
||||
This command makes it easy for fish scripts and functions to handle arguments like how fish builtin commands handle their arguments. You pass arguments that define the known options, followed by a literal ``--``, then the arguments to be parsed (which might also include a literal ``--``). ``argparse`` then sets variables to indicate the passed options with their values, and sets $argv (and always $argv) to the remaining arguments. More on this in the :ref:`usage <cmd-argparse-usage>` section below.
|
||||
|
||||
Each option specification (``OPTION_SPEC``) is written in the :ref:`domain specific language <cmd-argparse-option-specification>` described below. All OPTION_SPECs must appear after any argparse flags and before the ``--`` that separates them from the arguments to be parsed.
|
||||
|
||||
Each option that is seen in the ARG list will result in variables named ``_flag_X``, where **X** is the short flag letter and the long flag name (if they are defined). For example a **--help** option could cause argparse to define one variable called ``_flag_h`` and another called ``_flag_help``.
|
||||
Each option that is seen in the ARG list will result in variables named ``_flag_X``, where ``X`` is the short flag letter and the long flag name (if they are defined). For example a ``--help`` option could cause argparse to define one variable called ``_flag_h`` and another called ``_flag_help``.
|
||||
|
||||
The variables will be set with local scope (i.e., as if the script had done ``set -l _flag_X``). If the flag is a boolean (that is, it just is passed or not, it doesn't have a value) the values are the short and long flags seen. If the option is not a boolean the values will be zero or more values corresponding to the values collected when the ARG list is processed. If the flag was not seen the flag variable will not be set.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
The following ``argparse`` options are available. They must appear before all *OPTION_SPEC*\ s:
|
||||
The following ``argparse`` options are available. They must appear before all OPTION_SPECs:
|
||||
|
||||
**-n** or **--name**
|
||||
The command name for use in error messages. By default the current function name will be used, or ``argparse`` if run outside of a function.
|
||||
- ``-n`` or ``--name`` is the command name for use in error messages. By default the current function name will be used, or ``argparse`` if run outside of a function.
|
||||
|
||||
**-x** or **--exclusive** *OPTIONS*
|
||||
A comma separated list of options that are mutually exclusive. You can use this more than once to define multiple sets of mutually exclusive options.
|
||||
- ``-x`` or ``--exclusive`` should be followed by a comma separated list of short or long options that are mutually exclusive. You can use this more than once to define multiple sets of mutually exclusive options.
|
||||
|
||||
**-N** or **--min-args** *NUMBER*
|
||||
The minimum number of acceptable non-option arguments. The default is zero.
|
||||
- ``-N`` or ``--min-args`` is followed by an integer that defines the minimum number of acceptable non-option arguments. The default is zero.
|
||||
|
||||
**-X** or **--max-args** *NUMBER*
|
||||
The maximum number of acceptable non-option arguments. The default is infinity.
|
||||
- ``-X`` or ``--max-args`` is followed by an integer that defines the maximum number of acceptable non-option arguments. The default is infinity.
|
||||
|
||||
**-i** or **--ignore-unknown**
|
||||
Ignores unknown options, keeping them and their arguments in $argv instead.
|
||||
- ``-i`` or ``--ignore-unknown`` ignores unknown options, keeping them and their arguments in $argv instead.
|
||||
|
||||
**-s** or **--stop-nonopt**
|
||||
Causes scanning the arguments to stop as soon as the first non-option argument is seen. Among other things, this is useful to implement subcommands that have their own options.
|
||||
- ``-s`` or ``--stop-nonopt`` causes scanning the arguments to stop as soon as the first non-option argument is seen. Among other things, this is useful to implement subcommands that have their own options.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
- ``-h`` or ``--help`` displays help about using this command.
|
||||
|
||||
.. _cmd-argparse-usage:
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To use this command, pass the option specifications (**OPTION_SPEC**), a mandatory **--**, and then the arguments to be parsed.
|
||||
To use this command, pass the option specifications (``OPTION_SPEC``), then a mandatory ``--``, and then the arguments you want to have parsed.
|
||||
|
||||
A simple example::
|
||||
|
||||
argparse --name=my_function 'h/help' 'n/name=' -- $argv
|
||||
or return
|
||||
|
||||
|
||||
If ``$argv`` is empty then there is nothing to parse and ``argparse`` returns zero to indicate success. If ``$argv`` is not empty then it is checked for flags ``-h``, ``--help``, ``-n`` and ``--name``. If they are found they are removed from the arguments and local variables called ``_flag_OPTION`` are set so the script can determine which options were seen. If ``$argv`` doesn't have any errors, like a missing mandatory value for an option, then ``argparse`` exits with a status of zero. Otherwise it writes appropriate error messages to stderr and exits with a status of one.
|
||||
|
||||
The ``or return`` means that the function returns ``argparse``'s status if it failed, so if it goes on ``argparse`` succeeded.
|
||||
|
||||
The ``--`` argument is required. You do not have to include any option specifications or arguments after the ``--`` but you must include the ``--``. For example, this is acceptable::
|
||||
The ``--`` argument is required. You do not have to include any arguments after the ``--`` but you must include the ``--``. For example, this is acceptable::
|
||||
|
||||
set -l argv foo
|
||||
set -l argv
|
||||
argparse 'h/help' 'n/name' -- $argv
|
||||
argparse --min-args=1 -- $argv
|
||||
|
||||
|
||||
But this is not::
|
||||
|
||||
|
|
@ -84,21 +78,21 @@ Option Specifications
|
|||
|
||||
Each option specification consists of:
|
||||
|
||||
- An optional alphanumeric short flag character, followed by a ``/`` if the short flag can be used by someone invoking your command or, for backwards compatibility, a ``-`` if it should not be exposed as a valid short flag (in which case it will also not be exposed as a flag variable).
|
||||
- An optional alphanumeric short flag letter, followed by a ``/`` if the short flag can be used by someone invoking your command or, for backwards compatibility, a ``-`` if it should not be exposed as a valid short flag (in which case it will also not be exposed as a flag variable).
|
||||
|
||||
- An optional long flag name, which if not present the short flag can be used, and if that is also not present, an error is reported
|
||||
- An optional long flag name. If not present then only the short flag letter can be used, and if that is not present either it's an error.
|
||||
|
||||
- Nothing if the flag is a boolean that takes no argument or is an integer flag, or
|
||||
|
||||
- **=** if it requires a value and only the last instance of the flag is saved, or
|
||||
- ``=`` if it requires a value and only the last instance of the flag is saved, or
|
||||
|
||||
- **=?** if it takes an optional value and only the last instance of the flag is saved, or
|
||||
- ``=?`` it takes an optional value and only the last instance of the flag is saved, or
|
||||
|
||||
- **=+** if it requires a value and each instance of the flag is saved.
|
||||
- ``=+`` if it requires a value and each instance of the flag is saved.
|
||||
|
||||
- Optionally a ``!`` followed by fish script to validate the value. Typically this will be a function to run. If the exit status is zero the value for the flag is valid. If non-zero the value is invalid. Any error messages should be written to stdout (not stderr). See the section on :ref:`Flag Value Validation <flag-value-validation>` for more information.
|
||||
|
||||
See the :doc:`fish_opt <fish_opt>` command for a friendlier but more verbose way to create option specifications.
|
||||
See the :ref:`fish_opt <cmd-fish_opt>` command for a friendlier but more verbose way to create option specifications.
|
||||
|
||||
If a flag is not seen when parsing the arguments then the corresponding _flag_X var(s) will not be set.
|
||||
|
||||
|
|
@ -163,25 +157,14 @@ The script should write any error messages to stdout, not stderr. It should retu
|
|||
|
||||
Fish ships with a ``_validate_int`` function that accepts a ``--min`` and ``--max`` flag. Let's say your command accepts a ``-m`` or ``--max`` flag and the minimum allowable value is zero and the maximum is 5. You would define the option like this: ``m/max=!_validate_int --min 0 --max 5``. The default if you just call ``_validate_int`` without those flags is to simply check that the value is a valid integer with no limits on the min or max value allowed.
|
||||
|
||||
Here are some examples of flag validations::
|
||||
|
||||
# validate that a path is a directory
|
||||
argparse 'p/path=!test -d "$_flag_value"' -- --path $__fish_config_dir
|
||||
# validate that a function does not exist
|
||||
argparse 'f/func=!not functions -q "$_flag_value"' -- -f alias
|
||||
# validate that a string matches a regex
|
||||
argparse 'c/color=!string match -rq \'^#?[0-9a-fA-F]{6}$\' "$_flag_value"' -- -c 'c0ffee'
|
||||
# validate with a validator function
|
||||
argparse 'n/num=!_validate_int --min 0 --max 99' -- --num 42
|
||||
|
||||
Example OPTION_SPECs
|
||||
--------------------
|
||||
|
||||
Some *OPTION_SPEC* examples:
|
||||
Some OPTION_SPEC examples:
|
||||
|
||||
- ``h/help`` means that both ``-h`` and ``--help`` are valid. The flag is a boolean and can be used more than once. If either flag is used then ``_flag_h`` and ``_flag_help`` will be set to however either flag was seen, as many times as it was seen. So it could be set to ``-h``, ``-h`` and ``--help``, and ``count $_flag_h`` would yield "3".
|
||||
- ``h/help`` means that both ``-h`` and ``--help`` are valid. The flag is a boolean and can be used more than once. If either flag is used then ``_flag_h`` and ``_flag_help`` will be set to the count of how many times either flag was seen.
|
||||
|
||||
- ``help`` means that only ``--help`` is valid. The flag is a boolean and can be used more than once. If it is used then ``_flag_help`` will be set as above. Also ``h-help`` (with an arbitrary short letter) for backwards compatibility.
|
||||
- ``help`` means that only ``--help`` is valid. The flag is a boolean and can be used more than once. If it is used then ``_flag_help`` will be set to the count of how many times the long flag was seen. Also ``h-help`` (with an arbitrary short letter) for backwards compatibility.
|
||||
|
||||
- ``longonly=`` is a flag ``--longonly`` that requires an option, there is no short flag or even short flag variable.
|
||||
|
||||
|
|
@ -191,7 +174,7 @@ Some *OPTION_SPEC* examples:
|
|||
|
||||
- ``name=+`` means that only ``--name`` is valid. It requires a value and can be used more than once. If the flag is seen then ``_flag_name`` will be set with the values associated with each occurrence.
|
||||
|
||||
- ``x`` means that only ``-x`` is valid. It is a boolean that can be used more than once. If it is seen then ``_flag_x`` will be set as above.
|
||||
- ``x`` means that only ``-x`` is valid. It is a boolean that can be used more than once. If it is seen then ``_flag_x`` will be set to the count of how many times the flag was seen.
|
||||
|
||||
- ``x=``, ``x=?``, and ``x=+`` are similar to the n/name examples above but there is no long flag alternative to the short flag ``-x``.
|
||||
|
||||
|
|
@ -204,18 +187,3 @@ Some *OPTION_SPEC* examples:
|
|||
After parsing the arguments the ``argv`` variable is set with local scope to any values not already consumed during flag processing. If there are no unbound values the variable is set but ``count $argv`` will be zero.
|
||||
|
||||
If an error occurs during argparse processing it will exit with a non-zero status and print error messages to stderr.
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
One limitation with **--ignore-unknown** is that, if an unknown option is given in a group with known options, the entire group will be kept in $argv. ``argparse`` will not do any permutations here.
|
||||
|
||||
For instance::
|
||||
|
||||
argparse --ignore-unknown h -- -ho
|
||||
echo $_flag_h # is -h, because -h was given
|
||||
echo $argv # is still -ho
|
||||
|
||||
This limitation may be lifted in future.
|
||||
|
||||
Additionally, it can only parse known options up to the first unknown option in the group - the unknown option could take options, so it isn't clear what any character after an unknown option means.
|
||||
|
|
|
|||
|
|
@ -6,28 +6,30 @@ begin - start a new block of code
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
begin; [COMMANDS...;] end
|
||||
|
||||
begin; [COMMANDS ...]; end
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``begin`` is used to create a new block of code.
|
||||
|
||||
A block allows the introduction of a new :ref:`variable scope <variables-scope>`, redirection of the input or output of a set of commands as a group, or to specify precedence when using the conditional commands like ``and``.
|
||||
A block allows the introduction of a new variable scope, redirection of the input or output of a set of commands as a group, or to specify precedence when using the conditional commands like ``and``.
|
||||
|
||||
The block is unconditionally executed. ``begin; ...; end`` is equivalent to ``if true; ...; end``.
|
||||
|
||||
``begin`` does not change the current exit status itself. After the block has completed, ``$status`` will be set to the status returned by the most recent command.
|
||||
|
||||
The **-h** or **--help** option displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
The following code sets a number of variables inside of a block scope. Since the variables are set inside the block and have local scope, they will be automatically deleted when the block ends.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
begin
|
||||
|
|
@ -43,6 +45,8 @@ The following code sets a number of variables inside of a block scope. Since the
|
|||
|
||||
In the following code, all output is redirected to the file out.html.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
begin
|
||||
|
|
@ -53,3 +57,4 @@ In the following code, all output is redirected to the file out.html.
|
|||
end
|
||||
...
|
||||
end > out.html
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ bg - send jobs to background
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
bg [PID ...]
|
||||
bg [PID...]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -17,15 +17,13 @@ Description
|
|||
|
||||
A background job is executed simultaneously with fish, and does not have access to the keyboard. If no job is specified, the last job to be used is put in the background. If ``PID`` is specified, the jobs containing the specified process IDs are put in the background.
|
||||
|
||||
For compatibility with other shells, job expansion syntax is supported for ``bg``. A PID of the format ``%1`` will be interpreted as the PID of job 1. Job numbers can be seen in the output of :doc:`jobs <jobs>`.
|
||||
For compatibility with other shells, job expansion syntax is supported for ``bg``. A PID of the format ``%1`` will be interpreted as the PID of job 1. Job numbers can be seen in the output of :ref:`jobs <cmd-jobs>`.
|
||||
|
||||
When at least one of the arguments isn't a valid job specifier,
|
||||
``bg`` will print an error without backgrounding anything.
|
||||
|
||||
When all arguments are valid job specifiers, ``bg`` will background all matching jobs that exist.
|
||||
|
||||
The **-h** or **--help** option displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ bind - handle fish key bindings
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
bind [(-M | --mode) MODE] [(-m | --sets-mode) NEW_MODE] [--preset | --user] [-s | --silent] [-k | --key] SEQUENCE COMMAND ...
|
||||
bind [(-M | --mode) MODE] [-k | --key] [--preset] [--user] SEQUENCE
|
||||
bind (-K | --key-names) [-a | --all] [--preset] [--user]
|
||||
bind [(-M | --mode) MODE] [(-m | --sets-mode) NEW_MODE] [--preset | --user] [(-s | --silent)] [(-k | --key)] SEQUENCE COMMAND [COMMAND...]
|
||||
bind [(-M | --mode) MODE] [(-k | --key)] [--preset] [--user] SEQUENCE
|
||||
bind (-K | --key-names) [(-a | --all)] [--preset] [--user]
|
||||
bind (-f | --function-names)
|
||||
bind (-L | --list-modes)
|
||||
bind (-e | --erase) [(-M | --mode) MODE] [--preset] [--user] [-a | --all] | [-k | --key] SEQUENCE ...
|
||||
bind (-e | --erase) [(-M | --mode) MODE] [--preset] [--user] (-a | --all | [(-k | --key)] SEQUENCE [SEQUENCE...])
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -27,308 +27,199 @@ The generic key binding that matches if no other binding does can be set by spec
|
|||
|
||||
If the ``-k`` switch is used, the name of a key (such as 'down', 'up' or 'backspace') is used instead of a sequence. The names used are the same as the corresponding curses variables, but without the 'key\_' prefix. (See ``terminfo(5)`` for more information, or use ``bind --key-names`` for a list of all available named keys). Normally this will print an error if the current ``$TERM`` entry doesn't have a given key, unless the ``-s`` switch is given.
|
||||
|
||||
To find out what sequence a key combination sends, you can use :doc:`fish_key_reader <fish_key_reader>`.
|
||||
To find out what sequence a key combination sends, you can use :ref:`fish_key_reader <cmd-fish_key_reader>`.
|
||||
|
||||
``COMMAND`` can be any fish command, but it can also be one of a set of special input functions. These include functions for moving the cursor, operating on the kill-ring, performing tab completion, etc. Use ``bind --function-names`` for a complete list of these input functions.
|
||||
|
||||
When ``COMMAND`` is a shellscript command, it is a good practice to put the actual code into a :ref:`function <syntax-function>` and simply bind to the function name. This way it becomes significantly easier to test the function while editing, and the result is usually more readable as well.
|
||||
|
||||
If a script produces output, it should finish by calling ``commandline -f repaint`` to tell fish that a repaint is in order.
|
||||
|
||||
.. note::
|
||||
Special input functions cannot be combined with ordinary shell script commands. The commands must be entirely a sequence of special input functions (from ``bind -f``) or all shell script commands (i.e., valid fish script). To run special input functions from regular fish script, use ``commandline -f`` (see also :doc:`commandline <commandline>`). If a script produces output, it should finish by calling ``commandline -f repaint`` to tell fish that a repaint is in order.
|
||||
Note that special input functions cannot be combined with ordinary shell script commands. The commands must be entirely a sequence of special input functions (from ``bind -f``) or all shell script commands (i.e., valid fish script).
|
||||
|
||||
If no ``SEQUENCE`` is provided, all bindings (or just the bindings in the given ``MODE``) are printed. If ``SEQUENCE`` is provided but no ``COMMAND``, just the binding matching that sequence is printed.
|
||||
|
||||
To save custom key bindings, put the ``bind`` statements into :ref:`config.fish <configuration>`. Alternatively, fish also automatically executes a function called ``fish_user_key_bindings`` if it exists.
|
||||
To save custom keybindings, put the ``bind`` statements into :ref:`config.fish <configuration>`. Alternatively, fish also automatically executes a function called ``fish_user_key_bindings`` if it exists.
|
||||
|
||||
Key bindings may use "modes", which mimics Vi's modal input behavior. The default mode is "default". Every key binding applies to a single mode; you can specify which one with ``-M MODE``. If the key binding should change the mode, you can specify the new mode with ``-m NEW_MODE``. The mode can be viewed and changed via the ``$fish_bind_mode`` variable. If you want to change the mode from inside a fish function, use ``set fish_bind_mode MODE``.
|
||||
Key bindings may use "modes", which mimics Vi's modal input behavior. The default mode is "default", and every bind applies to a single mode. The mode can be viewed/changed with the ``$fish_bind_mode`` variable.
|
||||
|
||||
Options
|
||||
-------
|
||||
The following options are available:
|
||||
|
||||
**-k** or **--key**
|
||||
Specify a key name, such as 'left' or 'backspace' instead of a character sequence
|
||||
- ``-k`` or ``--key`` Specify a key name, such as 'left' or 'backspace' instead of a character sequence
|
||||
|
||||
**-K** or **--key-names**
|
||||
Display a list of available key names. Specifying **-a** or **--all** includes keys that don't have a known mapping
|
||||
- ``-K`` or ``--key-names`` Display a list of available key names. Specifying ``-a`` or ``--all`` includes keys that don't have a known mapping
|
||||
|
||||
**-f** or **--function-names**
|
||||
Display a list of available input functions
|
||||
- ``-f`` or ``--function-names`` Display a list of available input functions
|
||||
|
||||
**-L** or **--list-modes**
|
||||
Display a list of defined bind modes
|
||||
- ``-L`` or ``--list-modes`` Display a list of defined bind modes
|
||||
|
||||
**-M MODE** or **--mode** *MODE*
|
||||
Specify a bind mode that the bind is used in. Defaults to "default"
|
||||
- ``-M MODE`` or ``--mode MODE`` Specify a bind mode that the bind is used in. Defaults to "default"
|
||||
|
||||
**-m NEW_MODE** or **--sets-mode** *NEW_MODE*
|
||||
Change the current mode to *NEW_MODE* after this binding is executed
|
||||
- ``-m NEW_MODE`` or ``--sets-mode NEW_MODE`` Change the current mode to ``NEW_MODE`` after this binding is executed
|
||||
|
||||
**-e** or **--erase**
|
||||
Erase the binding with the given sequence and mode instead of defining a new one.
|
||||
Multiple sequences can be specified with this flag.
|
||||
Specifying **-a** or **--all** with **-M** or **--mode** erases all binds in the given mode regardless of sequence.
|
||||
Specifying **-a** or **--all** without **-M** or **--mode** erases all binds in all modes regardless of sequence.
|
||||
- ``-e`` or ``--erase`` Erase the binding with the given sequence and mode instead of defining a new one. Multiple sequences can be specified with this flag. Specifying ``-a`` or ``--all`` with ``-M`` or ``--mode`` erases all binds in the given mode regardless of sequence. Specifying ``-a`` or ``--all`` without ``-M`` or ``--mode`` erases all binds in all modes regardless of sequence.
|
||||
|
||||
**-a** or **--all**
|
||||
See **--erase** and **--key-names**
|
||||
- ``-a`` or ``--all`` See ``--erase`` and ``--key-names``
|
||||
|
||||
**--preset** and **--user**
|
||||
Specify if bind should operate on user or preset bindings.
|
||||
User bindings take precedence over preset bindings when fish looks up mappings.
|
||||
By default, all ``bind`` invocations work on the "user" level except for listing, which will show both levels.
|
||||
All invocations except for inserting new bindings can operate on both levels at the same time (if both **--preset** and **--user** are given).
|
||||
**--preset** should only be used in full binding sets (like when working on ``fish_vi_key_bindings``).
|
||||
|
||||
**-s** or **--silent**
|
||||
Silences some of the error messages, including for unknown key names and unbound sequences.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
- ``--preset`` and ``--user`` specify if bind should operate on user or preset bindings. User bindings take precedence over preset bindings when fish looks up mappings. By default, all ``bind`` invocations work on the "user" level except for listing, which will show both levels. All invocations except for inserting new bindings can operate on both levels at the same time (if both ``--preset`` and ``--user`` are given). ``--preset`` should only be used in full binding sets (like when working on ``fish_vi_key_bindings``).
|
||||
|
||||
Special input functions
|
||||
-----------------------
|
||||
The following special input functions are available:
|
||||
|
||||
``and``
|
||||
only execute the next function if the previous succeeded (note: only some functions report success)
|
||||
- ``and``, only execute the next function if the previous succeeded (note: only some functions report success)
|
||||
|
||||
``accept-autosuggestion``
|
||||
accept the current autosuggestion
|
||||
- ``accept-autosuggestion``, accept the current autosuggestion completely
|
||||
|
||||
``backward-char``
|
||||
move one character to the left.
|
||||
If the completion pager is active, select the previous completion instead.
|
||||
- ``backward-char``, moves one character to the left
|
||||
|
||||
``backward-bigword``
|
||||
move one whitespace-delimited word to the left
|
||||
- ``backward-bigword``, move one whitespace-delimited word to the left
|
||||
|
||||
``backward-delete-char``
|
||||
deletes one character of input to the left of the cursor
|
||||
- ``backward-delete-char``, deletes one character of input to the left of the cursor
|
||||
|
||||
``backward-kill-bigword``
|
||||
move the whitespace-delimited word to the left of the cursor to the killring
|
||||
- ``backward-kill-bigword``, move the whitespace-delimited word to the left of the cursor to the killring
|
||||
|
||||
``backward-kill-line``
|
||||
move everything from the beginning of the line to the cursor to the killring
|
||||
- ``backward-kill-line``, move everything from the beginning of the line to the cursor to the killring
|
||||
|
||||
``backward-kill-path-component``
|
||||
move one path component to the left of the cursor to the killring. A path component is everything likely to belong to a path component, i.e. not any of the following: `/={,}'\":@ |;<>&`, plus newlines and tabs.
|
||||
- ``backward-kill-path-component``, move one path component to the left of the cursor to the killring. A path component is everything likely to belong to a path component, i.e. not any of the following: `/={,}'\":@ |;<>&`, plus newlines and tabs.
|
||||
|
||||
``backward-kill-word``
|
||||
move the word to the left of the cursor to the killring. The "word" here is everything up to punctuation or whitespace.
|
||||
- ``backward-kill-word``, move the word to the left of the cursor to the killring. The "word" here is everything up to punctuation or whitespace.
|
||||
|
||||
``backward-word``
|
||||
move one word to the left
|
||||
- ``backward-word``, move one word to the left
|
||||
|
||||
``beginning-of-buffer``
|
||||
moves to the beginning of the buffer, i.e. the start of the first line
|
||||
- ``beginning-of-buffer``, moves to the beginning of the buffer, i.e. the start of the first line
|
||||
|
||||
``beginning-of-history``
|
||||
move to the beginning of the history
|
||||
- ``beginning-of-history``, move to the beginning of the history
|
||||
|
||||
``beginning-of-line``
|
||||
move to the beginning of the line
|
||||
- ``beginning-of-line``, move to the beginning of the line
|
||||
|
||||
``begin-selection``
|
||||
start selecting text
|
||||
- ``begin-selection``, start selecting text
|
||||
|
||||
``cancel``
|
||||
cancel the current commandline and replace it with a new empty one
|
||||
- ``cancel``, cancel the current commandline and replace it with a new empty one
|
||||
|
||||
``cancel-commandline``
|
||||
cancel the current commandline and replace it with a new empty one, leaving the old one in place with a marker to show that it was cancelled
|
||||
- ``cancel-commandline``, cancel the current commandline and replace it with a new empty one, leaving the old one in place with a marker to show that it was cancelled
|
||||
|
||||
``capitalize-word``
|
||||
make the current word begin with a capital letter
|
||||
- ``capitalize-word``, make the current word begin with a capital letter
|
||||
|
||||
``complete``
|
||||
guess the remainder of the current token
|
||||
- ``complete``, guess the remainder of the current token
|
||||
|
||||
``complete-and-search``
|
||||
invoke the searchable pager on completion options (for convenience, this also moves backwards in the completion pager)
|
||||
- ``complete-and-search``, invoke the searchable pager on completion options (for convenience, this also moves backwards in the completion pager)
|
||||
|
||||
``delete-char``
|
||||
delete one character to the right of the cursor
|
||||
- ``delete-char``, delete one character to the right of the cursor
|
||||
|
||||
``delete-or-exit``
|
||||
delete one character to the right of the cursor, or exit the shell if the commandline is empty
|
||||
- ``delete-or-exit``, deletes one character to the right of the cursor or exits the shell if the commandline is empty.
|
||||
|
||||
``down-line``
|
||||
move down one line
|
||||
- ``down-line``, move down one line
|
||||
|
||||
``downcase-word``
|
||||
make the current word lowercase
|
||||
- ``downcase-word``, make the current word lowercase
|
||||
|
||||
``end-of-buffer``
|
||||
moves to the end of the buffer, i.e. the end of the first line
|
||||
- ``end-of-buffer``, moves to the end of the buffer, i.e. the end of the first line
|
||||
|
||||
``end-of-history``
|
||||
move to the end of the history
|
||||
- ``end-of-history``, move to the end of the history
|
||||
|
||||
``end-of-line``
|
||||
move to the end of the line
|
||||
- ``end-of-line``, move to the end of the line
|
||||
|
||||
``end-selection``
|
||||
end selecting text
|
||||
- ``end-selection``, end selecting text
|
||||
|
||||
``expand-abbr``
|
||||
expands any abbreviation currently under the cursor
|
||||
- ``expand-abbr``, expands any abbreviation currently under the cursor
|
||||
|
||||
``execute``
|
||||
run the current commandline
|
||||
- ``execute``, run the current commandline
|
||||
|
||||
``exit``
|
||||
exit the shell
|
||||
- ``exit``, exit the shell
|
||||
|
||||
``forward-bigword``
|
||||
move one whitespace-delimited word to the right
|
||||
- ``forward-bigword``, move one whitespace-delimited word to the right
|
||||
|
||||
``forward-char``
|
||||
move one character to the right; or if at the end of the commandline, accept the current autosuggestion.
|
||||
If the completion pager is active, select the next completion instead.
|
||||
- ``forward-char``, move one character to the right
|
||||
|
||||
``forward-single-char``
|
||||
move one character to the right; or if at the end of the commandline, accept a single char from the current autosuggestion.
|
||||
- ``forward-single-char``, move one character to the right; if an autosuggestion is available, only take a single char from it
|
||||
|
||||
``forward-word``
|
||||
move one word to the right; or if at the end of the commandline, accept one word
|
||||
from the current autosuggestion.
|
||||
- ``forward-word``, move one word to the right
|
||||
|
||||
``history-pager``
|
||||
invoke the searchable pager on history (incremental search); or if the history pager is already active, search further backwards in time.
|
||||
- ``history-search-backward``, search the history for the previous match
|
||||
|
||||
``history-search-backward``
|
||||
search the history for the previous match
|
||||
- ``history-search-forward``, search the history for the next match
|
||||
|
||||
``history-search-forward``
|
||||
search the history for the next match
|
||||
- ``history-prefix-search-backward``, search the history for the previous prefix match
|
||||
|
||||
``history-prefix-search-backward``
|
||||
search the history for the previous prefix match
|
||||
- ``history-prefix-search-forward``, search the history for the next prefix match
|
||||
|
||||
``history-prefix-search-forward``
|
||||
search the history for the next prefix match
|
||||
- ``history-token-search-backward``, search the history for the previous matching argument
|
||||
|
||||
``history-token-search-backward``
|
||||
search the history for the previous matching argument
|
||||
- ``history-token-search-forward``, search the history for the next matching argument
|
||||
|
||||
``history-token-search-forward``
|
||||
search the history for the next matching argument
|
||||
- ``forward-jump`` and ``backward-jump``, read another character and jump to its next occurence after/before the cursor
|
||||
|
||||
``forward-jump`` and ``backward-jump``
|
||||
read another character and jump to its next occurence after/before the cursor
|
||||
- ``forward-jump-till`` and ``backward-jump-till``, jump to right *before* the next occurence
|
||||
|
||||
``forward-jump-till`` and ``backward-jump-till``
|
||||
jump to right *before* the next occurence
|
||||
- ``repeat-jump`` and ``repeat-jump-reverse``, redo the last jump in the same/opposite direction
|
||||
|
||||
``repeat-jump`` and ``repeat-jump-reverse``
|
||||
redo the last jump in the same/opposite direction
|
||||
- ``kill-bigword``, move the next whitespace-delimited word to the killring
|
||||
|
||||
``kill-bigword``
|
||||
move the next whitespace-delimited word to the killring
|
||||
- ``kill-line``, move everything from the cursor to the end of the line to the killring
|
||||
|
||||
``kill-line``
|
||||
move everything from the cursor to the end of the line to the killring
|
||||
- ``kill-selection``, move the selected text to the killring
|
||||
|
||||
``kill-selection``
|
||||
move the selected text to the killring
|
||||
- ``kill-whole-line``, move the line to the killring
|
||||
|
||||
``kill-whole-line``
|
||||
move the line (including the following newline) to the killring. If the line is the last line, its preceeding newline is also removed
|
||||
- ``kill-word``, move the next word to the killring
|
||||
|
||||
``kill-inner-line``
|
||||
move the line (without the following newline) to the killring
|
||||
- ``or``, only execute the next function if the previous succeeded (note: only some functions report success)
|
||||
|
||||
``kill-word``
|
||||
move the next word to the killring
|
||||
- ``pager-toggle-search``, toggles the search field if the completions pager is visible.
|
||||
|
||||
``nextd-or-forward-word``
|
||||
if the commandline is empty, then move forward in the directory history, otherwise move one word to the right;
|
||||
or if at the end of the commandline, accept one word from the current autosuggestion.
|
||||
- ``repaint``, reexecutes the prompt functions and redraws the prompt (also ``force-repaint`` for backwards-compatibility)
|
||||
|
||||
``or``
|
||||
only execute the next function if the previous did not succeed (note: only some functions report failure)
|
||||
- ``repaint-mode``, reexecutes the :ref:`fish_mode_prompt <cmd-fish_mode_prompt>` and redraws the prompt. This is useful for vi-mode. If no ``fish_mode_prompt`` exists or it prints nothing, it acts like a normal repaint.
|
||||
|
||||
``pager-toggle-search``
|
||||
toggles the search field if the completions pager is visible; or if used after ``history-pager``, search forwards in time.
|
||||
- ``self-insert``, inserts the matching sequence into the command line
|
||||
|
||||
``prevd-or-backward-word``
|
||||
if the commandline is empty, then move backward in the directory history, otherwise move one word to the left
|
||||
- ``self-insert-notfirst``, inserts the matching sequence into the command line, unless the cursor is at the beginning
|
||||
|
||||
``repaint``
|
||||
reexecutes the prompt functions and redraws the prompt (also ``force-repaint`` for backwards-compatibility)
|
||||
- ``suppress-autosuggestion``, remove the current autosuggestion. Returns true if there was a suggestion to remove.
|
||||
|
||||
``repaint-mode``
|
||||
reexecutes the :doc:`fish_mode_prompt <fish_mode_prompt>` and redraws the prompt. This is useful for vi-mode. If no ``fish_mode_prompt`` exists or it prints nothing, it acts like a normal repaint.
|
||||
- ``swap-selection-start-stop``, go to the other end of the highlighted text without changing the selection
|
||||
|
||||
``self-insert``
|
||||
inserts the matching sequence into the command line
|
||||
- ``transpose-chars``, transpose two characters to the left of the cursor
|
||||
|
||||
``self-insert-notfirst``
|
||||
inserts the matching sequence into the command line, unless the cursor is at the beginning
|
||||
- ``transpose-words``, transpose two words to the left of the cursor
|
||||
|
||||
``suppress-autosuggestion``
|
||||
remove the current autosuggestion. Returns true if there was a suggestion to remove.
|
||||
- ``togglecase-char``, toggle the capitalisation (case) of the character under the cursor
|
||||
|
||||
``swap-selection-start-stop``
|
||||
go to the other end of the highlighted text without changing the selection
|
||||
- ``togglecase-selection``, toggle the capitalisation (case) of the selection
|
||||
|
||||
``transpose-chars``
|
||||
transpose two characters to the left of the cursor
|
||||
- ``insert-line-under``, add a new line under the current line
|
||||
|
||||
``transpose-words``
|
||||
transpose two words to the left of the cursor
|
||||
- ``insert-line-over``, add a new line over the current line
|
||||
|
||||
``togglecase-char``
|
||||
toggle the capitalisation (case) of the character under the cursor
|
||||
- ``up-line``, move up one line
|
||||
|
||||
``togglecase-selection``
|
||||
toggle the capitalisation (case) of the selection
|
||||
- ``undo`` and ``redo``, revert or redo the most recent edits on the command line
|
||||
|
||||
``insert-line-under``
|
||||
add a new line under the current line
|
||||
- ``upcase-word``, make the current word uppercase
|
||||
|
||||
``insert-line-over``
|
||||
add a new line over the current line
|
||||
- ``yank``, insert the latest entry of the killring into the buffer
|
||||
|
||||
``up-line``
|
||||
move up one line
|
||||
|
||||
``undo`` and ``redo``
|
||||
revert or redo the most recent edits on the command line
|
||||
|
||||
``upcase-word``
|
||||
make the current word uppercase
|
||||
|
||||
``yank``
|
||||
insert the latest entry of the killring into the buffer
|
||||
|
||||
``yank-pop``
|
||||
rotate to the previous entry of the killring
|
||||
- ``yank-pop``, rotate to the previous entry of the killring
|
||||
|
||||
Additional functions
|
||||
--------------------
|
||||
The following functions are included as normal functions, but are particularly useful for input editing:
|
||||
|
||||
``up-or-search`` and ``down-or-search``
|
||||
move the cursor or search the history depending on the cursor position and current mode
|
||||
- ``up-or-search`` and ``down-or-search``, which move the cursor or search the history depending on the cursor position and current mode
|
||||
|
||||
``edit_command_buffer``
|
||||
open the visual editor (controlled by the :envvar:`VISUAL` or :envvar:`EDITOR` environment variables) with the current command-line contents
|
||||
- ``edit_command_buffer``, open the visual editor (controlled by the ``VISUAL`` or ``EDITOR`` environment variables) with the current command-line contents
|
||||
|
||||
``fish_clipboard_copy``
|
||||
copy the current selection to the system clipboard
|
||||
- ``delete-or-exit``, quit the shell if the current command-line is empty, or delete the character under the cursor if not
|
||||
|
||||
``fish_clipboard_paste``
|
||||
paste the current selection from the system clipboard before the cursor
|
||||
- ``fish_clipboard_copy``, copy the current selection to the system clipboard
|
||||
|
||||
``fish_commandline_append``
|
||||
append the argument to the command-line. If the command-line already ends with the argument, this removes the suffix instead. Starts with the last command from history if the command-line is empty.
|
||||
- ``fish_clipboard_paste``, paste the current selection from the system clipboard before the cursor
|
||||
|
||||
``fish_commandline_prepend``
|
||||
prepend the argument to the command-line. If the command-line already starts with the argument, this removes the prefix instead. Starts with the last command from history if the command-line is empty.
|
||||
- ``fish_commandline_append``, append the argument to the command-line. If the command-line already ends with the argument, this removes the suffix instead. Starts with the last command from history if the command-line is empty.
|
||||
|
||||
- ``fish_commandline_prepend``, prepend the argument to the command-line. If the command-line already starts with the argument, this removes the prefix instead. Starts with the last command from history if the command-line is empty.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
|
@ -359,7 +250,7 @@ Unix terminals, like the ones fish operates in, are at heart 70s technology. The
|
|||
|
||||
For instance, the control key modifies a character by setting the top three bits to 0. This means:
|
||||
|
||||
- Many characters + control are indistinguishable from other keys. :kbd:`Control`\ +\ :kbd:`I` *is* tab, :kbd:`Control`\ +\ :kbd:`J` *is* newline (``\n``).
|
||||
- Many characters + control are indistinguishable from other keys. :kbd:`Control`\ +\ :kbd:`I` *is* tab, :kbd:`Control`\ +\ :kbd:`J` *is* newline (`\n`).
|
||||
- Control and shift don't work simultaneously
|
||||
|
||||
Other keys don't have a direct encoding, and are sent as escape sequences. For example :kbd:`→` (Right) often sends ``\e\[C``. These can differ from terminal to terminal, and the mapping is typically available in `terminfo(5)`. Sometimes however a terminal identifies as e.g. ``xterm-256color`` for compatibility, but then implements xterm's sequences incorrectly.
|
||||
|
|
|
|||
|
|
@ -6,15 +6,15 @@ block - temporarily block delivery of events
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
block [OPTIONS...]
|
||||
|
||||
block [(--local | --global)]
|
||||
block --erase
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``block`` prevents events triggered by ``fish`` or the :doc:`emit <emit>` command from being delivered and acted upon while the block is in place.
|
||||
``block`` prevents events triggered by ``fish`` or the :ref:`emit <cmd-emit>` command from being delivered and acted upon while the block is in place.
|
||||
|
||||
In functions, ``block`` can be useful while performing work that should not be interrupted by the shell.
|
||||
|
||||
|
|
@ -22,24 +22,18 @@ The block can be removed. Any events which triggered while the block was in plac
|
|||
|
||||
Event blocks should not be confused with code blocks, which are created with ``begin``, ``if``, ``while`` or ``for``
|
||||
|
||||
Without options, the ``block`` command acts with function scope.
|
||||
The following parameters are available:
|
||||
|
||||
The following options are available:
|
||||
- ``-l`` or ``--local`` Release the block automatically at the end of the current innermost code block scope
|
||||
|
||||
**-l** or **--local**
|
||||
Release the block automatically at the end of the current innermost code block scope.
|
||||
- ``-g`` or ``--global`` Never automatically release the lock
|
||||
|
||||
**-g** or **--global**
|
||||
Never automatically release the lock.
|
||||
- ``-e`` or ``--erase`` Release global block
|
||||
|
||||
**-e** or **--erase**
|
||||
Release global block.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
::
|
||||
|
||||
# Create a function that listens for events
|
||||
|
|
@ -54,7 +48,8 @@ Example
|
|||
block -e
|
||||
# 'foo fired' will now be printed
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
Events are only received from the current fish process as there is no way to send events from one fish process to another (yet).
|
||||
Note that events are only received from the current fish process as there is no way to send events from one fish process to another.
|
||||
|
|
|
|||
|
|
@ -6,21 +6,19 @@ break - stop the current inner loop
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end
|
||||
|
||||
LOOP_CONSTRUCT
|
||||
[COMMANDS ...]
|
||||
break
|
||||
[COMMANDS ...]
|
||||
end
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``break`` halts a currently running loop (*LOOP_CONSTRUCT*), such as a :doc:`for <for>` or :doc:`while <while>` loop. It is usually added inside of a conditional block such as an :doc:`if <if>` block.
|
||||
``break`` halts a currently running loop, such as a :ref:`switch <cmd-switch>`, :ref:`for <cmd-for>` or :ref:`while <cmd-while>` loop. It is usually added inside of a conditional block such as an :ref:`if <cmd-if>` block.
|
||||
|
||||
There are no parameters for ``break``.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
The following code searches all .c files for "smurf", and halts at the first occurrence.
|
||||
|
|
@ -37,4 +35,4 @@ The following code searches all .c files for "smurf", and halts at the first occ
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`continue <continue>` command, to skip the remainder of the current iteration of the current inner loop
|
||||
- the :ref:`continue <cmd-continue>` command, to skip the remainder of the current iteration of the current inner loop
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@ breakpoint - launch debug mode
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
breakpoint
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
|
|
|
|||
|
|
@ -6,31 +6,27 @@ builtin - run a builtin command
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
builtin [OPTIONS] BUILTINNAME
|
||||
builtin --query BUILTINNAME ...
|
||||
builtin --names
|
||||
builtin [OPTIONS...] BUILTINNAME
|
||||
builtin --query BUILTINNAMES...
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``builtin`` forces the shell to use a builtin command named *BUILTIN*, rather than a function or external program.
|
||||
``builtin`` forces the shell to use a builtin command, rather than a function or program.
|
||||
|
||||
The following options are available:
|
||||
The following parameters are available:
|
||||
|
||||
**-n** or **--names**
|
||||
Lists the names of all defined builtins.
|
||||
- ``-n`` or ``--names`` List the names of all defined builtins
|
||||
- ``-q`` or ``--query`` tests if any of the specified builtins exists
|
||||
|
||||
**-q** or **--query** *BUILTIN*
|
||||
Tests if any of the specified builtins exist. If any exist, it returns 0, 1 otherwise.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
builtin jobs
|
||||
|
|
|
|||
|
|
@ -6,12 +6,9 @@ case - conditionally execute a block of commands
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
switch VALUE
|
||||
[case [GLOB ...]
|
||||
[COMMAND ...]]
|
||||
end
|
||||
switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ cd - change directory
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
cd [DIRECTORY]
|
||||
|
||||
|
|
@ -14,22 +14,16 @@ Description
|
|||
-----------
|
||||
``cd`` changes the current working directory.
|
||||
|
||||
If *DIRECTORY* is given, it will become the new directory. If no parameter is given, the :envvar:`HOME` environment variable will be used.
|
||||
If ``DIRECTORY`` is supplied, it will become the new directory. If no parameter is given, the contents of the ``HOME`` environment variable will be used.
|
||||
|
||||
If *DIRECTORY* is a relative path, all the paths in the :envvar:`CDPATH` will be tried as prefixes for it, in addition to :envvar:`PWD`.
|
||||
It is recommended to keep **.** as the first element of :envvar:`CDPATH`, or :envvar:`PWD` will be tried last.
|
||||
If ``DIRECTORY`` is a relative path, the paths found in the ``CDPATH`` list will be tried as prefixes for the specified path, in addition to $PWD.
|
||||
|
||||
Fish will also try to change directory if given a command that looks like a directory (starting with **.**, **/** or **~**, or ending with **/**), without explicitly requiring **cd**.
|
||||
Note that the shell will attempt to change directory without requiring ``cd`` if the name of a directory is provided (starting with ``.``, ``/`` or ``~``, or ending with ``/``).
|
||||
|
||||
Fish also ships a wrapper function around the builtin **cd** that understands ``cd -`` as changing to the previous directory.
|
||||
See also :doc:`prevd <prevd>`.
|
||||
This wrapper function maintains a history of the 25 most recently visited directories in the ``$dirprev`` and ``$dirnext`` global variables.
|
||||
If you make those universal variables your **cd** history is shared among all fish instances.
|
||||
Fish also ships a wrapper function around the builtin ``cd`` that understands ``cd -`` as changing to the previous directory. See also :ref:`prevd <cmd-prevd>`. This wrapper function maintains a history of the 25 most recently visited directories in the ``$dirprev`` and ``$dirnext`` global variables. If you make those universal variables your ``cd`` history is shared among all fish instances.
|
||||
|
||||
As a special case, ``cd .`` is equivalent to ``cd $PWD``, which is useful in cases where a mountpoint has been recycled or a directory has been removed and recreated.
|
||||
|
||||
The **--help** or **-h** option displays help about using this command, and does not change the directory.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
|
|
|
|||
|
|
@ -6,25 +6,20 @@ cdh - change to a recently visited directory
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
cdh [DIRECTORY]
|
||||
cdh [ directory ]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``cdh`` with no arguments presents a list of :ref:`recently visited directories <directory-history>`.
|
||||
You can then select one of the entries by letter or number.
|
||||
You can also press :kbd:`Tab` to use the completion pager to select an item from the list.
|
||||
If you give it a single argument it is equivalent to ``cd DIRECTORY``.
|
||||
``cdh`` with no arguments presents a list of :ref:`recently visited directories <directory-history>`. You can then select one of the entries by letter or number. You can also press :kbd:`Tab` to use the completion pager to select an item from the list. If you give it a single argument it is equivalent to ``cd directory``.
|
||||
|
||||
Note that the ``cd`` command limits directory history to the 25 most recently visited directories.
|
||||
The history is stored in the :envvar:`dirprev` and :envvar:`dirnext` variables, which this command manipulates.
|
||||
If you make those universal variables, your ``cd`` history is shared among all fish instances.
|
||||
Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables which this command manipulates. If you make those universal variables your ``cd`` history is shared among all fish instances.
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`dirh <dirh>` command to print the directory history
|
||||
- the :doc:`prevd <prevd>` command to move backward
|
||||
- the :doc:`nextd <nextd>` command to move forward
|
||||
- the :ref:`dirh <cmd-dirh>` command to print the directory history
|
||||
- the :ref:`prevd <cmd-prevd>` command to move backward
|
||||
- the :ref:`nextd <cmd-nextd>` command to move forward
|
||||
|
|
|
|||
|
|
@ -6,36 +6,32 @@ command - run a program
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
command [OPTIONS] [COMMANDNAME [ARG ...]]
|
||||
command [OPTIONS] COMMANDNAME [ARGS...]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
**command** forces the shell to execute the program *COMMANDNAME* and ignore any functions or builtins with the same name.
|
||||
``command`` forces the shell to execute the program ``COMMANDNAME`` and ignore any functions or builtins with the same name.
|
||||
|
||||
The following options are available:
|
||||
|
||||
**-a** or **--all**
|
||||
Prints all *COMMAND* found in :envvar:`PATH`, in the order found.
|
||||
- ``-a`` or ``--all`` returns all the external COMMANDNAMEs that are found in ``$PATH`` in the order they are found.
|
||||
|
||||
**-q** or **--query**
|
||||
Silence output and print nothing, setting only exit status.
|
||||
Implies **--search**.
|
||||
For compatibility, this is also **--quiet** (deprecated).
|
||||
- ``-q`` or ``--query``, silences the output and prints nothing, setting only the exit status. Implies ``--search``. For compatibility with old fish versions this is also ``--quiet`` (but this is deprecated).
|
||||
|
||||
**-v** (or **-s** or **--search**)
|
||||
Prints the external command that would be executed, or prints nothing if no file with the specified name could be found in :envvar:`PATH`.
|
||||
- ``-s`` or ``--search`` returns the name of the external command that would be executed, or nothing if no file with the specified name could be found in the ``$PATH``.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
With the ``-s`` option, ``command`` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found. Additionally passing a ``-q`` or ``--quiet`` option prevents any paths from being printed, like ``type -q``, for testing only the exit status.
|
||||
|
||||
With the **-v** option, ``command`` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 127 if no commands could be found. **--quiet** used with **-v** prevents commands being printed, like ``type -q``.
|
||||
For basic compatibility with POSIX ``command``, the ``-v`` flag is recognized as an alias for ``-s``.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
| ``command ls`` executes the ``ls`` program, even if an ``ls`` function also exists.
|
||||
| ``command -s ls`` prints the path to the ``ls`` program.
|
||||
| ``command -q git; and command git log`` runs ``git log`` only if ``git`` exists.
|
||||
``command ls`` causes fish to execute the ``ls`` program, even if an ``ls`` function exists.
|
||||
|
||||
``command -s ls`` returns the path to the ``ls`` program.
|
||||
|
||||
``command -q git; and command git log`` runs ``git log`` only if ``git`` exists.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ commandline - set or get the current command line buffer
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
commandline [OPTIONS] [CMD]
|
||||
|
||||
|
|
@ -17,87 +17,50 @@ Description
|
|||
|
||||
With no parameters, ``commandline`` returns the current value of the command line.
|
||||
|
||||
With **CMD** specified, the command line buffer is erased and replaced with the contents of **CMD**.
|
||||
With ``CMD`` specified, the command line buffer is erased and replaced with the contents of ``CMD``.
|
||||
|
||||
The following options are available:
|
||||
|
||||
**-C** or **--cursor**
|
||||
Set or get the current cursor position, not the contents of the buffer.
|
||||
If no argument is given, the current cursor position is printed, otherwise the argument is interpreted as the new cursor position.
|
||||
If one of the options **-j**, **-p** or **-t** is given, the position is relative to the respective substring instead of the entire command line buffer.
|
||||
- ``-C`` or ``--cursor`` set or get the current cursor position, not the contents of the buffer. If no argument is given, the current cursor position is printed, otherwise the argument is interpreted as the new cursor position. If one of the options ``-j``, ``-p`` or ``-t`` is given, the position is relative to the respective substring instead of the entire command line buffer.
|
||||
|
||||
**-B** or **--selection-start**
|
||||
Get current position of the selection start in the buffer.
|
||||
|
||||
**-E** or **--selection-end**
|
||||
Get current position of the selection end in the buffer.
|
||||
|
||||
**-f** or **--function**
|
||||
Causes any additional arguments to be interpreted as input functions, and puts them into the queue, so that they will be read before any additional actual key presses are.
|
||||
This option cannot be combined with any other option.
|
||||
See :doc:`bind <bind>` for a list of input functions.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
- ``-f`` or ``--function`` causes any additional arguments to be interpreted as input functions, and puts them into the queue, so that they will be read before any additional actual key presses are. This option cannot be combined with any other option. See :ref:`bind <cmd-bind>` for a list of input functions.
|
||||
|
||||
The following options change the way ``commandline`` updates the command line buffer:
|
||||
|
||||
**-a** or **--append**
|
||||
Do not remove the current commandline, append the specified string at the end of it.
|
||||
- ``-a`` or ``--append`` do not remove the current commandline, append the specified string at the end of it
|
||||
|
||||
**-i** or **--insert**
|
||||
Do not remove the current commandline, insert the specified string at the current cursor position
|
||||
- ``-i`` or ``--insert`` do not remove the current commandline, insert the specified string at the current cursor position
|
||||
|
||||
**-r** or **--replace**
|
||||
Remove the current commandline and replace it with the specified string (default)
|
||||
- ``-r`` or ``--replace`` remove the current commandline and replace it with the specified string (default)
|
||||
|
||||
The following options change what part of the commandline is printed or updated:
|
||||
|
||||
**-b** or **--current-buffer**
|
||||
Select the entire commandline, not including any displayed autosuggestion (default).
|
||||
- ``-b`` or ``--current-buffer`` select the entire commandline, not including any displayed autosuggestion (default)
|
||||
|
||||
**-j** or **--current-job**
|
||||
Select the current job - a **job** here is one pipeline.
|
||||
Stops at logical operators or terminators (**;**, **&**, and newlines).
|
||||
- ``-j`` or ``--current-job`` select the current job - a `job` here is one pipeline. It stops at logical operators or terminators (``;``, ``&`` or newlines).
|
||||
|
||||
**-p** or **--current-process**
|
||||
Select the current process - a **process** here is one command.
|
||||
Stops at logical operators, terminators, and pipes.
|
||||
- ``-p`` or ``--current-process`` select the current process - a `process` here is one simple command. It stops at logical operators, terminators or pipes.
|
||||
|
||||
**-s** or **--current-selection**
|
||||
Selects the current selection
|
||||
- ``-s`` or ``--current-selection`` selects the current selection
|
||||
|
||||
**-t** or **--current-token**
|
||||
Selects the current token
|
||||
- ``-t`` or ``--current-token`` select the current token
|
||||
|
||||
The following options change the way ``commandline`` prints the current commandline buffer:
|
||||
|
||||
**-c** or **--cut-at-cursor**
|
||||
Only print selection up until the current cursor position.
|
||||
- ``-c`` or ``--cut-at-cursor`` only print selection up until the current cursor position
|
||||
|
||||
**-o** or **--tokenize**
|
||||
Tokenize the selection and print one string-type token per line.
|
||||
- ``-o`` or ``--tokenize`` tokenize the selection and print one string-type token per line
|
||||
|
||||
If ``commandline`` is called during a call to complete a given string using ``complete -C STRING``, ``commandline`` will consider the specified string to be the current contents of the command line.
|
||||
|
||||
The following options output metadata about the commandline state:
|
||||
|
||||
**-L** or **--line**
|
||||
Print the line that the cursor is on, with the topmost line starting at 1.
|
||||
- ``-L`` or ``--line`` print the line that the cursor is on, with the topmost line starting at 1
|
||||
|
||||
**-S** or **--search-mode**
|
||||
Evaluates to true if the commandline is performing a history search.
|
||||
- ``-S`` or ``--search-mode`` evaluates to true if the commandline is performing a history search
|
||||
|
||||
**-P** or **--paging-mode**
|
||||
Evaluates to true if the commandline is showing pager contents, such as tab completions.
|
||||
- ``-P`` or ``--paging-mode`` evaluates to true if the commandline is showing pager contents, such as tab completions
|
||||
|
||||
**--paging-full-mode**
|
||||
Evaluates to true if the commandline is showing pager contents, such as tab completions and all lines are shown (no "<n> more rows" message).
|
||||
|
||||
**--is-valid**
|
||||
Returns true when the commandline is syntactically valid and complete.
|
||||
If it is, it would be executed when the ``execute`` bind function is called.
|
||||
If the commandline is incomplete, return 2, if erroneus, return 1.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
@ -118,7 +81,7 @@ The ``echo $flounder >&`` is the first process, ``less`` the second and ``and ec
|
|||
|
||||
``echo $flounder >&2 | less`` is the first job, ``and echo $catfish`` the second.
|
||||
|
||||
**$flounder** is the current token.
|
||||
``$flounder`` is the current token.
|
||||
|
||||
More examples:
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,23 @@ complete - edit command specific tab-completions
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
complete ((-c | --command) | (-p | --path)) COMMAND [OPTIONS]
|
||||
complete (-C | --do-complete) [--escape] STRING
|
||||
complete [( -c | --command | -p | --path )] COMMAND
|
||||
[( -c | --command | -p | --path ) COMMAND]...
|
||||
[( -e | --erase )]
|
||||
[( -s | --short-option ) SHORT_OPTION]...
|
||||
[( -l | --long-option | -o | --old-option ) LONG_OPTION]...
|
||||
[( -a | --arguments ) ARGUMENTS]
|
||||
[( -k | --keep-order )]
|
||||
[( -f | --no-files )]
|
||||
[( -F | --force-files )]
|
||||
[( -r | --require-parameter )]
|
||||
[( -x | --exclusive )]
|
||||
[( -w | --wraps ) WRAPPED_COMMAND]...
|
||||
[( -n | --condition ) CONDITION]
|
||||
[( -d | --description ) DESCRIPTION]
|
||||
complete ( -C [STRING] | --do-complete[=STRING] )
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -19,66 +32,43 @@ Description
|
|||
For an introduction to writing your own completions, see :ref:`Writing your own completions <completion-own>` in
|
||||
the fish manual.
|
||||
|
||||
The following options are available:
|
||||
- ``-c COMMAND`` or ``--command COMMAND`` specifies that ``COMMAND`` is the name of the command. If there is no ``-c`` or ``-p``, one non-option argument will be used as the command.
|
||||
|
||||
**-c** or **--command** *COMMAND*
|
||||
Specifies that *COMMAND* is the name of the command. If there is no **-c** or **-p**, one non-option argument will be used as the command.
|
||||
- ``-p COMMAND`` or ``--path COMMAND`` specifies that ``COMMAND`` is the absolute path of the command (optionally containing wildcards).
|
||||
|
||||
**-p** or **--path** *COMMAND*
|
||||
Specifies that *COMMAND* is the absolute path of the command (optionally containing wildcards).
|
||||
- ``-e`` or ``--erase`` deletes the specified completion.
|
||||
|
||||
**-e** or **--erase**
|
||||
Deletes the specified completion.
|
||||
- ``-s SHORT_OPTION`` or ``--short-option=SHORT_OPTION`` adds a short option to the completions list.
|
||||
|
||||
**-s** or **--short-option** *SHORT_OPTION*
|
||||
Adds a short option to the completions list.
|
||||
- ``-l LONG_OPTION`` or ``--long-option=LONG_OPTION`` adds a GNU style long option to the completions list.
|
||||
|
||||
**-l** or **--long-option** *LONG_OPTION*
|
||||
Adds a GNU-style long option to the completions list.
|
||||
- ``-o LONG_OPTION`` or ``--old-option=LONG_OPTION`` adds an old style long option to the completions list (See below for details).
|
||||
|
||||
**-o** or **--old-option** *OPTION*
|
||||
Adds an old-style short or long option (see below for details).
|
||||
- ``-a ARGUMENTS`` or ``--arguments=ARGUMENTS`` adds the specified option arguments to the completions list.
|
||||
|
||||
**-a** or **--arguments** *ARGUMENTS*
|
||||
Adds the specified option arguments to the completions list.
|
||||
- ``-k`` or ``--keep-order`` keeps the order of ``ARGUMENTS`` instead of sorting alphabetically. Multiple ``complete`` calls with ``-k`` result in arguments of the later ones displayed first.
|
||||
|
||||
**-k** or **--keep-order**
|
||||
Keeps the order of *ARGUMENTS* instead of sorting alphabetically. Multiple ``complete`` calls with **-k** result in arguments of the later ones displayed first.
|
||||
- ``-f`` or ``--no-files`` says that this completion may not be followed by a filename.
|
||||
|
||||
**-f** or **--no-files**
|
||||
This completion may not be followed by a filename.
|
||||
- ``-F`` or ``--force-files`` says that this completion may be followed by a filename, even if another applicable ``complete`` specified ``--no-files``.
|
||||
|
||||
**-F** or **--force-files**
|
||||
This completion may be followed by a filename, even if another applicable ``complete`` specified **--no-files**.
|
||||
- ``-r`` or ``--require-parameter`` says that this completion must have an option argument, i.e. may not be followed by another option.
|
||||
|
||||
**-r** or **--require-parameter**
|
||||
This completion must have an option argument, i.e. may not be followed by another option.
|
||||
- ``-x`` or ``--exclusive`` is short for ``-r`` and ``-f``.
|
||||
|
||||
**-x** or **--exclusive**
|
||||
Short for **-r** and **-f**.
|
||||
- ``-w WRAPPED_COMMAND`` or ``--wraps=WRAPPED_COMMAND`` causes the specified command to inherit completions from the wrapped command (See below for details).
|
||||
|
||||
**-w** or **--wraps** *WRAPPED_COMMAND*
|
||||
Causes the specified command to inherit completions from *WRAPPED_COMMAND* (see below for details).
|
||||
- ``-n CONDITION`` or ``--condition CONDITION`` specifies that this completion should only be used if the CONDITION (a shell command) returns 0. This makes it possible to specify completions that should only be used in some cases.
|
||||
|
||||
**-n** or **--condition** *CONDITION*
|
||||
This completion should only be used if the *CONDITION* (a shell command) returns 0. This makes it possible to specify completions that should only be used in some cases. If multiple conditions are specified, fish will try them in the order they are specified until one fails or all succeeded.
|
||||
|
||||
**-C** or **--do-complete** *STRING*
|
||||
Makes ``complete`` try to find all possible completions for the specified string. If there is no *STRING*, the current commandline is used instead.
|
||||
|
||||
**--escape**
|
||||
When used with ``-C``, escape special characters in completions.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
- ``-C STRING`` or ``--do-complete=STRING`` makes complete try to find all possible completions for the specified string. If there is no STRING, the current commandline is used instead.
|
||||
|
||||
Command specific tab-completions in ``fish`` are based on the notion of options and arguments. An option is a parameter which begins with a hyphen, such as ``-h``, ``-help`` or ``--help``. Arguments are parameters that do not begin with a hyphen. Fish recognizes three styles of options, the same styles as the GNU getopt library. These styles are:
|
||||
|
||||
- Short options, like ``-a``. Short options are a single character long, are preceded by a single hyphen and can be grouped together (like ``-la``, which is equivalent to ``-l -a``). Option arguments may be specified by appending the option with the value (``-w32``), or, if ``--require-parameter`` is given, in the following parameter (``-w 32``).
|
||||
- Short options, like ``-a``. Short options are a single character long, are preceded by a single hyphen and can be grouped together (like ``-la``, which is equivalent to ``-l -a``). Option arguments may be specified in the following parameter (``-w 32``) or by appending the option with the value (``-w32``).
|
||||
|
||||
- Old-style options, long like ``-Wall`` or ``-name`` or even short like ``-a``. Old-style options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified by default following a space (``-foo null``) or after ``=`` (``-foo=null``).
|
||||
- Old style long options, like ``-Wall`` or ``-name``. Old style long options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified in the following parameter (``-ao null``).
|
||||
|
||||
- GNU-style long options, like ``--colors``. GNU-style long options can be more than one character long, are preceded by two hyphens, and can't be grouped together. Option arguments may be specified after a ``=`` (``--quoting-style=shell``), or, if ``--require-parameter`` is given, in the following parameter (``--quoting-style shell``).
|
||||
- GNU style long options, like ``--colors``. GNU style long options can be more than one character long, are preceded by two hyphens, and can't be grouped together. Option arguments may be specified in the following parameter (``--quoting-style shell``) or after a ``=`` (``--quoting-style=shell``).
|
||||
|
||||
Multiple commands and paths can be given in one call to define the same completions for multiple commands.
|
||||
|
||||
|
|
@ -86,12 +76,10 @@ Multiple command switches and wrapped commands can also be given to define multi
|
|||
|
||||
Invoking ``complete`` multiple times for the same command adds the new definitions on top of any existing completions defined for the command.
|
||||
|
||||
When ``-a`` or ``--arguments`` is specified in conjunction with long, short, or old-style options, the specified arguments are only completed as arguments for any of the specified options. If ``-a`` or ``--arguments`` is specified without any long, short, or old-style options, the specified arguments are used when completing non-option arguments to the command (except when completing an option argument that was specified with ``-r`` or ``--require-parameter``).
|
||||
When ``-a`` or ``--arguments`` is specified in conjunction with long, short, or old style options, the specified arguments are only completed as arguments for any of the specified options. If ``-a`` or ``--arguments`` is specified without any long, short, or old style options, the specified arguments are used when completing non-option arguments to the command (except when completing an option argument that was specified with ``-r`` or ``--require-parameter``).
|
||||
|
||||
Command substitutions found in ``ARGUMENTS`` should return a newline-separated list of arguments, and each argument may optionally have a tab character followed by the argument description. Description given this way override a description given with ``-d`` or ``--description``.
|
||||
|
||||
Descriptions given with ``--description`` are also used to group options given with ``-s``, ``-o`` or ``-l``. Options with the same (non-empty) description will be listed as one candidate, and one of them will be picked. If the description is empty or no description was given this is skipped.
|
||||
|
||||
The ``-w`` or ``--wraps`` options causes the specified command to inherit completions from another command, "wrapping" the other command. The wrapping command can also have additional completions. A command can wrap multiple commands, and wrapping is transitive: if A wraps B, and B wraps C, then A automatically inherits all of C's completions. Wrapping can be removed using the ``-e`` or ``--erase`` options. Wrapping only works for completions specified with ``-c`` or ``--command`` and are ignored when specifying completions with ``-p`` or ``--path``.
|
||||
|
||||
When erasing completions, it is possible to either erase all completions for a specific command by specifying ``complete -c COMMAND -e``, or by specifying a specific completion option to delete.
|
||||
|
|
@ -101,14 +89,14 @@ When ``complete`` is called without anything that would define or erase completi
|
|||
Examples
|
||||
--------
|
||||
|
||||
The short-style option ``-o`` for the ``gcc`` command needs a file argument:
|
||||
The short style option ``-o`` for the ``gcc`` command needs a file argument:
|
||||
|
||||
::
|
||||
|
||||
complete -c gcc -s o -r
|
||||
|
||||
|
||||
The short-style option ``-d`` for the ``grep`` command requires one of ``read``, ``skip`` or ``recurse``:
|
||||
The short style option ``-d`` for the ``grep`` command requires one of ``read``, ``skip`` or ``recurse``:
|
||||
|
||||
::
|
||||
|
||||
|
|
@ -148,6 +136,4 @@ Now hub inherits all of the completions from git. Note this can also be specifie
|
|||
|
||||
complete -c git
|
||||
|
||||
Shows all completions for ``git``.
|
||||
|
||||
Any command ``foo`` that doesn't support grouping multiple short options in one string (not supporting ``-xf`` as short for ``-x -f``) or a short option and its value in one string (not supporting ``-d9`` instead of ``-d 9``) should be specified as a single-character old-style option instead of as a short-style option; for example, ``complete -c foo -o s; complete -c foo -o v`` would never suggest ``foo -ov`` but rather ``foo -o -v``.
|
||||
Show all completions for ``git``.
|
||||
|
|
|
|||
|
|
@ -6,32 +6,27 @@ contains - test if a word is present in a list
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
contains [OPTIONS] KEY [VALUES ...]
|
||||
contains [OPTIONS] KEY [VALUES...]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``contains`` tests whether the set *VALUES* contains the string *KEY*.
|
||||
If so, ``contains`` exits with code 0; if not, it exits with code 1.
|
||||
``contains`` tests whether the set ``VALUES`` contains the string ``KEY``. If so, ``contains`` exits with status 0; if not, it exits with status 1.
|
||||
|
||||
The following options are available:
|
||||
|
||||
**-i** or **--index**
|
||||
Print the index (number of the element in the set) of the first matching element.
|
||||
- ``-i`` or ``--index`` print the word index
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
||||
Note that ``contains`` interprets all arguments starting with a **-** as an option to ``contains``, until an **--** argument is reached.
|
||||
|
||||
See the examples below.
|
||||
Note that, like GNU tools and most of fish's builtins, ``contains`` interprets all arguments starting with a ``-`` as options to contains, until it reaches an argument that is ``--`` (two dashes). See the examples below.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
If *animals* is a list of animals, the following will test if *animals* contains "cat":
|
||||
If $animals is a list of animals, the following will test if it contains a cat:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
|
@ -40,7 +35,9 @@ If *animals* is a list of animals, the following will test if *animals* contains
|
|||
end
|
||||
|
||||
|
||||
This code will add some directories to :envvar:`PATH` if they aren't yet included:
|
||||
This code will add some directories to $PATH if they aren't yet included:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
|
@ -51,7 +48,9 @@ This code will add some directories to :envvar:`PATH` if they aren't yet include
|
|||
end
|
||||
|
||||
|
||||
While this will check if function ``hasargs`` is being ran with the **-q** option:
|
||||
While this will check if ``hasargs`` was run with the ``-q`` option:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
|
@ -62,5 +61,4 @@ While this will check if function ``hasargs`` is being ran with the **-q** optio
|
|||
end
|
||||
|
||||
|
||||
The **--** here stops ``contains`` from treating **-q** to an option to itself.
|
||||
Instead it treats it as a normal string to check.
|
||||
The ``--`` here stops ``contains`` from treating ``-q`` to an option to itself. Instead it treats it as a normal string to check.
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ continue - skip the remainder of the current iteration of the current inner loop
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
LOOP_CONSTRUCT; [COMMANDS ...;] continue; [COMMANDS ...;] end
|
||||
LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``continue`` skips the remainder of the current iteration of the current inner loop, such as a :doc:`for <for>` loop or a :doc:`while <while>` loop. It is usually added inside of a conditional block such as an :doc:`if <if>` statement or a :doc:`switch <switch>` statement.
|
||||
``continue`` skips the remainder of the current iteration of the current inner loop, such as a :ref:`for <cmd-for>` loop or a :ref:`while <cmd-while>` loop. It is usually added inside of a conditional block such as an :ref:`if <cmd-if>` statement or a :ref:`switch <cmd-switch>` statement.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
@ -35,4 +35,4 @@ The following code removes all tmp files that do not contain the word smurf.
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`break <break>` command, to stop the current inner loop
|
||||
- the :ref:`break <cmd-break>` command, to stop the current inner loop
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ count - count the number of elements of a list
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
count STRING1 STRING2 ...
|
||||
count $VARIABLE
|
||||
COMMAND | count
|
||||
count [...] < FILE
|
||||
count < FILE
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ dirh - print directory history
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
dirh
|
||||
|
||||
|
|
@ -17,11 +17,11 @@ Description
|
|||
|
||||
``dirh`` does not accept any parameters.
|
||||
|
||||
Note that the :doc:`cd <cd>` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables.
|
||||
Note that the :ref:`cd <cmd-cd>` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables.
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`cdh <cdh>` command to display a prompt to quickly navigate the history
|
||||
- the :doc:`prevd <prevd>` command to move backward
|
||||
- the :doc:`nextd <nextd>` command to move forward
|
||||
- the :ref:`cdh <cmd-cdh>` command to display a prompt to quickly navigate the history
|
||||
- the :ref:`prevd <cmd-prevd>` command to move backward
|
||||
- the :ref:`nextd <cmd-nextd>` command to move forward
|
||||
|
|
|
|||
|
|
@ -6,26 +6,21 @@ dirs - print directory stack
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
dirs [-c]
|
||||
dirs
|
||||
dirs -c
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``dirs`` prints the current :ref:`directory stack <directory-stack>`, as created by :doc:`pushd <pushd>` and modified by :doc:`popd <popd>`.
|
||||
``dirs`` prints the current :ref:`directory stack <directory-stack>`, as created by :ref:`pushd <cmd-pushd>` and modified by :ref:`popd <cmd-popd>`.
|
||||
|
||||
The following options are available:
|
||||
With "-c", it clears the directory stack instead.
|
||||
|
||||
**-c**:
|
||||
Clear the directory stack instead of printing it.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
||||
``dirs`` does not accept any arguments.
|
||||
``dirs`` does not accept any parameters.
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`cdh <cdh>` command, which provides a more intuitive way to navigate to recently visited directories.
|
||||
- the :ref:`cdh <cmd-cdh>` command which provides a more intuitive way to navigate to recently visited directories.
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ disown - remove a process from the list of jobs
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
disown [PID ...]
|
||||
disown [ PID ... ]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
|
@ -17,17 +17,15 @@ Description
|
|||
|
||||
Jobs in the list of jobs are sent a hang-up signal when fish terminates, which usually causes the job to terminate; ``disown`` allows these processes to continue regardless.
|
||||
|
||||
If no process is specified, the most recently-used job is removed (like :doc:`bg <bg>` and :doc:`fg <fg>`). If one or more PIDs are specified, jobs with the specified process IDs are removed from the job list. Invalid jobs are ignored and a warning is printed.
|
||||
If no process is specified, the most recently-used job is removed (like :ref:`bg <cmd-bg>` and :ref:`fg <cmd-fg>`). If one or more PIDs are specified, jobs with the specified process IDs are removed from the job list. Invalid jobs are ignored and a warning is printed.
|
||||
|
||||
If a job is stopped, it is sent a signal to continue running, and a warning is printed. It is not possible to use the :doc:`bg <bg>` builtin to continue a job once it has been disowned.
|
||||
If a job is stopped, it is sent a signal to continue running, and a warning is printed. It is not possible to use the :ref:`bg <cmd-bg>` builtin to continue a job once it has been disowned.
|
||||
|
||||
``disown`` returns 0 if all specified jobs were disowned successfully, and 1 if any problems were encountered.
|
||||
|
||||
The **--help** or **-h** option displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
``firefox &; disown`` will start the Firefox web browser in the background and remove it from the job list, meaning it will not be closed when the fish process is closed.
|
||||
|
||||
``disown (jobs -p)`` removes all :doc:`jobs <jobs>` from the job list without terminating them.
|
||||
``disown (jobs -p)`` removes all :ref:`jobs <cmd-jobs>` from the job list without terminating them.
|
||||
|
|
|
|||
|
|
@ -6,28 +6,24 @@ echo - display a line of text
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
echo [OPTIONS] [STRING]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``echo`` displays *STRING* of text.
|
||||
``echo`` displays a string of text.
|
||||
|
||||
The following options are available:
|
||||
|
||||
**-n**
|
||||
Do not output a newline.
|
||||
- ``-n``, Do not output a newline
|
||||
|
||||
**-s**
|
||||
Do not separate arguments with spaces.
|
||||
- ``-s``, Do not separate arguments with spaces
|
||||
|
||||
**-E**
|
||||
Disable interpretation of backslash escapes (default).
|
||||
- ``-E``, Disable interpretation of backslash escapes (default)
|
||||
|
||||
**-e**
|
||||
Enable interpretation of backslash escapes.
|
||||
- ``-e``, Enable interpretation of backslash escapes
|
||||
|
||||
Unlike other shells, this echo accepts ``--`` to signal the end of the options.
|
||||
|
||||
|
|
@ -78,4 +74,4 @@ Example
|
|||
See Also
|
||||
--------
|
||||
|
||||
- the :doc:`printf <printf>` command, for more control over output formatting
|
||||
- the :ref:`printf <cmd-printf>` command, for more control over output formatting
|
||||
|
|
|
|||
|
|
@ -6,22 +6,22 @@ else - execute command if a condition is not met
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
if CONDITION; COMMANDS_TRUE ...; [else; COMMANDS_FALSE ...;] end
|
||||
if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
:doc:`if <if>` will execute the command *CONDITION**.
|
||||
If the condition's exit status is 0, the commands *COMMANDS_TRUE* will execute.
|
||||
If it is not 0 and **else** is given, *COMMANDS_FALSE* will be executed.
|
||||
:ref:`if <cmd-if>` will execute the command ``CONDITION``. If the condition's exit status is 0, the commands ``COMMANDS_TRUE`` will execute. If it is not 0 and ``else`` is given, ``COMMANDS_FALSE`` will be executed.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
The following code tests whether a file *foo.txt* exists as a regular file.
|
||||
The following code tests whether a file ``foo.txt`` exists as a regular file.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
|
|
|||
|
|
@ -6,16 +6,15 @@ emit - emit a generic event
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
emit EVENT_NAME [ARGUMENTS ...]
|
||||
emit EVENT_NAME [ARGUMENTS...]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``emit`` emits, or fires, an event. Events are delivered to, or caught by, special functions called :ref:`event handlers <event>`. The arguments are passed to the event handlers as function arguments.
|
||||
|
||||
The **--help** or **-h** option displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -6,29 +6,23 @@ end - end a block of commands
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
begin
|
||||
[COMMANDS ...]
|
||||
end
|
||||
|
||||
.. synopsis::
|
||||
|
||||
function NAME [OPTIONS]; COMMANDS ...; end
|
||||
if CONDITION; COMMANDS_TRUE ...; [else; COMMANDS_FALSE ...;] end
|
||||
switch VALUE; [case [WILDCARD ...]; [COMMANDS ...]; ...] end
|
||||
while CONDITION; COMMANDS ...; end
|
||||
for VARNAME in [VALUES ...]; COMMANDS ...; end
|
||||
begin; [COMMANDS...] end
|
||||
function NAME [OPTIONS]; COMMANDS...; end
|
||||
if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end
|
||||
switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
|
||||
while CONDITION; COMMANDS...; end
|
||||
for VARNAME in [VALUES...]; COMMANDS...; end
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The **end** keyword ends a block of commands started by one of the following commands:
|
||||
``end`` ends a block of commands started by one of the following commands:
|
||||
|
||||
- :doc:`begin <begin>` to start a block of commands
|
||||
- :doc:`function <function>` to define a function
|
||||
- :doc:`if <if>`, :doc:`switch <switch>` to conditionally execute commands
|
||||
- :doc:`while <while>`, :doc:`for <for>` to perform commands multiple times
|
||||
- :ref:`begin <cmd-begin>` to start a block of commands
|
||||
- :ref:`function <cmd-function>` to define a function
|
||||
- :ref:`if <cmd-if>`, :ref:`switch <cmd-switch>` to conditionally execute commands
|
||||
- :ref:`while <cmd-while>`, :ref:`for <cmd-for>` to perform commands multiple times
|
||||
|
||||
The **end** keyword does not change the current exit status.
|
||||
Instead, the status after it will be the status returned by the most recent command.
|
||||
The ``end`` command does not change the current exit status. Instead, the status after it will be the status returned by the most recent command.
|
||||
|
|
|
|||
|
|
@ -6,19 +6,20 @@ eval - evaluate the specified commands
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
eval [COMMANDS...]
|
||||
|
||||
eval [COMMANDS ...]
|
||||
|
||||
Description
|
||||
-----------
|
||||
**eval** evaluates the specified parameters as a command.
|
||||
If more than one parameter is specified, all parameters will be joined using a space character as a separator.
|
||||
``eval`` evaluates the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator.
|
||||
|
||||
If the command does not need access to stdin, consider using :doc:`source <source>` instead.
|
||||
If your command does not need access to stdin, consider using :ref:`source <cmd-source>` instead.
|
||||
|
||||
If no piping or other compound shell constructs are required, variable-expansion-as-command, as in ``set cmd ls -la; $cmd``, is also an option.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
|
@ -29,3 +30,4 @@ The following code will call the ls command and truncate each filename to the fi
|
|||
set cmd ls \| cut -c 1-12
|
||||
eval $cmd
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,16 +6,15 @@ exec - execute command in current process
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
exec COMMAND
|
||||
exec COMMAND [OPTIONS...]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``exec`` replaces the currently running shell with a new command. On successful completion, ``exec`` never returns. ``exec`` cannot be used inside a pipeline.
|
||||
|
||||
The **--help** or **-h** option displays help about using this command.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
.. _cmd-exit:
|
||||
.. program::exit
|
||||
|
||||
exit - exit the shell
|
||||
=====================
|
||||
|
|
@ -7,16 +6,13 @@ exit - exit the shell
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
exit [CODE]
|
||||
exit [STATUS]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
**exit** is a special builtin that causes the shell to exit. Either 255 or the *CODE* supplied is used, whichever is lesser.
|
||||
Otherwise, the exit status will be that of the last command executed.
|
||||
``exit`` causes fish to exit. If ``STATUS`` is supplied, it will be converted to an integer and used as the exit status. Otherwise, the exit status will be that of the last command executed.
|
||||
|
||||
If exit is called while sourcing a file (using the :doc:`source <source>` builtin) the rest of the file will be skipped, but the shell itself will not exit.
|
||||
|
||||
The **--help** or **-h** option displays help about using this command.
|
||||
If exit is called while sourcing a file (using the :ref:`source <cmd-source>` builtin) the rest of the file will be skipped, but the shell itself will not exit.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ false - return an unsuccessful result
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
false
|
||||
|
||||
|
|
@ -18,5 +18,5 @@ Description
|
|||
See Also
|
||||
--------
|
||||
|
||||
- :doc:`true <true>` command
|
||||
- :ref:`true <cmd-true>` command
|
||||
- :ref:`$status <variables-status>` variable
|
||||
|
|
|
|||
|
|
@ -6,22 +6,16 @@ fg - bring job to foreground
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
fg [PID]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The **fg** builtin brings the specified :ref:`job <syntax-job-control>` to the foreground, resuming it if it is stopped.
|
||||
While a foreground job is executed, fish is suspended.
|
||||
If no job is specified, the last job to be used is put in the foreground.
|
||||
If ``PID`` is specified, the job containing a process with the specified process ID is put in the foreground.
|
||||
``fg`` brings the specified :ref:`job <syntax-job-control>` to the foreground, resuming it if it is stopped. While a foreground job is executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If ``PID`` is specified, the job containing a process with the specified process ID is put in the foreground.
|
||||
|
||||
For compatibility with other shells, job expansion syntax is supported for ``fg``. A *PID* of the format **%1** will foreground job 1.
|
||||
Job numbers can be seen in the output of :doc:`jobs <jobs>`.
|
||||
|
||||
The **--help** or **-h** option displays help about using this command.
|
||||
For compatibility with other shells, job expansion syntax is supported for ``fg``. A ``PID`` of the format ``%1`` will foreground job 1. Job numbers can be seen in the output of :ref:`jobs <cmd-jobs>`.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
.. _cmd-fish:
|
||||
.. program::fish
|
||||
|
||||
fish - the friendly interactive shell
|
||||
=====================================
|
||||
|
|
@ -7,96 +6,64 @@ fish - the friendly interactive shell
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
fish [OPTIONS] [FILE [ARG ...]]
|
||||
fish [OPTIONS] [-c COMMAND [ARG ...]]
|
||||
fish [OPTIONS] [-c command] [FILE] [ARGUMENTS...]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
:command:`fish` is a command-line shell written mainly with interactive use in mind.
|
||||
This page briefly describes the options for invoking :command:`fish`.
|
||||
The :ref:`full manual <intro>` is available in HTML by using the :command:`help` command from inside fish, and in the `fish-doc(1)` man page.
|
||||
The :ref:`tutorial <tutorial>` is available as HTML via ``help tutorial`` or in `man fish-tutorial`.
|
||||
|
||||
fish is a command-line shell written mainly with interactive use in mind. This page briefly describes the options for invoking fish. The :ref:`full manual <intro>` is available in HTML by using the :ref:`help <cmd-help>` command from inside fish, and in the `fish-doc(1)` man page. The :ref:`tutorial <tutorial>` is available as HTML via ``help tutorial`` or in `fish-tutorial(1)`.
|
||||
|
||||
The following options are available:
|
||||
|
||||
**-c** or **--command=COMMAND**
|
||||
Evaluate the specified commands instead of reading from the commandline, passing additional positional arguments through ``$argv``.
|
||||
- ``-c`` or ``--command=COMMANDS`` evaluate the specified commands instead of reading from the commandline, passing any additional positional arguments via :ref:`$argv <variables-argv>`. Note that, unlike other shells, the first argument is *not* the name of the program (``$0``), but simply the first normal argument.
|
||||
|
||||
**-C** or **--init-command=COMMANDS**
|
||||
Evaluate specified commands after reading the configuration but before executing command specified by **-c** or reading interactive input.
|
||||
- ``-C`` or ``--init-command=COMMANDS`` evaluate the specified commands after reading the configuration, before running the command specified by ``-c`` or reading interactive input
|
||||
|
||||
**-d** or **--debug=DEBUG_CATEGORIES**
|
||||
Enables debug output and specify a pattern for matching debug categories.
|
||||
See :ref:`Debugging <debugging-fish>` below for details.
|
||||
- ``-d`` or ``--debug=DEBUG_CATEGORIES`` enable debug output and specify a pattern for matching debug categories. See :ref:`Debugging <debugging-fish>` below for details.
|
||||
|
||||
**-o** or **--debug-output=DEBUG_FILE**
|
||||
Specifies a file path to receive the debug output, including categories and :envvar:`fish_trace`.
|
||||
The default is stderr.
|
||||
- ``-o`` or ``--debug-output=DEBUG_FILE`` specify a file path to receive the debug output, including categories and ``fish_trace``. The default is stderr.
|
||||
|
||||
**-i** or **--interactive**
|
||||
The shell is interactive.
|
||||
- ``-i`` or ``--interactive`` specify that fish is to run in interactive mode
|
||||
|
||||
**-l** or **--login**
|
||||
Act as if invoked as a login shell.
|
||||
- ``-l`` or ``--login`` specify that fish is to run as a login shell
|
||||
|
||||
**-N** or **--no-config**
|
||||
Do not read configuration files.
|
||||
- ``-n`` or ``--no-execute`` do not execute any commands, only perform syntax checking
|
||||
|
||||
**-n** or **--no-execute**
|
||||
Do not execute any commands, only perform syntax checking.
|
||||
- ``-p`` or ``--profile=PROFILE_FILE`` when fish exits, output timing information on all executed commands to the specified file. This excludes time spent starting up and reading the configuration.
|
||||
|
||||
**-p** or **--profile=PROFILE_FILE**
|
||||
when :command:`fish` exits, output timing information on all executed commands to the specified file.
|
||||
This excludes time spent starting up and reading the configuration.
|
||||
- ``--profile-startup=PROFILE_FILE`` will write timing information for fish's startup to the specified file. This is useful to profile your configuration.
|
||||
|
||||
**--profile-startup=PROFILE_FILE**
|
||||
Will write timing for ``fish`` startup to specified file.
|
||||
- ``-P`` or ``--private`` enables :ref:`private mode <private-mode>`, so fish will not access old or store new history.
|
||||
|
||||
**-P** or **--private**
|
||||
Enables :ref:`private mode <private-mode>`: **fish** will not access old or store new history.
|
||||
- ``--print-rusage-self`` when fish exits, output stats from getrusage
|
||||
|
||||
**--print-rusage-self**
|
||||
When :command:`fish` exits, output stats from getrusage.
|
||||
- ``--print-debug-categories`` outputs the list of debug categories, and then exits.
|
||||
|
||||
**--print-debug-categories**
|
||||
Print all debug categories, and then exit.
|
||||
- ``-v`` or ``--version`` display version and exit
|
||||
|
||||
**-v** or **--version**
|
||||
Print version and exit.
|
||||
- ``-f`` or ``--features=FEATURES`` enables one or more :ref:`feature flags <featureflags>` (separated by a comma). These are how fish stages changes that might break scripts.
|
||||
|
||||
**-f** or **--features=FEATURES**
|
||||
Enables one or more comma-separated :ref:`feature flags <featureflags>`.
|
||||
|
||||
The ``fish`` exit status is generally the :ref:`exit status of the last foreground command <variables-status>`.
|
||||
The fish exit status is generally the :ref:`exit status of the last foreground command <variables-status>`.
|
||||
|
||||
.. _debugging-fish:
|
||||
|
||||
Debugging
|
||||
---------
|
||||
|
||||
While fish provides extensive support for :ref:`debugging fish scripts <debugging>`, it is also possible to debug and instrument its internals.
|
||||
Debugging can be enabled by passing the **--debug** option.
|
||||
For example, the following command turns on debugging for background IO thread events, in addition to the default categories, i.e. *debug*, *error*, *warning*, and *warning-path*:
|
||||
::
|
||||
While fish provides extensive support for :ref:`debugging fish scripts <debugging>`, it is also possible to debug and instrument its internals. Debugging can be enabled by passing the ``--debug`` option. For example, the following command turns on debugging for background IO thread events, in addition to the default categories, i.e. *debug*, *error*, *warning*, and *warning-path*::
|
||||
|
||||
> fish --debug=iothread
|
||||
|
||||
Available categories are listed by ``fish --print-debug-categories``. The **--debug** option accepts a comma-separated list of categories, and supports glob syntax.
|
||||
The following command turns on debugging for *complete*, *history*, *history-file*, and *profile-history*, as well as the default categories:
|
||||
::
|
||||
Available categories are listed by ``fish --print-debug-categories``. The ``--debug`` option accepts a comma-separated list of categories, and supports glob syntax. The following command turns on debugging for *complete*, *history*, *history-file*, and *profile-history*, as well as the default categories::
|
||||
|
||||
> fish --debug='complete,*history*'
|
||||
|
||||
Debug messages output to stderr by default. Note that if :envvar:`fish_trace` is set, execution tracing also outputs to stderr by default. You can output to a file using the **--debug-output** option:
|
||||
::
|
||||
Debug messages output to stderr by default. Note that if ``fish_trace`` is set, execution tracing also outputs to stderr by default. You can output to a file using the ``--debug-output`` option::
|
||||
|
||||
> fish --debug='complete,*history*' --debug-output=/tmp/fish.log --init-command='set fish_trace on'
|
||||
|
||||
These options can also be changed via the :envvar:`FISH_DEBUG` and :envvar:`FISH_DEBUG_OUTPUT` variables.
|
||||
The categories enabled via **--debug** are *added* to the ones enabled by $FISH_DEBUG, so they can be disabled by prefixing them with **-** (**reader-*,-ast*** enables reader debugging and disables ast debugging).
|
||||
These options can also be changed via the $FISH_DEBUG and $FISH_DEBUG_OUTPUT variables. The categories enabled via ``--debug`` are *added* to the ones enabled by $FISH_DEBUG, so they can be disabled by prefixing them with ``-`` (``reader-*,-ast*`` enables reader debugging and disables ast debugging).
|
||||
|
||||
The file given in **--debug-output** takes precedence over the file in :envvar:`FISH_DEBUG_OUTPUT`.
|
||||
The file given in ``--debug-output`` takes precedence over the file in $FISH_DEBUG_OUTPUT.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
.. _cmd-fish_add_path:
|
||||
.. program::fish_add_path
|
||||
|
||||
fish_add_path - add to the path
|
||||
==============================================================
|
||||
|
|
@ -7,56 +6,39 @@ fish_add_path - add to the path
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
::
|
||||
|
||||
fish_add_path path ...
|
||||
fish_add_path [(-g | --global) | (-U | --universal) | (-P | --path)] [(-m | --move)] [(-a | --append) | (-p | --prepend)] [(-v | --verbose) | (-n | --dry-run)] PATHS ...
|
||||
fish_add_path [paths...]
|
||||
fish_add_path (-h | --help)
|
||||
fish_add_path [(-g | --global) | (-U | --universal) | (-P | --path)] [(-m | --move)] [(-a | --append) | (-p | --prepend)] [(-v | --verbose) | (-n | --dry-run)] [paths...]
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
:program:`fish_add_path` is a simple way to add more components to fish's :envvar:`PATH`. It does this by adding the components either to $fish_user_paths or directly to :envvar:`PATH` (if the ``--path`` switch is given).
|
||||
``fish_add_path`` is a simple way to add more components to fish's $PATH. It does this by adding the components either to $fish_user_paths or directly to $PATH (if the ``--path`` switch is given).
|
||||
|
||||
It is (by default) safe to use :program:`fish_add_path` in config.fish, or it can be used once, interactively, and the paths will stay in future because of :ref:`universal variables <variables-universal>`. This is a "do what I mean" style command, if you need more control, consider modifying the variable yourself.
|
||||
It is (by default) safe to use ``fish_add_path`` in config.fish, or it can be used once, interactively, and the paths will stay in future because of :ref:`universal variables <variables-universal>`. This is a "do what I mean" style command, if you need more control, consider modifying the variable yourself.
|
||||
|
||||
Components are normalized by :doc:`realpath <realpath>`. Trailing slashes are ignored and relative paths are made absolute (but symlinks are not resolved). If a component already exists, it is not added again and stays in the same place unless the ``--move`` switch is given.
|
||||
Components are normalized by :ref:`realpath <cmd-realpath>`. This means that trailing slashes are ignored and relative paths are made absolute (but symlinks are not resolved). If a component already exists, it is not added again and stays in the same place unless the ``--move`` switch is given.
|
||||
|
||||
Components are added in the order they are given, and they are prepended to the path unless ``--append`` is given (if $fish_user_paths is used, that means they are last in $fish_user_paths, which is itself prepended to :envvar:`PATH`, so they still stay ahead of the system paths).
|
||||
Components are added in the order they are given, and they are prepended to the path unless ``--append`` is given (if $fish_user_paths is used, that means they are last in $fish_user_paths, which is itself prepended to $PATH, so they still stay ahead of the system paths).
|
||||
|
||||
If no component is new, the variable (:envvar:`fish_user_paths` or :envvar:`PATH`) is not set again or otherwise modified, so variable handlers are not triggered.
|
||||
If no component is new, the variable ($fish_user_paths or $PATH) is not set again or otherwise modified, so variable handlers are not triggered.
|
||||
|
||||
If a component is not an existing directory, ``fish_add_path`` ignores it.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
**-a** or **--append**
|
||||
Add components to the *end* of the variable.
|
||||
|
||||
**-p** or **--prepend**
|
||||
Add components to the *front* of the variable (this is the default).
|
||||
|
||||
**-g** or **--global**
|
||||
Use a global :envvar:`fish_user_paths`.
|
||||
|
||||
**-U** or **--universal**
|
||||
Use a universal :envvar:`fish_user_paths` - this is the default if it doesn't already exist.
|
||||
|
||||
**-P** or **--path**
|
||||
Manipulate :envvar:`PATH` directly.
|
||||
|
||||
**-m** or **--move**
|
||||
Move already-existing components to the place they would be added - by default they would be left in place and not added again.
|
||||
|
||||
**-v** or **--verbose**
|
||||
Print the :doc:`set <set>` command used.
|
||||
|
||||
**-n** or **--dry-run**
|
||||
Print the ``set`` command that would be used without executing it.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
- ``-a`` or ``--append`` causes the components to be added to the *end* of the variable
|
||||
- ``-p`` or ``--prepend`` causes the components to be added to the *front* of the variable (this is the default)
|
||||
- ``-g`` or ``--global`` means to use a global $fish_user_paths
|
||||
- ``-U`` or ``--universal`` means to use a universal $fish_user_paths - this is the default if it doesn't already exist
|
||||
- ``-P`` or ``--path`` means to use $PATH directly
|
||||
- ``-m`` or ``--move`` means to move already existing components to the place they would be added - by default they would be left in place and not added again
|
||||
- ``-v`` or ``--verbose`` means to print the :ref:`set <cmd-set>` command used
|
||||
- ``-n`` or ``--dry-run`` means to print the ``set`` command that would be used without executing it
|
||||
|
||||
If ``--move`` is used, it may of course lead to the path swapping order, so you should be careful doing that in config.fish.
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,6 @@ fish_breakpoint_prompt - define the prompt when stopped at a breakpoint
|
|||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
|
||||
fish_breakpoint_prompt
|
||||
|
||||
::
|
||||
|
||||
function fish_breakpoint_prompt
|
||||
|
|
@ -20,7 +16,7 @@ Synopsis
|
|||
Description
|
||||
-----------
|
||||
|
||||
``fish_breakpoint_prompt`` is the prompt function when asking for input in response to a :doc:`breakpoint <breakpoint>` command.
|
||||
``fish_breakpoint_prompt`` is the prompt function when asking for input in response to a :ref:`breakpoint <cmd-breakpoint>` command.
|
||||
|
||||
The exit status of commands within ``fish_breakpoint_prompt`` will not modify the value of :ref:`$status <variables-status>` outside of the ``fish_breakpoint_prompt`` function.
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue