mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-10 09:41:16 -03:00
Compare commits
1 Commits
update-def
...
release-mo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a590e1ee1b |
@@ -24,4 +24,4 @@ tasks:
|
||||
ninja
|
||||
- test: |
|
||||
cd fish-shell/build
|
||||
ninja test
|
||||
env ninja test
|
||||
|
||||
@@ -20,4 +20,4 @@ tasks:
|
||||
ninja
|
||||
- test: |
|
||||
cd fish/build
|
||||
ninja test
|
||||
env ninja test
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# This file is _not_ included in the tarballs for now
|
||||
# Binary builds on Linux packaging infrastructure need to overwrite it to make `cargo vendor` work
|
||||
# Releases and development builds made using OBS/Launchpad will _not_ reflect the contents of this
|
||||
# file
|
||||
# For macOS, support 10.9 on x86-64, and 11.0 on aarch64, which
|
||||
# is the minimum supported version for Apple Silicon.
|
||||
[target.x86_64-apple-darwin]
|
||||
rustflags = ["-C", "link-arg=-mmacosx-version-min=10.9"]
|
||||
|
||||
[target.aarch64-apple-darwin]
|
||||
rustflags = ["-C", "link-arg=-mmacosx-version-min=11.0"]
|
||||
|
||||
[resolver]
|
||||
# Make cargo 1.84+ respect MSRV (rust-version in Cargo.toml)
|
||||
incompatible-rust-versions = "fallback"
|
||||
|
||||
@@ -20,6 +20,7 @@ linux_task:
|
||||
# container:
|
||||
# <<: *step
|
||||
# image: ghcr.io/krobelus/fish-ci/focal-32bit:latest
|
||||
|
||||
tests_script:
|
||||
# cirrus at times gives us 32 procs and 2 GB of RAM
|
||||
# Unrestriced parallelism results in OOM
|
||||
@@ -29,6 +30,7 @@ linux_task:
|
||||
- cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCTEST_PARALLEL_LEVEL=6 ..
|
||||
- ninja -j 6 fish
|
||||
- ninja fish_run_tests
|
||||
|
||||
only_if: $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
|
||||
linux_arm_task:
|
||||
@@ -39,6 +41,7 @@ linux_arm_task:
|
||||
- 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
|
||||
@@ -49,6 +52,7 @@ linux_arm_task:
|
||||
- ninja -j 6 fish
|
||||
- file ./fish
|
||||
- ninja fish_run_tests
|
||||
|
||||
# CI task disabled during RIIR transition
|
||||
only_if: false && $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
|
||||
@@ -88,4 +92,5 @@ freebsd_task:
|
||||
- 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'
|
||||
- sudo -u fish-user sh -c '. $HOME/.cargo/env; ninja fish_run_tests'
|
||||
|
||||
only_if: $CIRRUS_REPO_OWNER == 'fish-shell'
|
||||
|
||||
@@ -22,7 +22,7 @@ indent_size = 2
|
||||
indent_size = 2
|
||||
|
||||
[share/{completions,functions}/**.fish]
|
||||
max_line_length = unset
|
||||
max_line_length = off
|
||||
|
||||
[{COMMIT_EDITMSG,git-revise-todo}]
|
||||
max_line_length = 80
|
||||
|
||||
12
.gitattributes
vendored
12
.gitattributes
vendored
@@ -5,10 +5,9 @@
|
||||
|
||||
# let git show off diff hunk headers, help git diff -L:
|
||||
# https://git-scm.com/docs/gitattributes
|
||||
*.c diff=cpp
|
||||
*.cpp diff=cpp
|
||||
*.h diff=cpp
|
||||
*.py diff=py
|
||||
*.rs diff=rust
|
||||
# add a [diff "fish"] to git config with pattern
|
||||
*.fish diff=fish
|
||||
|
||||
@@ -22,13 +21,12 @@
|
||||
/.github/* export-ignore
|
||||
/.builds export-ignore
|
||||
/.builds/* export-ignore
|
||||
# to make cargo vendor work correctly
|
||||
/.cargo/ export-ignore
|
||||
/.cargo/config.toml export-ignore
|
||||
|
||||
# for linguist, which drives GitHub's language statistics
|
||||
# for linguist; let github identify our project as C++ instead of C due to pcre2
|
||||
pcre2/** linguist-vendored
|
||||
alpine.js linguist-vendored
|
||||
doc_src/** linguist-documentation
|
||||
*.fish linguist-language=fish
|
||||
# see 70f2899fcd which attempts to "rig the count"
|
||||
src/*.h linguist-language=c++
|
||||
src/builtins/*.h linguist-language=c++
|
||||
share/completions/*.fish linguist-documentation
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
---
|
||||
name: "Bug Report"
|
||||
about: "Simple template for bug reports"
|
||||
title: ""
|
||||
labels: []
|
||||
assignees: []
|
||||
---
|
||||
|
||||
<!--
|
||||
Please tell us which fish version you are using by executing the following:
|
||||
|
||||
fish --version
|
||||
echo $version
|
||||
|
||||
Please tell us which operating system (output of `uname`) and terminal you are using.
|
||||
Please tell us which operating system and terminal you are using. The output of `uname -a` and `echo $TERM` may be helpful in this regard although other commands might be relevant in your specific situation.
|
||||
|
||||
Please tell us if you tried fish without third-party customizations by executing this command and whether it affected the behavior you are reporting:
|
||||
|
||||
4
.github/workflows/mac_codesign.yml
vendored
4
.github/workflows/mac_codesign.yml
vendored
@@ -13,8 +13,8 @@ jobs:
|
||||
uses: dtolnay/rust-toolchain@1.73.0
|
||||
with:
|
||||
targets: x86_64-apple-darwin
|
||||
- name: Install Rust Stable
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
- name: Install Rust 1.79
|
||||
uses: dtolnay/rust-toolchain@1.79
|
||||
with:
|
||||
targets: aarch64-apple-darwin
|
||||
- name: build-and-codesign
|
||||
|
||||
32
.github/workflows/main.yml
vendored
32
.github/workflows/main.yml
vendored
@@ -1,9 +1,9 @@
|
||||
name: make fish_run_tests
|
||||
name: make test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
CTEST_PARALLEL_LEVEL: "4"
|
||||
CTEST_PARALLEL_LEVEL: "1"
|
||||
CMAKE_BUILD_PARALLEL_LEVEL: "4"
|
||||
|
||||
permissions:
|
||||
@@ -28,10 +28,10 @@ jobs:
|
||||
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
- name: make
|
||||
run: |
|
||||
make -C build VERBOSE=1
|
||||
- name: make fish_run_tests
|
||||
make VERBOSE=1
|
||||
- name: make test
|
||||
run: |
|
||||
make -C build VERBOSE=1 fish_run_tests
|
||||
make VERBOSE=1 test
|
||||
|
||||
ubuntu-32bit-static-pcre2:
|
||||
|
||||
@@ -54,10 +54,10 @@ jobs:
|
||||
cmake -DFISH_USE_SYSTEM_PCRE2=OFF -DRust_CARGO_TARGET=i586-unknown-linux-gnu ..
|
||||
- name: make
|
||||
run: |
|
||||
make -C build VERBOSE=1
|
||||
- name: make fish_run_tests
|
||||
make VERBOSE=1
|
||||
- name: make test
|
||||
run: |
|
||||
make -C build VERBOSE=1 fish_run_tests
|
||||
make VERBOSE=1 test
|
||||
|
||||
ubuntu-asan:
|
||||
|
||||
@@ -92,8 +92,8 @@ jobs:
|
||||
cmake .. -DASAN=1 -DRust_CARGO_TARGET=x86_64-unknown-linux-gnu -DCMAKE_BUILD_TYPE=Debug
|
||||
- name: make
|
||||
run: |
|
||||
make -C build VERBOSE=1
|
||||
- name: make fish_run_tests
|
||||
make VERBOSE=1
|
||||
- name: make test
|
||||
env:
|
||||
FISH_CI_SAN: 1
|
||||
ASAN_OPTIONS: check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1:fast_unwind_on_malloc=0
|
||||
@@ -107,7 +107,7 @@ jobs:
|
||||
llvm_version=$(clang --version | awk 'NR==1 { split($NF, version, "."); print version[1] }')
|
||||
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-$llvm_version
|
||||
export LSAN_OPTIONS="$LSAN_OPTIONS:suppressions=$PWD/build_tools/lsan_suppressions.txt"
|
||||
make -C build VERBOSE=1 fish_run_tests
|
||||
make VERBOSE=1 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
|
||||
@@ -133,9 +133,9 @@ jobs:
|
||||
# - name: make
|
||||
# run: |
|
||||
# make
|
||||
# - name: make fish_run_tests
|
||||
# - name: make test
|
||||
# run: |
|
||||
# make -C build fish_run_tests
|
||||
# make test
|
||||
|
||||
macos:
|
||||
|
||||
@@ -160,7 +160,7 @@ jobs:
|
||||
cmake -DWITH_GETTEXT=NO -DCMAKE_BUILD_TYPE=Debug ..
|
||||
- name: make
|
||||
run: |
|
||||
make -C build VERBOSE=1
|
||||
- name: make fish_run_tests
|
||||
make VERBOSE=1
|
||||
- name: make test
|
||||
run: |
|
||||
make -C build VERBOSE=1 fish_run_tests
|
||||
make VERBOSE=1 test
|
||||
|
||||
8
.github/workflows/rust_checks.yml
vendored
8
.github/workflows/rust_checks.yml
vendored
@@ -31,11 +31,3 @@ jobs:
|
||||
# This used to have --deny=warnings, but that turns rust release day
|
||||
# into automatic CI failure day, so we don't do that.
|
||||
run: cargo clippy --workspace --all-targets
|
||||
|
||||
# Disabling for now because it also checks "advisories",
|
||||
# making CI fail for reasons unrelated to the patch
|
||||
# cargo-deny:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
# - uses: EmbarkStudios/cargo-deny-action@v1
|
||||
|
||||
80
.github/workflows/staticbuild.yml
vendored
80
.github/workflows/staticbuild.yml
vendored
@@ -1,80 +0,0 @@
|
||||
name: staticbuilds
|
||||
|
||||
on:
|
||||
# release:
|
||||
# types: [published]
|
||||
# schedule:
|
||||
# - cron: "14 13 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CTEST_PARALLEL_LEVEL: "1"
|
||||
CMAKE_BUILD_PARALLEL_LEVEL: "4"
|
||||
|
||||
jobs:
|
||||
staticbuilds-linux:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- uses: dtolnay/rust-toolchain@1.70
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Prepare
|
||||
run: |
|
||||
sudo apt install python3-sphinx
|
||||
rustup target add x86_64-unknown-linux-musl
|
||||
rustup target add aarch64-unknown-linux-musl
|
||||
sudo apt install musl-tools crossbuild-essential-arm64 python3-pexpect tmux -y
|
||||
- name: Build
|
||||
run: |
|
||||
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2" CMAKE_WITH_GETTEXT=0 CC=aarch64-linux-gnu-gcc RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc -C link-arg=-lgcc -C link-arg=-D_FORTIFY_SOURCE=0" cargo build --release --target aarch64-unknown-linux-musl --bin fish
|
||||
cargo build --release --target x86_64-unknown-linux-musl
|
||||
- name: Test
|
||||
run: |
|
||||
test -e tests/test_driver.py && tests/test_driver.py -f /tmp target/x86_64-unknown-linux-musl/release/
|
||||
- name: Compress
|
||||
run: |
|
||||
tar -cazf fish-static-x86_64-$(git describe).tar.xz -C target/x86_64-unknown-linux-musl/release/ fish
|
||||
tar -cazf fish-static-aarch64-$(git describe).tar.xz -C target/aarch64-unknown-linux-musl/release/ fish
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fish-static-linux
|
||||
path: |
|
||||
fish-*.tar.xz
|
||||
retention-days: 14
|
||||
staticbuilds-macos:
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- uses: dtolnay/rust-toolchain@1.70
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Prepare
|
||||
run: |
|
||||
sudo pip3 install --break-system-packages sphinx
|
||||
rustup target add x86_64-apple-darwin
|
||||
rustup target add aarch64-apple-darwin
|
||||
- name: Build
|
||||
run: |
|
||||
PCRE2_SYS_STATIC=1 cargo build --release --target aarch64-apple-darwin --bin fish
|
||||
PCRE2_SYS_STATIC=1 cargo build --release --target x86_64-apple-darwin --bin fish
|
||||
- name: Compress
|
||||
run: |
|
||||
tar -cazf fish-macos-aarch64.tar.xz -C target/aarch64-apple-darwin/release/ fish
|
||||
tar -cazf fish-macos-x86_64.tar.xz -C target/x86_64-apple-darwin/release/ fish
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fish-static-macos
|
||||
path: |
|
||||
fish-macos-*.tar.xz
|
||||
retention-days: 14
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -102,6 +102,3 @@ target/
|
||||
|
||||
# Generated by clangd
|
||||
/.cache
|
||||
|
||||
# JetBrains editors.
|
||||
.idea/
|
||||
|
||||
@@ -31,7 +31,7 @@ PREFIX?=/usr/local
|
||||
build/fish: build/$(BUILDFILE)
|
||||
$(CMAKE) --build build
|
||||
|
||||
# Don't split the mkdir into its own rule because that would cause CMake to regenerate the build
|
||||
# Don't split the mkdir into its own rule because that would cause CMake to regenerate the build
|
||||
# files after each build (because it adds the mdate of the build directory into the out-of-date
|
||||
# calculation tree). GNUmake supports order-only dependencies, BSDmake does not seem to.
|
||||
build/$(BUILDFILE):
|
||||
@@ -48,11 +48,7 @@ clean:
|
||||
|
||||
.PHONY: test
|
||||
test: build/fish
|
||||
$(CMAKE) --build build --target fish_run_tests
|
||||
|
||||
.PHONY: fish_run_tests
|
||||
fish_run_tests: build/fish
|
||||
$(CMAKE) --build build --target fish_run_tests
|
||||
$(CMAKE) --build build --target test
|
||||
|
||||
.PHONY: run
|
||||
run: build/fish
|
||||
|
||||
416
CHANGELOG.rst
416
CHANGELOG.rst
@@ -1,144 +1,27 @@
|
||||
fish 4.1.0 (released ???)
|
||||
=========================
|
||||
fish 3.8.0 (released ???)
|
||||
===================================
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- Compound commands (``begin; echo 1; echo 2; end``) can now be now be abbreviated using braces (``{ echo1; echo 2 }``), like in other shells.
|
||||
- Fish now supports transient prompts: if :envvar:`fish_transient_prompt` is set to 1, fish will reexecute prompt functions with the ``--final-rendering`` argument before running a commandline (:issue:`11153`).
|
||||
- When tab completion results are truncated, any common directory name is omitted. E.g. if you complete "share/functions", and it includes the files "foo.fish" and "bar.fish",
|
||||
the completion pager will now show "…/foo.fish" and "…/bar.fish". This will make the candidates shorter and allow for more to be shown at once (:issue:`11250`).
|
||||
- The self-installing configuration introduced in fish 4.0 has been changed.
|
||||
Now fish built with embedded data will just read the data straight from its own binary or write it out when necessary, instead of requiring an installation step on start.
|
||||
That means it is now possible to build fish as a single file and copy it to a compatible system, including as a different user, without extracting any files.
|
||||
As before this is the default when building via `cargo`, and disabled when building via `cmake`, and for packagers we continue to recommend cmake.
|
||||
.. ignore: 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9544 9559 9561 9576 9575
|
||||
9568 9588 9556 9563 9567 9585 9591 9593 9594 9603 9600 9599 9592 9612 9613 9619 9630 9638 9625 9654 9637 9673 9666 9626 9688 9725 9636 9735
|
||||
9542 9332 9566 9573 9579 9586 9589 9607 9608 9615 9616 9621 9641 9642 9643 9653 9658 9661
|
||||
9671 9726 9729 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9816 9818 9821 9839
|
||||
9845 9864 9916 9923 9962 9963 9990 9991 10121 10179 9856 9859 9861 9863 9867 9869 9874 9879
|
||||
9881 9894 9896 9902 9873 10228 9925 9928 10145 10146 10161 10173 10195 10220 10222 10288
|
||||
10342 10358 9927 9930 9947 9948 9950 9952 9966 9968 9980 9981 9984 10040 10061 10101 10090
|
||||
10102 10108 10114 10115 10128 10129 10143 10174 10175 10180 10182 10184 10185 10186 10188
|
||||
10198 10200 10201 10204 10210 10214 10219 10223 10227 10232 10235 10237 10243 10244 10245
|
||||
10246 10251 10260 10267 10281 10347 10366 10368 10370 10371 10263 10270 10272 10276 10277
|
||||
10278 10279 10291 10293 10305 10306 10309 10316 10317 10327 10328 10329 10330 10336 10340
|
||||
10345 10346 10353 10354 10356 10372 10373 3299 10360 10359
|
||||
2037 2037 3017 3018 3162 4865 5284 5991 6981 6996 7172 9751 9893 10241 10254 10268 10290 10307
|
||||
10308 10321 10338 10348 10349 10355 10357 10379 10381 10388 10389 10390 10395 10398 10400 10403
|
||||
10404 10407 10408 10409 10411 10412 10417 10418 10427 10429 10438 10439 10440 10441 10442 10443
|
||||
10445 10448 10450 10451 10456 10457 10462 10463 10464 10466 10467 10474 10481 10490 10492 10494
|
||||
10499 10503 10505 10508 10509 10510 10511 10512 10513 10518 10547 10719
|
||||
|
||||
Note: When fish is built like this, the `$__fish_data_dir` variable will be empty because that directory no longer has meaning. If you need to load files from there,
|
||||
use `status get-file` or find alternatives (like loading completions for "foo" via `complete -C"foo "`).
|
||||
|
||||
We're considering making data embedding mandatory in future releases because it has a few advantages even for installation from a package (like making file conflicts with other packages impossible). (:issue:`11143`)
|
||||
|
||||
Deprecations and removed features
|
||||
---------------------------------
|
||||
- Tokens like ``{ echo, echo }`` in command position are no longer interpreted as brace expansion but as compound command.
|
||||
- Terminfo-style key names (``bind -k``) are no longer supported. They had been superseded by the native notation since 4.0,
|
||||
and currently they would map back to information from terminfo, which does not match what terminals would send with the kitty keyboard protocol (:issue:`11342`).
|
||||
- fish no longer reads the terminfo database, so its behavior is no longer affected by the :envvar:`TERM` environment variable (:issue:`11344`).
|
||||
For the time being, this can be turned off via the "ignore-terminfo" feature flag::
|
||||
|
||||
set -Ua fish_features no-ignore-terminfo
|
||||
|
||||
- The ``--install`` option when fish is built as self-installable was removed. If you need to write out fish's data you can use the new ``status list-files`` and ``status get-file`` subcommands, but it should no longer be necessary. (:issue:`11143`)
|
||||
- RGB colors (``set_color ff0000``) now default to using 24-bit RGB true-color commands, even if $COLORTERM is unset, because that is often lost e.g. over ssh (:issue:`11372`)
|
||||
|
||||
- To go back to using the nearest match from the 256-color palette, use ``set fish_term24bit 0`` or set $COLORTERM to a value that is not "24bit" or "truecolor".
|
||||
To make the nearest-match logic use the 16 color palette instead, use ``set fish_term256 0``.
|
||||
- Inside macOS Terminal.app, fish makes an attempt to still use the palette colors.
|
||||
If that doesn't work, use ``set fish_term24bit 0``.
|
||||
- ``set_color --background=COLOR`` no longer implicitly activates bold mode.
|
||||
To mitigate this change on existing installations that use a default theme, update your theme with ``fish_config theme choose`` or ``fish_config theme save``.
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- Autosuggestions are now also provided in multi-line command lines. Like `ctrl-r`, autosuggestions operate only on the current line.
|
||||
- Autosuggestions used to not suggest multi-line commandlines from history; now autosuggestions include individual lines from multi-line command lines.
|
||||
- The history search now preserves ordering between :kbd:`ctrl-s` forward and :kbd:`ctrl-r` backward searches.
|
||||
- Left mouse click (as requested by `click_events <terminal-compatibility.html#click-events>`__) can now select pager items (:issue:`10932`).
|
||||
- Instead of flashing all the text to the left of the cursor, fish now flashes the matched token during history token search, the completed token during completion (:issue:`11050`), the autosuggestion when deleting it, and the full command line in all other cases.
|
||||
- Pasted commands are now stripped of any ``$`` prefix.
|
||||
|
||||
New or improved bindings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- On non-macOS systems, :kbd:`alt-left`, :kbd:`alt-right`, :kbd:`alt-backspace`, :kbd:`alt-delete` no longer operate on punctuation-delimited words but on whole arguments, possibly including special characters like ``/`` and quoted spaces.
|
||||
On macOS, the corresponding :kbd:`ctrl-` prefixed keys operate on whole arguments.
|
||||
Word operations are still available via the other respective modifier, same as in the browser.
|
||||
- :kbd:`ctrl-z` (undo) after executing a command will restore the previous cursor position instead of placing the cursor at the end of the command line.
|
||||
- The OSC 133 prompt marking feature has learned about kitty's ``click_events=1`` flag, which allows moving fish's cursor by clicking.
|
||||
- :kbd:`ctrl-l` now pushes all text located above the prompt to the terminal's scrollback, before clearing and redrawing the screen (via a new special input function ``scrollback-push``).
|
||||
For compatibility with terminals that do not provide the scroll-forward command,
|
||||
this is only enabled by default if the terminal advertises support for the ``indn`` capability via XTGETTCAP.
|
||||
- Bindings using shift with non-ASCII letters (such as :kbd:`ctrl-shift-ä`) are now supported.
|
||||
If there is any modifier other than shift, this is the recommended notation (as opposed to :kbd:`ctrl-Ä`).
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- Support for curly underlines in `fish_color_*` variables and :doc:`set_color <cmds/set_color>` (:issue:`10957`).
|
||||
- Underlines can now be colored independent of text (:issue:`7619`).
|
||||
- New documentation page `Terminal Compatibility <terminal-compatibility.html>`_ (also accessible via ``man fish-terminal-compatibility``) lists required and optional terminal control sequences used by fish.
|
||||
|
||||
Other improvements
|
||||
------------------
|
||||
- ``fish_indent`` and ``fish_key_reader`` are now available as builtins, and if fish is called with that name it will act like the given tool (as a multi-call binary).
|
||||
This allows truly distributing fish as a single file. (:issue:`10876`)
|
||||
- ``fish_indent --dump-parse-tree`` now emits simple metrics about the tree including its memory consumption.
|
||||
|
||||
For distributors
|
||||
----------------
|
||||
- ``fish_indent`` and ``fish_key_reader`` are still built as separate binaries for now, but can also be replaced with a symlink if you want to save disk space (:issue:`10876`).
|
||||
- The CMake system was simplified and no longer second-guesses rustup. It will run rustc and cargo via $PATH or in ~/.cargo/bin/.
|
||||
If that doesn't match your setup, set the Rust_COMPILER and Rust_CARGO cmake variables (:issue:`11328`).
|
||||
- Cygwin support has been reintroduced, since rust gained a Cygwin target (https://github.com/rust-lang/rust/pull/134999, :issue:`11238`).
|
||||
|
||||
--------------
|
||||
|
||||
fish 4.0.2 (released April 20, 2025)
|
||||
====================================
|
||||
|
||||
This release of fish fixes a number of issues identified in fish 4.0.1:
|
||||
|
||||
- Completions are quoted, rather than backslash-escaped, only if the completion is unambiguous. Continuing to edit the token is therefore easier (:issue:`11271`). This changes the behavior introduced in 4.0.0 where all completions were quoted.
|
||||
- The warning when the terminfo database can't be found has been downgraded to a log message. fish will act as if the terminal behaves like xterm-256color, which is correct for the vast majority of cases (:issue:`11277`, :issue:`11290`).
|
||||
- Key combinations using the super (Windows/command) key can now (actually) be bound using the :kbd:`super-` prefix (:issue:`11217`). This was listed in the release notes for 4.0.1 but did not work correctly.
|
||||
- :doc:`function <cmds/function>` is stricter about argument parsing, rather than allowing additional parameters to be silently ignored (:issue:`11295`).
|
||||
- Using parentheses in the :doc:`test <cmds/test>` builtin works correctly, following a regression in 4.0.0 where they were not recognized (:issue:`11387`).
|
||||
- :kbd:`delete` in Vi mode when Num Lock is active will work correctly (:issue:`11303`).
|
||||
- Abbreviations cannot alter the command-line contents, preventing a crash (:issue:`11324`).
|
||||
- Improvements to various completions, including new completions for ``wl-randr`` (:issue:`11301`), performance improvements for ``cargo`` completions by avoiding network requests (:issue:`11347`), and other improvements for ``btrfs`` (:issue:`11320`), ``cryptsetup`` (:issue:`11315`), ``git`` (:issue:`11319`, :issue:`11322`, :issue:`11323`), ``jj`` (:issue:`11046`), and ``systemd-analyze`` (:issue:`11314`).
|
||||
- The Mercurial (``hg``) prompt can handle working directories that contain an embedded newline, rather than producing errors (:issue:`11348`).
|
||||
- A number of crashes have been fixed. Triggers include prompts containing backspace characters (:issue:`11280`), history pager search (:issue:`11355`), invalid UTF-8 in :doc:`read <cmds/read>` (:issue:`11383`), and the ``kill-selection`` binding (:issue:`11367`).
|
||||
- A race condition in the test suite has been fixed (:issue:`11254`), and a test for fish versioning relaxed to support downstream distributors' modifications (:issue:`11173`).
|
||||
- Small improvements to the documentation (:issue:`11264`, :issue:`11329`, :issue:`11361`).
|
||||
|
||||
--------------
|
||||
|
||||
fish 4.0.1 (released March 12, 2025)
|
||||
====================================
|
||||
|
||||
This release of fish includes the following improvements compared to fish 4.0.0:
|
||||
|
||||
- Key combinations using the super (Windows/command) key can be bound using the :kbd:`super-` prefix (:issue:`11217`).
|
||||
- Konsole's menu shows the "Open folder with" option again (:issue:`11198`).
|
||||
- ``$fish_color_search_match`` will now only be applied to the foreground color if it has an explicit foreground. For example, this allows setting::
|
||||
set -g fish_color_search_match --reverse
|
||||
- Cursor shape commands (``\e[2 q``) are no longer sent in non-interactive shells or in redirections (:issue:`11255`).
|
||||
- :doc:`status <cmds/status>` gained a ``is-interactive-read`` subcommand, to check whether the script is being called from an interactive :doc:`read <cmds/read>` invocation.
|
||||
- fish's background tasks are now started in a way that avoids an error on macOS Terminal.app (:issue:`11181`).
|
||||
- Using key combinations within qemu should work correctly.
|
||||
- Prompts containing control characters no longer cause incorrect display of command lines (:issue:`11252`).
|
||||
- Cancelling the command-line in Vi mode displays correctly again (:issue:`11261`).
|
||||
- The acidhub prompt properly displays the git branch again (:issue:`11179`).
|
||||
- Completions for ``wine`` correctly include files again (:issue:`11202`).
|
||||
- On macOS, paths from ``/etc/paths`` and ``/etc/manpaths`` containing colons are handled correctly (:issue:`10684`). This functionality was included in the 4.0.0 release notes but was missing from the source code.
|
||||
- The XTerm ``modifyOtherKeys`` keyboard encoding is no longer used under WezTerm, as it does not work correctly in all layouts (:issue:`11204`).
|
||||
- :kbd:`option-left` and other similar keys should now work in iTerm versions before 3.5.12; the kitty keyboard protocol is now disabled on these versions (:issue:`11192`).
|
||||
- The kitty keyboard protocol is no longer used under Midnight Commander, as it does not work correctly (:issue:`10640`).
|
||||
- fish now sends the commandline along with the OSC 133 semantic prompt command start sequence. This fixes a test in the kitty terminal (:issue:`11203`).
|
||||
- Git completions for third-party commands like "git-absorb" are completed correctly again (:issue:`11205`).
|
||||
- Completions for ``diskutil`` no longer produce an error (:issue:`11201`).
|
||||
- The output of certain error messages no longer prints newlines to standard output (:issue:`11248`).
|
||||
- A number of crashes have been fixed, including file names longer than 255 bytes (:issue:`11221`), using fish on a btrfs filesystem (:issue:`11219`), history files that do not have the expected format (:issue:`11236`), and pasting into an empty command line (:issue:`11256`).
|
||||
|
||||
--------------
|
||||
|
||||
fish 4.0.0 (released February 27, 2025)
|
||||
=======================================
|
||||
|
||||
fish's core code has been ported from C++ to Rust (:issue:`9512`). This means a large change in dependencies and how to build fish. However, there should be no direct impact on users. Packagers should see the :ref:`For Distributors <rust-packaging>` section at the end.
|
||||
The entirety of fish's C++ code has been ported to Rust (:issue:`9512`).
|
||||
This means a large change in dependencies and how to build fish.
|
||||
Packagers should see the :ref:`For Distributors <rust-packaging>` section at the end.
|
||||
|
||||
Notable backwards-incompatible changes
|
||||
--------------------------------------
|
||||
@@ -146,33 +29,36 @@ Notable backwards-incompatible changes
|
||||
- As part of a larger binding rework, ``bind`` gained a new key notation.
|
||||
In most cases the old notation should keep working, but in rare cases you may have to change a ``bind`` invocation to use the new notation.
|
||||
See :ref:`below <changelog-new-bindings>` for details.
|
||||
- :kbd:`ctrl-c` now calls a new bind function called ``clear-commandline``. The old behavior, which leaves a "^C" marker, is available as ``cancel-commandline`` (:issue:`10935`)
|
||||
- ``random`` will produce different values from previous versions of fish when used with the same seed, and will work more sensibly with small seed numbers.
|
||||
- Fish no longer supports terminals that fail to ignore OSC or CSI sequences they don't recognize.
|
||||
The typical problem is that terminals echo the raw sequences sent by fish instead of silently ignoring them.
|
||||
- :kbd:`alt-left` and :kbd:`alt-right` will now move by one argument (which may contain quoted spaces), not just one word like :kbd:`ctrl-left` and :kbd:`ctrl-right` do.
|
||||
- :kbd:`alt-backspace` will delete an entire argument, not just one word (which is :kbd:`ctrl-backspace` now).
|
||||
- ``random`` now uses a different random number generator and so the values you get even with the same seed have changed.
|
||||
Notably, it will now work much more sensibly with very small seeds.
|
||||
The seed was never guaranteed to give the same result across systems,
|
||||
so we do not expect this to have a large impact (:issue:`9593`).
|
||||
- Variables in command position that expand to a subcommand keyword are now forbidden to fix a likely user error.
|
||||
For example, ``set editor command emacs; $editor`` is no longer allowed (:issue:`10249`).
|
||||
- ``functions --handlers`` will now list handlers in a different order.
|
||||
Now it is definition order, first to last, where before it was last to first.
|
||||
This was never specifically defined, and we recommend not relying on a specific order (:issue:`9944`).
|
||||
- The ``qmark-noglob`` feature, introduced in fish 3.0, is enabled by default. That means ``?`` will no longer act as a single-character glob.
|
||||
- The ``qmark-noglob`` feature flag, introduced in fish 3.0, is now turned on by default. That means ``?`` will no longer act as a single-character glob.
|
||||
You can, for the time being, turn it back on by adding ``no-qmark-noglob`` to :envvar:`fish_features` and restarting fish::
|
||||
|
||||
set -Ua fish_features no-qmark-noglob
|
||||
|
||||
The flag will eventually be made read-only, making it impossible to turn off.
|
||||
- Terminals that fail to ignore unrecognized OSC or CSI sequences may display garbage. We know cool-retro-term and emacs' ansi-term are affected, but most mainstream terminals are not.
|
||||
- fish no longer searches directories from the Windows system/user ``$PATH`` environment variable for Linux executables. To execute Linux binaries by name (i.e. not with a relative or absolute path) from a Windows folder, make sure the ``/mnt/c/...`` path is explicitly added to ``$fish_user_paths`` and not just automatically appended to ``$PATH`` by ``wsl.exe`` (:issue:`10506`).
|
||||
- Under Microsoft Windows Subsystem for Linux 1 (not WSL 2), backgrounded jobs that have not been disowned and do not terminate on their own after a ``SIGHUP`` + ``SIGCONT`` sequence will be explicitly killed by fish on exit (after the usual prompt to close or disown them) to work around a WSL 1 deficiency that sees backgrounded processes that run into ``SIGTTOU`` remain in a suspended state indefinitely (:issue:`5263`). The workaround is to explicitly ``disown`` processes you wish to outlive the shell session.
|
||||
- Fish no longer searches directories from the Windows system/user ``$PATH`` environment variable for Linux executables. To execute Linux binaries by name (i.e. not with a relative or absolute path) from a Windows folder, make sure the ``/mnt/c/...`` path is explicitly added to ``$fish_user_paths`` and not just automatically appended to ``$PATH`` by ``wsl.exe`` (:issue:`10506`).
|
||||
- Under WSLv1, backgrounded jobs that have not been disowned and do not terminate on their own after a ``SIGHUP`` + ``SIGCONT`` sequence will be explicitly killed by fish on exit/exec (after the usual prompt to close or disown them) to work around a WSL deficiency that sees backgrounded processes that run into ``SIGTTOU`` remain in a suspended state indefinitely (:issue:`5263`). The workaround is to explicitly ``disown`` processes you wish to outlive the shell session.
|
||||
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
.. _changelog-new-bindings:
|
||||
|
||||
- fish now requests XTerm's ``modifyOtherKeys`` keyboard encoding and `kitty keyboard protocol's <https://sw.kovidgoyal.net/kitty/keyboard-protocol/>`_ progressive enhancements (:issue:`10359`).
|
||||
Depending on terminal support, this allows to binding more key combinations, including arbitrary combinations of modifiers :kbd:`ctrl`, :kbd:`alt` and :kbd:`shift`, and distinguishing (for example) :kbd:`ctrl-i` from :kbd:`tab`.
|
||||
- fish now requests XTerm's ``modifyOtherKeys`` keyboard encoding and `kitty keyboard protocol's <https://sw.kovidgoyal.net/kitty/keyboard-protocol/>`_ progressive enhancements for a CSI u encoding.
|
||||
Depending on terminal support, this allows to bind a lot more key combinations, including arbitrary combinations of modifiers :kbd:`ctrl`, :kbd:`alt` and :kbd:`shift`,
|
||||
and to distinguish e.g. :kbd:`ctrl-i` from :kbd:`tab`.
|
||||
|
||||
Additionally, ``bind`` now supports a human-readable syntax in addition to byte sequences.
|
||||
Additionally, builtin ``bind`` no longer requires specifying keys as byte sequences but learned a human-readable syntax.
|
||||
This includes modifier names, and names for keys like :kbd:`enter` and :kbd:`backspace`.
|
||||
For example
|
||||
|
||||
@@ -180,227 +66,181 @@ Notable improvements and fixes
|
||||
- ``bind ctrl-x,alt-c 'do something'`` binds a sequence of two keys.
|
||||
|
||||
Any key argument that starts with an ASCII control character (like ``\e`` or ``\cX``) or is up to 3 characters long, not a named key, and does not contain ``,`` or ``-`` will be interpreted in the old syntax to keep compatibility for the majority of bindings.
|
||||
|
||||
Keyboard protocols can be turned off by disabling the "keyboard-protocols" feature flag::
|
||||
|
||||
set -Ua fish_features no-keyboard-protocols
|
||||
|
||||
This is a temporary measure to work around buggy terminals (:issue:`11056`), which appear to be relatively rare.
|
||||
Use this if something like "=0" or "=5u" appears in your commandline mysteriously.
|
||||
|
||||
- fish can now be built as a self-installing binary (:issue:`10367`). That means it can be easily built on one system and copied to another, where it can extract supporting files.
|
||||
To do this, run::
|
||||
|
||||
cargo install --path . # in a clone of the fish repository
|
||||
# or `cargo build --release` and copy target/release/fish{,_indent,_key_reader} wherever you want
|
||||
|
||||
The first time it runs interactively, it will extract all the data files to ``~/.local/share/fish/install/``. A specific path can be used for the data files with ``fish --install=PATH`` To uninstall, remove the fish binaries and that directory.
|
||||
|
||||
This build system is experimental; the main build system, using ``cmake``, remains the recommended approach for packaging and installation to a prefix.
|
||||
- A new function ``fish_should_add_to_history`` can be overridden to decide whether a command should be added to the history (:issue:`10302`).
|
||||
- :kbd:`ctrl-c` during command input no longer prints ``^C`` and a new prompt but merely clears the command line. This restores the behavior from version 2.2. To revert to the old behavior use ``bind ctrl-c __fish_cancel_commandline`` (:issue:`10213`).
|
||||
- Bindings can now mix special input functions and shell commands, so ``bind ctrl-g expand-abbr "commandline -i \n"`` works as expected (:issue:`8186`).
|
||||
- Special input functions run from bindings via ``commandline -f`` are now applied immediately, instead of after the currently executing binding (:issue:`3031`, :issue:`10126`).
|
||||
- Special input functions run from bindings via ``commandline -f`` are now applied immediately instead of after the currently executing binding.
|
||||
For example, ``commandline -i foo; commandline | grep foo`` succeeds now.
|
||||
- Undo history is no longer truncated after every command, but kept for the lifetime of the shell process.
|
||||
- Undo history is no longer truncated after every command but kept for the lifetime of the shell process.
|
||||
- The :kbd:`ctrl-r` history search now uses glob syntax (:issue:`10131`).
|
||||
- The :kbd:`ctrl-r` history search now operates only on the line or command substitution at cursor, making it easier to combine commands from history (:issue:`9751`).
|
||||
- The :kbd:`ctrl-r` history search now operates only on the line or command substitution at cursor, making it easier to combine commands from history.
|
||||
- Abbreviations can now be restricted to specific commands. For instance::
|
||||
|
||||
abbr --add --command git back 'reset --hard HEAD^'
|
||||
|
||||
will expand "back" to ``reset --hard HEAD^``, but only when the command is ``git`` (:issue:`9411`).
|
||||
will expand "back" to ``reset --hard HEAD^``, but only when the command is ``git`` (:issue:`9411`, :issue:`10452`).
|
||||
|
||||
Deprecations and removed features
|
||||
---------------------------------
|
||||
|
||||
- ``commandline --tokenize`` (short option ``-o``) has been deprecated in favor of ``commandline --tokens-expanded`` (short option ``-x``) which expands variables and other shell syntax, removing the need to use :doc:`eval <cmds/eval>` in completion scripts (:issue:`10212`).
|
||||
- ``commandline --tokenize`` (short option ``-o``) has been deprecated in favor of ``commandline --tokens-expanded`` (short option ``-x``) which expands variables and other shell syntax, removing the need to use "eval" in completion scripts (:issue:`10212`).
|
||||
- Two new feature flags:
|
||||
|
||||
- ``remove-percent-self`` (see ``status features``) disables PID expansion of ``%self``, which has been supplanted by ``$fish_pid`` (:issue:`10262`).
|
||||
- ``test-require-arg`` disables ``test``'s one-argument mode. That means ``test -n`` without an additional argument will return false, ``test -z`` will keep returning true. Any other option without an argument, anything that is not an option and no argument will be an error. This also goes for ``[``, test's alternate name.
|
||||
- ``remove-percent-self`` (see ``status features``) disables PID expansion of ``%self`` which has been supplanted by ``$fish_pid`` (:issue:`10262`).
|
||||
- ``test-require-arg``, will disable ``test``'s one-argument mode. That means ``test -n`` without an additional argument will return false, ``test -z`` will keep returning true. Any other option without an argument, anything that is not an option and no argument will be an error. This also goes for ``[``, test's alternate name.
|
||||
This is a frequent source of confusion and so we are breaking with POSIX explicitly in this regard.
|
||||
In addition to the feature flag, there is a debug category "deprecated-test". Running fish with ``fish -d deprecated-test`` will show warnings whenever a ``test`` invocation that would change is used. (:issue:`10365`).
|
||||
|
||||
These can be enabled with::
|
||||
as always these can be enabled with::
|
||||
|
||||
set -Ua fish_features remove-percent-self test-require-arg
|
||||
|
||||
We intend to enable them by default in future, and after that eventually make them read-only.
|
||||
- Specifying key names as terminfo names (using the ``bind -k`` syntax) is deprecated and may be removed in a future version.
|
||||
They are available as a preview now, it is our intention to enable them by default in future, and after that eventually make them read-only.
|
||||
- Specifying key names as terminfo name (``bind -k``) is deprecated and may be removed in a future version.
|
||||
- When a terminal pastes text into fish using bracketed paste, fish used to switch to a special ``paste`` bind mode.
|
||||
This bind mode has been removed. The behavior on paste is no longer configurable.
|
||||
- When an interactive fish is stopped or terminated by a signal that cannot be caught (SIGSTOP or SIGKILL), it may leave the terminal in a state where keypresses with modifiers are sent as CSI u sequences, instead of traditional control characters or escape sequences that are recognized by Readline and compatible programs, such as bash and python.
|
||||
This bind mode has been removed. The behavior on paste is currently not meant to be configurable.
|
||||
- When an interactive fish is stopped or terminated by a signal that cannot be caught (SIGSTOP or SIGKILL), it may leave the terminal in a state where keypresses with modifiers are sent as CSI u sequences instead of traditional control characters or escape sequences (that are recognized by bash/readline).
|
||||
If this happens, you can use the ``reset`` command from ``ncurses`` to restore the terminal state.
|
||||
- ``fish_key_reader --verbose`` no longer shows timing information.
|
||||
- Terminal information is no longer read from hashed terminfo databases, or termcap databases (:issue:`10269`). The vast majority of systems use a non-hashed terminfo database, which is still supported.
|
||||
- ``source`` returns an error if used without a filename or pipe/redirection (:issue:`10774`).
|
||||
|
||||
Scripting improvements
|
||||
----------------------
|
||||
- ``for`` loops will no longer remember local variables from the previous iteration (:issue:`10525`).
|
||||
- A new ``history append`` subcommand appends a command to the history, without executing it (:issue:`4506`).
|
||||
- A new redirection: ``<? /path/to/file`` will try opening the file as input, and if it doesn't succeed silently uses ``/dev/null`` instead.
|
||||
- for-loops will no longer remember local variables from the previous iteration (:issue:`10525`).
|
||||
- Add ``history append`` subcommand to append a command to the history without executing it (:issue:`4506`).
|
||||
- A new redirection: ``<? /path/to/file`` will try opening the file as input, and if it doesn't succeed silently use /dev/null instead.
|
||||
This can help with checks like ``test -f /path/to/file; and string replace foo bar < /path/to/file``. (:issue:`10387`)
|
||||
- A new option ``commandline --tokens-raw`` prints a list of tokens without any unescaping (:issue:`10212`).
|
||||
- A new option ``commandline --showing-suggestion`` tests whether an autosuggestion is currently displayed (:issue:`10586`).
|
||||
- ``functions`` and ``type`` now show that a function was copied and its source, rather than solely ``Defined interactively`` (:issue:`6575`).
|
||||
- Stack trace now shows line numbers for copied functions (:issue:`6575`).
|
||||
- New option ``commandline --tokens-raw`` prints a list of tokens without any unescaping (:issue:`10212`).
|
||||
- New option ``commandline --showing-suggestion`` to check whether an autosuggestion is currently displayed (:issue:`10586`).
|
||||
- ``functions`` and ``type`` now show where a function was copied and where it originally was instead of saying ``Defined interactively`` (:issue:`6575`).
|
||||
- Stack trace now shows line numbers for copied functions.
|
||||
- ``foo & && bar`` is now a syntax error, like in other shells (:issue:`9911`).
|
||||
- ``if -e foo; end`` now prints a more accurate error (:issue:`10000`).
|
||||
- Variables in command position that expand to a subcommand keyword are now forbidden to fix a likely user error.
|
||||
For example ``set editor command emacs; $editor`` is no longer allowed (:issue:`10249`).
|
||||
- ``cd`` into a directory that is not readable but accessible (permissions ``--x``) is now possible (:issue:`10432`).
|
||||
- An integer overflow in ``string repeat`` leading to a near-infinite loop has been fixed (:issue:`9899`).
|
||||
- ``string shorten`` behaves better in the presence of non-printable characters, including fixing an integer overflow that shortened strings more than intended (:issue:`9854`).
|
||||
- ``string pad`` no longer allows non-printable characters as padding (:issue:`9854`).
|
||||
- ``string repeat`` now allows omission of ``-n`` when the first argument is an integer (:issue:`10282`).
|
||||
- ``string match`` and ``replace`` have a new ``--max-matches`` option to return as soon as the specified number of matches have been identified, which can improve performance in scripts (:issue:`10587`).
|
||||
- ``string shorten`` behaves better in the presence of non-printable characters, including fixing an integer overflow that shortened strings more than intended. (:issue:`9854`)
|
||||
- ``string pad`` no longer allows non-printable characters as padding. (:issue:`9854`)
|
||||
- ``string repeat`` now allows omission of ``-n`` when the first argument is an integer. (:issue:`10282`)
|
||||
- ``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``.
|
||||
- A new ``set --no-event`` option sets or erases variables without triggering a variable event. This can be useful to change a variable in an event handler (:issue:`10480`).
|
||||
- Commas in command substitution output are no longer used as separators in brace expansion, preventing a surprising expansion in some cases (:issue:`5048`).
|
||||
- Universal variables can now store strings containing invalid UTF-8 (:issue:`10313`).
|
||||
- A new ``path basename -E`` option that causes it to return the basename ("filename" with the directory prefix removed) with the final extension (if any) also removed. This is a shorter version of ``path change-extension "" (path basename $foo)`` (:issue:`10521`).
|
||||
- A new ``math --scale-mode`` option to select ``truncate``, ``round``, ``floor``, ``ceiling`` as you wish; the default value is ``truncate``. (:issue:`9117`).
|
||||
- ``random`` is now less strict about its arguments, allowing a start larger or equal to the end. (:issue:`10879`)
|
||||
- ``function --argument-names`` now produces an error if a read-only variable name is used, rather than simply ignoring it (:issue:`10842`).
|
||||
- Tilde expansion in braces (that is, ``{~,}``) works correctly (:issue:`10610`).
|
||||
- ``set`` has a new ``--no-event`` flag, to set or erase variables without triggering a variable event. This is useful e.g. to change a variable in an event handler. (:issue:`10480`)
|
||||
- Commas in command substitution output are no longer used as separators in brace expansion, preventing a surprising expansion in rare cases (:issue:`5048`).
|
||||
- Universal variables can now store strings containing invalid Unicode codepoints (:issue:`10313`).
|
||||
- ``path basename`` now takes a ``-E`` option that causes it to return the basename (i.e. "filename" with the directory prefix removed) with the final extension (if any) also removed. This is a shorter version of ``path change-extension "" (path basename $foo)`` (:issue:`10521`).
|
||||
- ``math`` now adds ``--scale-mode`` parameter. You can choose between ``truncate``, ``round``, ``floor``, ``ceiling`` as you wish (default value is ``truncate``). (:issue:`9117`).
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
- When using :kbd:`ctrl-x` on Wayland in the VSCode terminal, the clipboard is no longer cleared on :kbd:`ctrl-c`.
|
||||
- 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`).
|
||||
- Option completion now uses fuzzy subsequence filtering, just like non-option completion (:issue:`830`).
|
||||
This means that ``--fb`` may be completed to ``--foobar`` if there is no better match.
|
||||
- Completions that insert an entire token now use quotes instead of backslashes to escape special characters (:issue:`5433`).
|
||||
- Historically, file name completions are provided after the last ``:`` or ``=`` within a token.
|
||||
This helps commands like ``rsync --files-from=``.
|
||||
If the ``=`` or ``:`` is actually part of the filename, it will be escaped as ``\:`` and ``\=``,
|
||||
and no longer get this special treatment.
|
||||
This matches Bash's behavior.
|
||||
- Autosuggestions were sometimes not shown after recalling a line from history, which has been fixed (:issue:`10287`).
|
||||
- Up-arrow search matches -- which are highlighted in reverse colors -- are no longer syntax-highlighted, to fix bad contrast with the search match highlighting.
|
||||
- Up-arrow search matches -- which are highlighted in reverse video -- are no longer syntax-highlighted, to fix bad contrast with the search match highlighting.
|
||||
- Command abbreviations (those with ``--position command`` or without a ``--position``) now also expand after decorators like ``command`` (:issue:`10396`).
|
||||
- Abbreviations now expand after process separators like ``;`` and ``|``. This fixes a regression in version 3.6 (:issue:`9730`).
|
||||
- When exporting interactively defined functions (using ``type``, ``functions`` or ``funcsave``) the function body is now indented, to match the interactive command line editor (:issue:`8603`).
|
||||
- When exporting interactively defined functions (using ``type``, ``functions`` or ``funcsave``) the function body is now indented, same as in the interactive command line editor (:issue:`8603`).
|
||||
- :kbd:`ctrl-x` (``fish_clipboard_copy``) on multiline commands now includes indentation (:issue:`10437`).
|
||||
- :kbd:`ctrl-v` (``fish_clipboard_paste``) now strips ASCII control characters from the pasted text.
|
||||
This is consistent with normal keyboard input (:issue:`5274`).
|
||||
- When a command like ``fg %2`` fails to find the given job, it no longer behaves as if no job spec was given (:issue:`9835`).
|
||||
- Redirection in command position like ``>echo`` is now highlighted as error (:issue:`8877`).
|
||||
- ``fish_vi_cursor`` now works properly inside the prompt created by builtin ``read`` (:issue:`10088`).
|
||||
- fish no longer fails to open a FIFO if interrupted by a terminal resize signal (:issue:`10250`).
|
||||
- fish no longer fails to open a fifo if interrupted by a terminal resize signal (:issue:`10250`).
|
||||
- ``read --help`` and friends no longer ignore redirections. This fixes a regression in version 3.1 (:issue:`10274`).
|
||||
- Measuring a command with ``time`` now considers the time taken for command substitution (:issue:`9100`).
|
||||
- ``fish_add_path`` now automatically enables verbose mode when used interactively (in the command line), in an effort to be clearer about what it does (:issue:`10532`).
|
||||
- ``fish_add_path`` now automatically enables verbose mode when used interactively (in the commandline), in an effort to be clearer about what it does (:issue:`10532`).
|
||||
- fish no longer adopts TTY modes of failed commands (:issue:`10603`).
|
||||
- ``complete -e cmd`` now prevents autoloading completions for ``cmd`` (:issue:`6716`).
|
||||
- fish's default color scheme no longer uses the color "blue", as it has bad contrast against the background in a few terminal's default palettes (:issue:`10758`, :issue:`10786`)
|
||||
The color scheme will not be upgraded for existing installs. If you want, you should select it again via ``fish_config``.
|
||||
- Command lines which are larger than the terminal are now displayed correctly, instead of multiple blank lines being displayed (:issue:`7296`).
|
||||
- Prompts that use external commands will no longer produce an infinite loop if the command crashes (:issue:`9796`).
|
||||
- The output of ``jobs`` shows "-" for jobs that have the same process group ID as the fish process, rather than "-2" (:issue:`10833`).
|
||||
- Job expansion (``%1`` syntax) works properly for jobs that are a mixture of external commands and functions (:issue:`10832`).
|
||||
- Command lines which have more lines than the terminal can be displayed and edited correctly (:issue:`10827`).
|
||||
- Functions that have been erased are no longer highlighted as valid commands (:issue:`10866`).
|
||||
- ``not``, ``time``, and variable assignments (that is ``not time a=b env``) is correctly recognized as valid syntax (:issue:`10890`).
|
||||
- The Web-based configuration removes old right-hand-side prompts again, fixing a regression in fish 3.4.0 (:issue:`10675`).
|
||||
- Further protection against programs which crash and leave the terminal in an inconsistent state (:issue:`10834`, :issue:`11038`).
|
||||
- A workaround for git being very slow on macOS has been applied, improving performance after a fresh boot (:issue:`10535`).
|
||||
- `complete -e cmd` now prevents autoloading completions for `cmd` (:issue:`6716`).
|
||||
- fish's default colorscheme no longer uses the color "blue" as it has bad contrast against the background in a few terminal's default palettes (:issue:`10758`, :issue:`10786`)
|
||||
The colorscheme will not be upgraded for existing installs. If you want, you should select it again via ``fish_config``.
|
||||
|
||||
New or improved bindings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- When the cursor is on a command that resolves to an executable script, :kbd:`alt-o` will now open that script in your editor (:issue:`10266`).
|
||||
- During up-arrow history search, :kbd:`shift-delete` will delete the current search item and move to the next older item. Previously this was only supported in the history pager.
|
||||
- :kbd:`shift-delete` will also remove the currently-displayed autosuggestion from history, and remove it as a suggestion.
|
||||
- During up-arrow history search, :kbd:`shift-delete` will delete the current search item and move to the next older item. Previously this was only supported in the history pager.
|
||||
Same for autosuggestions.
|
||||
- :kbd:`ctrl-Z` (also known as :kbd:`ctrl-shift-z`) is now bound to redo.
|
||||
- Some improvements to the :kbd:`alt-e` binding which edits the command line in an external editor:
|
||||
|
||||
- :kbd:`alt-delete` now deletes the argument (which may contain quoted spaces) right of the cursor.
|
||||
- Some improvements to the :kbd:`alt-e` binding which edits the commandline in an external editor:
|
||||
- The editor's cursor position is copied back to fish. This is currently supported for Vim and Kakoune.
|
||||
- Cursor position synchronization is only supported for a set of known editors, which are now also detected in aliases which use ``complete --wraps``. For example, use ``complete --wraps my-vim vim`` to synchronize cursors when ``EDITOR=my-vim``.
|
||||
- Cursor position synchronization is only supported for a set of known editors. This has been extended by also resolving aliases. For example use ``complete --wraps my-vim vim`` to synchronize cursors when ``EDITOR=my-vim``.
|
||||
- Multiline commands are indented before being sent to the editor, which matches how they are displayed in fish.
|
||||
- The ``...-path-component`` bindings, like ``backward-kill-path-component``, now treat ``#`` as part of a path component (:issue:`10271`).
|
||||
- The ``*-path-component`` bindings like ``backward-kill-path-component`` now treat ``#`` as part of a path component (:issue:`10271`).
|
||||
- Bindings like :kbd:`alt-l` that print output in between prompts now work correctly with multiline commandlines.
|
||||
- :kbd:`ctrl-c` no longer cancels builtin ``read``.
|
||||
- :kbd:`alt-d` on an empty command line lists the directory history again. This restores the behavior of version 2.1.
|
||||
- ``history-prefix-search-backward`` and ``-forward`` now maintain the cursor position, instead of moving the cursor to the end of the command line (:issue:`10430`).
|
||||
- The following keys have refined behavior if the terminal supports :ref:`the new keyboard encodings <changelog-new-bindings>`:
|
||||
|
||||
- ``history-prefix-search-{backward,forward}`` now maintain the cursor position instead of moving the cursor to the end of the command line (:issue:`10430`).
|
||||
- The :kbd:`E` binding in vi mode now correctly handles the last character of the word, by jumping to the next word (:issue:`9700`).
|
||||
- The following keys have refined behavior if the terminal supports `disambiguating them <https://sw.kovidgoyal.net/kitty/keyboard-protocol/>`_:
|
||||
- :kbd:`shift-enter` now inserts a newline instead of executing the command line.
|
||||
- :kbd:`ctrl-backspace` now deletes the last word instead of only one character (:issue:`10741`).
|
||||
- :kbd:`ctrl-backspace` now deletes the last word instead of only one character.
|
||||
- :kbd:`ctrl-delete` deletes the next word (same as :kbd:`alt-d`).
|
||||
- New special input functions:
|
||||
|
||||
- ``forward-char-passive`` and ``backward-char-passive`` are like their non-passive variants but do not accept autosuggestions or move focus in the completion pager (:issue:`10398`).
|
||||
- ``forward-token``, ``backward-token``, ``kill-token``, and ``backward-kill-token`` are similar to the ``*-bigword`` variants but for the whole argument token (which includes escaped spaces) (:issue:`2014`).
|
||||
- ``clear-commandline``, which merely clears the command line, as an alternative to ``cancel-commandline`` which prints ``^C`` and a new prompt (:issue:`10213`).
|
||||
- The ``accept-autosuggestion`` special input function now returns false when there was nothing to accept (:issue:`10608`).
|
||||
- ``forward-token``, ``backward-token``, ``kill-token``, and ``backward-kill-token`` are similar to the ``*-bigword`` variants but for the whole argument token which includes escaped spaces (:issue:`2014`).
|
||||
- The ``accept-autosuggestion`` special input function now returns false when there was nothing to accept.
|
||||
- Vi mode has seen some improvements but continues to suffer from the lack of people working on it.
|
||||
|
||||
- New default cursor shapes for insert and replace mode.
|
||||
- :kbd:`ctrl-n` in insert mode accepts autosuggestions (:issue:`10339`).
|
||||
- Insert-mode :kbd:`ctrl-n` accepts autosuggestions (:issue:`10339`).
|
||||
- Outside insert mode, the cursor will no longer be placed beyond the last character on the commandline.
|
||||
- When the cursor is at the end of the commandline, a single :kbd:`l` will accept an autosuggestion (:issue:`10286`).
|
||||
- The cursor position after pasting (:kbd:`p`) has been corrected.
|
||||
- Added an additional binding, :kbd:`_`, for moving to the beginning of the line (:issue:`10720`).
|
||||
- When the cursor is at the start of a line, escaping from insert mode no longer moves the cursor to the previous line.
|
||||
- Added bindings for clipboard interaction, like :kbd:`",+,p` and :kbd:`",+,y,y`.
|
||||
- Deleting in visual mode now moves the cursor back, matching vi (:issue:`10394`).
|
||||
- The :kbd:`;`, :kbd:`,`, :kbd:`v`, :kbd:`V`, :kbd:`I`, and :kbd:`gU` bindings work in visual mode (:issue:`10601`, :issue:`10648`).
|
||||
- Support :kbd:`%` motion (:issue:`10593`).
|
||||
- :kbd:`ctrl-k` to remove the contents of the line beyond the cursor in all modes (:issue:`10648`).
|
||||
- Support `ab` and `ib` vi text objects. New input functions are introduced ``jump-{to,till}-matching-bracket`` (:issue:`1842`).
|
||||
- The :kbd:`E` binding now correctly handles the last character of the word, by jumping to the next word (:issue:`9700`).
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
- 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`).
|
||||
- Option completion now uses fuzzy subsequence filtering, just like non-option completion (:issue:`830`).
|
||||
This means that ``--fb`` may be completed to ``--foobar`` if there is no better match.
|
||||
- Completions that insert an entire token now use quotes instead of backslashes to escape special characters (:issue:`5433`).
|
||||
- Normally, file name completions start after the last ``:`` or ``=`` in a token.
|
||||
This helps commands like ``rsync --files-from=``.
|
||||
This special meaning can now disabled by escaping these separators as ``\:`` and ``\=``.
|
||||
This matches Bash's behavior.
|
||||
Note that this escaping is usually not necessary since the completion engine already tries
|
||||
to guess whether the separator is actually part of a file name.
|
||||
- Various new completion scripts and numerous updates to existing ones.
|
||||
- Completions could hang if the ``PAGER`` environment variable was sent to certain editors on macOS, FreeBSD and some other platforms. This has been fixed (:issue:`10820`).
|
||||
- Generated completions are now stored in ``$XDG_CACHE_HOME/fish`` or ``~/.cache/fish`` by default (:issue:`10369`)
|
||||
- A regression in fish 3.1, where completing a command line could change it completely, has been fixed (:issue:`10904`).
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- fish now marks the prompt and command-output regions (via OSC 133) to enable terminal shell integration (:issue:`10352`).
|
||||
- Fish now marks the prompt and command-output regions (via OSC 133) to enable terminal shell integration (:issue:`10352`).
|
||||
Shell integration shortcuts can scroll to the next/previous prompt or show the last command output in a pager.
|
||||
- fish now reports the working directory (via OSC 7) unconditionally instead of only for some terminals (:issue:`9955`).
|
||||
- fish now sets the terminal window title (via OSC 0) unconditionally instead of only for some terminals (:issue:`10037`).
|
||||
- Fish now reports the working directory (via OSC 7) unconditionally instead of only for some terminals (:issue:`9955`).
|
||||
- Fish now sets the terminal window title (via OSC 0) unconditionally instead of only for some terminals (:issue:`10037`).
|
||||
- Focus reporting in tmux is no longer disabled on the first prompt.
|
||||
- Focus reporting is now disabled during commands run inside key bindings (:issue:`6942`).
|
||||
- Cursor changes are applied to all terminals that support them, and the list of specifically-supported terminals has been removed (:issue:`10693`).
|
||||
- If it cannot find the terminfo entry given by :envvar:`TERM` environment variable, fish will now use an included ``xterm-256color`` definition to match the vast majority of current terminal emulators (:issue:`10905`). If you need to have a specific terminfo profile for your terminal's ``TERM`` variable, install it into the terminfo database.
|
||||
- Further improvements to the correct display of prompts which fill the width of the terminal (:issue:`8164`).
|
||||
- Focus reporting is now disabled during execution of bind commands (:issue:`6942`).
|
||||
- ``fish_vi_cursor`` no longer attempts to detect if the terminal is capable, as we can no longer find terminals that aren't and the allowlist was hard to keep up-to-date. (:issue:`10693`)
|
||||
|
||||
Other improvements
|
||||
------------------
|
||||
- ``status`` gained a ``buildinfo`` subcommand, to print information on how fish was built, to help with debugging (:issue:`10896`).
|
||||
- ``fish_indent`` will now collapse multiple empty lines into one (:issue:`10325`).
|
||||
- ``fish_indent`` will now collapse multiple successive empty lines into one (:issue:`10325`).
|
||||
- ``fish_indent`` now preserves the modification time of files if there were no changes (:issue:`10624`).
|
||||
- Performance in launching external processes has been improved for many cases (:issue:`10869`).
|
||||
- Performance and interactivity under Windows Subsystem for Linux has been improved, with a workaround for Windows-specific locations being appended to ``$PATH`` by default (:issue:`10506`).
|
||||
- On macOS, paths from ``/etc/paths`` and ``/etc/manpaths`` containing colons are handled correctly (:issue:`10684`).
|
||||
- Additional filesystems such as AFS are properly detected as remote, which avoids certain hangs due to expensive filesystem locks (:issue:`10818`).
|
||||
- A spurious error when launching multiple instances of fish for the first time has been removed (:issue:`10813`).
|
||||
- The HTML-based configuration UI (``fish_config``) now uses Alpine.js instead of AngularJS (:issue:`9554`).
|
||||
- ``fish_config`` now also works in a Windows MSYS environment (:issue:`10111`).
|
||||
- Performance and interactivity under WSLv1 and WSLv2 has been improved with a workaround for Windows-specific locations being appended to ``$PATH`` by default (:issue:`10506`).
|
||||
|
||||
.. _rust-packaging:
|
||||
|
||||
For distributors
|
||||
----------------
|
||||
|
||||
fish has been ported to Rust. This means a significant change in dependencies, which are listed in the README. In short, Rust 1.70 or greater is required, and a C++ compiler is no longer needed (although a C compiler is still required, for some C glue code and the tests).
|
||||
Fish has been ported to Rust. That means the dependencies have changed.
|
||||
|
||||
CMake remains the recommended build system, because of cargo's limited support for installing support files. Version 3.5 remains the minimum supported version. The Xcode generator for CMake is not supported any longer (:issue:`9924`). CMake builds default to optimized release builds (:issue:`10799`).
|
||||
It now requires Rust 1.70 at least.
|
||||
|
||||
fish no longer depends on the ncurses library, but still uses a terminfo database. When packaging fish, please add a dependency on the package containing your terminfo database instead of curses.
|
||||
CMake remains for now because cargo is unable to install the many asset files that fish needs. The minimum required CMake version has increased to 3.19.
|
||||
|
||||
The ``test`` target was removed as it can no longer be defined in new CMake versions. Use ``make fish_run_tests``. Any existing test target will not print output if it fails (:issue:`11116`).
|
||||
Some smaller changes:
|
||||
|
||||
The Web-based configuration has been rewritten to use Alpine.js (:issue:`9554`).
|
||||
|
||||
--------------
|
||||
|
||||
fish 4.0b1 (released December 17, 2024)
|
||||
=======================================
|
||||
|
||||
A number of improvements were included in fish 4.0.0 following the beta release of 4.0b1. These include fixes for regressions, improvements to completions and documentation, and the removal of a small number of problematic changes.
|
||||
|
||||
The full list of fixed issues can be found on the `GitHub milestone page for 4.0-final <https://github.com/fish-shell/fish-shell/milestone/43>`_.
|
||||
- The default build configuration has changed to "Debug".
|
||||
Please pass ``-DCMAKE_BUILD_TYPE=Release`` if you want to build a package.
|
||||
- Xcode support has been removed (:issue:`9924`).
|
||||
- fish no longer links against the (n)curses library, opting to read the terminfo database via the terminfo crate.
|
||||
This means hashed terminfo databases are no longer supported (from our research, they are basically unmaintained and unused).
|
||||
When packaging fish, please add a dependency on the package containing your terminfo database instead of curses,
|
||||
if such a package is required.
|
||||
If it cannot find a terminfo database, fish will now fall back on an included ``xterm-256color`` definition (:issue:`10269`).
|
||||
|
||||
--------------
|
||||
|
||||
@@ -660,7 +500,7 @@ fish 3.6.0 (released January 7, 2023)
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
- By default, :kbd:`ctrl-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.
|
||||
- Abbreviations are more flexible (:issue:`9313`, :issue:`5003`, :issue:`2287`):
|
||||
- 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
|
||||
@@ -756,7 +596,7 @@ Interactive improvements
|
||||
- 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 interactively.
|
||||
- ``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:`ctrl-\\` (``\x1c``), can now be used as a binding (:issue:`9234`).
|
||||
@@ -985,7 +825,7 @@ Interactive improvements
|
||||
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 preceding the last line. This makes ``dd`` in vi-mode clear the last line properly.
|
||||
- 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-enter` is bound like :kbd:`return` (:issue:`8874`).
|
||||
|
||||
@@ -1094,7 +934,7 @@ Deprecations and removed 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 desirable (:issue:`8214`).
|
||||
- ``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."
|
||||
@@ -1117,7 +957,7 @@ Scripting improvements
|
||||
- ``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 occurring 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`).
|
||||
- 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`).
|
||||
@@ -1623,7 +1463,7 @@ Interactive improvements
|
||||
- :kbd:`ctrl-c` handling has been reimplemented in C++ and is therefore quicker (:issue:`5259`), no longer occasionally prints an "unknown command" error (:issue:`7145`) or overwrites multiline prompts (:issue:`3537`).
|
||||
- :kbd:`ctrl-c` no longer kills background jobs for which job control is
|
||||
disabled, matching POSIX semantics (:issue:`6828`, :issue:`6861`).
|
||||
- Autosuggestions work properly after :kbd:`ctrl-c` cancels the current command line (:issue:`6937`).
|
||||
- Autosuggestions work properly after :kbd:`ctrl-c` cancels the current commmand line (:issue:`6937`).
|
||||
- History search is now case-insensitive unless the search string contains an uppercase character (:issue:`7273`).
|
||||
- ``fish_update_completions`` gained a new ``--keep`` option, which improves speed by skipping completions that already exist (:issue:`6775`, :issue:`6796`).
|
||||
- Aliases containing an embedded backslash appear properly in the output of ``alias`` (:issue:`6910`).
|
||||
@@ -2177,7 +2017,7 @@ Interactive improvements
|
||||
argument.
|
||||
- Syntax highlighting works correctly with variables as commands
|
||||
(:issue:`5658`) and redirections to close file descriptors (:issue:`6092`).
|
||||
- ``help`` works properly on Windows Subsystem for Linux (:issue:`5759`, :issue:`6338`).
|
||||
- ``help`` works properly on Windows Subsytem for Linux (:issue:`5759`, :issue:`6338`).
|
||||
- A bug where ``disown`` could crash the shell has been fixed (:issue:`5720`).
|
||||
- fish will not autosuggest files ending with ``~`` unless there are no
|
||||
other candidates, as these are generally backup files (:issue:`985`).
|
||||
@@ -3119,7 +2959,7 @@ Other significant changes
|
||||
- Some systems’ ``su`` implementations do not set the ``USER``
|
||||
environment variable; it is now reset for root users (:issue:`3916`).
|
||||
- Under terminals which support it, bracketed paste is enabled,
|
||||
escaping problematic characters for security and convenience (:issue:`3871`).
|
||||
escaping problematic characters for security and convience (:issue:`3871`).
|
||||
Inside single quotes (``'``), single quotes and backslashes in pasted
|
||||
text are escaped (:issue:`967`). The ``fish_clipboard_paste`` function (bound
|
||||
to ``C-v`` by default) is still the recommended pasting method where
|
||||
@@ -3248,9 +3088,9 @@ Other significant changes
|
||||
- fish no longer prints a warning when it identifies a running instance
|
||||
of an old version (2.1.0 and earlier). Changes to universal variables
|
||||
may not propagate between these old versions and 2.5b1.
|
||||
- Improved compatibility with Android (:issue:`3585`), MSYS/mingw (:issue:`2360`), and
|
||||
- Improved compatiblity with Android (:issue:`3585`), MSYS/mingw (:issue:`2360`), and
|
||||
Solaris (:issue:`3456`, :issue:`3340`).
|
||||
- Like other shells, the ``test`` built-in now returns an error for
|
||||
- Like other shells, the ``test`` builting now returns an error for
|
||||
numeric operations on invalid integers (:issue:`3346`, :issue:`3581`).
|
||||
- ``complete`` no longer recognises ``--authoritative`` and
|
||||
``--unauthoritative`` options, and they are marked as obsolete.
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
project(fish LANGUAGES C)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
set(DEFAULT_BUILD_TYPE "RelWithDebInfo")
|
||||
set(DEFAULT_BUILD_TYPE "Debug")
|
||||
|
||||
# Generate Xcode schemas (but not for tests).
|
||||
set(CMAKE_XCODE_GENERATE_SCHEME 1)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to default '${DEFAULT_BUILD_TYPE}'")
|
||||
@@ -14,6 +17,7 @@ endif()
|
||||
|
||||
# Set up standard directories.
|
||||
include(GNUInstallDirs)
|
||||
add_definitions(-D_UNICODE=1)
|
||||
|
||||
include(cmake/gettext.cmake)
|
||||
|
||||
@@ -26,6 +30,12 @@ include(cmake/Rust.cmake)
|
||||
# Work around issue where archive-built libs go in the wrong place.
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
set(FISH_IN_TREE_BUILD TRUE)
|
||||
else()
|
||||
set(FISH_IN_TREE_BUILD FALSE)
|
||||
endif()
|
||||
|
||||
# Set up the machinery around FISH-BUILD-VERSION-FILE
|
||||
# This defines the FBVF variable.
|
||||
include(Version)
|
||||
@@ -36,11 +46,6 @@ get_filename_component(REAL_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}" REALPATH)
|
||||
add_definitions(-DCMAKE_BINARY_DIR="${REAL_CMAKE_BINARY_DIR}")
|
||||
add_definitions(-DCMAKE_SOURCE_DIR="${REAL_CMAKE_SOURCE_DIR}")
|
||||
|
||||
set(build_types Release RelWithDebInfo Debug "")
|
||||
if(NOT "${CMAKE_BUILD_TYPE}" IN_LIST build_types)
|
||||
message(WARNING "Unsupported build type ${CMAKE_BUILD_TYPE}. If this doesn't build, try one of Release, RelWithDebInfo or Debug")
|
||||
endif()
|
||||
|
||||
# Define a function to build and link dependencies.
|
||||
function(CREATE_TARGET target)
|
||||
add_custom_target(
|
||||
@@ -51,9 +56,8 @@ function(CREATE_TARGET target)
|
||||
${Rust_CARGO}
|
||||
build --bin ${target}
|
||||
$<$<CONFIG:Release>:--release>
|
||||
$<$<CONFIG:RelWithDebInfo>:--profile=release-with-debug>
|
||||
$<$<CONFIG:RelWithDebInfo>:--release>
|
||||
--target ${Rust_CARGO_TARGET}
|
||||
--no-default-features
|
||||
${CARGO_FLAGS}
|
||||
${FEATURES_ARG}
|
||||
&&
|
||||
@@ -76,6 +80,8 @@ create_target(fish_key_reader)
|
||||
# Set up the docs.
|
||||
include(cmake/Docs.cmake)
|
||||
|
||||
# A helper for running tests.
|
||||
add_executable(fish_test_helper src/fish_test_helper.c)
|
||||
# Set up tests.
|
||||
include(cmake/Tests.cmake)
|
||||
|
||||
|
||||
@@ -126,3 +126,4 @@ enforcement ladder](https://github.com/mozilla/diversity).
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
|
||||
|
||||
@@ -42,15 +42,15 @@ Guidelines
|
||||
|
||||
In short:
|
||||
|
||||
- Be conservative in what you need (keep to the agreed minimum supported Rust version, limit new dependencies)
|
||||
- Use automated tools to help you (including ``make fish_run_tests`` and ``build_tools/style.fish``)
|
||||
- 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 publicly available.
|
||||
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.
|
||||
@@ -101,7 +101,7 @@ To ensure your changes conform to the style rules run
|
||||
|
||||
before committing your change. That will run our autoformatters:
|
||||
|
||||
- ``rustfmt`` for Rust
|
||||
- ``git-clang-format`` for c++
|
||||
- ``fish_indent`` (shipped with fish) for fish script
|
||||
- ``black`` for python
|
||||
|
||||
@@ -196,14 +196,8 @@ The tests can be found in three places:
|
||||
- tests/pexpects for interactive tests using `pexpect <https://pexpect.readthedocs.io/en/stable/>`__
|
||||
|
||||
When in doubt, the bulk of the tests should be added as a littlecheck test in tests/checks, as they are the easiest to modify and run, and much faster and more dependable than pexpect tests. The syntax is fairly self-explanatory. It's a fish script with the expected output in ``# CHECK:`` or ``# CHECKERR:`` (for stderr) comments.
|
||||
If your littlecheck test has a specific dependency, use ``# REQUIRE: ...`` with a posix sh script.
|
||||
|
||||
The pexpects are written in python and can simulate input and output to/from a terminal, so they are needed for anything that needs actual interactivity. The runner is in tests/pexpect_helper.py, in case you need to modify something there.
|
||||
|
||||
These tests can be run via the tests/test_driver.py python script, which will set up the environment.
|
||||
It sets up a temporary $HOME and also uses it as the current directory, so you do not need to create a temporary directory in them.
|
||||
|
||||
If you need a command to do something weird to test something, maybe add it to the ``fish_test_helper`` binary (in tests/fish_test_helper.c), or see if it can already do it.
|
||||
The pexpects are written in python and can simulate input and output to/from a terminal, so they are needed for anything that needs actual interactivity. The runner is in build_tools/pexpect_helper.py, in case you need to modify something there.
|
||||
|
||||
Local testing
|
||||
-------------
|
||||
@@ -213,18 +207,7 @@ The tests can be run on your local computer on all operating systems.
|
||||
::
|
||||
|
||||
cmake path/to/fish-shell
|
||||
make fish_run_tests
|
||||
|
||||
Or you can run them on a fish, without involving cmake::
|
||||
|
||||
cargo build
|
||||
cargo test # for the unit tests
|
||||
tests/test_driver.py --cachedir=/tmp target/debug # for the script and interactive tests
|
||||
|
||||
Here, the first argument to test_driver.py refers to a directory with ``fish``, ``fish_indent`` and ``fish_key_reader`` in it.
|
||||
In this example we're in the root of the git repo and have run ``cargo build`` without ``--release``, so it's a debug build.
|
||||
The ``--cachedir /tmp`` argument means it will keep the fish_test_helper binary in /tmp instead of recompiling it for every test.
|
||||
This saves some time, but isn't strictly necessary.
|
||||
make test
|
||||
|
||||
Git hooks
|
||||
---------
|
||||
@@ -252,7 +235,7 @@ One possibility is a pre-push hook script like this one:
|
||||
done
|
||||
if [ "x$isprotected" = x1 ]; then
|
||||
echo "Running tests before push to master"
|
||||
make fish_run_tests
|
||||
make test
|
||||
RESULT=$?
|
||||
if [ $RESULT -ne 0 ]; then
|
||||
echo "Tests failed for a push to master, we can't let you do that" >&2
|
||||
@@ -262,7 +245,7 @@ One possibility is a pre-push hook script like this one:
|
||||
exit 0
|
||||
|
||||
This will check if the push is to the master branch and, if it is, only
|
||||
allow the push if running ``make fish_run_tests`` succeeds. In some circumstances
|
||||
allow the push if running ``make test`` succeeds. In some circumstances
|
||||
it may be advisable to circumvent this check with
|
||||
``git push --no-verify``, but usually that isn’t necessary.
|
||||
|
||||
@@ -339,12 +322,12 @@ Setting Code Up For Translations
|
||||
--------------------------------
|
||||
|
||||
All non-debug messages output for user consumption should be marked for
|
||||
translation. In Rust, this requires the use of the ``wgettext!`` or ``wgettext_fmt!``
|
||||
macros:
|
||||
translation. In C++, this requires the use of the ``_`` (underscore)
|
||||
macro:
|
||||
|
||||
::
|
||||
|
||||
streams.out.append(wgettext_fmt!("%ls: There are no jobs\n", argv[0]));
|
||||
streams.out.append_format(_(L"%ls: There are no jobs\n"), argv[0]);
|
||||
|
||||
All messages in fish script must be enclosed in single or double quote
|
||||
characters for our message extraction script to find them.
|
||||
|
||||
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- fish-shell contributors
|
||||
Copyright (C) 2009-2024 fish-shell contributors
|
||||
|
||||
fish is free software.
|
||||
|
||||
|
||||
279
Cargo.lock
generated
279
Cargo.lock
generated
@@ -4,9 +4,9 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
version = "0.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
@@ -20,20 +20,11 @@ version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.7"
|
||||
version = "1.1.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7"
|
||||
checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
@@ -53,32 +44,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.16"
|
||||
name = "dashmap"
|
||||
version = "5.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3"
|
||||
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
"cfg-if",
|
||||
"hashbrown 0.14.5",
|
||||
"lock_api",
|
||||
"once_cell",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -89,9 +64,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.10"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
@@ -99,12 +74,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fish"
|
||||
version = "4.1.0-alpha0"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"errno",
|
||||
"fish-printf",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"lru",
|
||||
"nix",
|
||||
@@ -114,10 +90,8 @@ dependencies = [
|
||||
"portable-atomic",
|
||||
"rand",
|
||||
"rsconf",
|
||||
"rust-embed",
|
||||
"serial_test",
|
||||
"terminfo",
|
||||
"unix_path",
|
||||
"widestring",
|
||||
]
|
||||
|
||||
@@ -137,25 +111,21 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.4"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.2"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
@@ -172,10 +142,16 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.169"
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.159"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
@@ -195,11 +171,11 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.13.0"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465"
|
||||
checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38"
|
||||
dependencies = [
|
||||
"hashbrown",
|
||||
"hashbrown 0.15.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -296,18 +272,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.11.3"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
|
||||
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_codegen"
|
||||
version = "0.11.3"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a"
|
||||
checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_shared",
|
||||
@@ -315,9 +291,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.11.3"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
|
||||
checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
"rand",
|
||||
@@ -325,9 +301,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.11.3"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
|
||||
checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b"
|
||||
dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
@@ -340,24 +316,24 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.10.0"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
|
||||
checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.92"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.38"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -379,9 +355,9 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.8"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
|
||||
checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
@@ -395,104 +371,35 @@ dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed"
|
||||
version = "8.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa66af4a4fdd5e7ebc276f115e895611a34739a9c1c01028383d612d550953c0"
|
||||
dependencies = [
|
||||
"rust-embed-impl",
|
||||
"rust-embed-utils",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed-impl"
|
||||
version = "8.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6125dbc8867951125eec87294137f4e9c2c96566e61bf72c45095a7c77761478"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rust-embed-utils",
|
||||
"syn",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-embed-utils"
|
||||
version = "8.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e5347777e9aacb56039b0e1f28785929a8a3b709e87482e7442c72e7c12529d"
|
||||
dependencies = [
|
||||
"sha2",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scc"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28e1c91382686d21b5ac7959341fcb9780fa7c03773646995a87c950fa7be640"
|
||||
dependencies = [
|
||||
"sdd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "sdd"
|
||||
version = "3.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9"
|
||||
|
||||
[[package]]
|
||||
name = "serial_test"
|
||||
version = "3.2.0"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9"
|
||||
checksum = "538c30747ae860d6fb88330addbbd3e0ddbe46d662d032855596d8a8ca260611"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"dashmap",
|
||||
"lazy_static",
|
||||
"parking_lot",
|
||||
"scc",
|
||||
"serial_test_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test_derive"
|
||||
version = "3.2.0"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef"
|
||||
checksum = "079a83df15f85d89a68d64ae1238f142f172b1fa915d0d76b26a7cba1b659a69"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
@@ -501,9 +408,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "1.0.1"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
|
||||
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
@@ -513,9 +420,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.95"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -534,69 +441,23 @@ dependencies = [
|
||||
"phf_codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.14"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "unix_path"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af8e291873ae77c4c8d9c9b34d0bee68a35b048fb39c263a5155e0e353783eaf"
|
||||
dependencies = [
|
||||
"unix_str",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unix_str"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ace0b4755d0a2959962769239d56267f8a024fef2d9b32666b3dcd0946b0906"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
]
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
|
||||
[[package]]
|
||||
name = "widestring"
|
||||
version = "1.2.0"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
31
Cargo.toml
31
Cargo.toml
@@ -3,21 +3,15 @@ resolver = "2"
|
||||
members = ["printf"]
|
||||
|
||||
[workspace.package]
|
||||
# To build revisions that use Corrosion (those before 2024-01), use CMake 3.19, Rustc 1.78 and Rustup 1.27.
|
||||
rust-version = "1.70"
|
||||
edition = "2021"
|
||||
|
||||
[profile.release]
|
||||
overflow-checks = true
|
||||
lto = true
|
||||
|
||||
[profile.release-with-debug]
|
||||
inherits = "release"
|
||||
debug = true
|
||||
|
||||
[package]
|
||||
name = "fish"
|
||||
version = "4.1.0-alpha0"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
default-run = "fish"
|
||||
@@ -35,11 +29,12 @@ pcre2 = { git = "https://github.com/fish-shell/rust-pcre2", tag = "0.2.9-utf32",
|
||||
|
||||
bitflags = "2.5.0"
|
||||
errno = "0.3.0"
|
||||
libc = "0.2"
|
||||
lazy_static = "1.4.0"
|
||||
libc = "0.2.155"
|
||||
# lru pulls in hashbrown by default, which uses a faster (though less DoS resistant) hashing algo.
|
||||
# disabling default features uses the stdlib instead, but it doubles the time to rewrite the history
|
||||
# files as of 22 April 2024.
|
||||
lru = "0.13.0"
|
||||
lru = "0.12.3"
|
||||
nix = { version = "0.29.0", default-features = false, features = [
|
||||
"event",
|
||||
"inotify",
|
||||
@@ -54,10 +49,9 @@ fish-printf = { path = "./printf", features = ["widestring"] }
|
||||
# available on macOS < 10.12. We can enable "getrandom" when we raise the
|
||||
# minimum supported version to 10.12.
|
||||
rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }
|
||||
widestring = "1.2.0"
|
||||
widestring = "1.1.0"
|
||||
# We need 0.9.0 specifically for some crash fixes.
|
||||
terminfo = "0.9.0"
|
||||
rust-embed = { version = "8.2.0", optional = true }
|
||||
|
||||
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||
portable-atomic = { version = "1", default-features = false, features = [
|
||||
@@ -65,15 +59,12 @@ portable-atomic = { version = "1", default-features = false, features = [
|
||||
] }
|
||||
|
||||
[dev-dependencies]
|
||||
serial_test = { version = "3", default-features = false }
|
||||
serial_test = { version = "1.0.0", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0.94"
|
||||
rsconf = "0.2.2"
|
||||
|
||||
[target.'cfg(windows)'.build-dependencies]
|
||||
unix_path = "1.0.1"
|
||||
|
||||
[lib]
|
||||
crate-type = ["rlib"]
|
||||
path = "src/lib.rs"
|
||||
@@ -91,9 +82,8 @@ name = "fish_key_reader"
|
||||
path = "src/bin/fish_key_reader.rs"
|
||||
|
||||
[features]
|
||||
default = ["embed-data"]
|
||||
default = []
|
||||
benchmark = []
|
||||
embed-data = ["dep:rust-embed"]
|
||||
|
||||
# The following features are auto-detected by the build-script and should not be enabled manually.
|
||||
asan = []
|
||||
@@ -106,10 +96,3 @@ rust.unknown_lints = "allow"
|
||||
rust.unstable_name_collisions = "allow"
|
||||
clippy.manual_range_contains = "allow"
|
||||
clippy.needless_return = "allow"
|
||||
clippy.needless_lifetimes = "allow"
|
||||
|
||||
# We do not want to use the e?print(ln)?! macros.
|
||||
# These lints flag their use.
|
||||
# In the future, they might change to flag other methods of printing.
|
||||
clippy.print_stdout = "deny"
|
||||
clippy.print_stderr = "deny"
|
||||
|
||||
@@ -16,3 +16,4 @@ WORKDIR /src
|
||||
RUN cmake3 . &&\
|
||||
make &&\
|
||||
make install
|
||||
|
||||
|
||||
@@ -55,11 +55,7 @@ clean:
|
||||
|
||||
.PHONY: test
|
||||
test: build/fish
|
||||
$(CMAKE) --build build --target fish_run_tests
|
||||
|
||||
.PHONY: fish_run_tests
|
||||
fish_run_tests: build/fish
|
||||
$(CMAKE) --build build --target fish_run_tests
|
||||
$(CMAKE) --build build --target test
|
||||
|
||||
.PHONY: install
|
||||
install: build/fish
|
||||
|
||||
85
README.rst
85
README.rst
@@ -47,12 +47,12 @@ Linux/CentOS are available from the `openSUSE Build
|
||||
Service <https://software.opensuse.org/download.html?project=shells%3Afish&package=fish>`__.
|
||||
|
||||
Packages for Ubuntu are available from the `fish
|
||||
PPA <https://launchpad.net/~fish-shell/+archive/ubuntu/release-4>`__,
|
||||
PPA <https://launchpad.net/~fish-shell/+archive/ubuntu/release-3>`__,
|
||||
and can be installed using the following commands:
|
||||
|
||||
::
|
||||
|
||||
sudo apt-add-repository ppa:fish-shell/release-4
|
||||
sudo apt-add-repository ppa:fish-shell/release-3
|
||||
sudo apt update
|
||||
sudo apt install fish
|
||||
|
||||
@@ -66,7 +66,8 @@ Windows
|
||||
for Linux with the instructions for the appropriate distribution
|
||||
listed above under “Packages for Linux”, or from source with the
|
||||
instructions below.
|
||||
- fish (4.0 on and onwards) cannot be installed in Cygwin, due to a lack of Rust support.
|
||||
- Fish can also be installed on all versions of Windows using
|
||||
`Cygwin <https://cygwin.com/>`__ (from the **Shells** category).
|
||||
|
||||
Building from source
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -75,7 +76,7 @@ If packages are not available for your platform, GPG-signed tarballs are
|
||||
available from `fishshell.com <https://fishshell.com/>`__ and
|
||||
`fish-shell on
|
||||
GitHub <https://github.com/fish-shell/fish-shell/releases>`__. See the
|
||||
`Building <#building>`_ section for instructions.
|
||||
`Building <#building>`__ section for instructions.
|
||||
|
||||
Running fish
|
||||
------------
|
||||
@@ -87,6 +88,8 @@ Dependencies
|
||||
|
||||
Running fish requires:
|
||||
|
||||
- A terminfo database, typically from curses or ncurses (preinstalled on most \*nix systems) - this needs to be the directory tree format, not the "hashed" database.
|
||||
If this is unavailable, fish uses an included xterm-256color definition.
|
||||
- some common \*nix system utilities (currently ``mktemp``), in
|
||||
addition to the basic POSIX utilities (``cat``, ``cut``, ``dirname``,
|
||||
``file``, ``ls``, ``mkdir``, ``mkfifo``, ``rm``, ``sort``, ``tee``, ``tr``,
|
||||
@@ -118,27 +121,33 @@ Building
|
||||
Dependencies
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Compiling fish requires:
|
||||
Compiling fish from a tarball requires:
|
||||
|
||||
- a C++11 compiler (g++ 4.8 or later, or clang 3.3 or later)
|
||||
- CMake (version 3.5 or later)
|
||||
- PCRE2 (headers and libraries) - optional, this will be downloaded if missing
|
||||
- gettext (headers and libraries) - optional, for translation support
|
||||
|
||||
Sphinx is also optionally required to build the documentation from a
|
||||
cloned git repository.
|
||||
|
||||
Additionally, running the test suite requires Python 3.5+ and the pexpect package.
|
||||
|
||||
Dependencies, git master
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Building from git master currently requires:
|
||||
|
||||
- Rust (version 1.70 or later)
|
||||
- CMake (version 3.15 or later)
|
||||
- CMake (version 3.19 or later)
|
||||
- a C compiler (for system feature detection and the test helper binary)
|
||||
- PCRE2 (headers and libraries) - optional, this will be downloaded if missing
|
||||
- gettext (headers and libraries) - optional, for translation support
|
||||
- an Internet connection, as other dependencies will be downloaded automatically
|
||||
|
||||
Sphinx is also optionally required to build the documentation from a
|
||||
cloned git repository.
|
||||
|
||||
Additionally, running the full test suite requires Python 3, tmux, and the pexpect package.
|
||||
|
||||
Building from source with CMake
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Rather than building from source, consider using a packaged build for your platform. Using the
|
||||
steps below makes fish difficult to uninstall or upgrade. Release packages are available from the
|
||||
links above, and up-to-date `development builds of fish are available for many platforms
|
||||
<https://github.com/fish-shell/fish-shell/wiki/Development-builds>`__
|
||||
Building from source (all platforms) - Makefile generator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To install into ``/usr/local``, run:
|
||||
|
||||
@@ -146,53 +155,35 @@ To install into ``/usr/local``, run:
|
||||
|
||||
mkdir build; cd build
|
||||
cmake ..
|
||||
cmake --build .
|
||||
sudo cmake --install .
|
||||
make
|
||||
sudo make install
|
||||
|
||||
The install directory can be changed using the
|
||||
``-DCMAKE_INSTALL_PREFIX`` parameter for ``cmake``.
|
||||
|
||||
CMake Build options
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
Build options
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
In addition to the normal CMake build options (like ``CMAKE_INSTALL_PREFIX``), fish's CMake build has some other options available to customize it.
|
||||
In addition to the normal CMake build options (like ``CMAKE_INSTALL_PREFIX``), fish has some other options available to customize it.
|
||||
|
||||
- Rust_COMPILER=path - the path to rustc. If not set, cmake will check $PATH and ~/.cargo/bin
|
||||
- Rust_CARGO=path - the path to cargo. If not set, cmake will check $PATH and ~/.cargo/bin
|
||||
- Rust_CARGO_TARGET=target - the target to pass to cargo. Set this for cross-compilation.
|
||||
- BUILD_DOCS=ON|OFF - whether to build the documentation. This is automatically set to OFF when Sphinx isn't installed.
|
||||
- INSTALL_DOCS=ON|OFF - whether to install the docs. This is automatically set to on when BUILD_DOCS is or prebuilt documentation is available (like when building in-tree from a tarball).
|
||||
- FISH_USE_SYSTEM_PCRE2=ON|OFF - whether to use an installed pcre2. This is normally autodetected.
|
||||
- MAC_CODESIGN_ID=String|OFF - the codesign ID to use on Mac, or "OFF" to disable codesigning.
|
||||
- WITH_GETTEXT=ON|OFF - whether to build with gettext support for translations.
|
||||
- extra_functionsdir, extra_completionsdir and extra_confdir - to compile in an additional directory to be searched for functions, completions and configuration snippets
|
||||
|
||||
Building fish with embedded data (experimental)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Note that fish does *not* support static linking and will attempt to error out if it detects it.
|
||||
|
||||
You can also build fish with the data files embedded.
|
||||
Help, it didn’t build!
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This will include all the datafiles like the included functions or web configuration tool in the main ``fish`` binary.
|
||||
On Debian or Ubuntu you want these packages:
|
||||
|
||||
Fish will then read these right from its own binary, and print them out when needed. Some files, like the webconfig tool and the manpage completion generator, will be extracted to a temporary directory on-demand. You can list the files with ``status list-files`` and print one with ``status get-file path/to/file`` (e.g. ``status get-file functions/fish_prompt.fish`` to get the default prompt).
|
||||
::
|
||||
|
||||
To install fish with embedded files, just use ``cargo``, like::
|
||||
sudo apt install build-essential cmake libpcre2-dev gettext
|
||||
|
||||
cargo install --path /path/to/fish # if you have a git clone
|
||||
cargo install --git https://github.com/fish-shell/fish-shell --tag 4.0.0 # to build from git with a specific version
|
||||
cargo install --git https://github.com/fish-shell/fish-shell # to build the current development snapshot without cloning
|
||||
|
||||
This will place the binaries in ``~/.cargo/bin/``, but you can place them wherever you want.
|
||||
|
||||
This build won't have the HTML docs (``help`` will open the online version) or translations.
|
||||
|
||||
It will try to build the man pages with sphinx-build. If that is not available and you would like to include man pages, you need to install it and retrigger the build script, e.g. by setting FISH_BUILD_DOCS=1::
|
||||
|
||||
FISH_BUILD_DOCS=1 cargo install --path .
|
||||
|
||||
Setting it to "0" disables the inclusion of man pages.
|
||||
|
||||
You can also link this build statically (but not against glibc) and move it to other computers.
|
||||
On RedHat, CentOS, or Amazon EC2 everything should be preinstalled.
|
||||
|
||||
Contributing Changes to the Code
|
||||
--------------------------------
|
||||
|
||||
@@ -8,4 +8,5 @@ for file in *.fish
|
||||
echo FAILING FILE $file
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$#" -gt 2 ] || [ "$#" -eq 0 ]; then
|
||||
if [ "$#" -gt 2 -o "$#" -eq 0 ]; then
|
||||
echo "Usage: driver.sh /path/to/fish [/path/to/other/fish]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
213
build.rs
213
build.rs
@@ -3,7 +3,7 @@
|
||||
use rsconf::{LinkType, Target};
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
fn main() {
|
||||
setup_paths();
|
||||
@@ -29,40 +29,14 @@ fn main() {
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
// Some build info
|
||||
rsconf::set_env_value("BUILD_TARGET_TRIPLE", &env::var("TARGET").unwrap());
|
||||
rsconf::set_env_value("BUILD_HOST_TRIPLE", &env::var("HOST").unwrap());
|
||||
rsconf::set_env_value("BUILD_PROFILE", &env::var("PROFILE").unwrap());
|
||||
|
||||
let version = &get_version(&env::current_dir().unwrap());
|
||||
// Per https://doc.rust-lang.org/cargo/reference/build-scripts.html#inputs-to-the-build-script,
|
||||
// the source directory is the current working directory of the build script
|
||||
rsconf::set_env_value("FISH_BUILD_VERSION", version);
|
||||
|
||||
std::env::set_var("FISH_BUILD_VERSION", version);
|
||||
|
||||
let cman = std::fs::canonicalize(env!("CARGO_MANIFEST_DIR")).unwrap();
|
||||
let targetman = cman.as_path().join("target").join("man");
|
||||
|
||||
#[cfg(feature = "embed-data")]
|
||||
#[cfg(not(clippy))]
|
||||
{
|
||||
build_man(&targetman);
|
||||
}
|
||||
#[cfg(any(not(feature = "embed-data"), clippy))]
|
||||
{
|
||||
let sec1dir = targetman.join("man1");
|
||||
let _ = std::fs::create_dir_all(sec1dir.to_str().unwrap());
|
||||
}
|
||||
|
||||
rsconf::rebuild_if_paths_changed(&["src", "printf", "Cargo.toml", "Cargo.lock", "build.rs"]);
|
||||
|
||||
// These are necessary if built with embedded functions,
|
||||
// but only in release builds (because rust-embed in debug builds reads from the filesystem).
|
||||
#[cfg(feature = "embed-data")]
|
||||
#[cfg(not(debug_assertions))]
|
||||
rsconf::rebuild_if_paths_changed(&["doc_src", "share"]);
|
||||
rsconf::set_env_value(
|
||||
"FISH_BUILD_VERSION",
|
||||
&get_version(&env::current_dir().unwrap()),
|
||||
);
|
||||
|
||||
rsconf::rebuild_if_path_changed("src/libc.c");
|
||||
cc::Build::new()
|
||||
.file("src/libc.c")
|
||||
.include(build_dir)
|
||||
@@ -102,9 +76,7 @@ fn detect_cfgs(target: &mut Target) {
|
||||
"",
|
||||
&(|_: &Target| Ok(false)) as &dyn Fn(&Target) -> Result<bool, Box<dyn Error>>,
|
||||
),
|
||||
("apple", &detect_apple),
|
||||
("bsd", &detect_bsd),
|
||||
("cygwin", &detect_cygwin),
|
||||
("gettext", &have_gettext),
|
||||
("small_main_stack", &has_small_stack),
|
||||
// See if libc supports the thread-safe localeconv_l(3) alternative to localeconv(3).
|
||||
@@ -139,15 +111,6 @@ fn detect_cfgs(target: &mut Target) {
|
||||
}
|
||||
}
|
||||
|
||||
fn detect_apple(_: &Target) -> Result<bool, Box<dyn Error>> {
|
||||
Ok(cfg!(any(target_os = "ios", target_os = "macos")))
|
||||
}
|
||||
|
||||
#[allow(unexpected_cfgs)]
|
||||
fn detect_cygwin(_: &Target) -> Result<bool, Box<dyn Error>> {
|
||||
Ok(cfg!(target_os = "cygwin"))
|
||||
}
|
||||
|
||||
/// Detect if we're being compiled for a BSD-derived OS, allowing targeting code conditionally with
|
||||
/// `#[cfg(bsd)]`.
|
||||
///
|
||||
@@ -224,14 +187,14 @@ fn have_gettext(target: &Target) -> Result<bool, Box<dyn Error>> {
|
||||
/// 0.5 MiB is small enough that we'd have to drastically reduce MAX_STACK_DEPTH to less than 10, so
|
||||
/// we instead use a workaround to increase the main thread size.
|
||||
fn has_small_stack(_: &Target) -> Result<bool, Box<dyn Error>> {
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "netbsd")))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "netbsd")))]
|
||||
return Ok(false);
|
||||
|
||||
// NetBSD 10 also needs this but can't find pthread_get_stacksize_np.
|
||||
#[cfg(target_os = "netbsd")]
|
||||
return Ok(true);
|
||||
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
use core::ffi;
|
||||
|
||||
@@ -252,12 +215,7 @@ fn has_small_stack(_: &Target) -> Result<bool, Box<dyn Error>> {
|
||||
}
|
||||
|
||||
fn setup_paths() {
|
||||
#[cfg(unix)]
|
||||
use std::path::PathBuf;
|
||||
#[cfg(windows)]
|
||||
use unix_path::{Path, PathBuf};
|
||||
|
||||
fn get_path(name: &str, default: &str, onvar: &Path) -> PathBuf {
|
||||
fn get_path(name: &str, default: &str, onvar: PathBuf) -> PathBuf {
|
||||
let mut var = PathBuf::from(env::var(name).unwrap_or(default.to_string()));
|
||||
if var.is_relative() {
|
||||
var = onvar.join(var);
|
||||
@@ -265,51 +223,30 @@ fn get_path(name: &str, default: &str, onvar: &Path) -> PathBuf {
|
||||
var
|
||||
}
|
||||
|
||||
let (prefix_from_home, prefix) = if let Ok(pre) = env::var("PREFIX") {
|
||||
(false, PathBuf::from(pre))
|
||||
} else {
|
||||
(true, PathBuf::from(".local/"))
|
||||
};
|
||||
|
||||
// If someone gives us a $PREFIX, we need it to be absolute.
|
||||
// Otherwise we would try to get it from $HOME and that won't really work.
|
||||
if !prefix_from_home && prefix.is_relative() {
|
||||
let prefix = PathBuf::from(env::var("PREFIX").unwrap_or("/usr/local".to_string()));
|
||||
if prefix.is_relative() {
|
||||
panic!("Can't have relative prefix");
|
||||
}
|
||||
|
||||
rsconf::rebuild_if_env_changed("PREFIX");
|
||||
rsconf::set_env_value("PREFIX", prefix.to_str().unwrap());
|
||||
|
||||
let datadir = get_path("DATADIR", "share/", &prefix);
|
||||
let datadir = get_path("DATADIR", "share/", prefix.clone());
|
||||
rsconf::set_env_value("DATADIR", datadir.to_str().unwrap());
|
||||
rsconf::rebuild_if_env_changed("DATADIR");
|
||||
|
||||
let datadir_subdir = if prefix_from_home {
|
||||
"fish/install"
|
||||
} else {
|
||||
"fish"
|
||||
};
|
||||
rsconf::set_env_value("DATADIR_SUBDIR", datadir_subdir);
|
||||
|
||||
let bindir = get_path("BINDIR", "bin/", &prefix);
|
||||
let bindir = get_path("BINDIR", "bin/", prefix.clone());
|
||||
rsconf::set_env_value("BINDIR", bindir.to_str().unwrap());
|
||||
rsconf::rebuild_if_env_changed("BINDIR");
|
||||
|
||||
let sysconfdir = get_path(
|
||||
"SYSCONFDIR",
|
||||
// If we get our prefix from $HOME, we should use the system's /etc/
|
||||
// ~/.local/share/etc/ makes no sense
|
||||
if prefix_from_home { "/etc/" } else { "etc/" },
|
||||
&datadir,
|
||||
);
|
||||
let sysconfdir = get_path("SYSCONFDIR", "etc/", datadir.clone());
|
||||
rsconf::set_env_value("SYSCONFDIR", sysconfdir.to_str().unwrap());
|
||||
rsconf::rebuild_if_env_changed("SYSCONFDIR");
|
||||
|
||||
let localedir = get_path("LOCALEDIR", "locale/", &datadir);
|
||||
let localedir = get_path("LOCALEDIR", "locale/", datadir.clone());
|
||||
rsconf::set_env_value("LOCALEDIR", localedir.to_str().unwrap());
|
||||
rsconf::rebuild_if_env_changed("LOCALEDIR");
|
||||
|
||||
let docdir = get_path("DOCDIR", "doc/fish", &datadir);
|
||||
let docdir = get_path("DOCDIR", "doc/fish", datadir.clone());
|
||||
rsconf::set_env_value("DOCDIR", docdir.to_str().unwrap());
|
||||
rsconf::rebuild_if_env_changed("DOCDIR");
|
||||
}
|
||||
@@ -322,7 +259,7 @@ fn get_version(src_dir: &Path) -> String {
|
||||
return var;
|
||||
}
|
||||
|
||||
let path = src_dir.join("version");
|
||||
let path = PathBuf::from(src_dir).join("version");
|
||||
if let Ok(strver) = read_to_string(path) {
|
||||
return strver.to_string();
|
||||
}
|
||||
@@ -333,7 +270,7 @@ fn get_version(src_dir: &Path) -> String {
|
||||
if !rev.is_empty() {
|
||||
// If it contains a ".", we have a proper version like "3.7",
|
||||
// or "23.2.1-1234-gfab1234"
|
||||
if rev.contains('.') {
|
||||
if rev.contains(".") {
|
||||
return rev;
|
||||
}
|
||||
// If it doesn't, we probably got *just* the commit SHA,
|
||||
@@ -346,117 +283,7 @@ fn get_version(src_dir: &Path) -> String {
|
||||
return version + "-g" + &rev;
|
||||
}
|
||||
}
|
||||
// TODO: Do we just use the cargo version here?
|
||||
|
||||
// git did not tell us a SHA either because it isn't installed,
|
||||
// or because it refused (safe.directory applies to `git describe`!)
|
||||
// So we read the SHA ourselves.
|
||||
fn get_git_hash() -> Result<String, Box<dyn std::error::Error>> {
|
||||
let gitdir = Path::new(env!("CARGO_MANIFEST_DIR")).join(".git");
|
||||
let jjdir = Path::new(env!("CARGO_MANIFEST_DIR")).join(".jj");
|
||||
let commit_id = if gitdir.exists() {
|
||||
// .git/HEAD contains ref: refs/heads/branch
|
||||
let headpath = gitdir.join("HEAD");
|
||||
let headstr = read_to_string(headpath)?;
|
||||
let headref = headstr.split(' ').nth(1).unwrap().trim();
|
||||
|
||||
// .git/refs/heads/branch contains the SHA
|
||||
let refpath = gitdir.join(headref);
|
||||
// Shorten to 9 characters (what git describe does currently)
|
||||
read_to_string(refpath)?
|
||||
} else if jjdir.exists() {
|
||||
let output = Command::new("jj")
|
||||
.args([
|
||||
"log",
|
||||
"--revisions",
|
||||
"@",
|
||||
"--no-graph",
|
||||
"--ignore-working-copy",
|
||||
"--template",
|
||||
"commit_id",
|
||||
])
|
||||
.output()
|
||||
.unwrap();
|
||||
String::from_utf8_lossy(&output.stdout).to_string()
|
||||
} else {
|
||||
return Err("did not find either of .git or .jj".into());
|
||||
};
|
||||
let refstr = &commit_id[0..9];
|
||||
let refstr = refstr.trim();
|
||||
|
||||
let version = env!("CARGO_PKG_VERSION").to_owned();
|
||||
Ok(version + "-g" + refstr)
|
||||
}
|
||||
|
||||
get_git_hash().expect("Could not get a version. Either set $FISH_BUILD_VERSION or install git.")
|
||||
}
|
||||
|
||||
#[cfg(feature = "embed-data")]
|
||||
// disable clippy because otherwise it would panic without sphinx
|
||||
#[cfg(not(clippy))]
|
||||
fn build_man(build_dir: &Path) {
|
||||
use std::process::Command;
|
||||
let mandir = build_dir;
|
||||
let sec1dir = mandir.join("man1");
|
||||
let docsrc_path = std::fs::canonicalize(env!("CARGO_MANIFEST_DIR"))
|
||||
.unwrap()
|
||||
.as_path()
|
||||
.join("doc_src");
|
||||
let docsrc = docsrc_path.to_str().unwrap();
|
||||
let args = &[
|
||||
"-j",
|
||||
"auto",
|
||||
"-q",
|
||||
"-b",
|
||||
"man",
|
||||
"-c",
|
||||
docsrc,
|
||||
// doctree path - put this *above* the man1 dir to exclude it.
|
||||
// this is ~6M
|
||||
"-d",
|
||||
mandir.to_str().unwrap(),
|
||||
docsrc,
|
||||
sec1dir.to_str().unwrap(),
|
||||
];
|
||||
let _ = std::fs::create_dir_all(sec1dir.to_str().unwrap());
|
||||
|
||||
rsconf::rebuild_if_env_changed("FISH_BUILD_DOCS");
|
||||
if env::var("FISH_BUILD_DOCS") == Ok("0".to_string()) {
|
||||
println!("cargo:warning=Skipping man pages because $FISH_BUILD_DOCS is set to 0");
|
||||
return;
|
||||
}
|
||||
|
||||
// We run sphinx to build the man pages.
|
||||
// Every error here is fatal so cargo doesn't cache the result
|
||||
// - if we skipped the docs with sphinx not installed, installing it would not then build the docs.
|
||||
// That means you need to explicitly set $FISH_BUILD_DOCS=0 (`FISH_BUILD_DOCS=0 cargo install --path .`),
|
||||
// which is unfortunate - but the docs are pretty important because they're also used for --help.
|
||||
match Command::new("sphinx-build").args(args).spawn() {
|
||||
Err(x) if x.kind() == std::io::ErrorKind::NotFound => {
|
||||
if env::var("FISH_BUILD_DOCS") == Ok("1".to_string()) {
|
||||
panic!("Could not find sphinx-build to build man pages.\nInstall sphinx or disable building the docs by setting $FISH_BUILD_DOCS=0.");
|
||||
}
|
||||
println!("cargo:warning=Cannot find sphinx-build to build man pages.");
|
||||
println!("cargo:warning=If you install it now you need to run `cargo clean` and rebuild, or set $FISH_BUILD_DOCS=1 explicitly.");
|
||||
}
|
||||
Err(x) => {
|
||||
// Another error - permissions wrong etc
|
||||
panic!("Error starting sphinx-build to build man pages: {:?}", x);
|
||||
}
|
||||
Ok(mut x) => match x.wait() {
|
||||
Err(err) => {
|
||||
panic!(
|
||||
"Error waiting for sphinx-build to build man pages: {:?}",
|
||||
err
|
||||
);
|
||||
}
|
||||
Ok(out) => {
|
||||
if out.success() {
|
||||
// Success!
|
||||
return;
|
||||
} else {
|
||||
panic!("sphinx-build failed to build the man pages.");
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
"unknown".to_string()
|
||||
}
|
||||
|
||||
@@ -47,24 +47,24 @@ 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
|
||||
date +%s > ${OUTPUT_DIR}fish-build-version-witness.txt
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -r "$FBVF"
|
||||
then
|
||||
VC=$(cat "$FBVF")
|
||||
VC=$(grep -v '^#' "$FBVF" | tr -d '"' | sed -e 's/^FISH_BUILD_VERSION=//')
|
||||
else
|
||||
VC="unset"
|
||||
fi
|
||||
|
||||
# Maybe output the FBVF
|
||||
# It looks like "2.7.1-621-ga2f065e6"
|
||||
# It looks like FISH_BUILD_VERSION="2.7.1-621-ga2f065e6"
|
||||
test "$VN" = "$VC" || {
|
||||
echo >&2 "$VN"
|
||||
echo "$VN" >"$FBVF"
|
||||
echo >&2 "FISH_BUILD_VERSION=$VN"
|
||||
echo "FISH_BUILD_VERSION=\"$VN\"" >"$FBVF"
|
||||
}
|
||||
|
||||
# Output the fish-build-version-witness.txt
|
||||
# See https://cmake.org/cmake/help/v3.4/policy/CMP0058.html
|
||||
date +%s > "${OUTPUT_DIR}"fish-build-version-witness.txt
|
||||
date +%s > ${OUTPUT_DIR}fish-build-version-witness.txt
|
||||
|
||||
@@ -1,392 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>platform-application</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.no-container</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.container-manager</key>
|
||||
<true/>
|
||||
<key>com.apple.private.skip-library-validation</key>
|
||||
<true/>
|
||||
<key>com.apple.private.MobileContainerManager.allowed</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.adprivacyd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.amfid</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.AppBundles</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.AppDataContainers</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.automation-mode</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Biome</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Calendar</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.CallHistory</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.CarrierBundles</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.chronod</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.CloudDocsDB</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.CloudKit</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.containers</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.CoreFollowUp</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.CoreKnowledge</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Cryptex</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.demo_backup</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.DocumentRevisions</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.DumpPanic</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.ExposureNotification</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.FaceTime</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.familycircled</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.FindMy</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.fpsd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Health</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.HomeAI</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.HomeKit</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.iCloudDrive</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.idcredd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.IdentityServices</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.kbd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Keychains</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Lockdown</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Mail</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Messages</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.MessagesMetaData</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.MobileContainerManager</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.MobileDocuments</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.MobileIdentityService</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.mobilesync</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.multimodalsearchd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.NanoTimeKit.FaceSupport</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.News</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Notes</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Photos</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.PhotosLibraries</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.pipelined</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.preferences</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.PrivacyAccounting</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Safari</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SearchParty</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SecureElementService</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SensorKit</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SFAnalytics</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SiriInference</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SiriReferenceResolution</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SiriVocabulary</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SoC</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SpeechPersonalizedLM</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Spotlight</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.StatusKit</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Stocks</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Suggestions</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SymptomFramework</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.sysdagnose.ScreenshotServicesService</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.TCC</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.TimeMachine</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.triald</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.trustd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.trustd-private</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.universalaccess</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Voicemail</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Wireless</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.disk-device-access</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.ane_model_cache</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.apfs_boot_mount</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.clientScripter</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.mediaanalysisd</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.CarPlayAppBlacklist</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.DeviceCheck</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.DictionaryServices.dictionary2</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.DuetExpertCenterAsset</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.EmbeddedNL</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Font5</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Font6</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.HealthKt.FeatureAvailability</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.HomeKit</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.MacinTalkVoiceAssets</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.MailDynamicData</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.MXLongFormVideoApps</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.network.networknomicon</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.PKITrustSupplementals</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.SharingDeviceAssets</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.SiriShortcutsMobileAsset</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.TimeZoneUpdate</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.VoiceServices.CombinedVocalizerVoices</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.VoiceServices.CustomVoice</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.VoiceServices.GryphonVoice</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.VoiceServicesVocalizerVoice</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.VoiceServices.VoiceResources</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.VoiceTriggerAssets</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.CoreAnalytics</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.coreduet_knowledge_store</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.coreidvd</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.coreknowledge</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.CoreRoutine</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.CoreSpeech</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.dmd</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.dprivacyd_storage</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.ExtensibleSSO</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.facekit</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.fpsd</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.MobileStorageMounter</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.MusicApp</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.nsurlsessiond</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.pearl-field-diagnostics</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.proactivepredictions</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.QLThumbnailCache</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.remotemanagementd</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.RoleAccountStaging</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.sensorkit</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.shortcuts</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.siriremembers</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.timezone</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.triald</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.voiceshortcuts</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage-exempt.heritable</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.AppleMediaServices</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.ContactlessReader</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.CoreRoutine</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.DiagnosticReports</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.DiagnosticReports.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.DoNotDisturb</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Home</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.IntelligencePlatform</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Location</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.ManagedConfiguration</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.MapsSync</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.MobileBackup</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.MobileStorageMounter</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.PassKit</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SiriFeatureStore</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SiriSELF</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.SoundProfileAsset</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.TextUnderstanding</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.Weather</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.appleaccountd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.ciconia</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.clipserviced</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.coreduet_knowledge_store</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.driverkitd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.geoanalyticsd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.geod</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.launchd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.sessionkitd</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.sysdiagnose.ScreenshotServicesService</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.sysdiagnose.sysdiagnose</key>
|
||||
<true/>
|
||||
<key>com.apple.private.security.storage.tmp</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.critical</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.datavault.metadata</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.install</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.install.heritable</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.restricted-block-devices</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.MobileAssetDownload</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.amsengagementd</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.HealthKit.FeatureAvailability</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriDialogAssets</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriExperienceCam</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriFindMyConfigurationFiles</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriInferredHelpfulness</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriTextToSpeech</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriUnderstandingAsrAssistant</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriUnderstandingAsrHammer</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriUnderstandingAsrUaap</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriUnderstandingAttentionAssets</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriUnderstandingMorphun</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriUnderstandingNL</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.com.apple.MobileAsset.Trial.Siri.SiriUnderstandingNLOverrides</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.coreparsec_feedbacks</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.coreparsec_uploadables</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.early_boot_mount</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.storage.screentime</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.volume.ISCRecovery</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.volume.Preboot</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.volume.Recovery</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.volume.Update</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.volume.VM</key>
|
||||
<true/>
|
||||
<key>com.apple.rootless.volume.iSCPreboot</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""Command line test driver."""
|
||||
""" Command line test driver. """
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
@@ -32,11 +32,8 @@ CHECK_STDOUT_RE = re.compile(COMMENT_RE + r"CHECK:\s+(.*)\n")
|
||||
# A regex capturing lines that should be checked against stderr.
|
||||
CHECK_STDERR_RE = re.compile(COMMENT_RE + r"CHECKERR:\s+(.*)\n")
|
||||
|
||||
VARIABLE_OVERRIDE_RE = re.compile(r"\w+=.*")
|
||||
|
||||
SKIP = object()
|
||||
|
||||
|
||||
def find_command(program):
|
||||
import os
|
||||
|
||||
@@ -50,7 +47,6 @@ def find_command(program):
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class Config(object):
|
||||
def __init__(self):
|
||||
# Whether to have verbose output.
|
||||
@@ -61,7 +57,7 @@ class Config(object):
|
||||
self.progress = False
|
||||
|
||||
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 "\033[%dm" % n if self.colorize else ""
|
||||
@@ -132,7 +128,7 @@ class CheckerError(Exception):
|
||||
|
||||
|
||||
class Line(object):
|
||||
"""A line that remembers where it came from."""
|
||||
""" A line that remembers where it came from. """
|
||||
|
||||
def __init__(self, text, number, file):
|
||||
self.text = text
|
||||
@@ -160,7 +156,7 @@ class Line(object):
|
||||
raise NotImplementedError
|
||||
|
||||
def subline(self, text):
|
||||
"""Return a substring of our line with the given text, preserving number and file."""
|
||||
""" Return a substring of our line with the given text, preserving number and file. """
|
||||
return Line(text, self.number, self.file)
|
||||
|
||||
@staticmethod
|
||||
@@ -232,7 +228,7 @@ class TestFailure(object):
|
||||
if self.signal:
|
||||
fmtstrs += [
|
||||
" Process was killed by signal {BOLD}" + self.signal + "{RESET}",
|
||||
"",
|
||||
""
|
||||
]
|
||||
if self.line and self.check:
|
||||
fmtstrs += [
|
||||
@@ -353,7 +349,7 @@ class TestFailure(object):
|
||||
return "\n".join(fmtstrs).format(**fields)
|
||||
|
||||
def print_message(self):
|
||||
"""Print our message to stdout."""
|
||||
""" Print our message to stdout. """
|
||||
print(self.message())
|
||||
|
||||
|
||||
@@ -371,10 +367,7 @@ def perform_substitution(input_str, subs):
|
||||
text = m.group(1)
|
||||
for key, replacement in subs_ordered:
|
||||
if text.startswith(key):
|
||||
# shell-quote the replacement, so it's usable in #RUN lines.
|
||||
# We could loosen this and only do it for #RUN/#REQUIRES,
|
||||
# but so far we don't need it anywhere.
|
||||
return shlex.quote(replacement + text[len(key) :])
|
||||
return replacement + text[len(key) :]
|
||||
# No substitution found, so we default to running it as-is,
|
||||
# which will end up running it via $PATH.
|
||||
return text
|
||||
@@ -383,7 +376,7 @@ def perform_substitution(input_str, subs):
|
||||
|
||||
|
||||
def runproc(cmd):
|
||||
"""Wrapper around subprocess.Popen to save typing"""
|
||||
""" Wrapper around subprocess.Popen to save typing """
|
||||
PIPE = subprocess.PIPE
|
||||
proc = subprocess.Popen(
|
||||
cmd,
|
||||
@@ -448,7 +441,7 @@ class TestRun(object):
|
||||
# SCREENFULS of text.
|
||||
# So we truncate the check list.
|
||||
if len(usedchecks) > len(usedlines):
|
||||
usedchecks = usedchecks[: len(usedlines) + 5]
|
||||
usedchecks = usedchecks[:len(usedlines) + 5]
|
||||
|
||||
# Do a SequenceMatch! This gives us a diff-like thing.
|
||||
diff = SequenceMatcher(a=usedlines, b=usedchecks, autojunk=False)
|
||||
@@ -476,16 +469,13 @@ class TestRun(object):
|
||||
return None
|
||||
|
||||
def run(self):
|
||||
"""Run the command. Return a TestFailure, or None."""
|
||||
""" Run the command. Return a TestFailure, or None. """
|
||||
|
||||
def split_by_newlines(s):
|
||||
"""Decode a string and split it by newlines only,
|
||||
retaining the newlines.
|
||||
"""
|
||||
return [
|
||||
s + "\n"
|
||||
for s in s.decode("utf-8", errors="backslashreplace").split("\n")
|
||||
]
|
||||
return [s + "\n" for s in s.decode("utf-8").split("\n")]
|
||||
|
||||
if self.config.verbose:
|
||||
print(self.subbed_command)
|
||||
@@ -496,13 +486,7 @@ class TestRun(object):
|
||||
# most likely when the last command in a shell script doesn't exist.
|
||||
# So we check if the command *we execute* exists, and complain then.
|
||||
status = proc.returncode
|
||||
cmd = next(
|
||||
(
|
||||
word
|
||||
for word in shlex.split(self.subbed_command)
|
||||
if not VARIABLE_OVERRIDE_RE.match(word)
|
||||
)
|
||||
)
|
||||
cmd = shlex.split(self.subbed_command)[0]
|
||||
if status == 127 and not find_command(cmd):
|
||||
raise CheckerError("Command could not be found: " + cmd)
|
||||
if status == 126 and not find_command(cmd):
|
||||
@@ -533,7 +517,6 @@ class TestRun(object):
|
||||
# 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"):
|
||||
@@ -636,7 +619,6 @@ class CheckCmd(object):
|
||||
class Checker(object):
|
||||
def __init__(self, name, lines):
|
||||
self.name = name
|
||||
|
||||
# Helper to yield subline containing group1 from all matching lines.
|
||||
def group1s(regex):
|
||||
for line in lines:
|
||||
@@ -669,7 +651,7 @@ class Checker(object):
|
||||
|
||||
|
||||
def check_file(input_file, name, subs, config, failure_handler):
|
||||
"""Check a single file. Return a True on success, False on error."""
|
||||
""" Check a single file. Return a True on success, False on error. """
|
||||
success = True
|
||||
lines = Line.readfile(input_file, name)
|
||||
checker = Checker(name, lines)
|
||||
@@ -677,7 +659,9 @@ def check_file(input_file, name, subs, config, failure_handler):
|
||||
# Run all the REQUIRES lines first,
|
||||
# if any of them fail it's a SKIP
|
||||
for reqcmd in checker.requirecmds:
|
||||
proc = runproc(perform_substitution(reqcmd.args, subs))
|
||||
proc = runproc(
|
||||
perform_substitution(reqcmd.args, subs)
|
||||
)
|
||||
proc.communicate()
|
||||
if proc.returncode > 0:
|
||||
return SKIP
|
||||
@@ -721,7 +705,7 @@ def parse_subs(subs):
|
||||
|
||||
|
||||
def get_argparse():
|
||||
"""Return a littlecheck argument parser."""
|
||||
""" Return a littlecheck argument parser. """
|
||||
parser = argparse.ArgumentParser(
|
||||
description="littlecheck: command line tool tester."
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Helper to notarize an .app.zip or .pkg file.
|
||||
|
||||
@@ -13,7 +13,7 @@ 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"
|
||||
(test "$ext" = "zip" || test "$ext" = "pkg") || die "Unrecognized extension: $ext"
|
||||
|
||||
xcrun notarytool submit "$INPUT" --keychain-profile AC_PASSWORD --wait
|
||||
|
||||
@@ -21,7 +21,9 @@ for INPUT in "$@"; do
|
||||
TMPDIR=$(mktemp -d)
|
||||
echo "Extracting to $TMPDIR"
|
||||
unzip -q "$INPUT" -d "$TMPDIR"
|
||||
STAPLE_TARGET=$(echo "$TMPDIR"/*)
|
||||
# Force glob expansion.
|
||||
STAPLE_TARGET="$TMPDIR"/*
|
||||
STAPLE_TARGET=$(echo $STAPLE_TARGET)
|
||||
else
|
||||
STAPLE_TARGET="$INPUT"
|
||||
fi
|
||||
@@ -33,7 +35,7 @@ for INPUT in "$@"; do
|
||||
INPUT_FULL=$(realpath "$INPUT")
|
||||
rm -f "$INPUT"
|
||||
cd "$(dirname "$STAPLE_TARGET")"
|
||||
zip -r -q "$INPUT_FULL" "$(basename "$STAPLE_TARGET")"
|
||||
zip -r -q "$INPUT_FULL" $(basename "$STAPLE_TARGET")
|
||||
fi
|
||||
echo "Processed $INPUT"
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ usage() {
|
||||
echo " -p <PASSWORD> Password for the .p12 files (necessary to access the certificates)"
|
||||
echo " -e <entitlements file> (Optional) Path to an entitlements XML file"
|
||||
echo " -n Enables notarization. This will fail if code signing is not also enabled."
|
||||
echo " -j <API_KEY.JSON> Path to JSON file generated with \`rcodesign encode-app-store-connect-api-key\` (required for notarization)"
|
||||
echo " -j <API_KEY.JSON> Path to JSON file generated with `rcodesign encode-app-store-connect-api-key` (required for notarization)"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
@@ -45,7 +45,7 @@ while getopts "sf:i:p:e:nj:" opt; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -n "$SIGN" ] && { [ -z "$P12_APP_FILE" ] || [ -z "$P12_INSTALL_FILE" ] || [ -z "$P12_PASSWORD" ]; }; then
|
||||
if [ -n "$SIGN" ] && ([ -z "$P12_APP_FILE" ] || [-z "$P12_INSTALL_FILE"] || [ -z "$P12_PASSWORD" ]); then
|
||||
usage
|
||||
fi
|
||||
|
||||
@@ -103,7 +103,7 @@ mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/in
|
||||
|
||||
# Fatten them up.
|
||||
for FILE in "$PKGDIR"/root/usr/local/bin/*; do
|
||||
X86_FILE="$PKGDIR/build_x86_64/$(basename "$FILE")"
|
||||
X86_FILE="$PKGDIR/build_x86_64/$(basename $FILE)"
|
||||
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
|
||||
chmod 755 "$FILE"
|
||||
done
|
||||
@@ -142,10 +142,10 @@ fi
|
||||
(cd "$PKGDIR/build_arm64" && env $ARM64_DEPLOY_TARGET make -j 12 fish_macapp)
|
||||
(cd "$PKGDIR/build_x86_64" && env $X86_64_DEPLOY_TARGET make -j 12 fish_macapp)
|
||||
|
||||
# Make the app's /usr/local/bin binaries universal. Note fish.app/Contents/MacOS/fish already is, courtesy of CMake.
|
||||
# Make the app's /usr/local/bin binaries universal. Note fish.app/Contents/MacOS/fish already is, courtsey of CMake.
|
||||
cd "$PKGDIR/build_arm64"
|
||||
for FILE in fish.app/Contents/Resources/base/usr/local/bin/*; do
|
||||
X86_FILE="$PKGDIR/build_x86_64/fish.app/Contents/Resources/base/usr/local/bin/$(basename "$FILE")"
|
||||
X86_FILE="$PKGDIR/build_x86_64/fish.app/Contents/Resources/base/usr/local/bin/$(basename $FILE)"
|
||||
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
|
||||
|
||||
# macho-universal-create screws up the permissions.
|
||||
|
||||
@@ -59,7 +59,7 @@ git archive --format=tar --prefix="$prefix"/ HEAD > "$path"
|
||||
PREFIX_TMPDIR=$(mktemp -d)
|
||||
cd "$PREFIX_TMPDIR"
|
||||
echo "$VERSION" > version
|
||||
cmake -G "$BUILD_GENERATOR" -DCMAKE_BUILD_TYPE=Debug "$wd"
|
||||
cmake -G "$BUILD_GENERATOR" "$wd"
|
||||
$BUILD_TOOL doc
|
||||
|
||||
TAR_APPEND="$TAR --append --file=$path --mtime=now --owner=0 --group=0 \
|
||||
|
||||
@@ -45,7 +45,7 @@ cd "$PREFIX_TMPDIR"
|
||||
mkdir .cargo
|
||||
cargo vendor --manifest-path "$wd/Cargo.toml" > .cargo/config.toml
|
||||
|
||||
tar cfvJ "$path".xz vendor .cargo
|
||||
tar cfvJ $path.xz vendor .cargo
|
||||
|
||||
cd -
|
||||
rm -r "$PREFIX_TMPDIR"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
code, tt {
|
||||
font-family: ui-monospace, Menlo, monospace;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
if test $# -eq 0
|
||||
then
|
||||
echo "usage: $0 shellname [shellname ...]"
|
||||
echo usage: $0 shellname [shellname ...]
|
||||
exit 1
|
||||
fi
|
||||
|
||||
scriptname=$(basename "$0")
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
scriptname=`basename "$0"`
|
||||
if [[ $UID -ne 0 ]]; then
|
||||
echo "${scriptname} must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
@@ -20,7 +20,6 @@ tmpfile=${file}.tmp
|
||||
|
||||
set -o noclobber
|
||||
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -f $tmpfile" EXIT
|
||||
|
||||
if ! cat $file > $tmpfile
|
||||
@@ -33,13 +32,15 @@ EOF
|
||||
fi
|
||||
|
||||
# Append a newline if it doesn't exist
|
||||
[ -z "$(tail -c1 "$tmpfile")" ] || echo "" >> "$tmpfile"
|
||||
if [ "$(tail -c1 "$tmpfile"; echo x)" != $'\nx' ]; then
|
||||
echo "" >> "$tmpfile"
|
||||
fi
|
||||
|
||||
for i
|
||||
do
|
||||
if ! grep -q "^${i}$" "$tmpfile"
|
||||
then
|
||||
echo "$i" >> "$tmpfile"
|
||||
echo $i >> "$tmpfile"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/sh -x
|
||||
|
||||
./add-shell "${DSTVOLUME}"usr/local/bin/fish
|
||||
./add-shell ${DSTVOLUME}usr/local/bin/fish
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/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 -r installed
|
||||
do rm -v "${DSTVOLUME}${installed}"
|
||||
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"
|
||||
|
||||
@@ -30,27 +30,20 @@ TIMEOUT_SECS = 5
|
||||
UNEXPECTED_SUCCESS = object()
|
||||
|
||||
# When rendering fish's output, remove the control sequences that modify terminal state,
|
||||
# to avoid confusing the calling terminal.
|
||||
# to avoid confusing the calling terminal. No need to replace things like colors and cursor
|
||||
# movement that are harmless and/or will not leak anyway.
|
||||
SANITIZE_FOR_PRINTING_RE = re.compile(
|
||||
r"""
|
||||
# Filter CSI commands except for colors and cursor movement.
|
||||
(?!\x1b\[\d*m)
|
||||
(?!\x1b\[K)
|
||||
(?!\x1b\[\d*[ABCD])
|
||||
\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]
|
||||
# OSC
|
||||
| \x1b\].*?\x07
|
||||
# DCS
|
||||
| \x1bP.*?\x1b\\
|
||||
# application keypad mode
|
||||
\x1b\[\?1004[hl]
|
||||
| \x1b\[\?2004[hl]
|
||||
| \x1b\[>4;[10]m
|
||||
| \x1b\[>5u
|
||||
| \x1b\[<1u
|
||||
| \x1b=
|
||||
| \x1b>
|
||||
| \x1b\].*?\x07
|
||||
""",
|
||||
re.VERBOSE,
|
||||
)
|
||||
|
||||
assert SANITIZE_FOR_PRINTING_RE.sub("", "\x1b[>4;1m") == ""
|
||||
assert SANITIZE_FOR_PRINTING_RE.sub("", "\x1b[31m") == "\x1b[31m"
|
||||
re.VERBOSE)
|
||||
|
||||
|
||||
def get_prompt_re(counter):
|
||||
@@ -162,15 +155,9 @@ class SpawnedProc(object):
|
||||
before giving up on some expected output.
|
||||
env: a string->string dictionary, describing the environment variables.
|
||||
"""
|
||||
import shlex
|
||||
|
||||
if name not in env:
|
||||
raise ValueError("'%s' variable not found in environment" % name)
|
||||
exe_path = env.get(name)
|
||||
# HACK: If there are no args, pexpect will fail if exe_path contains any shell metachars.
|
||||
# But not if there are args, in which case it probably switches spawning method?
|
||||
if "args" not in kwargs:
|
||||
exe_path = shlex.quote(exe_path)
|
||||
self.colorize = sys.stdout.isatty() or env.get("FISH_FORCE_COLOR", "0") == "1"
|
||||
self.messages = []
|
||||
self.start_time = None
|
||||
@@ -179,8 +166,6 @@ class SpawnedProc(object):
|
||||
)
|
||||
self.spawn.delaybeforesend = None
|
||||
self.prompt_counter = 0
|
||||
if env.get("TERM") != "dumb":
|
||||
self.spawn.send("\x1b[?123c") # Primary Device Attribute
|
||||
|
||||
def time_since_first_message(self):
|
||||
"""Return a delta in seconds since the first message, or 0 if this is the first."""
|
||||
@@ -274,11 +259,7 @@ class SpawnedProc(object):
|
||||
failtype = pexpect_error_type(err)
|
||||
# If we get an EOF, we check if the process exited with a signal.
|
||||
# This shows us e.g. if it crashed
|
||||
if (
|
||||
failtype == "EOF"
|
||||
and self.spawn.signalstatus is not None
|
||||
and self.spawn.signalstatus != 0
|
||||
):
|
||||
if failtype == 'EOF' and self.spawn.signalstatus is not None and self.spawn.signalstatus != 0:
|
||||
failtype = "SIGNAL " + Signals(self.spawn.signalstatus).name
|
||||
|
||||
fmtkeys = {"failtype": failtype, "pat": escape(pat)}
|
||||
@@ -308,14 +289,12 @@ class SpawnedProc(object):
|
||||
print("")
|
||||
print("{CYAN}When written to the tty, this looks like:{RESET}".format(**colors))
|
||||
print("{CYAN}<-------{RESET}".format(**colors))
|
||||
sys.stdout.write(SANITIZE_FOR_PRINTING_RE.sub("", self.spawn.before))
|
||||
sys.stdout.write(SANITIZE_FOR_PRINTING_RE.sub('', self.spawn.before))
|
||||
sys.stdout.flush()
|
||||
maybe_nl = ""
|
||||
maybe_nl=""
|
||||
if not self.spawn.before.endswith("\n"):
|
||||
maybe_nl = "\n{CYAN}(no trailing newline)".format(**colors)
|
||||
print(
|
||||
"{RESET}{maybe_nl}{CYAN}------->{RESET}".format(maybe_nl=maybe_nl, **colors)
|
||||
)
|
||||
maybe_nl="\n{CYAN}(no trailing newline)".format(**colors)
|
||||
print("{RESET}{maybe_nl}{CYAN}------->{RESET}".format(maybe_nl=maybe_nl, **colors))
|
||||
|
||||
print("")
|
||||
|
||||
@@ -382,24 +361,22 @@ class SpawnedProc(object):
|
||||
|
||||
|
||||
def control(char: str) -> str:
|
||||
"""Returns the char sent when control is pressed along the given key."""
|
||||
""" 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]
|
||||
)
|
||||
return chr({
|
||||
"@": 0,
|
||||
"`": 0,
|
||||
"[": 27,
|
||||
"{": 27,
|
||||
"\\": 28,
|
||||
"|": 28,
|
||||
"]": 29,
|
||||
"}": 29,
|
||||
"^": 30,
|
||||
"~": 30,
|
||||
"_": 31,
|
||||
"?": 127,
|
||||
}[char])
|
||||
@@ -29,7 +29,7 @@ add_custom_target(sphinx-docs
|
||||
|
||||
# sphinx-manpages needs the fish_indent binary for the version number
|
||||
add_custom_target(sphinx-manpages
|
||||
env FISH_BUILD_VERSION_FILE=${CMAKE_CURRENT_BINARY_DIR}/${FBVF}
|
||||
env PATH="${CMAKE_BINARY_DIR}:$$PATH"
|
||||
${SPHINX_EXECUTABLE}
|
||||
-j auto
|
||||
-q -b man
|
||||
@@ -38,7 +38,7 @@ add_custom_target(sphinx-manpages
|
||||
"${SPHINX_SRC_DIR}"
|
||||
# TODO: This only works if we only have section 1 manpages.
|
||||
"${SPHINX_MANPAGE_DIR}/man1"
|
||||
DEPENDS CHECK-FISH-BUILD-VERSION-FILE
|
||||
DEPENDS fish_indent
|
||||
COMMENT "Building man pages with Sphinx")
|
||||
|
||||
if(SPHINX_EXECUTABLE)
|
||||
|
||||
@@ -1,18 +1,298 @@
|
||||
#[=======================================================================[.rst:
|
||||
FindRust
|
||||
--------
|
||||
|
||||
Find Rust
|
||||
|
||||
This module finds an installed rustc compiler and the cargo build tool. If Rust
|
||||
is managed by rustup it determines the available toolchains and returns a
|
||||
concrete Rust version, not a rustup proxy.
|
||||
|
||||
Imported from Corrosion https://github.com/corrosion-rs/corrosion/
|
||||
|
||||
Copyright (c) 2018 Andrew Gaspar
|
||||
|
||||
Licensed under the MIT license
|
||||
|
||||
However this is absolutely gutted and reduced to the bare minimum.
|
||||
#]=======================================================================]
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
# search for Cargo here and set up a bunch of cool flags and stuff
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
list(APPEND CMAKE_MESSAGE_CONTEXT "FindRust")
|
||||
|
||||
# Print error message and return.
|
||||
macro(_findrust_failed)
|
||||
if("${Rust_FIND_REQUIRED}")
|
||||
message(FATAL_ERROR ${ARGN})
|
||||
elseif(NOT "${Rust_FIND_QUIETLY}")
|
||||
message(WARNING ${ARGN})
|
||||
endif()
|
||||
# Note: PARENT_SCOPE is the scope of the caller of the caller of this macro.
|
||||
set(Rust_FOUND "" PARENT_SCOPE)
|
||||
return()
|
||||
endmacro()
|
||||
|
||||
# Checks if the actual version of a Rust toolchain matches the VERSION requirements specified in find_package.
|
||||
function(_findrust_version_ok ACTUAL_VERSION OUT_IS_OK)
|
||||
if(DEFINED Rust_FIND_VERSION_RANGE)
|
||||
if(Rust_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE")
|
||||
set(COMPARSION_OPERATOR "VERSION_LESS_EQUAL")
|
||||
elseif(Rust_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE")
|
||||
set(COMPARSION_OPERATOR "VERSION_LESS")
|
||||
else()
|
||||
message(FATAL_ERROR "Unexpected value in `<PackageName>_FIND_VERSION_RANGE_MAX`: "
|
||||
"`${Rust_FIND_VERSION_RANGE_MAX}`.")
|
||||
endif()
|
||||
if(("${ACTUAL_VERSION}" VERSION_GREATER_EQUAL "${Rust_FIND_VERSION_RANGE_MIN}")
|
||||
AND
|
||||
( "${ACTUAL_VERSION}" ${COMPARSION_OPERATOR} "${Rust_FIND_VERSION_RANGE_MAX}" )
|
||||
)
|
||||
set("${OUT_IS_OK}" TRUE PARENT_SCOPE)
|
||||
else()
|
||||
set("${OUT_IS_OK}" FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(DEFINED Rust_FIND_VERSION)
|
||||
if(Rust_VERSION_EXACT)
|
||||
set(COMPARISON_OPERATOR VERSION_EQUAL)
|
||||
else()
|
||||
set(COMPARISON_OPERATOR VERSION_GREATER_EQUAL)
|
||||
endif()
|
||||
if(_TOOLCHAIN_${_TOOLCHAIN_SELECTED}_VERSION "${COMPARISON_OPERATOR}" Rust_FIND_VERSION)
|
||||
set("${OUT_IS_OK}" TRUE PARENT_SCOPE)
|
||||
else()
|
||||
set("${OUT_IS_OK}" FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
# if no VERSION requirement was specified, the version is always okay.
|
||||
set("${OUT_IS_OK}" TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(_corrosion_strip_target_triple input_triple_or_path output_triple)
|
||||
# If the target_triple is a path to a custom target specification file, then strip everything
|
||||
# except the filename from `target_triple`.
|
||||
get_filename_component(target_triple_ext "${input_triple_or_path}" EXT)
|
||||
set(target_triple "${input_triple_or_path}")
|
||||
if(target_triple_ext)
|
||||
if(target_triple_ext STREQUAL ".json")
|
||||
get_filename_component(target_triple "${input_triple_or_path}" NAME_WE)
|
||||
endif()
|
||||
endif()
|
||||
set(${output_triple} "${target_triple}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(_corrosion_parse_target_triple target_triple out_arch out_vendor out_os out_env)
|
||||
_corrosion_strip_target_triple(${target_triple} target_triple)
|
||||
|
||||
# The vendor part may be left out from the target triple, and since `env` is also optional,
|
||||
# we determine if vendor is present by matching against a list of known vendors.
|
||||
set(known_vendors
|
||||
"apple"
|
||||
"esp[a-z0-9]*" # espressif, e.g. riscv32imc-esp-espidf or xtensa-esp32s3-none-elf
|
||||
"fortanix"
|
||||
"kmc"
|
||||
"pc"
|
||||
"nintendo"
|
||||
"nvidia"
|
||||
"openwrt"
|
||||
"alpine"
|
||||
"chimera"
|
||||
"unikraft"
|
||||
"unknown"
|
||||
"uwp" # aarch64-uwp-windows-msvc
|
||||
"wrs" # e.g. aarch64-wrs-vxworks
|
||||
"sony"
|
||||
"sun"
|
||||
)
|
||||
# todo: allow users to add additional vendors to the list via a cmake variable.
|
||||
list(JOIN known_vendors "|" known_vendors_joined)
|
||||
# vendor is optional - We detect if vendor is present by matching against a known list of
|
||||
# vendors. The next field is the OS, which we assume to always be present, while the last field
|
||||
# is again optional and contains the environment.
|
||||
string(REGEX MATCH
|
||||
"^([a-z0-9_\.]+)-((${known_vendors_joined})-)?([a-z0-9_]+)(-([a-z0-9_]+))?$"
|
||||
whole_match
|
||||
"${target_triple}"
|
||||
)
|
||||
if((NOT whole_match) AND (NOT CORROSION_NO_WARN_PARSE_TARGET_TRIPLE_FAILED))
|
||||
message(WARNING "Failed to parse target-triple `${target_triple}`."
|
||||
"Corrosion determines some information about the output artifacts based on OS "
|
||||
"specified in the Rust target-triple.\n"
|
||||
"Currently this is relevant for windows and darwin (mac) targets, since file "
|
||||
"extensions differ.\n"
|
||||
"Note: If you are targeting a different OS you can suppress this warning by"
|
||||
" setting the CMake cache variable "
|
||||
"`CORROSION_NO_WARN_PARSE_TARGET_TRIPLE_FAILED`."
|
||||
"Please consider opening an issue on github if you you need to add a new vendor to the list."
|
||||
)
|
||||
endif()
|
||||
|
||||
message(DEBUG "Parsed Target triple: arch: ${CMAKE_MATCH_1}, vendor: ${CMAKE_MATCH_3}, "
|
||||
"OS: ${CMAKE_MATCH_4}, env: ${CMAKE_MATCH_6}")
|
||||
|
||||
set("${out_arch}" "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
||||
set("${out_vendor}" "${CMAKE_MATCH_3}" PARENT_SCOPE)
|
||||
set("${out_os}" "${CMAKE_MATCH_4}" PARENT_SCOPE)
|
||||
set("${out_env}" "${CMAKE_MATCH_6}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(_corrosion_determine_libs_new target_triple out_libs)
|
||||
set(package_dir "${CMAKE_BINARY_DIR}/corrosion/required_libs")
|
||||
# Cleanup on reconfigure to get a cleans state (in case we change something in the future)
|
||||
file(REMOVE_RECURSE "${package_dir}")
|
||||
file(MAKE_DIRECTORY "${package_dir}")
|
||||
set(manifest "[package]\nname = \"required_libs\"\nedition = \"2018\"\nversion = \"0.1.0\"\n")
|
||||
string(APPEND manifest "\n[lib]\ncrate-type=[\"staticlib\"]\npath = \"lib.rs\"\n")
|
||||
string(APPEND manifest "\n[workspace]\n")
|
||||
file(WRITE "${package_dir}/Cargo.toml" "${manifest}")
|
||||
file(WRITE "${package_dir}/lib.rs" "pub fn add(left: usize, right: usize) -> usize {left + right}\n")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
"CARGO_BUILD_RUSTC=${Rust_COMPILER_CACHED}"
|
||||
${Rust_CARGO_CACHED} rustc --verbose --color never --target=${target_triple} -- --print=native-static-libs
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/corrosion/required_libs"
|
||||
RESULT_VARIABLE cargo_build_result
|
||||
ERROR_VARIABLE cargo_build_error_message
|
||||
)
|
||||
if(cargo_build_result)
|
||||
message(DEBUG "Determining required native libraries - failed: ${cargo_build_result}.")
|
||||
message(TRACE "The cargo build error was: ${cargo_build_error_message}")
|
||||
message(DEBUG "Note: This is expected for Rust targets without std support")
|
||||
return()
|
||||
else()
|
||||
# The pattern starts with `native-static-libs:` and goes to the end of the line.
|
||||
if(cargo_build_error_message MATCHES "native-static-libs: ([^\r\n]+)\r?\n")
|
||||
string(REPLACE " " ";" "libs_list" "${CMAKE_MATCH_1}")
|
||||
set(stripped_lib_list "")
|
||||
|
||||
set(was_last_framework OFF)
|
||||
foreach(lib ${libs_list})
|
||||
# merge -framework;lib -> "-framework lib" as CMake does de-duplication of link libraries, and -framework prefix is required
|
||||
if (lib STREQUAL "-framework")
|
||||
set(was_last_framework ON)
|
||||
continue()
|
||||
endif()
|
||||
if (was_last_framework)
|
||||
list(APPEND stripped_lib_list "-framework ${lib}")
|
||||
set(was_last_framework OFF)
|
||||
continue()
|
||||
endif()
|
||||
# Strip leading `-l` (unix) and potential .lib suffix (windows)
|
||||
string(REGEX REPLACE "^-l" "" "stripped_lib" "${lib}")
|
||||
string(REGEX REPLACE "\.lib$" "" "stripped_lib" "${stripped_lib}")
|
||||
list(APPEND stripped_lib_list "${stripped_lib}")
|
||||
endforeach()
|
||||
set(libs_list "${stripped_lib_list}")
|
||||
# Special case `msvcrt` to link with the debug version in Debug mode.
|
||||
list(TRANSFORM libs_list REPLACE "^msvcrt$" "\$<\$<CONFIG:Debug>:msvcrtd>")
|
||||
else()
|
||||
message(DEBUG "Determining required native libraries - failed: Regex match failure.")
|
||||
message(DEBUG "`native-static-libs` not found in: `${cargo_build_error_message}`")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
set("${out_libs}" "${libs_list}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if (NOT "${Rust_TOOLCHAIN}" STREQUAL "$CACHE{Rust_TOOLCHAIN}")
|
||||
# Promote Rust_TOOLCHAIN to a cache variable if it is not already a cache variable
|
||||
set(Rust_TOOLCHAIN ${Rust_TOOLCHAIN} CACHE STRING "Requested rustup toolchain" FORCE)
|
||||
endif()
|
||||
|
||||
set(_RESOLVE_RUSTUP_TOOLCHAINS_DESC "Indicates whether to descend into the toolchain pointed to by rustup")
|
||||
set(Rust_RESOLVE_RUSTUP_TOOLCHAINS ON CACHE BOOL ${_RESOLVE_RUSTUP_TOOLCHAINS_DESC})
|
||||
|
||||
# This block checks to see if we're prioritizing a rustup-managed toolchain.
|
||||
if (DEFINED Rust_TOOLCHAIN)
|
||||
# If the user specifies `Rust_TOOLCHAIN`, then look for `rustup` first, rather than `rustc`.
|
||||
find_program(Rust_RUSTUP rustup PATHS "$ENV{HOME}/.cargo/bin")
|
||||
if(NOT Rust_RUSTUP)
|
||||
if(NOT "${Rust_FIND_QUIETLY}")
|
||||
message(
|
||||
WARNING "CMake variable `Rust_TOOLCHAIN` specified, but `rustup` was not found. "
|
||||
"Ignoring toolchain and looking for a Rust toolchain not managed by rustup.")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# If we aren't definitely using a rustup toolchain, look for rustc first - the user may have
|
||||
# a toolchain installed via a method other than rustup higher in the PATH, which should be
|
||||
# preferred. However, if the first-found rustc is a rustup proxy, then we'll revert to
|
||||
# finding the preferred toolchain via rustup.
|
||||
|
||||
# Uses `Rust_COMPILER` to let user-specified `rustc` win. But we will still "override" the
|
||||
# user's setting if it is pointing to `rustup`. Default rustup install path is provided as a
|
||||
# backup if a toolchain cannot be found in the user's PATH.
|
||||
|
||||
if (DEFINED Rust_COMPILER)
|
||||
set(_Rust_COMPILER_TEST "${Rust_COMPILER}")
|
||||
set(_USER_SPECIFIED_RUSTC ON)
|
||||
if(NOT (EXISTS "${_Rust_COMPILER_TEST}" AND NOT IS_DIRECTORY "${_Rust_COMPILER_TEST}"))
|
||||
set(_ERROR_MESSAGE "Rust_COMPILER was set to `${Rust_COMPILER}`, but this file does "
|
||||
"not exist."
|
||||
)
|
||||
_findrust_failed(${_ERROR_MESSAGE})
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
find_program(_Rust_COMPILER_TEST rustc PATHS "$ENV{HOME}/.cargo/bin")
|
||||
if(NOT EXISTS "${_Rust_COMPILER_TEST}")
|
||||
set(_ERROR_MESSAGE "`rustc` not found in PATH or `$ENV{HOME}/.cargo/bin`.\n"
|
||||
"Hint: Check if `rustc` is in PATH or manually specify the location "
|
||||
"by setting `Rust_COMPILER` to the path to `rustc`.")
|
||||
_findrust_failed(${_ERROR_MESSAGE})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check if the discovered rustc is actually a "rustup" proxy.
|
||||
execute_process(
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E env
|
||||
RUSTUP_FORCE_ARG0=rustup
|
||||
"${_Rust_COMPILER_TEST}" --version
|
||||
OUTPUT_VARIABLE _RUSTC_VERSION_RAW
|
||||
ERROR_VARIABLE _RUSTC_VERSION_STDERR
|
||||
RESULT_VARIABLE _RUSTC_VERSION_RESULT
|
||||
)
|
||||
|
||||
if(NOT (_RUSTC_VERSION_RESULT EQUAL "0"))
|
||||
_findrust_failed("`${_Rust_COMPILER_TEST} --version` failed with ${_RUSTC_VERSION_RESULT}\n"
|
||||
"rustc stderr:\n${_RUSTC_VERSION_STDERR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (_RUSTC_VERSION_RAW MATCHES "rustup [0-9\\.]+")
|
||||
if (_USER_SPECIFIED_RUSTC)
|
||||
message(
|
||||
WARNING "User-specified Rust_COMPILER pointed to rustup's rustc proxy. Corrosion's "
|
||||
"FindRust will always try to evaluate to an actual Rust toolchain, and so the "
|
||||
"user-specified Rust_COMPILER will be discarded in favor of the default "
|
||||
"rustup-managed toolchain."
|
||||
)
|
||||
|
||||
unset(Rust_COMPILER)
|
||||
unset(Rust_COMPILER CACHE)
|
||||
endif()
|
||||
|
||||
# Get `rustup` next to the `rustc` proxy
|
||||
get_filename_component(_RUST_PROXIES_PATH "${_Rust_COMPILER_TEST}" DIRECTORY)
|
||||
find_program(Rust_RUSTUP rustup HINTS "${_RUST_PROXIES_PATH}" NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
unset(_Rust_COMPILER_TEST CACHE)
|
||||
endif()
|
||||
|
||||
# At this point, the only thing we should have evaluated is a path to `rustup` _if that's what the
|
||||
# best source for a Rust toolchain was determined to be_.
|
||||
if (NOT Rust_RUSTUP)
|
||||
set(Rust_RESOLVE_RUSTUP_TOOLCHAINS OFF CACHE BOOL ${_RESOLVE_RUSTUP_TOOLCHAINS_DESC} FORCE)
|
||||
endif()
|
||||
|
||||
# List of user variables that will override any toolchain-provided setting
|
||||
set(_Rust_USER_VARS Rust_COMPILER Rust_CARGO Rust_CARGO_TARGET)
|
||||
set(_Rust_USER_VARS Rust_COMPILER Rust_CARGO Rust_CARGO_TARGET Rust_CARGO_HOST_TARGET)
|
||||
foreach(_VAR ${_Rust_USER_VARS})
|
||||
if (DEFINED "${_VAR}")
|
||||
set(${_VAR}_CACHED "${${_VAR}}" CACHE INTERNAL "Internal cache of ${_VAR}")
|
||||
@@ -21,55 +301,482 @@ foreach(_VAR ${_Rust_USER_VARS})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (NOT DEFINED Rust_CARGO_CACHED)
|
||||
find_program(Rust_CARGO_CACHED cargo PATHS "$ENV{HOME}/.cargo/bin")
|
||||
endif()
|
||||
# Discover what toolchains are installed by rustup, if the discovered `rustc` is a proxy from
|
||||
# `rustup` and the user hasn't explicitly requested to override this behavior, then select either
|
||||
# the default toolchain, or the requested toolchain Rust_TOOLCHAIN
|
||||
if (Rust_RESOLVE_RUSTUP_TOOLCHAINS)
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${Rust_RUSTUP}" toolchain list --verbose
|
||||
OUTPUT_VARIABLE _TOOLCHAINS_RAW
|
||||
)
|
||||
|
||||
if (NOT EXISTS "${Rust_CARGO_CACHED}")
|
||||
message(FATAL_ERROR "The cargo executable ${Rust_CARGO_CACHED} was not found. "
|
||||
"Consider setting `Rust_CARGO_CACHED` to the absolute path of `cargo`."
|
||||
)
|
||||
endif()
|
||||
string(REPLACE "\n" ";" _TOOLCHAINS_RAW "${_TOOLCHAINS_RAW}")
|
||||
set(_DISCOVERED_TOOLCHAINS "")
|
||||
set(_DISCOVERED_TOOLCHAINS_RUSTC_PATH "")
|
||||
set(_DISCOVERED_TOOLCHAINS_CARGO_PATH "")
|
||||
set(_DISCOVERED_TOOLCHAINS_VERSION "")
|
||||
|
||||
if (NOT DEFINED Rust_COMPILER_CACHED)
|
||||
find_program(Rust_COMPILER_CACHED rustc PATHS "$ENV{HOME}/.cargo/bin")
|
||||
endif()
|
||||
foreach(_TOOLCHAIN_RAW ${_TOOLCHAINS_RAW})
|
||||
if (_TOOLCHAIN_RAW MATCHES "([a-zA-Z0-9\\._\\-]+)[ \t\r\n]?(\\(default\\) \\(override\\)|\\(default\\)|\\(override\\))?[ \t\r\n]+(.+)")
|
||||
set(_TOOLCHAIN "${CMAKE_MATCH_1}")
|
||||
set(_TOOLCHAIN_TYPE "${CMAKE_MATCH_2}")
|
||||
|
||||
set(_TOOLCHAIN_PATH "${CMAKE_MATCH_3}")
|
||||
set(_TOOLCHAIN_${_TOOLCHAIN}_PATH "${CMAKE_MATCH_3}")
|
||||
|
||||
if (_TOOLCHAIN_TYPE MATCHES ".*\\(default\\).*")
|
||||
set(_TOOLCHAIN_DEFAULT "${_TOOLCHAIN}")
|
||||
endif()
|
||||
|
||||
if (_TOOLCHAIN_TYPE MATCHES ".*\\(override\\).*")
|
||||
set(_TOOLCHAIN_OVERRIDE "${_TOOLCHAIN}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${_TOOLCHAIN_PATH}/bin/rustc" --version
|
||||
OUTPUT_VARIABLE _TOOLCHAIN_RAW_VERSION
|
||||
)
|
||||
if (_TOOLCHAIN_RAW_VERSION MATCHES "rustc ([0-9]+)\\.([0-9]+)\\.([0-9]+)(-nightly)?")
|
||||
list(APPEND _DISCOVERED_TOOLCHAINS "${_TOOLCHAIN}")
|
||||
list(APPEND _DISCOVERED_TOOLCHAINS_RUSTC_PATH "${_TOOLCHAIN_PATH}/bin/rustc")
|
||||
list(APPEND _DISCOVERED_TOOLCHAINS_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
|
||||
|
||||
# We need this variable to determine the default toolchain, since `foreach(... IN ZIP_LISTS ...)`
|
||||
# requires CMake 3.17. As a workaround we define this variable to lookup the version when iterating
|
||||
# through the `_DISCOVERED_TOOLCHAINS` lists.
|
||||
set(_TOOLCHAIN_${_TOOLCHAIN}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
|
||||
if(CMAKE_MATCH_4)
|
||||
set(_TOOLCHAIN_${_TOOLCHAIN}_IS_NIGHTLY "TRUE")
|
||||
else()
|
||||
set(_TOOLCHAIN_${_TOOLCHAIN}_IS_NIGHTLY "FALSE")
|
||||
endif()
|
||||
if(EXISTS "${_TOOLCHAIN_PATH}/bin/cargo")
|
||||
list(APPEND _DISCOVERED_TOOLCHAINS_CARGO_PATH "${_TOOLCHAIN_PATH}/bin/cargo")
|
||||
else()
|
||||
list(APPEND _DISCOVERED_TOOLCHAINS_CARGO_PATH "NOTFOUND")
|
||||
endif()
|
||||
else()
|
||||
message(AUTHOR_WARNING "Unexpected output from `rustc --version` for Toolchain `${_TOOLCHAIN}`: "
|
||||
"`${_TOOLCHAIN_RAW_VERSION}`.\n"
|
||||
"Ignoring this toolchain."
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
message(AUTHOR_WARNING "Didn't recognize toolchain: ${_TOOLCHAIN_RAW}. Ignoring this toolchain.\n"
|
||||
"Rustup toolchain list output( `${Rust_RUSTUP} toolchain list --verbose`):\n"
|
||||
"${_TOOLCHAINS_RAW}"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Expose a list of available rustup toolchains.
|
||||
list(LENGTH _DISCOVERED_TOOLCHAINS _toolchain_len)
|
||||
list(LENGTH _DISCOVERED_TOOLCHAINS_RUSTC_PATH _toolchain_rustc_len)
|
||||
list(LENGTH _DISCOVERED_TOOLCHAINS_CARGO_PATH _toolchain_cargo_len)
|
||||
list(LENGTH _DISCOVERED_TOOLCHAINS_VERSION _toolchain_version_len)
|
||||
if(NOT
|
||||
(_toolchain_len EQUAL _toolchain_rustc_len
|
||||
AND _toolchain_cargo_len EQUAL _toolchain_version_len
|
||||
AND _toolchain_len EQUAL _toolchain_cargo_len)
|
||||
)
|
||||
message(FATAL_ERROR "Internal error - list length mismatch."
|
||||
"List lengths: ${_toolchain_len} toolchains, ${_toolchain_rustc_len} rustc, ${_toolchain_cargo_len} cargo,"
|
||||
" ${_toolchain_version_len} version. The lengths should be the same."
|
||||
)
|
||||
endif()
|
||||
|
||||
set(Rust_RUSTUP_TOOLCHAINS CACHE INTERNAL "List of available Rustup toolchains" "${_DISCOVERED_TOOLCHAINS}")
|
||||
set(Rust_RUSTUP_TOOLCHAINS_RUSTC_PATH
|
||||
CACHE INTERNAL
|
||||
"List of the rustc paths corresponding to the toolchain at the same index in `Rust_RUSTUP_TOOLCHAINS`."
|
||||
"${_DISCOVERED_TOOLCHAINS_RUSTC_PATH}"
|
||||
)
|
||||
set(Rust_RUSTUP_TOOLCHAINS_CARGO_PATH
|
||||
CACHE INTERNAL
|
||||
"List of the cargo paths corresponding to the toolchain at the same index in `Rust_RUSTUP_TOOLCHAINS`. \
|
||||
May also be `NOTFOUND` if the toolchain does not have a cargo executable."
|
||||
"${_DISCOVERED_TOOLCHAINS_CARGO_PATH}"
|
||||
)
|
||||
set(Rust_RUSTUP_TOOLCHAINS_VERSION
|
||||
CACHE INTERNAL
|
||||
"List of the rust toolchain version corresponding to the toolchain at the same index in \
|
||||
`Rust_RUSTUP_TOOLCHAINS`."
|
||||
"${_DISCOVERED_TOOLCHAINS_VERSION}"
|
||||
)
|
||||
|
||||
# Rust_TOOLCHAIN is preferred over a requested version if it is set.
|
||||
if (NOT DEFINED Rust_TOOLCHAIN)
|
||||
if (NOT DEFINED _TOOLCHAIN_OVERRIDE)
|
||||
set(_TOOLCHAIN_SELECTED "${_TOOLCHAIN_DEFAULT}")
|
||||
else()
|
||||
set(_TOOLCHAIN_SELECTED "${_TOOLCHAIN_OVERRIDE}")
|
||||
endif()
|
||||
# Check default toolchain first.
|
||||
_findrust_version_ok("_TOOLCHAIN_${_TOOLCHAIN_SELECTED}_VERSION" _VERSION_OK)
|
||||
if(NOT "${_VERSION_OK}")
|
||||
foreach(_TOOLCHAIN "${_DISCOVERED_TOOLCHAINS}")
|
||||
_findrust_version_ok("_TOOLCHAIN_${_TOOLCHAIN}_VERSION" _VERSION_OK)
|
||||
if("${_VERSION_OK}")
|
||||
set(_TOOLCHAIN_SELECTED "${_TOOLCHAIN}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
# Check if we found a suitable version in the for loop.
|
||||
if(NOT "${_VERSION_OK}")
|
||||
string(REPLACE ";" "\n" _DISCOVERED_TOOLCHAINS "${_DISCOVERED_TOOLCHAINS}")
|
||||
_findrust_failed("Failed to find a Rust toolchain matching the version requirements of "
|
||||
"${Rust_FIND_VERSION}. Available toolchains: ${_DISCOVERED_TOOLCHAINS}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(Rust_TOOLCHAIN "${_TOOLCHAIN_SELECTED}" CACHE STRING "The rustup toolchain to use")
|
||||
set_property(CACHE Rust_TOOLCHAIN PROPERTY STRINGS "${_DISCOVERED_TOOLCHAINS}")
|
||||
|
||||
if(NOT Rust_FIND_QUIETLY)
|
||||
message(STATUS "Rust Toolchain: ${Rust_TOOLCHAIN}")
|
||||
endif()
|
||||
|
||||
if (NOT Rust_TOOLCHAIN IN_LIST _DISCOVERED_TOOLCHAINS)
|
||||
# If the precise toolchain wasn't found, try appending the default host
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${Rust_RUSTUP}" show
|
||||
RESULT_VARIABLE _SHOW_RESULT
|
||||
OUTPUT_VARIABLE _SHOW_RAW
|
||||
)
|
||||
if(NOT "${_SHOW_RESULT}" EQUAL "0")
|
||||
_findrust_failed("Command `${Rust_RUSTUP} show` failed")
|
||||
endif()
|
||||
|
||||
if (_SHOW_RAW MATCHES "Default host: ([a-zA-Z0-9_\\-]*)\n")
|
||||
set(_DEFAULT_HOST "${CMAKE_MATCH_1}")
|
||||
else()
|
||||
_findrust_failed("Failed to parse \"Default host\" from `${Rust_RUSTUP} show`. Got: ${_SHOW_RAW}")
|
||||
endif()
|
||||
|
||||
if (NOT "${Rust_TOOLCHAIN}-${_DEFAULT_HOST}" IN_LIST _DISCOVERED_TOOLCHAINS)
|
||||
set(_NOT_FOUND_MESSAGE "Could not find toolchain '${Rust_TOOLCHAIN}'\n"
|
||||
"Available toolchains:\n"
|
||||
)
|
||||
foreach(_TOOLCHAIN ${_DISCOVERED_TOOLCHAINS})
|
||||
list(APPEND _NOT_FOUND_MESSAGE " `${_TOOLCHAIN}`\n")
|
||||
endforeach()
|
||||
_findrust_failed(${_NOT_FOUND_MESSAGE})
|
||||
endif()
|
||||
|
||||
set(_RUSTUP_TOOLCHAIN_FULL "${Rust_TOOLCHAIN}-${_DEFAULT_HOST}")
|
||||
else()
|
||||
set(_RUSTUP_TOOLCHAIN_FULL "${Rust_TOOLCHAIN}")
|
||||
endif()
|
||||
|
||||
set(_RUST_TOOLCHAIN_PATH "${_TOOLCHAIN_${_RUSTUP_TOOLCHAIN_FULL}_PATH}")
|
||||
if(NOT "${Rust_FIND_QUIETLY}")
|
||||
message(VERBOSE "Rust toolchain ${_RUSTUP_TOOLCHAIN_FULL}")
|
||||
message(VERBOSE "Rust toolchain path ${_RUST_TOOLCHAIN_PATH}")
|
||||
endif()
|
||||
|
||||
# Is overridden if the user specifies `Rust_COMPILER` explicitly.
|
||||
find_program(
|
||||
Rust_COMPILER_CACHED
|
||||
rustc
|
||||
HINTS "${_RUST_TOOLCHAIN_PATH}/bin"
|
||||
NO_DEFAULT_PATH)
|
||||
elseif (Rust_RUSTUP)
|
||||
get_filename_component(_RUST_TOOLCHAIN_PATH "${Rust_RUSTUP}" DIRECTORY)
|
||||
get_filename_component(_RUST_TOOLCHAIN_PATH "${_RUST_TOOLCHAIN_PATH}" DIRECTORY)
|
||||
find_program(
|
||||
Rust_COMPILER_CACHED
|
||||
rustc
|
||||
HINTS "${_RUST_TOOLCHAIN_PATH}/bin"
|
||||
NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_program(Rust_COMPILER_CACHED rustc)
|
||||
if (EXISTS "${Rust_COMPILER_CACHED}")
|
||||
# rustc is expected to be at `<toolchain_path>/bin/rustc`.
|
||||
get_filename_component(_RUST_TOOLCHAIN_PATH "${Rust_COMPILER_CACHED}" DIRECTORY)
|
||||
get_filename_component(_RUST_TOOLCHAIN_PATH "${_RUST_TOOLCHAIN_PATH}" DIRECTORY)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT EXISTS "${Rust_COMPILER_CACHED}")
|
||||
message(FATAL_ERROR "The rustc executable ${Rust_COMPILER} was not found. "
|
||||
"Consider setting `Rust_COMPILER` to the absolute path of `rustc`."
|
||||
set(_NOT_FOUND_MESSAGE "The rustc executable was not found. "
|
||||
"Rust not installed or ~/.cargo/bin not added to path?\n"
|
||||
"Hint: Consider setting `Rust_COMPILER` to the absolute path of `rustc`."
|
||||
)
|
||||
_findrust_failed(${_NOT_FOUND_MESSAGE})
|
||||
endif()
|
||||
|
||||
if (Rust_RESOLVE_RUSTUP_TOOLCHAINS)
|
||||
set(_NOT_FOUND_MESSAGE "Rust was detected to be managed by rustup, but failed to find `cargo` "
|
||||
"next to `rustc` in `${_RUST_TOOLCHAIN_PATH}/bin`. This can happen for custom toolchains, "
|
||||
"if cargo was not built. "
|
||||
"Please manually specify the path to a compatible `cargo` by setting `Rust_CARGO`."
|
||||
)
|
||||
find_program(
|
||||
Rust_CARGO_CACHED
|
||||
cargo
|
||||
HINTS "${_RUST_TOOLCHAIN_PATH}/bin"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
# note: maybe can use find_package_handle_standard_args here, if we remove the _CACHED postfix.
|
||||
# not sure why that is here...
|
||||
if(NOT EXISTS "${Rust_CARGO_CACHED}")
|
||||
_findrust_failed(${_NOT_FOUND_MESSAGE})
|
||||
endif()
|
||||
set(Rust_TOOLCHAIN_IS_RUSTUP_MANAGED TRUE CACHE INTERNAL "" FORCE)
|
||||
else()
|
||||
set(_NOT_FOUND_MESSAGE "Failed to find `cargo` in PATH and `${_RUST_TOOLCHAIN_PATH}/bin`.\n"
|
||||
"Please ensure cargo is in PATH or manually specify the path to a compatible `cargo` by "
|
||||
"setting `Rust_CARGO`."
|
||||
)
|
||||
# On some systems (e.g. NixOS) cargo is not managed by rustup and also not next to rustc.
|
||||
find_program(
|
||||
Rust_CARGO_CACHED
|
||||
cargo
|
||||
HINTS "${_RUST_TOOLCHAIN_PATH}/bin"
|
||||
)
|
||||
# note: maybe can use find_package_handle_standard_args here, if we remove the _CACHED postfix.
|
||||
# not sure why that is here...
|
||||
if(NOT EXISTS "${Rust_CARGO_CACHED}")
|
||||
_findrust_failed(${_NOT_FOUND_MESSAGE})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${Rust_CARGO_CACHED}" --version --verbose
|
||||
OUTPUT_VARIABLE _CARGO_VERSION_RAW
|
||||
RESULT_VARIABLE _CARGO_VERSION_RESULT
|
||||
)
|
||||
# todo: check if cargo is a required component!
|
||||
if(NOT ( "${_CARGO_VERSION_RESULT}" EQUAL "0" ))
|
||||
_findrust_failed("Failed to get cargo version.\n"
|
||||
"`${Rust_CARGO_CACHED} --version` failed with error: `${_CARGO_VERSION_RESULT}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# todo: don't set cache variables here, but let find_package_handle_standard_args do the promotion
|
||||
# later.
|
||||
if (_CARGO_VERSION_RAW MATCHES "cargo ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
|
||||
set(Rust_CARGO_VERSION_MAJOR "${CMAKE_MATCH_1}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_CARGO_VERSION_MINOR "${CMAKE_MATCH_2}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_CARGO_VERSION_PATCH "${CMAKE_MATCH_3}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_CARGO_VERSION "${Rust_CARGO_VERSION_MAJOR}.${Rust_CARGO_VERSION_MINOR}.${Rust_CARGO_VERSION_PATCH}" CACHE INTERNAL "" FORCE)
|
||||
# Workaround for the version strings where the `cargo ` prefix is missing.
|
||||
elseif(_CARGO_VERSION_RAW MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
|
||||
set(Rust_CARGO_VERSION_MAJOR "${CMAKE_MATCH_1}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_CARGO_VERSION_MINOR "${CMAKE_MATCH_2}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_CARGO_VERSION_PATCH "${CMAKE_MATCH_3}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_CARGO_VERSION "${Rust_CARGO_VERSION_MAJOR}.${Rust_CARGO_VERSION_MINOR}.${Rust_CARGO_VERSION_PATCH}" CACHE INTERNAL "" FORCE)
|
||||
else()
|
||||
_findrust_failed(
|
||||
"Failed to parse cargo version. `cargo --version` evaluated to (${_CARGO_VERSION_RAW}). "
|
||||
"Expected a <Major>.<Minor>.<Patch> version triple."
|
||||
)
|
||||
endif()
|
||||
|
||||
# Figure out the target by just using the host target.
|
||||
# If you want to cross-compile, you'll have to set Rust_CARGO_TARGET
|
||||
if(NOT Rust_CARGO_TARGET_CACHED)
|
||||
execute_process(
|
||||
execute_process(
|
||||
COMMAND "${Rust_COMPILER_CACHED}" --version --verbose
|
||||
OUTPUT_VARIABLE _RUSTC_VERSION_RAW
|
||||
RESULT_VARIABLE _RUSTC_VERSION_RESULT
|
||||
)
|
||||
)
|
||||
|
||||
if(NOT ( "${_RUSTC_VERSION_RESULT}" EQUAL "0" ))
|
||||
message(FATAL_ERROR "Failed to get rustc version.\n"
|
||||
"${Rust_COMPILER} --version failed with error: `${_RUSTC_VERSION_RESULT}`")
|
||||
endif()
|
||||
if(NOT ( "${_RUSTC_VERSION_RESULT}" EQUAL "0" ))
|
||||
_findrust_failed("Failed to get rustc version.\n"
|
||||
"${Rust_COMPILER_CACHED} --version failed with error: `${_RUSTC_VERSION_RESULT}`")
|
||||
endif()
|
||||
|
||||
if (_RUSTC_VERSION_RAW MATCHES "host: ([a-zA-Z0-9_\\-]*)\n")
|
||||
if (_RUSTC_VERSION_RAW MATCHES "rustc ([0-9]+)\\.([0-9]+)\\.([0-9]+)(-nightly)?")
|
||||
set(Rust_VERSION_MAJOR "${CMAKE_MATCH_1}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_VERSION_MINOR "${CMAKE_MATCH_2}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_VERSION_PATCH "${CMAKE_MATCH_3}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_VERSION "${Rust_VERSION_MAJOR}.${Rust_VERSION_MINOR}.${Rust_VERSION_PATCH}" CACHE INTERNAL "" FORCE)
|
||||
if(CMAKE_MATCH_4)
|
||||
set(Rust_IS_NIGHTLY 1 CACHE INTERNAL "" FORCE)
|
||||
else()
|
||||
set(Rust_IS_NIGHTLY 0 CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
else()
|
||||
_findrust_failed("Failed to parse rustc version. `${Rust_COMPILER_CACHED} --version --verbose` "
|
||||
"evaluated to:\n`${_RUSTC_VERSION_RAW}`"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (_RUSTC_VERSION_RAW MATCHES "host: ([a-zA-Z0-9_\\-]*)\n")
|
||||
set(Rust_DEFAULT_HOST_TARGET "${CMAKE_MATCH_1}")
|
||||
else()
|
||||
message(FATAL_ERROR
|
||||
"Failed to parse rustc host target. `rustc --version --verbose` evaluated to:\n${_RUSTC_VERSION_RAW}"
|
||||
set(Rust_CARGO_HOST_TARGET_CACHED "${Rust_DEFAULT_HOST_TARGET}" CACHE STRING "Host triple")
|
||||
else()
|
||||
_findrust_failed(
|
||||
"Failed to parse rustc host target. `rustc --version --verbose` evaluated to:\n${_RUSTC_VERSION_RAW}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
message(FATAL_ERROR "CMake is in cross-compiling mode."
|
||||
"Manually set `Rust_CARGO_TARGET`."
|
||||
if (_RUSTC_VERSION_RAW MATCHES "LLVM version: ([0-9]+)\\.([0-9]+)(\\.([0-9]+))?")
|
||||
set(Rust_LLVM_VERSION_MAJOR "${CMAKE_MATCH_1}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_LLVM_VERSION_MINOR "${CMAKE_MATCH_2}" CACHE INTERNAL "" FORCE)
|
||||
# With the Rust toolchain 1.44.1 the reported LLVM version is 9.0, i.e. without a patch version.
|
||||
# Since cmake regex does not support non-capturing groups, just ignore Match 3.
|
||||
set(Rust_LLVM_VERSION_PATCH "${CMAKE_MATCH_4}" CACHE INTERNAL "" FORCE)
|
||||
set(Rust_LLVM_VERSION "${Rust_LLVM_VERSION_MAJOR}.${Rust_LLVM_VERSION_MINOR}.${Rust_LLVM_VERSION_PATCH}" CACHE INTERNAL "" FORCE)
|
||||
elseif(NOT Rust_FIND_QUIETLY)
|
||||
message(
|
||||
WARNING
|
||||
"Failed to parse rustc LLVM version. `rustc --version --verbose` evaluated to:\n${_RUSTC_VERSION_RAW}"
|
||||
)
|
||||
endif()
|
||||
set(Rust_CARGO_TARGET_CACHED "${Rust_DEFAULT_HOST_TARGET}" CACHE STRING "Target triple")
|
||||
endif()
|
||||
|
||||
if (NOT Rust_CARGO_TARGET_CACHED)
|
||||
unset(_CARGO_ARCH)
|
||||
unset(_CARGO_ABI)
|
||||
if (WIN32)
|
||||
if (CMAKE_VS_PLATFORM_NAME)
|
||||
string(TOLOWER "${CMAKE_VS_PLATFORM_NAME}" LOWER_VS_PLATFORM_NAME)
|
||||
if ("${LOWER_VS_PLATFORM_NAME}" STREQUAL "win32")
|
||||
set(_CARGO_ARCH i686)
|
||||
elseif("${LOWER_VS_PLATFORM_NAME}" STREQUAL "x64")
|
||||
set(_CARGO_ARCH x86_64)
|
||||
elseif("${LOWER_VS_PLATFORM_NAME}" STREQUAL "arm64")
|
||||
set(_CARGO_ARCH aarch64)
|
||||
else()
|
||||
message(WARNING "VS Platform '${CMAKE_VS_PLATFORM_NAME}' not recognized")
|
||||
endif()
|
||||
endif()
|
||||
# Fallback path
|
||||
if(NOT DEFINED _CARGO_ARCH)
|
||||
# Possible values for windows when not cross-compiling taken from here:
|
||||
# https://learn.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details
|
||||
# When cross-compiling the user is expected to supply the value, so we match more variants.
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(AMD64|amd64|x86_64)$")
|
||||
set(_CARGO_ARCH x86_64)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(ARM64|arm64|aarch64)$")
|
||||
set(_CARGO_ARCH aarch64)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(X86|x86|i686)$")
|
||||
set(_CARGO_ARCH i686)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "i586")
|
||||
set(_CARGO_ARCH i586)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "IA64")
|
||||
message(FATAL_ERROR "No rust target for Intel Itanium.")
|
||||
elseif(NOT "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
message(WARNING "Failed to detect target architecture. Please set `CMAKE_SYSTEM_PROCESSOR`"
|
||||
" to your target architecture or set `Rust_CARGO_TARGET` to your cargo target triple."
|
||||
)
|
||||
else()
|
||||
message(WARNING "Failed to detect target architecture. Please set "
|
||||
"`Rust_CARGO_TARGET` to your cargo target triple."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(_CARGO_VENDOR "pc-windows")
|
||||
|
||||
# The MSVC Generators will always target the msvc ABI.
|
||||
# For other generators we check the compiler ID and compiler target (if present)
|
||||
# If no compiler is set and we are not cross-compiling then we just choose the
|
||||
# default rust host target.
|
||||
if(DEFINED MSVC
|
||||
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"
|
||||
OR "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC"
|
||||
OR "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "-msvc$"
|
||||
OR "${CMAKE_C_COMPILER_TARGET}" MATCHES "-msvc$"
|
||||
)
|
||||
set(_CARGO_ABI msvc)
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"
|
||||
OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU"
|
||||
OR "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "-gnu$"
|
||||
OR "${CMAKE_C_COMPILER_TARGET}" MATCHES "-gnu$"
|
||||
OR (NOT CMAKE_CROSSCOMPILING AND "${Rust_DEFAULT_HOST_TARGET}" MATCHES "-gnu$")
|
||||
)
|
||||
set(_CARGO_ABI gnu)
|
||||
elseif(NOT "${CMAKE_CROSSCOMPILING}" AND "${Rust_DEFAULT_HOST_TARGET}" MATCHES "-msvc$")
|
||||
# We first check if the gnu branch matches to ensure this fallback is only used
|
||||
# if no compiler is enabled.
|
||||
set(_CARGO_ABI msvc)
|
||||
else()
|
||||
message(WARNING "Could not determine the target ABI. Please specify `Rust_CARGO_TARGET` manually.")
|
||||
endif()
|
||||
|
||||
if(DEFINED _CARGO_ARCH AND DEFINED _CARGO_VENDOR AND DEFINED _CARGO_ABI)
|
||||
set(Rust_CARGO_TARGET_CACHED "${_CARGO_ARCH}-${_CARGO_VENDOR}-${_CARGO_ABI}"
|
||||
CACHE STRING "Target triple")
|
||||
endif()
|
||||
elseif (ANDROID)
|
||||
if (CMAKE_ANDROID_ARCH_ABI STREQUAL armeabi-v7a)
|
||||
if (CMAKE_ANDROID_ARM_MODE)
|
||||
set(_Rust_ANDROID_TARGET armv7-linux-androideabi)
|
||||
else ()
|
||||
set(_Rust_ANDROID_TARGET thumbv7neon-linux-androideabi)
|
||||
endif()
|
||||
elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL arm64-v8a)
|
||||
set(_Rust_ANDROID_TARGET aarch64-linux-android)
|
||||
elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL x86)
|
||||
set(_Rust_ANDROID_TARGET i686-linux-android)
|
||||
elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL x86_64)
|
||||
set(_Rust_ANDROID_TARGET x86_64-linux-android)
|
||||
endif()
|
||||
|
||||
if (_Rust_ANDROID_TARGET)
|
||||
set(Rust_CARGO_TARGET_CACHED "${_Rust_ANDROID_TARGET}" CACHE STRING "Target triple")
|
||||
endif()
|
||||
endif()
|
||||
# Fallback to the default host target
|
||||
if(NOT Rust_CARGO_TARGET_CACHED)
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
message(WARNING "CMake is in cross-compiling mode, but the cargo target-triple could not be inferred."
|
||||
"Falling back to the default host target. Please consider manually setting `Rust_CARGO_TARGET`."
|
||||
)
|
||||
endif()
|
||||
set(Rust_CARGO_TARGET_CACHED "${Rust_DEFAULT_HOST_TARGET}" CACHE STRING "Target triple")
|
||||
endif()
|
||||
|
||||
message(STATUS "Rust Target: ${Rust_CARGO_TARGET_CACHED}")
|
||||
endif()
|
||||
|
||||
if(Rust_CARGO_TARGET_CACHED STREQUAL Rust_DEFAULT_HOST_TARGET)
|
||||
set(Rust_CROSSCOMPILING FALSE CACHE INTERNAL "Rust is configured for cross-compiling")
|
||||
else()
|
||||
set(Rust_CROSSCOMPILING TRUE CACHE INTERNAL "Rust is configured for cross-compiling")
|
||||
endif()
|
||||
|
||||
_corrosion_parse_target_triple("${Rust_CARGO_TARGET_CACHED}" rust_arch rust_vendor rust_os rust_env)
|
||||
_corrosion_parse_target_triple("${Rust_CARGO_HOST_TARGET_CACHED}" rust_host_arch rust_host_vendor rust_host_os rust_host_env)
|
||||
|
||||
set(Rust_CARGO_TARGET_ARCH "${rust_arch}" CACHE INTERNAL "Target architecture")
|
||||
set(Rust_CARGO_TARGET_VENDOR "${rust_vendor}" CACHE INTERNAL "Target vendor")
|
||||
set(Rust_CARGO_TARGET_OS "${rust_os}" CACHE INTERNAL "Target Operating System")
|
||||
set(Rust_CARGO_TARGET_ENV "${rust_env}" CACHE INTERNAL "Target environment")
|
||||
|
||||
set(Rust_CARGO_HOST_ARCH "${rust_host_arch}" CACHE INTERNAL "Host architecture")
|
||||
set(Rust_CARGO_HOST_VENDOR "${rust_host_vendor}" CACHE INTERNAL "Host vendor")
|
||||
set(Rust_CARGO_HOST_OS "${rust_host_os}" CACHE INTERNAL "Host Operating System")
|
||||
set(Rust_CARGO_HOST_ENV "${rust_host_env}" CACHE INTERNAL "Host environment")
|
||||
|
||||
if(NOT DEFINED CACHE{Rust_CARGO_TARGET_LINK_NATIVE_LIBS})
|
||||
message(STATUS "Determining required link libraries for target ${Rust_CARGO_TARGET_CACHED}")
|
||||
unset(required_native_libs)
|
||||
_corrosion_determine_libs_new("${Rust_CARGO_TARGET_CACHED}" required_native_libs)
|
||||
if(DEFINED required_native_libs)
|
||||
message(STATUS "Required static libs for target ${Rust_CARGO_TARGET_CACHED}: ${required_native_libs}" )
|
||||
endif()
|
||||
# In very recent corrosion versions it is possible to override the rust compiler version
|
||||
# per target, so to be totally correct we would need to determine the libraries for
|
||||
# every installed Rust version, that the user could choose from.
|
||||
# In practice there aren't likely going to be any major differences, so we just do it once
|
||||
# for the target and once for the host target (if cross-compiling).
|
||||
set(Rust_CARGO_TARGET_LINK_NATIVE_LIBS "${required_native_libs}" CACHE INTERNAL
|
||||
"Required native libraries when linking Rust static libraries")
|
||||
endif()
|
||||
|
||||
if(Rust_CROSSCOMPILING AND NOT DEFINED CACHE{Rust_CARGO_HOST_TARGET_LINK_NATIVE_LIBS})
|
||||
message(STATUS "Determining required link libraries for target ${Rust_CARGO_HOST_TARGET_CACHED}")
|
||||
unset(host_libs)
|
||||
_corrosion_determine_libs_new("${Rust_CARGO_HOST_TARGET_CACHED}" host_libs)
|
||||
if(DEFINED host_libs)
|
||||
message(STATUS "Required static libs for host target ${Rust_CARGO_HOST_TARGET_CACHED}: ${host_libs}" )
|
||||
endif()
|
||||
set(Rust_CARGO_HOST_TARGET_LINK_NATIVE_LIBS "${host_libs}" CACHE INTERNAL
|
||||
"Required native libraries when linking Rust static libraries for the host target")
|
||||
endif()
|
||||
|
||||
# Set the input variables as non-cache variables so that the variables are available after
|
||||
@@ -82,6 +789,24 @@ endforeach()
|
||||
|
||||
find_package_handle_standard_args(
|
||||
Rust
|
||||
REQUIRED_VARS Rust_COMPILER Rust_CARGO Rust_CARGO_TARGET
|
||||
REQUIRED_VARS Rust_COMPILER Rust_VERSION Rust_CARGO Rust_CARGO_VERSION Rust_CARGO_TARGET Rust_CARGO_HOST_TARGET
|
||||
VERSION_VAR Rust_VERSION
|
||||
)
|
||||
|
||||
|
||||
if(NOT TARGET Rust::Rustc)
|
||||
add_executable(Rust::Rustc IMPORTED GLOBAL)
|
||||
set_property(
|
||||
TARGET Rust::Rustc
|
||||
PROPERTY IMPORTED_LOCATION "${Rust_COMPILER_CACHED}"
|
||||
)
|
||||
|
||||
add_executable(Rust::Cargo IMPORTED GLOBAL)
|
||||
set_property(
|
||||
TARGET Rust::Cargo
|
||||
PROPERTY IMPORTED_LOCATION "${Rust_CARGO_CACHED}"
|
||||
)
|
||||
set(Rust_FOUND true)
|
||||
endif()
|
||||
|
||||
list(POP_BACK CMAKE_MESSAGE_CONTEXT)
|
||||
|
||||
@@ -106,7 +106,7 @@ configure_file(fish.pc.in fish.pc.noversion @ONLY)
|
||||
add_custom_command(OUTPUT fish.pc
|
||||
COMMAND sed '/Version/d' fish.pc.noversion > fish.pc
|
||||
COMMAND printf "Version: " >> fish.pc
|
||||
COMMAND cat ${FBVF} >> fish.pc
|
||||
COMMAND sed 's/FISH_BUILD_VERSION=//\;s/\"//g' ${FBVF} >> fish.pc
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS CHECK-FISH-BUILD-VERSION-FILE ${CMAKE_CURRENT_BINARY_DIR}/fish.pc.noversion)
|
||||
|
||||
@@ -164,8 +164,14 @@ 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()
|
||||
|
||||
# Group install targets into a InstallTargets folder
|
||||
set_property(TARGET build_fish_pc CHECK-FISH-BUILD-VERSION-FILE
|
||||
tests_buildroot_target
|
||||
PROPERTY FOLDER cmake/InstallTargets)
|
||||
|
||||
# Make a target build_root that installs into the buildroot directory, for testing.
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# Trying to build using the resolved toolchain causes all kinds of weird errors
|
||||
# Just let rustup do its job
|
||||
set(Rust_RESOLVE_RUSTUP_TOOLCHAINS Off)
|
||||
|
||||
include(FindRust)
|
||||
find_package(Rust REQUIRED)
|
||||
|
||||
@@ -18,11 +22,11 @@ else()
|
||||
set(rust_target_dir "${FISH_RUST_BUILD_DIR}/${Rust_CARGO_HOST_TARGET}")
|
||||
endif()
|
||||
|
||||
set(rust_profile $<IF:$<CONFIG:Debug>,debug,$<IF:$<CONFIG:RelWithDebInfo>,release-with-debug,release>>)
|
||||
set(rust_profile $<IF:$<CONFIG:Debug>,debug,release>)
|
||||
set(rust_debugflags "$<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g>")
|
||||
|
||||
|
||||
# Temporary hack to propagate CMake flags/options to build.rs. We need to get CMake to evaluate the
|
||||
# Temporary hack to propogate CMake flags/options to build.rs. We need to get CMake to evaluate the
|
||||
# truthiness of the strings if they are set.
|
||||
set(CMAKE_WITH_GETTEXT "1")
|
||||
if(DEFINED WITH_GETTEXT AND NOT "${WITH_GETTEXT}")
|
||||
@@ -34,21 +38,24 @@ if(FISH_CRATE_FEATURES)
|
||||
list(PREPEND FEATURES_ARG "--features")
|
||||
endif()
|
||||
|
||||
get_property(
|
||||
RUSTC_EXECUTABLE
|
||||
TARGET Rust::Rustc PROPERTY IMPORTED_LOCATION
|
||||
)
|
||||
|
||||
# Tell Cargo where our build directory is so it can find Cargo.toml.
|
||||
set(VARS_FOR_CARGO
|
||||
"FISH_BUILD_DIR=${CMAKE_BINARY_DIR}"
|
||||
"PREFIX=${CMAKE_INSTALL_PREFIX}"
|
||||
# Temporary hack to propagate CMake flags/options to build.rs.
|
||||
# Temporary hack to propogate CMake flags/options to build.rs.
|
||||
"CMAKE_WITH_GETTEXT=${CMAKE_WITH_GETTEXT}"
|
||||
# Cheesy so we can tell cmake was used to build
|
||||
"CMAKE=1"
|
||||
"DOCDIR=${CMAKE_INSTALL_FULL_DOCDIR}"
|
||||
"DATADIR=${CMAKE_INSTALL_FULL_DATADIR}"
|
||||
"SYSCONFDIR=${CMAKE_INSTALL_FULL_SYSCONFDIR}"
|
||||
"BINDIR=${CMAKE_INSTALL_FULL_BINDIR}"
|
||||
"LOCALEDIR=${CMAKE_INSTALL_FULL_LOCALEDIR}"
|
||||
"CARGO_TARGET_DIR=${FISH_RUST_BUILD_DIR}"
|
||||
"CARGO_BUILD_RUSTC=${Rust_COMPILER}"
|
||||
"CARGO_BUILD_RUSTC=${RUSTC_EXECUTABLE}"
|
||||
"${FISH_PCRE2_BUILDFLAG}"
|
||||
"RUSTFLAGS=$ENV{RUSTFLAGS} ${rust_debugflags}"
|
||||
)
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
# This adds ctest support to the project
|
||||
enable_testing()
|
||||
|
||||
# By default, ctest runs tests serially
|
||||
# Support CTEST_PARALLEL_LEVEL as an environment variable in addition to a CMake variable
|
||||
if(NOT CTEST_PARALLEL_LEVEL)
|
||||
set(CTEST_PARALLEL_LEVEL $ENV{CTEST_PARALLEL_LEVEL})
|
||||
if(NOT CTEST_PARALLEL_LEVEL)
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(CORES)
|
||||
math(EXPR halfcores "${CORES} / 2")
|
||||
set(CTEST_PARALLEL_LEVEL ${halfcores})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# Put in a tests folder to reduce the top level targets in IDEs.
|
||||
set(CMAKE_FOLDER tests)
|
||||
|
||||
@@ -21,15 +8,13 @@ set(CMAKE_FOLDER tests)
|
||||
# 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 fish_run_tests` target
|
||||
# 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 fish_run_tests` to never depend on `make all`, i.e.
|
||||
# running `make fish_run_tests` does not require any of the binaries to be built before testing.
|
||||
# * It is not possible to set top-level CTest options/settings such as CTEST_PARALLEL_LEVEL from
|
||||
# within the CMake configuration file.
|
||||
# * 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.
|
||||
# * Circling back to the point about individual tests not being actual Makefile targets, CMake does
|
||||
@@ -39,33 +24,92 @@ set(SKIP_RETURN_CODE 125)
|
||||
|
||||
# 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
|
||||
COMMAND env FISH_FORCE_COLOR=1
|
||||
FISH_SOURCE_DIR=${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_CTEST_COMMAND} --force-new-ctest-process # --verbose
|
||||
--output-on-failure --progress
|
||||
DEPENDS fish fish_indent fish_key_reader fish_test_helper
|
||||
DEPENDS tests_dir funcs_dir 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)
|
||||
|
||||
# The "test" directory.
|
||||
set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test)
|
||||
|
||||
# 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)
|
||||
|
||||
add_custom_target(tests_dir DEPENDS tests)
|
||||
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)
|
||||
endif()
|
||||
|
||||
# Copy littlecheck.py
|
||||
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 fish_run_tests` is executed (requiring `make all` first),
|
||||
# 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
|
||||
# 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 fish_indent fish_key_reader fish_test_helper USES_TERMINAL)
|
||||
DEPENDS tests_dir funcs_dir tests_buildroot_target USES_TERMINAL )
|
||||
endfunction()
|
||||
|
||||
add_executable(fish_test_helper tests/fish_test_helper.c)
|
||||
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}
|
||||
--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)
|
||||
|
||||
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_SOURCE_DIR}/tests/test_driver.py --cachedir=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
checks/${CHECK}.fish
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
||||
COMMAND 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)
|
||||
@@ -76,9 +120,9 @@ 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_SOURCE_DIR}/tests/test_driver.py --cachedir=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
pexpects/${PEXPECT}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
||||
COMMAND 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)
|
||||
@@ -109,7 +153,7 @@ endif()
|
||||
|
||||
add_test(
|
||||
NAME "cargo-test"
|
||||
COMMAND env ${VARS_FOR_CARGO} cargo test --no-default-features ${CARGO_FLAGS} --workspace --target-dir ${rust_target_dir} ${cargo_test_flags}
|
||||
COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --workspace --target-dir ${rust_target_dir} ${cargo_test_flags}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
set_tests_properties("cargo-test" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
|
||||
|
||||
29
debian/control
vendored
29
debian/control
vendored
@@ -3,16 +3,10 @@ Section: shells
|
||||
Priority: optional
|
||||
Maintainer: ridiculous_fish <corydoras@ridiculousfish.com>
|
||||
Uploaders: David Adam <zanchey@ucc.gu.uwa.edu.au>
|
||||
Build-Depends: debhelper (>= 12),
|
||||
cargo (>= 0.66) | cargo-mozilla (>= 0.66),
|
||||
cmake (>= 3.15.0) | cmake-mozilla (>= 3.15.0),
|
||||
gettext,
|
||||
libpcre2-dev,
|
||||
rustc (>= 1.70),
|
||||
Build-Depends: debhelper (>= 12), cmake (>= 3.19.0) | cmake-mozilla (>= 3.19.0), gettext,
|
||||
rustc (>= 1.70), cargo (>= 0.66) | cargo-mozilla (>= 0.66), libpcre2-dev,
|
||||
# Test dependencies
|
||||
locales-all,
|
||||
ncurses-base,
|
||||
python3
|
||||
locales-all, python3
|
||||
Standards-Version: 4.1.5
|
||||
Homepage: https://fishshell.com/
|
||||
Vcs-Git: https://github.com/fish-shell/fish-shell.git
|
||||
@@ -20,21 +14,8 @@ Vcs-Browser: https://github.com/fish-shell/fish-shell
|
||||
|
||||
Package: fish
|
||||
Architecture: any
|
||||
# for col and lock - bsdmainutils is required in Ubuntu focal
|
||||
Depends: bsdextrautils | bsdmainutils,
|
||||
file,
|
||||
# for the gettext command
|
||||
gettext-base,
|
||||
# for nroff and preconv
|
||||
groff-base,
|
||||
man-db,
|
||||
# for terminal definitions
|
||||
ncurses-base,
|
||||
# for kill
|
||||
procps,
|
||||
python3 (>=3.5),
|
||||
${misc:Depends},
|
||||
${shlibs:Depends}
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, passwd (>= 4.0.3-10), gettext-base, man-db,
|
||||
procps, python3 (>=3.5)
|
||||
Conflicts: fish-common
|
||||
Recommends: xsel (>=1.2.0)
|
||||
Suggests: xdg-utils
|
||||
|
||||
4
debian/copyright
vendored
4
debian/copyright
vendored
@@ -5,12 +5,12 @@ Source: https://fishshell.com/
|
||||
|
||||
Files: *
|
||||
Copyright: 2005-2009 Axel Liljencrantz <axel@liljencrantz.se>
|
||||
2009- fish-shell contributors
|
||||
2009-2024 fish-shell contributors
|
||||
License: GPL-2
|
||||
|
||||
Files: doc_src/python_docs_theme/*
|
||||
Copyright: 2001-2017 Python Software Foundation
|
||||
2020- fish-shell contributors
|
||||
2020-2024 fish-shell contributors
|
||||
License: Python
|
||||
|
||||
Files: share/tools/web_config/js/alpine.js
|
||||
|
||||
3
debian/rules
vendored
3
debian/rules
vendored
@@ -20,6 +20,3 @@ override_dh_clean:
|
||||
dh_clean
|
||||
-unlink .cargo
|
||||
-unlink vendor
|
||||
|
||||
override_dh_auto_test:
|
||||
make fish_run_tests
|
||||
|
||||
23
deny.toml
23
deny.toml
@@ -1,23 +0,0 @@
|
||||
[licenses]
|
||||
# We want really high confidence when inferring licenses from text
|
||||
confidence-threshold = 0.93
|
||||
unused-allowed-license = "allow" # don't warn for unused licenses in this list
|
||||
allow = [
|
||||
"BSD-2-Clause",
|
||||
"BSD-3-Clause",
|
||||
"BSL-1.0",
|
||||
"GPL-2.0",
|
||||
"ISC",
|
||||
"LGPL-2.0",
|
||||
"MIT",
|
||||
"MPL-2.0",
|
||||
"PSF-2.0",
|
||||
"Unicode-DFS-2016",
|
||||
"Unicode-3.0",
|
||||
"WTFPL",
|
||||
"Zlib",
|
||||
]
|
||||
|
||||
[sources.allow-org]
|
||||
# 1 or more github.com organizations to allow git sources for
|
||||
github = ["fish-shell"]
|
||||
@@ -17,7 +17,7 @@ Description
|
||||
|
||||
It is equivalent to ``gettext fish STRING``, meaning it can only be used to look up fish's own translations.
|
||||
|
||||
It requires fish to be built with gettext support. If that support is disabled, or there is no translation it will echo the argument back.
|
||||
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`.
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ Combining these features, it is possible to create custom syntaxes, where a regu
|
||||
|
||||
> abbr > ~/.config/fish/conf.d/myabbrs.fish
|
||||
|
||||
This will save all your abbreviations in "myabbrs.fish", overwriting the whole file so it doesn't leave any duplicates,
|
||||
This will save all your abbrevations in "myabbrs.fish", overwriting the whole file so it doesn't leave any duplicates,
|
||||
or restore abbreviations you had erased.
|
||||
Of course any functions will have to be saved separately, see :doc:`funcsave <funcsave>`.
|
||||
|
||||
@@ -125,7 +125,6 @@ This first creates a function ``vim_edit`` which prepends ``vim`` before its arg
|
||||
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.
|
||||
|
||||
::
|
||||
|
||||
abbr --command git co checkout
|
||||
|
||||
Turns "co" as an argument to "git" into "checkout". Multiple commands are possible, ``--command={git,hg}`` would expand "co" to "checkout" for both git and hg.
|
||||
|
||||
@@ -20,7 +20,7 @@ Each option specification (``OPTION_SPEC``) is written in the :ref:`domain speci
|
||||
|
||||
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 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.
|
||||
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
|
||||
-------
|
||||
@@ -165,7 +165,7 @@ This isn't specific to argparse but common to all things using ``getopt(3)`` (if
|
||||
Flag Value Validation
|
||||
---------------------
|
||||
|
||||
Sometimes you need to validate the option values. For example, that it is a valid integer within a specific range, or an ip address, or something entirely different. You can always do this after ``argparse`` returns but you can also request that ``argparse`` perform the validation by executing arbitrary fish script. To do so append an ``!`` (exclamation-mark) then the fish script to be run. When that code is executed three vars will be defined:
|
||||
Sometimes you need to validate the option values. For example, that it is a valid integer within a specific range, or an ip address, or something entirely different. You can always do this after ``argparse`` returns but you can also request that ``argparse`` perform the validation by executing arbitrary fish script. To do so simply append an ``!`` (exclamation-mark) then the fish script to be run. When that code is executed three vars will be defined:
|
||||
|
||||
- ``_argparse_cmd`` will be set to the value of the value of the ``argparse --name`` value.
|
||||
|
||||
@@ -177,7 +177,7 @@ These variables are passed to the function as local exported variables.
|
||||
|
||||
The script should write any error messages to stdout, not stderr. It should return a status of zero if the flag value is valid otherwise a non-zero status to indicate it is invalid.
|
||||
|
||||
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 call ``_validate_int`` without those flags is to check that the value is a valid integer with no limits on the min or max value allowed.
|
||||
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::
|
||||
|
||||
@@ -234,7 +234,7 @@ A simple use::
|
||||
return 0
|
||||
end
|
||||
|
||||
This supports one option - ``-h`` / ``--help``. Any other option is an error. If it is given it prints help and exits.
|
||||
This just wants one option - ``-h`` / ``--help``. Any other option is an error. If it is given it prints help and exits.
|
||||
|
||||
How :doc:`fish_add_path` parses its args::
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ Synopsis
|
||||
.. synopsis::
|
||||
|
||||
begin; [COMMANDS ...]; end
|
||||
{ [COMMANDS ...] }
|
||||
|
||||
Description
|
||||
-----------
|
||||
@@ -22,8 +21,6 @@ The block is unconditionally executed. ``begin; ...; end`` is equivalent to ``if
|
||||
|
||||
``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.
|
||||
|
||||
Some other shells only support the ``{ [COMMANDS ...] ; }`` notation.
|
||||
|
||||
The **-h** or **--help** option displays help about using this command.
|
||||
|
||||
Example
|
||||
|
||||
@@ -11,7 +11,6 @@ Synopsis
|
||||
bind [(-M | --mode) MODE] [--preset] [--user] [KEYS]
|
||||
bind [-a | --all] [--preset] [--user]
|
||||
bind (-f | --function-names)
|
||||
bind (-K | --key-names)
|
||||
bind (-L | --list-modes)
|
||||
bind (-e | --erase) [(-M | --mode) MODE] [--preset] [--user] [-a | --all] | KEYS ...
|
||||
|
||||
@@ -21,11 +20,10 @@ Description
|
||||
``bind`` manages key bindings.
|
||||
|
||||
If both ``KEYS`` and ``COMMAND`` are given, ``bind`` adds (or replaces) a binding in ``MODE``.
|
||||
If only ``KEYS`` is given, any existing binding for those keys in the given ``MODE`` will be printed.
|
||||
If no ``KEYS`` argument is provided, all bindings (in the given ``MODE``) are printed.
|
||||
If only ``KEYS`` is given, any existing binding in the given ``MODE`` will be printed.
|
||||
|
||||
``KEYS`` is a comma-separated list of key names.
|
||||
Modifier keys can be specified by prefixing a key name with a combination of ``ctrl-``, ``alt-``, ``shift-`` and ``super-`` (i.e. the "windows" or "command" key).
|
||||
Modifier keys can be specified by prefixing a key name with a combination of ``ctrl-``/``c-``, ``alt-``/``a-`` and ``shift-``.
|
||||
For example, pressing :kbd:`w` while holding the Alt modifier is written as ``alt-w``.
|
||||
Key names are case-sensitive; for example ``alt-W`` is the same as ``alt-shift-w``.
|
||||
``ctrl-x,ctrl-e`` would mean pressing :kbd:`ctrl-x` followed by :kbd:`ctrl-e`.
|
||||
@@ -43,11 +41,9 @@ They are:
|
||||
- ``f1`` through ``f12``.
|
||||
- ``home``,
|
||||
- ``insert``,
|
||||
- ``menu``,
|
||||
- ``minus`` (``-``),
|
||||
- ``pageup``,
|
||||
- ``pagedown``,
|
||||
- ``printscreen``,
|
||||
- ``space`` and
|
||||
- ``tab``,
|
||||
|
||||
@@ -62,7 +58,9 @@ To find the name of a key combination you can use :doc:`fish_key_reader <fish_ke
|
||||
.. note::
|
||||
If a script changes the commandline, it should finish by calling the ``repaint`` special input function.
|
||||
|
||||
Key bindings may use "modes", which mimics vi's modal input behavior. The default mode is "default" (in vi-mode, that's vi's "normal" mode). 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``.
|
||||
If no ``KEYS`` argument is provided, all bindings (in the given ``MODE``) are printed. If ``KEYS`` is provided but no ``COMMAND``, just the binding matching that sequence is printed.
|
||||
|
||||
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``.
|
||||
|
||||
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.
|
||||
|
||||
@@ -73,16 +71,11 @@ The following options are available:
|
||||
**-f** or **--function-names**
|
||||
Display a list of available input functions
|
||||
|
||||
**-K** or **--key-names**
|
||||
Display a list of available named keys such as ``backspace``.
|
||||
|
||||
**-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".
|
||||
If you use :ref:`vi bindings <vi-mode>`, that's the *command* mode,
|
||||
what vi calls "normal" 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
|
||||
@@ -169,7 +162,7 @@ The following special input functions are available:
|
||||
start selecting text
|
||||
|
||||
``cancel``
|
||||
close the pager if it is open, or undo the most recent completion if one was just inserted
|
||||
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
|
||||
@@ -177,14 +170,8 @@ The following special input functions are available:
|
||||
``capitalize-word``
|
||||
make the current word begin with a capital letter
|
||||
|
||||
``clear-commandline``
|
||||
empty the entire commandline
|
||||
|
||||
``clear-screen``
|
||||
clears the screen and redraws the prompt.
|
||||
|
||||
``scrollback-push``
|
||||
pushes earlier output to the terminal scrollback, positioning the prompt at the top.
|
||||
clears the screen and redraws the prompt. if the terminal doesn't support clearing the screen it is the same as ``repaint``.
|
||||
|
||||
``complete``
|
||||
guess the remainder of the current token
|
||||
@@ -250,7 +237,7 @@ The following special input functions are available:
|
||||
``history-pager``
|
||||
invoke the searchable pager on history (incremental search); or if the history pager is already active, search further backwards in time.
|
||||
|
||||
``history-delete``
|
||||
``history-pager-delete``
|
||||
permanently delete the current history item, either from the history pager or from an active up-arrow history search
|
||||
|
||||
``history-search-backward``
|
||||
@@ -271,14 +258,8 @@ The following special input functions are available:
|
||||
``history-token-search-forward``
|
||||
search the history for the next matching argument
|
||||
|
||||
``history-last-token-search-backward``
|
||||
search the history for the previous matching last argument
|
||||
|
||||
``history-last-token-search-forward``
|
||||
search the history for the next matching last argument
|
||||
|
||||
``forward-jump`` and ``backward-jump``
|
||||
read another character and jump to its next occurrence after/before the cursor
|
||||
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 occurrence
|
||||
@@ -288,7 +269,7 @@ The following special input functions are available:
|
||||
|
||||
``jump-to-matching-bracket``
|
||||
jump to matching bracket if the character under the cursor is bracket;
|
||||
otherwise, jump to the next occurrence of *any right* bracket after the cursor.
|
||||
otherwise, jump to the next occurence of *any right* bracket after the cursor.
|
||||
The following brackets are considered: ``([{}])``
|
||||
|
||||
``jump-till-matching-bracket``
|
||||
@@ -311,7 +292,7 @@ The following special input functions are available:
|
||||
move the selected text to the killring
|
||||
|
||||
``kill-whole-line``
|
||||
move the line (including the following newline) to the killring. If the line is the last line, its preceding newline is also removed
|
||||
move the line (including the following newline) to the killring. If the line is the last line, its preceeding newline is also removed
|
||||
|
||||
``kill-inner-line``
|
||||
move the line (without the following newline) to the killring
|
||||
|
||||
@@ -45,9 +45,8 @@ The following options change the way ``commandline`` updates the command line bu
|
||||
**-a** or **--append**
|
||||
Do not remove the current commandline, append the specified string at the end of it.
|
||||
|
||||
**-i**, **--insert** or **--insert-smart**
|
||||
Do not remove the current commandline, insert the specified string at the current cursor position.
|
||||
The **--insert-smart** option turns on a Do-What-I-Mean (DWIM) mode: it strips any **$** prefix from the first command on each line.
|
||||
**-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)
|
||||
@@ -72,7 +71,7 @@ The following options change what part of the commandline is printed or updated:
|
||||
Selects the current token
|
||||
|
||||
**--search-field**
|
||||
Use the pager search field instead of the command line. Returns false if the search field is not shown.
|
||||
Use the pager search field instead of the command line. Returns false is the search field is not shown.
|
||||
|
||||
The following options change the way ``commandline`` prints the current commandline buffer:
|
||||
|
||||
@@ -98,12 +97,7 @@ If ``commandline`` is called during a call to complete a given string using ``co
|
||||
The following options output metadata about the commandline state:
|
||||
|
||||
**-L** or **--line**
|
||||
If no argument is given, print the line that the cursor is on, with the topmost line starting at 1.
|
||||
Otherwise, set the cursor to the given line.
|
||||
|
||||
**--column**
|
||||
If no argument is given, print the 1-based offset from the start of the line to the cursor position in Unicode code points.
|
||||
Otherwise, set the cursor to the given code point offset.
|
||||
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.
|
||||
@@ -117,7 +111,7 @@ The following options output metadata about the commandline state:
|
||||
**--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 erroneous, return 1.
|
||||
If the commandline is incomplete, return 2, if erroneus, return 1.
|
||||
|
||||
**--showing-suggestion**
|
||||
Evaluates to true (i.e. returns 0) when the shell is currently showing an automatic history completion/suggestion, available to be consumed via one of the `forward-` bindings.
|
||||
|
||||
@@ -63,9 +63,7 @@ The following options are available:
|
||||
Add a description for this completion, to be shown in the completion pager.
|
||||
|
||||
**-w** or **--wraps** *WRAPPED_COMMAND*
|
||||
Causes the specified command to inherit completions from *WRAPPED_COMMAND*.
|
||||
This is used for "this command completes like that other command" kinds of relationships.
|
||||
See below for details.
|
||||
Causes the specified command to inherit completions from *WRAPPED_COMMAND* (see below for details).
|
||||
|
||||
**-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.
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
.. _cmd-export:
|
||||
|
||||
export - compatibility function for exporting variables
|
||||
=======================================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. synopsis::
|
||||
|
||||
export
|
||||
export NAME=VALUE
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``export`` is a function included for compatibility with POSIX shells. In general, the :doc:`set <set>`
|
||||
builtin should be used instead.
|
||||
|
||||
When called without arguments, ``export`` prints a list of currently-exported variables, like ``set
|
||||
-x``.
|
||||
|
||||
When called with a ``NAME=VALUE`` pair, the variable ``NAME`` is set to ``VALUE`` in the global
|
||||
scope, and exported as an environment variable to other commands.
|
||||
|
||||
There are no options available.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
The following commands have an identical effect.
|
||||
|
||||
::
|
||||
|
||||
set -gx PAGER bat
|
||||
export PAGER=bat
|
||||
|
||||
Note: If you want to add to e.g. ``$PATH``, you need to be careful to :ref:`combine the list <cartesian-product>`. Quote it, like so::
|
||||
|
||||
export PATH="$PATH:/opt/bin"
|
||||
|
||||
Or just use ``set``, which avoids this::
|
||||
|
||||
set -gx PATH $PATH /opt/bin
|
||||
|
||||
See more
|
||||
--------
|
||||
|
||||
1. The :doc:`set <set>` command.
|
||||
@@ -24,8 +24,7 @@ The :ref:`tutorial <tutorial>` is available as HTML via ``help tutorial`` or in
|
||||
The following options are available:
|
||||
|
||||
**-c** or **--command=COMMAND**
|
||||
Evaluate the specified commands instead of reading from the commandline.
|
||||
Any additional positional arguments are used as ``$argv``.
|
||||
Evaluate the specified commands instead of reading from the commandline, passing additional positional arguments through ``$argv``.
|
||||
|
||||
**-C** or **--init-command=COMMANDS**
|
||||
Evaluate specified commands after reading the configuration but before executing command specified by **-c** or reading interactive input.
|
||||
@@ -35,8 +34,8 @@ The following options are available:
|
||||
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 standard error.
|
||||
Specifies a file path to receive the debug output, including categories and :envvar:`fish_trace`.
|
||||
The default is stderr.
|
||||
|
||||
**-i** or **--interactive**
|
||||
The shell is interactive.
|
||||
@@ -101,33 +100,3 @@ These options can also be changed via the :envvar:`FISH_DEBUG` and :envvar:`FISH
|
||||
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`.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
To just start fish::
|
||||
|
||||
fish
|
||||
|
||||
To run a file with fish::
|
||||
|
||||
fish /path/to/script.fish
|
||||
|
||||
To run some commands with fish::
|
||||
|
||||
fish -c 'echo Hi there!'
|
||||
|
||||
You can also pass arguments to those commands::
|
||||
|
||||
> fish -c 'printf %s\n $argv' "first line" "second line"
|
||||
first line
|
||||
second line
|
||||
|
||||
To run a script, except read this other file first::
|
||||
|
||||
fish --init-cmd "source otherfile" script.fish
|
||||
|
||||
To :ref:`profile <profiling>` fish's startup and find what takes the most time in your configuration::
|
||||
|
||||
fish --profile-startup /tmp/start.prof -ic exit
|
||||
sort -nk2 /tmp/start.prof
|
||||
|
||||
@@ -29,7 +29,6 @@ Currently supported are:
|
||||
- ``wl-copy`` using wayland
|
||||
- ``xsel`` and ``xclip`` for X11
|
||||
- ``clip.exe`` on Windows.
|
||||
- The OSC 52 clipboard sequence, which your terminal might support
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
@@ -10,7 +10,7 @@ Synopsis
|
||||
|
||||
fish_config [browse]
|
||||
fish_config prompt (choose | list | save | show)
|
||||
fish_config theme (choose | demo | dump | list | save | show | update)
|
||||
fish_config theme (choose | demo | dump | list | save | show)
|
||||
|
||||
Description
|
||||
-----------
|
||||
@@ -40,9 +40,6 @@ Available subcommands for the ``theme`` command:
|
||||
- ``list`` lists the names of the available sample themes.
|
||||
- ``save`` saves the given theme to :ref:`universal variables <variables-universal>`.
|
||||
- ``show`` shows what the given sample theme (or all) would look like.
|
||||
- ``update`` updates any ``fish_color_*`` and ``fish_pager_color_*`` variables whose value contains
|
||||
"--track=THEME". They are set to the latest version of that theme, and the tracking
|
||||
option is preserved. Note that ``fish_config theme update`` is run at fish startup.
|
||||
|
||||
The **-h** or **--help** option displays help about using this command.
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ The following options are available:
|
||||
Displays the current :program:`fish` version and then exits.
|
||||
|
||||
**--ansi**
|
||||
Colorizes the output using ANSI escape sequences using the colors defined in the environment (such as :envvar:`fish_color_command`).
|
||||
Colorizes the output using ANSI escape sequences, appropriate for the current :envvar:`TERM`, using the colors defined in the environment (such as :envvar:`fish_color_command`).
|
||||
|
||||
**--html**
|
||||
Outputs HTML, which supports syntax highlighting if the appropriate CSS is defined. The CSS class names are the same as the variable names, such as ``fish_color_command``.
|
||||
|
||||
@@ -31,8 +31,6 @@ You can also define an empty ``fish_mode_prompt`` function to remove the vi mode
|
||||
|
||||
``fish_mode_prompt`` will be executed when the vi mode changes. If it produces any output, it is displayed and used. If it does not, the other prompt functions (:doc:`fish_prompt <fish_prompt>` and :doc:`fish_right_prompt <fish_right_prompt>`) will be executed as well in case they contain a mode display.
|
||||
|
||||
If :envvar:`fish_transient_prompt` is set to 1, ``fish_mode_prompt --final-rendering`` is run before executing the commandline.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@ The ``fish_prompt`` function is executed when the prompt is to be shown, and the
|
||||
|
||||
The exit status of commands within ``fish_prompt`` will not modify the value of :ref:`$status <variables-status>` outside of the ``fish_prompt`` function.
|
||||
|
||||
If :envvar:`fish_transient_prompt` is set to 1, ``fish_prompt --final-rendering`` is run before executing the commandline.
|
||||
|
||||
``fish`` ships with a number of example prompts that can be chosen with the ``fish_config`` command.
|
||||
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@ Description
|
||||
|
||||
Multiple lines are not supported in ``fish_right_prompt``.
|
||||
|
||||
If :envvar:`fish_transient_prompt` is set to 1, ``fish_right_prompt --final-rendering`` is run before executing the commandline.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
@@ -26,12 +26,15 @@ The first argument to fish_title contains the most recently executed foreground
|
||||
|
||||
This requires that your terminal supports programmable titles and the feature is turned on.
|
||||
|
||||
To disable setting the title, use an empty function (see below).
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
A simple title::
|
||||
A simple title:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
function fish_title
|
||||
set -q argv[1]; or set argv fish
|
||||
@@ -40,7 +43,3 @@ A simple title::
|
||||
echo (fish_prompt_pwd_dir_length=1 prompt_pwd): $argv;
|
||||
end
|
||||
|
||||
Do not change the title::
|
||||
|
||||
function fish_title
|
||||
end
|
||||
|
||||
@@ -27,11 +27,7 @@ The following options are available:
|
||||
A description of what the function does, suitable as a completion description.
|
||||
|
||||
**-w** *WRAPPED_COMMAND* or **--wraps** *WRAPPED_COMMAND*
|
||||
Inherit completions from the given *WRAPPED_COMMAND*.
|
||||
This is used to say that this function completes like that command,
|
||||
for example if you're creating an alias.
|
||||
See the documentation for :doc:`complete <complete>` for more information.
|
||||
If the wrapped command is the same as the function name, this will be ignored.
|
||||
Inherit completions from the given *WRAPPED_COMMAND*. See the documentation for :doc:`complete <complete>` for more information.
|
||||
|
||||
**-e** *EVENT_NAME* or **--on-event** *EVENT_NAME*
|
||||
Run this function when the specified named event is emitted. Fish internally generates named events, for example, when showing the prompt. Custom events can be emitted using the :doc:`emit <emit>` command.
|
||||
|
||||
@@ -27,10 +27,10 @@ Description
|
||||
The following operations (sub-commands) are available:
|
||||
|
||||
**search**
|
||||
Returns history items matching the search string. If no search string is provided it returns all history items. This is the default operation if no other operation is specified. You only have to explicitly say ``history search`` if you wish to search for one of the subcommands. The ``--contains`` search option will be used if you don't specify a different search option. Entries are ordered newest to oldest unless you use the ``--reverse`` flag. If stdout is attached to a tty the output will be piped through your pager by the history function. The history builtin writes the results to stdout.
|
||||
Returns history items matching the search string. If no search string is provided it returns all history items. This is the default operation if no other operation is specified. You only have to explicitly say ``history search`` if you wish to search for one of the subcommands. The ``--contains`` search option will be used if you don't specify a different search option. Entries are ordered newest to oldest unless you use the ``--reverse`` flag. If stdout is attached to a tty the output will be piped through your pager by the history function. The history builtin simply writes the results to stdout.
|
||||
|
||||
**delete**
|
||||
Deletes history items. The ``--contains`` search option will be used if you don't specify a different search option. If you don't specify ``--exact`` a prompt will be displayed before any items are deleted asking you which entries are to be deleted. You can enter the word "all" to delete all matching entries. You can enter a single ID (the number in square brackets) to delete just that single entry. You can enter more than one ID, or an ID range separated by a space to delete multiple entries. Press [enter] to not delete anything. Note that the interactive delete behavior is a feature of the history function. The history builtin only supports ``--exact --case-sensitive`` deletion.
|
||||
Deletes history items. The ``--contains`` search option will be used if you don't specify a different search option. If you don't specify ``--exact`` a prompt will be displayed before any items are deleted asking you which entries are to be deleted. You can enter the word "all" to delete all matching entries. You can enter a single ID (the number in square brackets) to delete just that single entry. You can enter more than one ID, or an ID range separated by a space to delete multiple entries. Just press [enter] to not delete anything. Note that the interactive delete behavior is a feature of the history function. The history builtin only supports ``--exact --case-sensitive`` deletion.
|
||||
|
||||
**merge**
|
||||
Immediately incorporates history changes from other sessions. Ordinarily ``fish`` ignores history changes from sessions started after the current one. This command applies those changes immediately.
|
||||
@@ -52,7 +52,7 @@ The following options are available:
|
||||
These flags can appear before or immediately after one of the sub-commands listed above.
|
||||
|
||||
**-C** or **--case-sensitive**
|
||||
Does a case-sensitive search. The default is case-insensitive.
|
||||
Does a case-sensitive search. The default is case-insensitive. Note that prior to fish 2.4.0 the default was case-sensitive.
|
||||
|
||||
**-c** or **--contains**
|
||||
Searches items in the history that contain the specified text string. This is the default for the **--search** flag. This is not currently supported by the **delete** subcommand.
|
||||
|
||||
@@ -279,7 +279,7 @@ Examples
|
||||
|
||||
path normalize [-z | --null-in] [-Z | --null-out] [-q | --quiet] [PATH ...]
|
||||
|
||||
``path normalize`` returns the normalized versions of all paths. That means it squashes duplicate "/", collapses "../" with earlier components and removes "." components.
|
||||
``path normalize`` returns the normalized versions of all paths. That means it squashes duplicate "/" (except for two leading "//"), collapses "../" with earlier components and removes "." components.
|
||||
|
||||
Unlike ``realpath`` or ``path resolve``, it does not make the paths absolute. It also does not resolve any symlinks. As such it can operate on non-existent paths.
|
||||
|
||||
@@ -346,7 +346,7 @@ Examples
|
||||
path change-extension [-z | --null-in] [-Z | --null-out] \
|
||||
[-q | --quiet] EXTENSION [PATH ...]
|
||||
|
||||
``path change-extension`` returns the given paths, with their extension changed to the given new extension. The extension is the part after (and including) the last ".", unless that "." followed a "/" or the basename is "." or "..", in which case there is no previous extension and the new one is added.
|
||||
``path change-extension`` returns the given paths, with their extension changed to the given new extension. The extension is the part after (and including) the last ".", unless that "." followed a "/" or the basename is "." or "..", in which case there is no previous extension and the new one is simply added.
|
||||
|
||||
If the extension is empty, any previous extension is stripped, along with the ".". This is, of course, the inverse of ``path extension``.
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ If no option to determine how to split like ``--delimiter``, ``--line`` or ``--t
|
||||
|
||||
With the ``--line`` option, ``read`` reads a line of input from standard input into each provided variable, stopping when each variable has been filled. The line is not tokenized.
|
||||
|
||||
If no variable names are provided, ``read`` enters a special case that provides redirection from standard input to standard output, useful for command substitution. For instance, the fish shell command below can be used to read a password from the console instead of hardcoding it in the command itself, which prevents it from showing up in fish's history::
|
||||
If no variable names are provided, ``read`` enters a special case that simply provides redirection from standard input to standard output, useful for command substitution. For instance, the fish shell command below can be used to read a password from the console instead of hardcoding it in the command itself, which prevents it from showing up in fish's history::
|
||||
|
||||
mysql -uuser -p(read)
|
||||
|
||||
|
||||
@@ -22,25 +22,15 @@ Valid colors include:
|
||||
|
||||
The *br*- (as in 'bright') forms are full-brightness variants of the 8 standard-brightness colors on many terminals. **brblack** has higher brightness than **black** - towards gray.
|
||||
|
||||
An RGB value with three or six hex digits, such as A0FF33 or f2f can be used.
|
||||
A three digit value is equivalent to specifying each digit twice; e.g., ``set_color 2BC`` is the same as ``set_color 22BBCC``.
|
||||
Hexadecimal RGB values can be in lower or uppercase.
|
||||
An RGB value with three or six hex digits, such as A0FF33 or f2f can be used. Fish will choose the closest supported color. A three digit value is equivalent to specifying each digit twice; e.g., ``set_color 2BC`` is the same as ``set_color 22BBCC``. Hexadecimal RGB values can be in lower or uppercase. Depending on the capabilities of your terminal (and the level of support ``set_color`` has for it) the actual color may be approximated by a nearby matching reserved color name or ``set_color`` may not have an effect on color.
|
||||
|
||||
If :envvar:`fish_term24bit` is set to 0, fish will translate RGB values to the nearest color on the 256-color palette.
|
||||
If :envvar:`fish_term256` is also set to 0, fish will translate them to the 16-color palette instead.
|
||||
Fish launched as ``fish -d term_support`` will include diagnostic messages that indicate the color support mode in use.
|
||||
|
||||
If multiple colors are specified, fish prefers the first RGB one.
|
||||
However if :envvar:`fish_term256` is set to 0, fish prefers the first named color specified.
|
||||
A second color may be given as a desired fallback color. e.g. ``set_color 124212 brblue`` will instruct set_color to use *brblue* if a terminal is not capable of the exact shade of grey desired. This is very useful when an 8 or 16 color terminal might otherwise not use a color.
|
||||
|
||||
The following options are available:
|
||||
|
||||
**-b** or **--background** *COLOR*
|
||||
Sets the background color.
|
||||
|
||||
**--underline-color** *COLOR*
|
||||
Set the underline color.
|
||||
|
||||
**-c** or **--print-colors**
|
||||
Prints the given colors or a colored list of the 16 named colors.
|
||||
|
||||
@@ -56,22 +46,18 @@ The following options are available:
|
||||
**-r** or **--reverse**
|
||||
Sets reverse mode.
|
||||
|
||||
**-u** or **--underline**, or **-uSTYLE** or **--underline=STYLE**
|
||||
Set the underline mode; supported styles are **single** (default) and **curly**.
|
||||
|
||||
**--track=THEME**
|
||||
Ignored. Included by default in universally-scoped color variables to tell fish to update
|
||||
them as the associated theme changes.
|
||||
This flag can be set for all variables when loading a theme with the `--track`` option, that is
|
||||
:doc:`fish_config theme save THEME --track <fish_config>`.
|
||||
**-u** or **--underline**
|
||||
Sets underlined mode.
|
||||
|
||||
**-h** or **--help**
|
||||
Displays help about using this command.
|
||||
|
||||
Using the **normal** keyword will reset foreground, background, and all formatting back to default.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
1. Using **set_color normal** will reset all colors and modes to the terminal's default.
|
||||
1. Using the **normal** keyword will reset both background and foreground colors to whatever is the default for the terminal.
|
||||
2. Setting the background color only affects subsequently written characters. Fish provides no way to set the background color for the entire terminal window. Configuring the window background color (and other attributes such as its opacity) has to be done using whatever mechanisms the terminal provides. Look for a config option.
|
||||
3. Some terminals use the ``--bold`` escape sequence to switch to a brighter color set rather than increasing the weight of text.
|
||||
4. ``set_color`` works by printing sequences of characters to standard output. If used in command substitution or a pipe, these characters will also be captured. This may or may not be desirable. Checking the exit status of ``isatty stdout`` before using ``set_color`` can be useful to decide not to colorize output in a script.
|
||||
@@ -86,3 +72,24 @@ Examples
|
||||
set_color blue; echo "Violets are blue"
|
||||
set_color 62A; echo "Eggplants are dark purple"
|
||||
set_color normal; echo "Normal is nice" # Resets the background too
|
||||
|
||||
|
||||
Terminal Capability Detection
|
||||
-----------------------------
|
||||
|
||||
Fish uses some heuristics to determine what colors a terminal supports to avoid sending sequences that it won't understand.
|
||||
|
||||
In particular it will:
|
||||
|
||||
- Enable 256 colors if :envvar:`TERM` contains "xterm", except for known exceptions (like MacOS 10.6 Terminal.app)
|
||||
- Enable 24-bit ("true-color") even if the $TERM entry only reports 256 colors. This includes modern xterm, VTE-based terminals like Gnome Terminal, Konsole and iTerm2.
|
||||
- Detect support for italics, dim, reverse and other modes.
|
||||
|
||||
If terminfo reports 256 color support for a terminal, 256 color support will always be enabled.
|
||||
|
||||
To force true-color support on or off, set :envvar:`fish_term24bit` to "1" for on and 0 for off - ``set -g fish_term24bit 1``.
|
||||
|
||||
To debug color palette problems, ``tput colors`` may be useful to see the number of colors in terminfo for a terminal. Fish launched as ``fish -d term_support`` will include diagnostic messages that indicate the color support mode in use.
|
||||
|
||||
The ``set_color`` command uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and lack color information for terminals that support it. Fish assumes that all terminals can use the `ANSI X3.64 <https://en.wikipedia.org/wiki/ANSI_escape_code>`_ escape sequences if the terminfo definition indicates a color below 16 is not supported.
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Description
|
||||
|
||||
fish will search the working directory to resolve relative paths but will not search :envvar:`PATH` .
|
||||
|
||||
If no file is specified and a file or pipeline is connected to standard input, or if the file name ``-`` is used, ``source`` will read from standard input. If no file is specified and there is no redirected file or pipeline on standard input, an error will be printed.
|
||||
If no file is specified and stdin is not the terminal, or if the file name ``-`` is used, stdin will be read.
|
||||
|
||||
The exit status of ``source`` is the exit status of the last job to execute. If something goes wrong while opening or reading the file, ``source`` exits with a non-zero status.
|
||||
|
||||
@@ -41,3 +41,8 @@ Example
|
||||
source ~/.config/fish/config.fish
|
||||
# Causes fish to re-read its initialization file.
|
||||
|
||||
|
||||
Caveats
|
||||
-------
|
||||
|
||||
In fish versions prior to 2.3.0, the :envvar:`argv` variable would have a single element (the name of the sourced file) if no arguments are present. Otherwise, it would contain arguments without the name of the sourced file. That behavior was very confusing and unlike other shells such as bash and zsh.
|
||||
|
||||
@@ -11,7 +11,6 @@ Synopsis
|
||||
status
|
||||
status is-login
|
||||
status is-interactive
|
||||
status is-interactive-read
|
||||
status is-block
|
||||
status is-breakpoint
|
||||
status is-command-substitution
|
||||
@@ -30,9 +29,6 @@ Synopsis
|
||||
status job-control CONTROL_TYPE
|
||||
status features
|
||||
status test-feature FEATURE
|
||||
status buildinfo
|
||||
status get-file FILE
|
||||
status list-files [PATH]
|
||||
|
||||
Description
|
||||
-----------
|
||||
@@ -53,9 +49,6 @@ The following operations (subcommands) are available:
|
||||
**is-interactive**, **-i** or **--is-interactive**
|
||||
Returns 0 if fish is interactive - that is, connected to a keyboard.
|
||||
|
||||
**is-interactive-read** or **--is-interactive-read**
|
||||
Returns 0 if fish is running an interactive :doc:`read <read>` builtin which is connected to a keyboard.
|
||||
|
||||
**is-login**, **-l** or **--is-login**
|
||||
Returns 0 if fish is a login shell - that is, if fish should perform login tasks such as setting up :envvar:`PATH`.
|
||||
|
||||
@@ -104,19 +97,6 @@ The following operations (subcommands) are available:
|
||||
**test-feature** *FEATURE*
|
||||
Returns 0 when FEATURE is enabled, 1 if it is disabled, and 2 if it is not recognized.
|
||||
|
||||
**buildinfo**
|
||||
This prints information on how fish was build - which architecture, which build system or profile was used, etc.
|
||||
This is mainly useful for debugging.
|
||||
|
||||
**get-file** *FILE*
|
||||
This prints a file embedded in the fish binary at compile time. This includes the default set of functions and completions,
|
||||
as well as the man pages and themes. Which files are included depends on build settings.
|
||||
Returns 0 if the file was included, 1 otherwise.
|
||||
|
||||
**list-files** *FILE*
|
||||
This lists the files embedded in the fish binary at compile time. Only files where the path starts with the optional *FILE* argument are shown.
|
||||
Returns 0 if something was printed, 1 otherwise.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
|
||||
@@ -18,9 +18,7 @@ Description
|
||||
|
||||
.. BEGIN DESCRIPTION
|
||||
|
||||
``string escape`` escapes each *STRING* in one of several ways.
|
||||
|
||||
**--style=script** (default) alters the string such that it can be passed back to ``eval`` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If **-n** or **--no-quoted** is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise.
|
||||
``string escape`` escapes each *STRING* in one of three ways. The first is **--style=script**. This is the default. It alters the string such that it can be passed back to ``eval`` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If **-n** or **--no-quoted** is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise.
|
||||
|
||||
**--style=var** ensures the string can be used as a variable name by hex encoding any non-alphanumeric characters. The string is first converted to UTF-8 before being encoded.
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ Description
|
||||
|
||||
``string match`` tests each *STRING* against *PATTERN* and prints matching substrings. Only the first match for each *STRING* is reported unless **-a** or **--all** is given, in which case all matches are reported.
|
||||
|
||||
If you specify the **-e** or **--entire** then each matching string is printed including any prefix or suffix not matched by the pattern (equivalent to ``grep`` without the **-o** flag). You can, obviously, achieve the same result by prepending and appending **\*** or **.*** depending on whether or not you have specified the **--regex** flag. The **--entire** flag is a way to avoid having to complicate the pattern in that fashion and make the intent of the ``string match`` clearer. Without **--entire** and **--regex**, a *PATTERN* will need to match the entire *STRING* before it will be reported.
|
||||
If you specify the **-e** or **--entire** then each matching string is printed including any prefix or suffix not matched by the pattern (equivalent to ``grep`` without the **-o** flag). You can, obviously, achieve the same result by prepending and appending **\*** or **.*** depending on whether or not you have specified the **--regex** flag. The **--entire** flag is simply a way to avoid having to complicate the pattern in that fashion and make the intent of the ``string match`` clearer. Without **--entire** and **--regex**, a *PATTERN* will need to match the entire *STRING* before it will be reported.
|
||||
|
||||
Matching can be made case-insensitive with **--ignore-case** or **-i**.
|
||||
|
||||
If **--groups-only** or **-g** is given, only the capturing groups will be reported - meaning the full match will be skipped. This is incompatible with **--entire** and **--invert**, and requires **--regex**. It is useful as a simple cutting tool instead of ``string replace``, so you can choose "this part" of a string.
|
||||
If **--groups-only** or **-g** is given, only the capturing groups will be reported - meaning the full match will be skipped. This is incompatible with **--entire** and **--invert**, and requires **--regex**. It is useful as a simple cutting tool instead of ``string replace``, so you can simply choose "this part" of a string.
|
||||
|
||||
If **--index** or **-n** is given, each match is reported as a 1-based start position and a length. By default, PATTERN is interpreted as a glob pattern matched against each entire *STRING* argument. A glob pattern is only considered a valid match if it matches the entire *STRING*.
|
||||
|
||||
@@ -52,13 +52,13 @@ Match Glob Examples
|
||||
|
||||
::
|
||||
|
||||
>_ string match 'a' a
|
||||
>_ string match '?' a
|
||||
a
|
||||
|
||||
>_ string match 'a*b' axxb
|
||||
axxb
|
||||
|
||||
>_ string match -i 'a*B' Axxb
|
||||
>_ string match -i 'a??B' Axxb
|
||||
Axxb
|
||||
|
||||
>_ string match -- '-*' -h foo --version bar
|
||||
@@ -67,7 +67,7 @@ Match Glob Examples
|
||||
-h
|
||||
--version
|
||||
|
||||
>_ echo 'ok?' | string match '*?'
|
||||
>_ echo 'ok?' | string match '*\?'
|
||||
ok?
|
||||
|
||||
# Note that only the second STRING will match here.
|
||||
@@ -79,7 +79,7 @@ Match Glob Examples
|
||||
foo
|
||||
foo2
|
||||
|
||||
>_ string match 'foo*' 'foo1' 'foo' 'foo2'
|
||||
>_ string match 'foo?' 'foo1' 'foo' 'foo2'
|
||||
foo1
|
||||
foo2
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ Description
|
||||
|
||||
.. BEGIN DESCRIPTION
|
||||
|
||||
``string repeat`` repeats the *STRING* **-n** or **--count** times. The **-m** or **--max** option will limit the number of outputted characters (excluding the newline). This option can be used by itself or in conjunction with **--count**. If both **--count** and **--max** are present, max char will be outputted unless the final repeated string size is less than max, in that case, the string will repeat until count has been reached. Both **--count** and **--max** will accept a number greater than or equal to zero, in the case of zero, nothing will be outputted. The first argument is interpreted as *COUNT* if **--count** or **--max** are not explicitly specified. If **-N** or **--no-newline** is given, the output won't contain a newline character at the end. Exit status: 0 if yielded string is not empty, 1 otherwise.
|
||||
``string repeat`` repeats the *STRING* **-n** or **--count** times. The **-m** or **--max** option will limit the number of outputted characters (excluding the newline). This option can be used by itself or in conjunction with **--count**. If both **--count** and **--max** are present, max char will be outputed unless the final repeated string size is less than max, in that case, the string will repeat until count has been reached. Both **--count** and **--max** will accept a number greater than or equal to zero, in the case of zero, nothing will be outputed. The first argument is interpreted as *COUNT* if **--count** or **--max** are not explicilty specified. If **-N** or **--no-newline** is given, the output won't contain a newline character at the end. Exit status: 0 if yielded string is not empty, 1 otherwise.
|
||||
|
||||
.. END DESCRIPTION
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ If **-q** or **--quiet** is given, ``string shorten`` only runs for the return v
|
||||
|
||||
The default ellipsis is ``…``. If fish thinks your system is incapable because of your locale, it will use ``...`` instead.
|
||||
|
||||
The return value is 0 if any shortening occurred, 1 otherwise.
|
||||
The return value is 0 if any shortening occured, 1 otherwise.
|
||||
|
||||
.. END DESCRIPTION
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ See also the **--delimiter** option of the :doc:`read <read>` command.
|
||||
|
||||
``split0`` has the important property that its output is not further split when used in a command substitution, allowing for the command substitution to produce elements containing newlines. This is most useful when used with Unix tools that produce zero bytes, such as ``find -print0`` or ``sort -z``. See split0 examples below.
|
||||
|
||||
Be aware that commandline arguments cannot include NULs, so you likely want to pass to ``string split0`` via a pipe, not a command substitution.
|
||||
|
||||
.. END DESCRIPTION
|
||||
|
||||
@@ -66,7 +65,6 @@ NUL Delimited Examples
|
||||
::
|
||||
|
||||
>_ # Count files in a directory, without being confused by newlines.
|
||||
>_ # Note: Don't use `string split0 (find . -print0)`, because arguments cannot include NUL.
|
||||
>_ count (find . -print0 | string split0)
|
||||
42
|
||||
|
||||
|
||||
@@ -18,11 +18,7 @@ Description
|
||||
|
||||
.. BEGIN DESCRIPTION
|
||||
|
||||
``string trim`` removes leading and trailing whitespace from each *STRING*. If **-l** or **--left** is given, only leading whitespace is removed. If **-r** or **--right** is given, only trailing whitespace is trimmed.
|
||||
|
||||
The **-c** or **--chars** switch causes the set of characters in *CHARS* to be removed instead of whitespace. This is a set of characters, not a string - if you pass ``-c foo``, it will remove any "f" or "o", not just "foo" as a whole.
|
||||
|
||||
Exit status: 0 if at least one character was trimmed, or 1 otherwise.
|
||||
``string trim`` removes leading and trailing whitespace from each *STRING*. If **-l** or **--left** is given, only leading whitespace is removed. If **-r** or **--right** is given, only trailing whitespace is trimmed. The **-c** or **--chars** switch causes the characters in *CHARS* to be removed instead of whitespace. Exit status: 0 if at least one character was trimmed, or 1 otherwise.
|
||||
|
||||
.. END DESCRIPTION
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ Parentheses and the ``-o`` and ``-a`` operators can be combined to produce more
|
||||
end
|
||||
|
||||
|
||||
Numerical comparisons will fail if one of the operands is not a number:
|
||||
Numerical comparisons will simply fail if one of the operands is not a number:
|
||||
|
||||
::
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ Some helper functions, often to give you information for use in your prompt:
|
||||
- :doc:`fish_add_path <cmds/fish_add_path>` to easily add a path to $PATH.
|
||||
- :doc:`alias <cmds/alias>` to quickly define wrapper functions ("aliases").
|
||||
- :doc:`fish_delta <cmds/fish_delta>` to show what you have changed from the default configuration.
|
||||
- :doc:`export <cmds/export>` as a compatibility function for other shells.
|
||||
|
||||
Helper commands
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -59,22 +59,15 @@ highlight_language = "fish-docs-samples"
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = "fish-shell"
|
||||
copyright = "fish-shell developers"
|
||||
copyright = "2024, fish-shell developers"
|
||||
author = "fish-shell developers"
|
||||
issue_url = "https://github.com/fish-shell/fish-shell/issues"
|
||||
|
||||
# Parsing FISH-BUILD-VERSION-FILE is possible but hard to ensure that it is in the right place
|
||||
# fish_indent is guaranteed to be on PATH for the Pygments highlighter anyway
|
||||
if "FISH_BUILD_VERSION_FILE" in os.environ:
|
||||
f = open(os.environ["FISH_BUILD_VERSION_FILE"], "r")
|
||||
ret = f.readline().strip()
|
||||
elif "FISH_BUILD_VERSION" in os.environ:
|
||||
ret = os.environ["FISH_BUILD_VERSION"]
|
||||
else:
|
||||
ret = subprocess.check_output(
|
||||
("fish_indent", "--version"), stderr=subprocess.STDOUT
|
||||
).decode("utf-8")
|
||||
|
||||
ret = subprocess.check_output(
|
||||
("fish_indent", "--version"), stderr=subprocess.STDOUT
|
||||
).decode("utf-8")
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = ret.strip().split(" ")[-1]
|
||||
# The short X.Y version
|
||||
@@ -195,7 +188,6 @@ man_pages = [
|
||||
("language", "fish-language", "", [author], 1),
|
||||
("interactive", "fish-interactive", "", [author], 1),
|
||||
("relnotes", "fish-releasenotes", "", [author], 1),
|
||||
("terminal-compatibility", "fish-terminal-compatibility", "", [author], 1),
|
||||
("completions", "fish-completions", "", [author], 1),
|
||||
("prompt", "fish-prompt-tutorial", "", [author], 1),
|
||||
(
|
||||
|
||||
@@ -13,7 +13,7 @@ Use the :doc:`set <cmds/set>` command::
|
||||
set -x key value # typically set -gx key value
|
||||
set -e key
|
||||
|
||||
Since fish 3.1 you can set an environment variable for one command using the ``key=value some command`` syntax, like in other shells. The two lines below behave identically - unlike other shells, fish will output ``value`` both times::
|
||||
Since fish 3.1 you can set an environment variable for just one command using the ``key=value some command`` syntax, like in other shells. The two lines below behave identically - unlike other shells, fish will output ``value`` both times::
|
||||
|
||||
key=value echo $key
|
||||
begin; set -lx key value; echo $key; end
|
||||
@@ -154,7 +154,7 @@ in :ref:`config.fish <configuration>`.
|
||||
|
||||
How do I run a command from history?
|
||||
------------------------------------
|
||||
Type some part of the command, and then hit the :kbd:`up` (``↑``) or :kbd:`down` (``↓``) arrow keys to navigate through history matches, or press :kbd:`ctrl-r` to open the history in a searchable pager. In this pager you can press :kbd:`ctrl-r` or :kbd:`ctrl-s` to move to older or younger history respectively.
|
||||
Type some part of the command, and then hit the :kbd:`up` (``↑``) or :kbd:`ctrl-down` (``↓``) arrow keys to navigate through history matches, or press :kbd:`ctrl-r` to open the history in a searchable pager. In this pager you can press :kbd:`ctrl-r` or :kbd:`ctrl-s` to move to older or younger history respectively.
|
||||
|
||||
Additional default key bindings include :kbd:`ctrl-p` (up) and :kbd:`ctrl-n` (down). See :ref:`Searchable command history <history-search>` for more information.
|
||||
|
||||
@@ -162,19 +162,19 @@ Why doesn't history substitution ("!$" etc.) work?
|
||||
--------------------------------------------------
|
||||
Because history substitution is an awkward interface that was invented before interactive line editing was even possible. Instead of adding this pseudo-syntax, fish opts for nice history searching and recall features. Switching requires a small change of habits: if you want to modify an old line/word, first recall it, then edit.
|
||||
|
||||
As a special case, most of the time history substitution is used as ``sudo !!``. In that case press :kbd:`alt-s`, and it will recall your last commandline with ``sudo`` prefixed (or toggle a ``sudo`` prefix on the current commandline if there is anything).
|
||||
As a special case, most of the time history substitution is used as ``sudo !!``. In that case just press :kbd:`alt-s`, and it will recall your last commandline with ``sudo`` prefixed (or toggle a ``sudo`` prefix on the current commandline if there is anything).
|
||||
|
||||
In general, fish's history recall works like this:
|
||||
|
||||
- Like other shells, the Up arrow, ``up`` recalls whole lines, starting from the last executed line. So instead of typing ``!!``, you would hit the up-arrow.
|
||||
- Like other shells, the Up arrow, ``up`` recalls whole lines, starting from the last executed line. So instead of typing ``!!``, you would just hit the up-arrow.
|
||||
|
||||
- If the line you want is far back in the history, type any part of the line and then press Up one or more times. This will filter the recalled lines to ones that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like. If you want to see more context, you can press ``ctrl-r`` to open the history in the pager.
|
||||
- If the line you want is far back in the history, type any part of the line and then press Up one or more times. This will filter the recalled lines to ones that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like. If you want to see more context, you can press ``ctlr-b`` to open the history in the pager.
|
||||
|
||||
- ``alt-up`` recalls individual arguments, starting from the last argument in the last executed line. This can be used instead of "!$".
|
||||
|
||||
See :ref:`documentation <editor>` for more details about line editing in fish.
|
||||
|
||||
That being said, you can use :ref:`abbreviations` to implement history substitution. Here's ``!!`` only::
|
||||
That being said, you can use :ref:`abbreviations` to implement history substitution. Here's just ``!!``::
|
||||
|
||||
function last_history_item; echo $history[1]; end
|
||||
abbr -a !! --position anywhere --function last_history_item
|
||||
@@ -232,7 +232,7 @@ Use the ``$status`` variable. This replaces the ``$?`` variable used in other sh
|
||||
end
|
||||
|
||||
|
||||
If you are only interested in success or failure, you can run the command directly as the if-condition::
|
||||
If you are just interested in success or failure, you can run the command directly as the if-condition::
|
||||
|
||||
if somecommand
|
||||
echo "Command succeeded"
|
||||
@@ -330,7 +330,7 @@ This is more important to fish than other shells because features like syntax hi
|
||||
|
||||
Sometimes, there is disagreement on the width. There are numerous causes and fixes for this:
|
||||
|
||||
- It is possible the character is too new for your system to know - in this case you need to refrain from using it.
|
||||
- It is possible the character is simply too new for your system to know - in this case you need to refrain from using it.
|
||||
- Fish or your terminal might not know about the character or handle it wrong - in this case fish or your terminal needs to be fixed, or you need to update to a fixed version.
|
||||
- The character has an "ambiguous" width and fish thinks that means a width of X while your terminal thinks it's Y. In this case you either need to change your terminal's configuration or set $fish_ambiguous_width to the correct value.
|
||||
- The character is an emoji and the host system only supports Unicode 8, while you are running the terminal on a system that uses Unicode >= 9. In this case set $fish_emoji_width to 2.
|
||||
@@ -340,21 +340,13 @@ This also means that a few things are unsupportable:
|
||||
- Non-monospace fonts - there is *no way* for fish to figure out what width a specific character has as it has no influence on the terminal's font rendering.
|
||||
- Different widths for multiple ambiguous width characters - there is no way for fish to know which width you assign to each character.
|
||||
|
||||
.. _faq-terminal-compatibility:
|
||||
|
||||
fish does not work in a specific terminal
|
||||
-----------------------------------------
|
||||
|
||||
The terminal might not meet all of :doc:`fish's requirements <terminal-compatibility>`.
|
||||
Please report this to your terminal's and to fish's issue tracker.
|
||||
|
||||
.. _faq-uninstalling:
|
||||
|
||||
Uninstalling fish
|
||||
-----------------
|
||||
If you want to uninstall fish, first make sure fish is not set as your shell. Run ``chsh -s /bin/bash`` if you are not sure.
|
||||
|
||||
If you installed it with a package manager, use that package manager's uninstall function. If you built fish yourself, assuming you installed it to /usr/local, do this::
|
||||
If you installed it with a package manager, just use that package manager's uninstall function. If you built fish yourself, assuming you installed it to /usr/local, do this::
|
||||
|
||||
rm -Rf /usr/local/etc/fish /usr/local/share/fish ~/.config/fish
|
||||
rm /usr/local/share/man/man1/fish*.1
|
||||
|
||||
@@ -192,7 +192,7 @@ Note that both of these are bashisms, and most things can easily be expressed wi
|
||||
|
||||
source (command | psub)
|
||||
|
||||
Use::
|
||||
just use::
|
||||
|
||||
command | source
|
||||
|
||||
@@ -246,7 +246,7 @@ is mostly the same as
|
||||
foo
|
||||
EOF
|
||||
|
||||
Like with heredocs, the command has to be prepared to read from stdin. Sometimes this requires special options to be used, often giving a filename of ``-`` turns it on.
|
||||
Just like with heredocs, the command has to be prepared to read from stdin. Sometimes this requires special options to be used, often giving a filename of ``-`` turns it on.
|
||||
|
||||
For example::
|
||||
|
||||
@@ -266,7 +266,7 @@ and could be written in other shells as
|
||||
rxvt-unicode
|
||||
EOF
|
||||
|
||||
So heredocs really are minor syntactical sugar that introduces a lot of special rules, which is why fish doesn't have them. Pipes are a core concept, and are simpler and compose nicer.
|
||||
So heredocs really are just minor syntactical sugar that introduces a lot of special rules, which is why fish doesn't have them. Pipes are a core concept, and are simpler and compose nicer.
|
||||
|
||||
.. [#] For example, the "EOF" is just a convention, the terminator can be an arbitrary string, something like "THISISTHEEND" also works. And using ``<<-`` trims leading *tab* characters (but not other whitespace), so you can indent the lines, but only with tabs. Substitutions (variables, commands) are done on the heredoc by default, but not if the terminator is quoted: ``cat << "EOF"``.
|
||||
|
||||
@@ -326,7 +326,7 @@ and a rough fish equivalent::
|
||||
This shows a few differences:
|
||||
|
||||
- Fish provides :doc:`set_color <cmds/set_color>` to color text. It can use the 16 named colors and also RGB sequences (so you could also use ``set_color 5555FF``)
|
||||
- Instead of introducing specific escapes like ``\h`` for the hostname, the prompt is a function. To achieve the effect of ``\h``, fish provides helper functions like :doc:`prompt_hostname <cmds/prompt_hostname>`, which prints a shortened version of the hostname.
|
||||
- Instead of introducing specific escapes like ``\h`` for the hostname, the prompt is simply a function. To achieve the effect of ``\h``, fish provides helper functions like :doc:`prompt_hostname <cmds/prompt_hostname>`, which prints a shortened version of the hostname.
|
||||
- Fish offers other helper functions for adding things to the prompt, like :doc:`fish_vcs_prompt <cmds/fish_vcs_prompt>` for adding a display for common version control systems (git, mercurial, svn), and :doc:`prompt_pwd <cmds/prompt_pwd>` for showing a shortened ``$PWD`` (the user's home directory becomes ``~`` and any path component is shortened).
|
||||
|
||||
The default prompt is reasonably full-featured and its code can be read via ``type fish_prompt``.
|
||||
@@ -417,7 +417,7 @@ This includes things like:
|
||||
baz &
|
||||
done
|
||||
|
||||
Fish does not currently have subshells. You will have to find a different solution. The isolation can usually be achieved by scoping variables (with ``set -l``), but if you really do need to run your code in a new shell environment you can use ``fish -c 'your code here'`` to do so explicitly.
|
||||
Fish does not currently have subshells. You will have to find a different solution. The isolation can usually be achieved by just scoping variables (with ``set -l``), but if you really do need to run your code in a new shell environment you can use ``fish -c 'your code here'`` to do so explicitly.
|
||||
|
||||
``()`` subshells are often confused with ``{}`` grouping, which does *not* use a subshell. When you just need to group, you can use ``begin; end`` in fish::
|
||||
|
||||
@@ -427,7 +427,7 @@ Fish does not currently have subshells. You will have to find a different soluti
|
||||
# becomes
|
||||
begin; foo; bar; end | baz
|
||||
|
||||
The pipe will be run in the same process, so ``while read`` loops can set variables outside::
|
||||
The pipe will simply be run in the same process, so ``while read`` loops can set variables outside::
|
||||
|
||||
foo | while read bar
|
||||
set -g VAR VAL
|
||||
|
||||
@@ -53,7 +53,7 @@ lexer_rules = [
|
||||
# Hack: treat the "[ expr ]" alias of builtin test as command token (not as grammar
|
||||
# metacharacter). This works because we write it without spaces in the grammar (like
|
||||
# "[OPTIONS]").
|
||||
(r"\. |! |\[ | \]|\{ | \}", Name.Constant),
|
||||
(r"\. |! |\[ | \]", Name.Constant),
|
||||
# Statement separators.
|
||||
(r"\n", Text.Whitespace),
|
||||
(r";", Punctuation),
|
||||
|
||||
@@ -150,7 +150,7 @@ Resources
|
||||
|
||||
- The `GitHub page <https://github.com/fish-shell/fish-shell/>`_
|
||||
|
||||
- The official `Matrix room <https://matrix.to/#/#fish-shell:matrix.org>`_
|
||||
- The official `Gitter channel <https://gitter.im/fish-shell/fish-shell>`_
|
||||
|
||||
- The official mailing list at `fish-users@lists.sourceforge.net <https://lists.sourceforge.net/lists/listinfo/fish-users>`_
|
||||
|
||||
@@ -174,6 +174,5 @@ Other help pages
|
||||
prompt
|
||||
design
|
||||
relnotes
|
||||
terminal-compatibility
|
||||
contributing
|
||||
license
|
||||
|
||||
@@ -25,7 +25,7 @@ Autosuggestions
|
||||
|
||||
fish suggests commands as you type, based on :ref:`command history <history-search>`, completions, and valid file paths. As you type commands, you will see a suggestion offered after the cursor, in a muted gray color (which can be changed with the ``fish_color_autosuggestion`` variable).
|
||||
|
||||
To accept the autosuggestion (replacing the command line contents), press :kbd:`right` (``→``) or :kbd:`ctrl-f`. To accept the first suggested word, press :kbd:`alt-right` (``→``) or :kbd:`alt-f`. If the autosuggestion is not what you want, ignore it: it won't execute unless you accept it.
|
||||
To accept the autosuggestion (replacing the command line contents), press :kbd:`right` (``→``) or :kbd:`ctrl-f`. To accept the first suggested word, press :kbd:`alt-right` (``→``) or :kbd:`alt-f`. If the autosuggestion is not what you want, just ignore it: it won't execute unless you accept it.
|
||||
|
||||
Autosuggestions are a powerful way to quickly summon frequently entered commands, by typing the first few characters. They are also an efficient technique for navigating through directory hierarchies.
|
||||
|
||||
@@ -38,7 +38,7 @@ If you don't like autosuggestions, you can disable them by setting ``$fish_autos
|
||||
Tab Completion
|
||||
--------------
|
||||
|
||||
Tab completion is a time saving feature of any modern shell. When you type :kbd:`tab`, fish tries to guess the rest of the word under the cursor. If it finds exactly one possibility, it inserts it. If it finds more, it inserts the longest unambiguous part and then opens a menu (the "pager") that you can navigate to find what you're looking for.
|
||||
Tab completion is a time saving feature of any modern shell. When you type :kbd:`tab`, fish tries to guess the rest of the word under the cursor. If it finds just one possibility, it inserts it. If it finds more, it inserts the longest unambiguous part and then opens a menu (the "pager") that you can navigate to find what you're looking for.
|
||||
|
||||
The pager can be navigated with the arrow keys, :kbd:`pageup` / :kbd:`pagedown`, :kbd:`tab` or :kbd:`shift-tab`. Pressing :kbd:`ctrl-s` (the ``pager-toggle-search`` binding - :kbd:`/` in vi mode) opens up a search menu that you can use to filter the list.
|
||||
|
||||
@@ -56,7 +56,7 @@ It also provides a large number of program specific scripted completions. Most o
|
||||
|
||||
You can also write your own completions or install some you got from someone else. For that, see :ref:`Writing your own completions <completion-own>`.
|
||||
|
||||
Completion scripts are loaded on demand, like :ref:`functions are <syntax-function-autoloading>`. The difference is the ``$fish_complete_path`` :ref:`list <variables-lists>` is used instead of ``$fish_function_path``. Typically you can drop new completions in ~/.config/fish/completions/name-of-command.fish and fish will find them automatically.
|
||||
Completion scripts are loaded on demand, just like :ref:`functions are <syntax-function-autoloading>`. The difference is the ``$fish_complete_path`` :ref:`list <variables-lists>` is used instead of ``$fish_function_path``. Typically you can drop new completions in ~/.config/fish/completions/name-of-command.fish and fish will find them automatically.
|
||||
|
||||
.. _color:
|
||||
|
||||
@@ -89,16 +89,7 @@ Or, to see all themes, right in your terminal::
|
||||
Syntax highlighting variables
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The colors used by fish for syntax highlighting can be configured by changing the values of various variables. The value of these variables can be one of the colors accepted by the :doc:`set_color <cmds/set_color>` command.
|
||||
Options accepted by ``set_color`` like
|
||||
``--background=``,
|
||||
``--bold``,
|
||||
``--dim``,
|
||||
``--italics``,
|
||||
``--reverse``,
|
||||
``--underline`` and
|
||||
``--underline-color=``
|
||||
are also accepted.
|
||||
The colors used by fish for syntax highlighting can be configured by changing the values of various variables. The value of these variables can be one of the colors accepted by the :doc:`set_color <cmds/set_color>` command. The modifier switches accepted by ``set_color`` like ``--bold``, ``--dim``, ``--italics``, ``--reverse`` and ``--underline`` are also accepted.
|
||||
|
||||
|
||||
Example: to make errors highlighted and red, use::
|
||||
@@ -226,8 +217,6 @@ This prompt is determined by running the :doc:`fish_prompt <cmds/fish_prompt>` a
|
||||
The output of the former is displayed on the left and the latter's output on the right side of the terminal.
|
||||
For :ref:`vi mode <vi-mode>`, the output of :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` will be prepended on the left.
|
||||
|
||||
If :envvar:`fish_transient_prompt` is set to 1, fish will redraw the prompt with a ``--final-rendering`` argument before running a commandline, allowing you to change it before pushing it to the scrollback.
|
||||
|
||||
Fish ships with a few prompts which you can see with :doc:`fish_config <cmds/fish_config>`. If you run just ``fish_config`` it will open a web interface [#]_ where you'll be shown the prompts and can pick which one you want. ``fish_config prompt show`` will show you the prompts right in your terminal.
|
||||
|
||||
For example ``fish_config prompt choose disco`` will temporarily select the "disco" prompt. If you like it and decide to keep it, run ``fish_config prompt save``.
|
||||
@@ -314,11 +303,9 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit
|
||||
|
||||
- :kbd:`alt-enter` inserts a newline at the cursor position. This is useful to add a line to a commandline that's already complete.
|
||||
|
||||
- :kbd:`alt-left` (``←``) and :kbd:`alt-right` (``→``) move the cursor left or right by one argument (or one word on macOS).
|
||||
If the command line is empty, they move forward/backward in the directory history.
|
||||
If the cursor is already at the end of the line, and an autosuggestion is available, :kbd:`alt-right` (``→``) (or :kbd:`alt-f`) accepts the first argument (or word on macOS) in the suggestion.
|
||||
- :kbd:`alt-left` (``←``) and :kbd:`alt-right` (``→``) move the cursor one argument left or right, or moves forward/backward in the directory history if the command line is empty. If the cursor is already at the end of the line, and an autosuggestion is available, :kbd:`alt-right` (``→``) (or :kbd:`alt-f`) accepts the first argument in the suggestion.
|
||||
|
||||
- :kbd:`ctrl-left` (``←``) and :kbd:`ctrl-right` (``→``) move the cursor left or right by one word. These accept one word of the autosuggestion - the part they'd move over.
|
||||
- :kbd:`ctrl-left` (``←``) and :kbd:`ctrl-right` (``→``) move the cursor one word left or right. These accept one word of the autosuggestion - the part they'd move over.
|
||||
|
||||
- :kbd:`shift-left` (``←``) and :kbd:`shift-right` (``→``) move the cursor one word left or right, without stopping on punctuation. These accept one big word of the autosuggestion.
|
||||
|
||||
@@ -338,15 +325,9 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit
|
||||
|
||||
- :kbd:`ctrl-x` copies the current buffer to the system's clipboard, :kbd:`ctrl-v` inserts the clipboard contents. (see :doc:`fish_clipboard_copy <cmds/fish_clipboard_copy>` and :doc:`fish_clipboard_paste <cmds/fish_clipboard_paste>`)
|
||||
|
||||
- :kbd:`alt-d` moves the next word to the :ref:`killring`.
|
||||
- :kbd:`alt-d` or :kbd:`ctrl-delete` moves the next word to the :ref:`killring`.
|
||||
|
||||
- :kbd:`ctrl-delete` moves the next word (or next argument on macOS) to the :ref:`killring`.
|
||||
|
||||
- :kbd:`alt-d` lists the directory history if the command line is empty.
|
||||
|
||||
- :kbd:`alt-delete` moves the next argument (or word on macOS) to the :ref:`killring`.
|
||||
|
||||
- :kbd:`shift-delete` removes the current history item or autosuggestion from the command history.
|
||||
- :kbd:`alt-delete` moves the next argument to the :ref:`killring`.
|
||||
|
||||
- :kbd:`alt-h` (or :kbd:`f1`) shows the manual page for the current command, if one exists.
|
||||
|
||||
@@ -379,14 +360,11 @@ To enable emacs mode, use :doc:`fish_default_key_bindings <cmds/fish_default_key
|
||||
|
||||
- :kbd:`ctrl-b`, :kbd:`ctrl-f` move the cursor one character left or right or accept the autosuggestion just like the :kbd:`left` (``←``) and :kbd:`right` (``→``) shared bindings (which are available as well).
|
||||
|
||||
- :kbd:`alt-b`, :kbd:`alt-f` move the cursor one word left or right, or accept one word of the autosuggestion. If the command line is empty, moves forward/backward in the directory history instead.
|
||||
|
||||
- :kbd:`ctrl-n`, :kbd:`ctrl-p` move the cursor up/down or through history, like the up and down arrow shared bindings.
|
||||
|
||||
- :kbd:`delete` or :kbd:`backspace` or :kbd:`ctrl-h` removes one character forwards or backwards respectively.
|
||||
|
||||
- :kbd:`ctrl-backspace` removes one word backwards and :kbd:`alt-backspace` removes one argument backwards.
|
||||
On macOS, it's the other way round.
|
||||
|
||||
- :kbd:`alt-<` moves to the beginning of the commandline, :kbd:`alt->` moves to the end.
|
||||
|
||||
@@ -404,7 +382,7 @@ To enable emacs mode, use :doc:`fish_default_key_bindings <cmds/fish_default_key
|
||||
|
||||
- :kbd:`ctrl-z`, :kbd:`ctrl-_` (:kbd:`ctrl-/` on some terminals) undo the most recent edit of the line.
|
||||
|
||||
- :kbd:`alt-/` or :kbd:`ctrl-shift-z` reverts the most recent undo.
|
||||
- :kbd:`alt-/` reverts the most recent undo.
|
||||
|
||||
- :kbd:`ctrl-r` opens the history in a pager. This will show history entries matching the search, a few at a time. Pressing :kbd:`ctrl-r` again will search older entries, pressing :kbd:`ctrl-s` (that otherwise toggles pager search) will go to newer entries. The search bar will always be selected.
|
||||
|
||||
@@ -498,7 +476,6 @@ Command mode is also known as normal mode.
|
||||
- :kbd:`p` pastes text from the :ref:`killring`.
|
||||
|
||||
- :kbd:`u` undoes the most recent edit of the command line.
|
||||
|
||||
- :kbd:`ctrl-r` redoes the most recent edit.
|
||||
|
||||
- :kbd:`[` and :kbd:`]` search the command history for the previous/next token containing the token under the cursor before the search was started. See the :ref:`history <history-search>` section for more information on history searching.
|
||||
@@ -520,8 +497,6 @@ Insert mode
|
||||
|
||||
- :kbd:`backspace` removes one character to the left.
|
||||
|
||||
- :kbd:`ctrl-n` accepts the autosuggestion.
|
||||
|
||||
.. _vi-mode-visual:
|
||||
|
||||
Visual mode
|
||||
@@ -560,12 +535,12 @@ Custom bindings
|
||||
|
||||
In addition to the standard bindings listed here, you can also define your own with :doc:`bind <cmds/bind>`::
|
||||
|
||||
# Prints ``^C`` and a new prompt
|
||||
bind ctrl-c cancel-commandline
|
||||
# Just clear the commandline on control-c
|
||||
bind ctrl-c 'commandline -r ""'
|
||||
|
||||
Put ``bind`` statements into :ref:`config.fish <configuration>` or a function called ``fish_user_key_bindings``.
|
||||
|
||||
If you change your mind on a binding and want to go back to fish's default, you can erase it again::
|
||||
If you change your mind on a binding and want to go back to fish's default, you can simply erase it again::
|
||||
|
||||
bind --erase ctrl-c
|
||||
|
||||
@@ -617,7 +592,7 @@ Copy and paste (Kill Ring)
|
||||
Fish uses an Emacs-style kill ring for copy and paste functionality. For example, use :kbd:`ctrl-k` (`kill-line`) to cut from the current cursor position to the end of the line. The string that is cut (a.k.a. killed in emacs-ese) is inserted into a list of kills, called the kill ring. To paste the latest value from the kill ring (emacs calls this "yanking") use :kbd:`ctrl-y` (the ``yank`` input function). After pasting, use :kbd:`alt-y` (``yank-pop``) to rotate to the previous kill.
|
||||
|
||||
Copy and paste from outside are also supported, both via the :kbd:`ctrl-x` / :kbd:`ctrl-v` bindings (the ``fish_clipboard_copy`` and ``fish_clipboard_paste`` functions [#]_) and via the terminal's paste function, for which fish enables "Bracketed Paste Mode", so it can tell a paste from manually entered text.
|
||||
In addition, when pasting inside single quotes, pasted single quotes and backslashes are automatically escaped so that the result can be used as a single token by closing the quote after.
|
||||
In addition, when pasting inside single quotes, pasted single quotes and backslashes are automatically escaped so that the result can be used as a single token simply by closing the quote after.
|
||||
Kill ring entries are stored in ``fish_killring`` variable.
|
||||
|
||||
The commands ``begin-selection`` and ``end-selection`` (unbound by default; used for selection in vi visual mode) control text selection together with cursor movement commands that extend the current selection.
|
||||
@@ -647,7 +622,7 @@ Searchable command history
|
||||
|
||||
After a command has been executed, it is remembered in the history list. Any duplicate history items are automatically removed. By pressing the up and down keys, you can search forwards and backwards in the history. If the current command line is not empty when starting a history search, only the commands containing the string entered into the command line are shown.
|
||||
|
||||
By pressing :kbd:`alt-up` (``↑``) and :kbd:`alt-down` (``↓``), a history search is also performed, but instead of searching for a complete commandline, each commandline is broken into separate elements like it would be before execution, and the history is searched for an element matching that under the cursor.
|
||||
By pressing :kbd:`alt-up` (``↑``) and :kbd:`alt-down` (``↓``), a history search is also performed, but instead of searching for a complete commandline, each commandline is broken into separate elements just like it would be before execution, and the history is searched for an element matching that under the cursor.
|
||||
|
||||
For more complicated searches, you can press :kbd:`ctrl-r` to open a pager that allows you to search the history. It shows a limited number of entries in one page, press :kbd:`ctrl-r` [#]_ again to move to the next page and :kbd:`ctrl-s` [#]_ to move to the previous page. You can change the text to refine your search.
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ This is important when any redirections reference other file descriptors with th
|
||||
|
||||
Consider this helper function::
|
||||
|
||||
# Make a function that prints something to stdout and stderr
|
||||
# Just make a function that prints something to stdout and stderr
|
||||
function print
|
||||
echo out
|
||||
echo err >&2
|
||||
@@ -266,9 +266,8 @@ Consider this helper function::
|
||||
Now let's see a few cases::
|
||||
|
||||
# Redirect both stderr and stdout to less
|
||||
# (can also be spelt as `&|`)
|
||||
print 2>&1 | less
|
||||
# or
|
||||
print &| less
|
||||
|
||||
# Show the "out" on stderr, silence the "err"
|
||||
print >&2 2>/dev/null
|
||||
@@ -281,7 +280,7 @@ Now let's see a few cases::
|
||||
Job control
|
||||
-----------
|
||||
|
||||
When you start a job in fish, fish itself will pause, and give control of the terminal to the program it just started. Sometimes, you want to continue using the commandline, and have the job run in the background. To create a background job, append an ``&`` (ampersand) to your command. This will tell fish to run the job in the background. Background jobs are very useful when running programs that have a graphical user interface.
|
||||
When you start a job in fish, fish itself will pause, and give control of the terminal to the program just started. Sometimes, you want to continue using the commandline, and have the job run in the background. To create a background job, append an ``&`` (ampersand) to your command. This will tell fish to run the job in the background. Background jobs are very useful when running programs that have a graphical user interface.
|
||||
|
||||
Example::
|
||||
|
||||
@@ -314,7 +313,7 @@ For example, here's a simple function to list directories::
|
||||
ls -l $argv
|
||||
end
|
||||
|
||||
The first line tells fish to define a function by the name of ``ll``, so it can be used by writing ``ll`` on the commandline. The second line tells fish that the command ``ls -l $argv`` should be called when ``ll`` is invoked. :ref:`$argv <variables-argv>` is a :ref:`list variable <variables-lists>`, which always contains all arguments sent to the function. In the example above, these are passed on to the ``ls`` command. The ``end`` on the third line ends the definition.
|
||||
The first line tells fish to define a function by the name of ``ll``, so it can be used by simply writing ``ll`` on the commandline. The second line tells fish that the command ``ls -l $argv`` should be called when ``ll`` is invoked. :ref:`$argv <variables-argv>` is a :ref:`list variable <variables-lists>`, which always contains all arguments sent to the function. In the example above, these are simply passed on to the ``ls`` command. The ``end`` on the third line ends the definition.
|
||||
|
||||
Calling this as ``ll /tmp/`` will end up running ``ls -l /tmp/``, which will list the contents of /tmp.
|
||||
|
||||
@@ -408,7 +407,7 @@ This is useful to explain what and why you are doing something::
|
||||
command ls --color=auto $argv
|
||||
end
|
||||
|
||||
There are no multiline comments. If you want to make a comment span multiple lines, start each line with a ``#``.
|
||||
There are no multiline comments. If you want to make a comment span multiple lines, simply start each line with a ``#``.
|
||||
|
||||
Comments can also appear after a line like so::
|
||||
|
||||
@@ -436,7 +435,7 @@ Like other shells, but unlike typical programming languages you might know, the
|
||||
|
||||
This uses the :doc:`test <cmds/test>` command to see if the file /etc/os-release exists. If it does, it runs ``cat``, which prints it on the screen.
|
||||
|
||||
Unlike other shells, the condition command ends after the first job, there is no ``then`` here. Combiners like ``and`` and ``or`` extend the condition.
|
||||
Unlike other shells, the condition command just ends after the first job, there is no ``then`` here. Combiners like ``and`` and ``or`` extend the condition.
|
||||
|
||||
A more complicated example with a :ref:`command substitution <expand-command-substitution>`::
|
||||
|
||||
@@ -460,7 +459,7 @@ Because ``test`` can be used for many different tests, it is important to quote
|
||||
|
||||
The :doc:`not <cmds/not>` keyword can be used to invert the status::
|
||||
|
||||
# Check if the file contains the string "fish" anywhere.
|
||||
# Just see if the file contains the string "fish" anywhere.
|
||||
# This executes the `grep` command, which searches for a string,
|
||||
# and if it finds it returns a status of 0.
|
||||
# The `not` then turns 0 into 1 or anything else into 0.
|
||||
@@ -530,7 +529,7 @@ Or you can have a case where it is necessary to stop early::
|
||||
|
||||
If this went on after seeing that the command "foo" doesn't exist, it would try to run ``foo`` and error because it wasn't found!
|
||||
|
||||
Combiners execute step-by-step, so it isn't recommended to build longer chains of them because they might do something you don't want. Consider::
|
||||
Combiners really just execute step-by-step, so it isn't recommended to build longer chains of them because they might do something you don't want. Consider::
|
||||
|
||||
test -e /etc/my.config
|
||||
or echo "OH NO WE NEED A CONFIG FILE"
|
||||
@@ -567,7 +566,7 @@ will print "Still running" once a second. You can abort it with ctrl-c.
|
||||
echo file: $file
|
||||
end
|
||||
|
||||
will print each file in the current directory. The part after the ``in`` is a list of arguments, so you can use any :ref:`expansions <expand>` there::
|
||||
will print each file in the current directory. The part after the ``in`` is just a list of arguments, so you can use any :ref:`expansions <expand>` there::
|
||||
|
||||
set moreanimals bird fox
|
||||
for animal in {cat,}fish dog $moreanimals
|
||||
@@ -620,7 +619,7 @@ When a parameter includes an :ref:`unquoted <quotes>` ``*`` star (or "asterisk")
|
||||
|
||||
- ``**`` matches any number of characters (including zero), and also descends into subdirectories. If ``**`` is a segment by itself, that segment may match zero times, for compatibility with other shells.
|
||||
|
||||
- ``?`` can match any single character except ``/``. This is deprecated and can be disabled via the ``qmark-noglob`` :ref:`feature flag<featureflags>`, so ``?`` will be an ordinary character.
|
||||
- ``?`` can match any single character except ``/``. This is deprecated and can be disabled via the ``qmark-noglob`` :ref:`feature flag<featureflags>`, so ``?`` will just be an ordinary character.
|
||||
|
||||
Wildcard matches are sorted case insensitively. When sorting matches containing numbers, they are naturally sorted, so that the strings '1' '5' and '12' would be sorted like 1, 5, 12.
|
||||
|
||||
@@ -658,7 +657,7 @@ Variable expansion
|
||||
|
||||
One of the most important expansions in fish is the "variable expansion". This is the replacing of a dollar sign (``$``) followed by a variable name with the _value_ of that variable.
|
||||
|
||||
A simple example::
|
||||
In the simplest case, this is just something like::
|
||||
|
||||
echo $HOME
|
||||
|
||||
@@ -788,10 +787,11 @@ Some more examples::
|
||||
# Output is 1 2 3
|
||||
|
||||
echo $$var[2][3]
|
||||
# $var[2] is listtwo, third element of that is 6, output is 6
|
||||
# $var[1] is listtwo, third element of that is 6, output is 6
|
||||
|
||||
echo $$var[..][2]
|
||||
# The second element of every variable, so output is 2 5
|
||||
# The second element of every variable, so output is
|
||||
# 2 5
|
||||
|
||||
Variables as command
|
||||
''''''''''''''''''''
|
||||
@@ -858,18 +858,18 @@ Examples::
|
||||
# Set ``$data`` to the contents of data, splitting on NUL-bytes.
|
||||
set data (cat data | string split0)
|
||||
|
||||
Sometimes you want to pass the output of a command to another command that only accepts files. If it's just one file, you can usually pass it via a pipe, like::
|
||||
Sometimes you want to pass the output of a command to another command that only accepts files. If it's just one file, you can usually just pass it via a pipe, like::
|
||||
|
||||
grep fish myanimallist1 | wc -l
|
||||
|
||||
but if you need multiple or the command doesn't read from standard input, "process substitution" is useful. Other shells allow this via ``foo <(bar) <(baz)``, and fish uses the :doc:`psub <cmds/psub>` command::
|
||||
|
||||
# Compare only the lines containing "fish" in two files:
|
||||
# Compare just the lines containing "fish" in two files:
|
||||
diff -u (grep fish myanimallist1 | psub) (grep fish myanimallist2 | psub)
|
||||
|
||||
This creates a temporary file, stores the output of the command in that file and prints the filename, so it is given to the outer command.
|
||||
|
||||
Fish has a default limit of 1 GiB on the data it will read in a command substitution. If that limit is reached the command (all of it, not just the command substitution - the outer command won't be executed at all) fails and ``$status`` is set to 122. This is so command substitutions can't cause the system to go out of memory, because typically your operating system has a much lower limit, so reading more than that would be useless and harmful. This limit can be adjusted with the ``fish_read_limit`` variable (`0` meaning no limit). This limit also affects the :doc:`read <cmds/read>` command.
|
||||
Fish has a default limit of 100 MiB on the data it will read in a command sustitution. If that limit is reached the command (all of it, not just the command substitution - the outer command won't be executed at all) fails and ``$status`` is set to 122. This is so command substitutions can't cause the system to go out of memory, because typically your operating system has a much lower limit, so reading more than that would be useless and harmful. This limit can be adjusted with the ``fish_read_limit`` variable (`0` meaning no limit). This limit also affects the :doc:`read <cmds/read>` command.
|
||||
|
||||
.. [#] One exception: Setting ``$IFS`` to empty will disable line splitting. This is deprecated, use :doc:`string split <cmds/string-split>` instead.
|
||||
|
||||
@@ -908,7 +908,7 @@ If there is no "," or variable expansion between the curly braces, they will not
|
||||
If after expansion there is nothing between the braces, the argument will be removed (see :ref:`the Combining Lists <cartesian-product>` section)::
|
||||
|
||||
> echo foo-{$undefinedvar}
|
||||
# Output is an empty line, like a bare `echo`.
|
||||
# Output is an empty line, just like a bare `echo`.
|
||||
|
||||
If there is nothing between a brace and a comma or two commas, it's interpreted as an empty element::
|
||||
|
||||
@@ -1325,7 +1325,7 @@ To see universal variables in action, start two fish sessions side by side, and
|
||||
|
||||
:ref:`Universal variables <variables-universal>` are stored in the file ``.config/fish/fish_variables``. Do not edit this file directly, as your edits may be overwritten. Edit the variables through fish scripts or by using fish interactively instead.
|
||||
|
||||
Do not append to universal variables in :ref:`config.fish <configuration>`, because these variables will then get longer with each new shell instance. Instead, set them once at the command line.
|
||||
Do not append to universal variables in :ref:`config.fish <configuration>`, because these variables will then get longer with each new shell instance. Instead, simply set them once at the command line.
|
||||
|
||||
.. _variables-export:
|
||||
|
||||
@@ -1368,7 +1368,7 @@ To access one element of a list, use the index of the element inside of square b
|
||||
|
||||
echo $PATH[3]
|
||||
|
||||
List indices start at 1 in fish, not 0 like in other languages. This is because it requires less subtracting of 1 and many common Unix tools like ``seq`` work better with it (``seq 5`` prints 1 to 5, not 0 to 5). An invalid index is silently ignored resulting in no value (not even an empty string, no argument at all).
|
||||
List indices start at 1 in fish, not 0 like in other languages. This is because it requires less subtracting of 1 and many common Unix tools like ``seq`` work better with it (``seq 5`` prints 1 to 5, not 0 to 5). An invalid index is silently ignored resulting in no value (not even an empty string, just no argument at all).
|
||||
|
||||
If you don't use any brackets, all the elements of the list will be passed to the command as separate items. This means you can iterate over a list with ``for``::
|
||||
|
||||
@@ -1378,7 +1378,7 @@ If you don't use any brackets, all the elements of the list will be passed to th
|
||||
|
||||
This goes over every directory in :envvar:`PATH` separately and prints a line saying it is in the path.
|
||||
|
||||
To create a variable ``smurf``, containing the items ``blue`` and ``small``, write::
|
||||
To create a variable ``smurf``, containing the items ``blue`` and ``small``, simply write::
|
||||
|
||||
set smurf blue small
|
||||
|
||||
@@ -1440,7 +1440,7 @@ Lists can be inspected with the :doc:`count <cmds/count>` or the :doc:`contains
|
||||
> contains -i blue $smurf
|
||||
1
|
||||
|
||||
A nice thing about lists is that they are passed to commands one element as one argument, so once you've set your list, you can pass it::
|
||||
A nice thing about lists is that they are passed to commands one element as one argument, so once you've set your list, you can just pass it::
|
||||
|
||||
set -l grep_args -r "my string"
|
||||
grep $grep_args . # will run the same as `grep -r "my string"` .
|
||||
@@ -1565,12 +1565,13 @@ You can change the settings of fish by changing the values of certain variables.
|
||||
|
||||
.. envvar:: fish_term24bit
|
||||
|
||||
If this is set to 0, fish will not output 24-bit RGB true-color sequences but the nearest color on the 256 color palette (or the 16 color palette, if :envvar:`fish_term256` is 0).
|
||||
If this is set to 1, fish will assume the terminal understands 24-bit RGB color sequences, and won't translate them to the 256 or 16 color palette.
|
||||
This is often detected automatically.
|
||||
|
||||
.. envvar:: fish_term256
|
||||
|
||||
If this is set to 0 and :envvar:`fish_term24bit` is 0, translate RGB colors down to the 16 color palette.
|
||||
Also, if this is set to 0, :doc:`set_color <cmds/set_color>`/` commands such as ``set_color ff0000 red`` will prefer the named color.
|
||||
If this is set to 1, fish will assume the terminal understands 256 colors, and won't translate matching colors down to the 16 color palette.
|
||||
This is usually autodetected.
|
||||
|
||||
.. envvar:: fish_ambiguous_width
|
||||
|
||||
@@ -1584,10 +1585,6 @@ You can change the settings of fish by changing the values of certain variables.
|
||||
|
||||
controls if :ref:`autosuggestions` are enabled. Set it to 0 to disable, anything else to enable. By default they are on.
|
||||
|
||||
.. envvar:: fish_transient_prompt
|
||||
|
||||
If this is set to 1, fish will redraw prompts with a ``--final-rendering`` argument before running a commandline, allowing you to change it before pushing it to the scrollback. This enables :ref:`transient prompts <transient-prompt>`.
|
||||
|
||||
.. envvar:: fish_handle_reflow
|
||||
|
||||
determines whether fish should try to repaint the commandline when the terminal resizes. In terminals that reflow text this should be disabled. Set it to 1 to enable, anything else to disable.
|
||||
@@ -1717,7 +1714,7 @@ Fish also provides additional information through the values of certain environm
|
||||
|
||||
.. ENVVAR:: SHLVL
|
||||
|
||||
the level of nesting of shells. Fish increments this in interactive shells, otherwise it only passes it along.
|
||||
the level of nesting of shells. Fish increments this in interactive shells, otherwise it simply passes it along.
|
||||
|
||||
.. envvar:: status
|
||||
|
||||
@@ -1727,6 +1724,12 @@ Fish also provides additional information through the values of certain environm
|
||||
|
||||
the "generation" count of ``$status``. This will be incremented only when the previous command produced an explicit status. (For example, background jobs will not increment this).
|
||||
|
||||
.. ENVVAR:: TERM
|
||||
|
||||
the type of the current terminal. When fish tries to determine how the terminal works - how many colors it supports, what sequences it sends for keys and other things - it looks at this variable and the corresponding information in the terminfo database (see ``man terminfo``).
|
||||
|
||||
Note: Typically this should not be changed as the terminal sets it to the correct value.
|
||||
|
||||
.. ENVVAR:: USER
|
||||
|
||||
the current username. This variable can be changed.
|
||||
@@ -1841,7 +1844,7 @@ The "locale" of a program is its set of language and regional settings that depe
|
||||
|
||||
.. envvar:: LC_MONETARY
|
||||
|
||||
Determines currency, how it is formatted, and the symbols used.
|
||||
Determines currency, how it is formated, and the symbols used.
|
||||
|
||||
.. envvar:: LC_NUMERIC
|
||||
|
||||
@@ -1950,7 +1953,7 @@ Let's make up an example. This function will :ref:`glob <expand-wildcard>` the f
|
||||
printf '%s\n' $files
|
||||
end
|
||||
|
||||
If you run this as ``show_files /``, it will most likely ask you until you press Y/y or N/n. If you run this as ``show_files / | cat``, it will print the files without asking. If you run this as ``show_files .``, it might print something without asking because there are fewer than five files.
|
||||
If you run this as ``show_files /``, it will most likely ask you until you press Y/y or N/n. If you run this as ``show_files / | cat``, it will print the files without asking. If you run this as ``show_files .``, it might just print something without asking because there are fewer than five files.
|
||||
|
||||
.. _identifiers:
|
||||
|
||||
@@ -2018,19 +2021,17 @@ You can see the current list of features via ``status features``::
|
||||
qmark-noglob on 3.0 ? no longer globs
|
||||
regex-easyesc on 3.1 string replace -r needs fewer \\'s
|
||||
ampersand-nobg-in-token on 3.4 & only backgrounds if followed by a separating character
|
||||
remove-percent-self off 4.0 %self is no longer expanded (use $fish_pid)
|
||||
test-require-arg off 4.0 builtin test requires an argument
|
||||
ignore-terminfo on 4.1 do not look up $TERM in terminfo database
|
||||
remove-percent-self off 3.8 %self is no longer expanded (use $fish_pid)
|
||||
test-require-arg off 3.8 builtin test requires an argument
|
||||
|
||||
Here is what they mean:
|
||||
|
||||
- ``stderr-nocaret`` was introduced in fish 3.0 and cannot be turned off since fish 3.5. It can still be tested for compatibility, but a ``no-stderr-nocaret`` value will be ignored. The flag made ``^`` an ordinary character instead of denoting an stderr redirection. Use ``2>`` instead.
|
||||
- ``qmark-noglob`` was also introduced in fish 3.0 (and made the default in 4.0). It makes ``?`` an ordinary character instead of a single-character glob. Use a ``*`` instead (which will match multiple characters) or find other ways to match files like ``find``.
|
||||
- ``regex-easyesc`` was introduced in 3.1 (and made the default in 3.5). It makes it so the replacement expression in ``string replace -r`` does one fewer round of escaping. Before, to escape a backslash you would have to use ``string replace -ra '([ab])' '\\\\\\\\$1'``. After, just ``'\\\\$1'`` is enough. Check your ``string replace`` calls if you use this anywhere.
|
||||
- ``ampersand-nobg-in-token`` was introduced in fish 3.4 (and made the default in 3.5). It makes it so a ``&`` i no longer interpreted as the backgrounding operator in the middle of a token, so dealing with URLs becomes easier. Either put spaces or a semicolon after the ``&``. This is recommended formatting anyway, and ``fish_indent`` will have done it for you already.
|
||||
- ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 4.0. To get fish's pid, you can use the :envvar:`fish_pid` variable.
|
||||
- ``test-require-arg`` removes :doc:`builtin test <cmds/test>`'s one-argument form (``test "string"``. It was introduced in 4.0. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message <debugging-fish>` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls.
|
||||
- ``ignore-terminfo`` disables lookup of $TERM in the terminfo database. Use ``no-ignore-terminfo`` to turn it back on.
|
||||
- ``stderr-nocaret`` was introduced in fish 3.0 (and made the default in 3.3). It makes ``^`` an ordinary character instead of denoting an stderr redirection, to make dealing with quoting and such easier. Use ``2>`` instead. This can no longer be turned off since fish 3.5. The flag can still be tested for compatibility, but a ``no-stderr-nocaret`` value will simply be ignored.
|
||||
- ``qmark-noglob`` was also introduced in fish 3.0 (and made the default in 3.8). It makes ``?`` an ordinary character instead of a single-character glob. Use a ``*`` instead (which will match multiple characters) or find other ways to match files like ``find``.
|
||||
- ``regex-easyesc`` was introduced in 3.1. It makes it so the replacement expression in ``string replace -r`` does one fewer round of escaping. Before, to escape a backslash you would have to use ``string replace -ra '([ab])' '\\\\\\\\$1'``. After, just ``'\\\\$1'`` is enough. Check your ``string replace`` calls if you use this anywhere.
|
||||
- ``ampersand-nobg-in-token`` was introduced in fish 3.4. It makes it so a ``&`` i no longer interpreted as the backgrounding operator in the middle of a token, so dealing with URLs becomes easier. Either put spaces or a semicolon after the ``&``. This is recommended formatting anyway, and ``fish_indent`` will have done it for you already.
|
||||
- ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 3.8. To get fish's pid, you can use the :envvar:`fish_pid` variable.
|
||||
- ``test-require-arg`` removes :doc:`builtin test <cmds/test>`'s one-argument form (``test "string"``. It was introduced in 3.8. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message <debugging-fish>` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls.
|
||||
|
||||
|
||||
These changes are introduced off by default. They can be enabled on a per session basis::
|
||||
@@ -2051,6 +2052,12 @@ Prefixing a feature with ``no-`` turns it off instead. E.g. to reenable the ``?`
|
||||
|
||||
set -Ua fish_features no-qmark-noglob
|
||||
|
||||
Currently, the following features are enabled by default:
|
||||
|
||||
- stderr-nocaret - ``^`` no longer redirects stderr, use ``2>``. Enabled by default in fish 3.3.0. No longer changeable since fish 3.5.0.
|
||||
- regex-easyesc - ``string replace -r`` requires fewer backslashes in the replacement part. Enabled by default in fish 3.5.0.
|
||||
- ampersand-nobg-in-token - ``&`` in the middle of a word is a normal character instead of backgrounding. Enabled by default in fish 3.5.0.
|
||||
|
||||
.. _event:
|
||||
|
||||
Event handlers
|
||||
@@ -2114,14 +2121,12 @@ For more information on how to define new event handlers, see the documentation
|
||||
Debugging fish scripts
|
||||
----------------------
|
||||
|
||||
Fish includes basic built-in debugging facilities that allow you to stop execution of a script at an arbitrary point. When this happens you are presented with an interactive prompt where you can execute any fish command to inspect or change state (there are no debug commands as such). For example, you can check or change the value of any variables using :doc:`printf <cmds/printf>` and :doc:`set <cmds/set>`. As another example, you can run :doc:`status print-stack-trace <cmds/status>` to see how the current breakpoint was reached. To resume normal execution of the script, type :doc:`exit <cmds/exit>` or :kbd:`ctrl-d`.
|
||||
Fish includes basic built-in debugging facilities that allow you to stop execution of a script at an arbitrary point. When this happens you are presented with an interactive prompt where you can execute any fish command to inspect or change state (there are no debug commands as such). For example, you can check or change the value of any variables using :doc:`printf <cmds/printf>` and :doc:`set <cmds/set>`. As another example, you can run :doc:`status print-stack-trace <cmds/status>` to see how the current breakpoint was reached. To resume normal execution of the script, simply type :doc:`exit <cmds/exit>` or :kbd:`ctrl-d`.
|
||||
|
||||
To start a debug session insert the :doc:`builtin command <cmds/breakpoint>` ``breakpoint`` at the point in a function or script where you wish to gain control, then run the function or script. Also, the default action of the ``TRAP`` signal is to call this builtin, meaning a running script can be actively debugged by sending it the ``TRAP`` signal (``kill -s TRAP <PID>``). There is limited support for interactively setting or modifying breakpoints from this debug prompt: it is possible to insert new breakpoints in (or remove old ones from) other functions by using the ``funced`` function to edit the definition of a function, but it is not possible to add or remove a breakpoint from the function/script currently loaded and being executed.
|
||||
To start a debug session simply insert the :doc:`builtin command <cmds/breakpoint>` ``breakpoint`` at the point in a function or script where you wish to gain control, then run the function or script. Also, the default action of the ``TRAP`` signal is to call this builtin, meaning a running script can be actively debugged by sending it the ``TRAP`` signal (``kill -s TRAP <PID>``). There is limited support for interactively setting or modifying breakpoints from this debug prompt: it is possible to insert new breakpoints in (or remove old ones from) other functions by using the ``funced`` function to edit the definition of a function, but it is not possible to add or remove a breakpoint from the function/script currently loaded and being executed.
|
||||
|
||||
Another way to debug script issues is to set the :envvar:`fish_trace` variable, e.g. ``fish_trace=1 fish_prompt`` to see which commands fish executes when running the :doc:`fish_prompt <cmds/fish_prompt>` function.
|
||||
|
||||
.. _profiling:
|
||||
|
||||
Profiling fish scripts
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ License
|
||||
License for fish
|
||||
----------------
|
||||
|
||||
``fish`` Copyright © 2005-2009 Axel Liljencrantz, 2009- fish-shell contributors. ``fish`` is released under the GNU General Public License, version 2.
|
||||
``fish`` Copyright © 2005-2009 Axel Liljencrantz, 2009-2024 fish-shell contributors. ``fish`` is released under the GNU General Public License, version 2.
|
||||
|
||||
``fish`` includes other code licensed under the GNU General Public License, version 2, including GNU ``printf``.
|
||||
|
||||
|
||||
@@ -148,51 +148,10 @@ And it looks like:
|
||||
.. parsed-literal::
|
||||
:class: highlight
|
||||
|
||||
:green:`~/M/L/Oneknowing`>false
|
||||
:green:`~/M/L/Oneknowing`\ :red:`[1]`>_
|
||||
|
||||
after we run ``false`` (which returns 1).
|
||||
|
||||
.. _transient-prompt:
|
||||
|
||||
Transient prompt
|
||||
----------------
|
||||
|
||||
To enable transient prompt functionality, set the :envvar:`fish_transient_prompt` variable to 1::
|
||||
|
||||
set -g fish_transient_prompt 1
|
||||
|
||||
With this set, fish re-runs prompt functions with a ``--final-rendering`` argument before running a commandline.
|
||||
So you can use it to declutter your old prompts. For example if you want to see only the current directory name when you scroll up::
|
||||
|
||||
function fish_prompt
|
||||
set -l last_status $status
|
||||
set -l stat
|
||||
set -l pwd
|
||||
# Check if it's a transient or final prompt
|
||||
if contains -- --final-rendering $argv
|
||||
set pwd (path basename $PWD)
|
||||
else
|
||||
set pwd (prompt_pwd)
|
||||
# Prompt status only if it's not 0
|
||||
if test $last_status -ne 0
|
||||
set stat (set_color red)"[$last_status]"(set_color normal)
|
||||
end
|
||||
end
|
||||
|
||||
string join '' -- (set_color green) $pwd (set_color normal) $stat '>'
|
||||
end
|
||||
|
||||
Now running two commands in the same directory could result in this screen:
|
||||
|
||||
.. role:: green
|
||||
.. role:: red
|
||||
.. parsed-literal::
|
||||
:class: highlight
|
||||
|
||||
:green:`Oneknowing`>false
|
||||
:green:`~/M/L/Oneknowing`\ :red:`[1]`>_
|
||||
|
||||
Save the prompt
|
||||
---------------
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ body {
|
||||
div.related ul {
|
||||
margin: 0;
|
||||
padding: 0 0 0 10px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
div.related {
|
||||
@@ -70,10 +71,12 @@ div.related h3 {
|
||||
}
|
||||
|
||||
div.related li.right {
|
||||
float: right;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
div.sphinxsidebar {
|
||||
width: 230px;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
@@ -110,6 +113,7 @@ div.sphinxsidebar ul {
|
||||
margin: 10px;
|
||||
padding: 0;
|
||||
color: var(--secondary-link-color);
|
||||
margin: 10px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
@@ -544,6 +548,10 @@ div.sphinxsidebar ul {
|
||||
}
|
||||
|
||||
|
||||
div.bodywrapper {
|
||||
margin-left: 230px;
|
||||
}
|
||||
|
||||
aside.footnote > .label {
|
||||
display: inline;
|
||||
}
|
||||
@@ -557,36 +565,19 @@ div.documentwrapper {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.document {
|
||||
display: grid;
|
||||
grid-template: 1fr min-content / 12rem minmax(0,1fr);
|
||||
}
|
||||
|
||||
/* On screens that are less than 700px wide remove anything non-essential
|
||||
- the sidebar, the gradient background, ... */
|
||||
@media screen and (max-width: 700px) {
|
||||
div.document {
|
||||
display: grid;
|
||||
grid-template: 30vh min-content / 100%;
|
||||
}
|
||||
div.sphinxsidebar {
|
||||
font-size: 16px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
position: relative;
|
||||
/* To separate the "side"bar from the content below */
|
||||
border-bottom: 1px solid;
|
||||
border-color: var(--sidebar-border-color);
|
||||
}
|
||||
|
||||
/* Reduce margins to save space */
|
||||
div.sphinxsidebar ul ul, div.bodywrapper, div.content {
|
||||
div.bodywrapper {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar h3, div.sphinxsidebar h4 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.sphinxsidebar ul {
|
||||
flex-basis: content;
|
||||
@@ -594,15 +585,14 @@ div.document {
|
||||
}
|
||||
div.sphinxsidebarwrapper {
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
justify-content: space-between;
|
||||
}
|
||||
div.sphinxsidebarwrapper > h3:nth-child(5) {
|
||||
display: none;
|
||||
}
|
||||
#searchbox {
|
||||
div#searchbox {
|
||||
display: none !important;
|
||||
}
|
||||
div.content {margin-left: 0;}
|
||||
div.body {
|
||||
padding: 1rem;
|
||||
}
|
||||
@@ -623,9 +613,6 @@ div.document {
|
||||
|
||||
/* On print media remove anything non-essential. */
|
||||
@media print {
|
||||
div.document {
|
||||
display: block;
|
||||
}
|
||||
.inline-search {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -1,274 +0,0 @@
|
||||
Terminal Compatibility
|
||||
======================
|
||||
|
||||
fish writes various control sequences to the terminal.
|
||||
Some must be implemented to enable basic functionality,
|
||||
while others enable optional features and may be ignored by the terminal.
|
||||
|
||||
The terminal must be able to parse Control Sequence Introducer (CSI) commands, Operating System Commands (OSC) and optionally Device Control Strings (DCS).
|
||||
These are defined by ECMA-48.
|
||||
If a valid CSI, OSC or DCS sequence does not represent a command implemented by the terminal, the terminal must ignore it.
|
||||
|
||||
Control sequences are denoted in a fish-like syntax.
|
||||
Special characters other than ``\`` are not escaped.
|
||||
Spaces are only added for readability and are not part of the sequence.
|
||||
Placeholders are written as ``<Ps>`` for a number or ``<Pt>`` for an arbitrary printable string.
|
||||
|
||||
**NOTE:** fish does not rely on your system's terminfo database.
|
||||
In this document, terminfo (TI) codes are included for reference only.
|
||||
|
||||
Required Commands
|
||||
-----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: auto
|
||||
:header-rows: 1
|
||||
|
||||
* - Sequence
|
||||
- TI
|
||||
- Description
|
||||
- Origin
|
||||
* - ``\r``
|
||||
- n/a
|
||||
- Move cursor to the beginning of the line
|
||||
-
|
||||
* - ``\n``
|
||||
- cud1
|
||||
- Move cursor down one line.
|
||||
-
|
||||
* - ``\e[ Ps A``
|
||||
- cuu
|
||||
- Move cursor up Ps columns, or one column if no parameter.
|
||||
- VT100
|
||||
* - ``\e[ Ps C``
|
||||
- cuf
|
||||
- Move cursor to the right Ps columns, or one column if no parameter.
|
||||
- VT100
|
||||
* - ``\x08``
|
||||
- cub1
|
||||
- Move cursor one column to the left.
|
||||
- VT100
|
||||
* - ``\e[ Ps D``
|
||||
- cub
|
||||
- Move cursor to the left Ps times.
|
||||
- VT100
|
||||
* - ``\e[H``
|
||||
- cup
|
||||
- Set cursor position (no parameters means: move to row 1, column 1).
|
||||
- VT100
|
||||
* - ``\e[K``
|
||||
- el
|
||||
- Clear to end of line.
|
||||
- VT100
|
||||
* - ``\e[J``
|
||||
- ed
|
||||
- Clear to the end of screen.
|
||||
- VT100
|
||||
* - ``\e[2J``
|
||||
- clear
|
||||
- Clear the screen.
|
||||
- VT100
|
||||
* - ``\e[0c``
|
||||
-
|
||||
- Request primary device attribute.
|
||||
The terminal must respond with a CSI command that starts with the ``?`` parameter byte (so a sequence starting with ``\e[?``) and has ``c`` as final byte.
|
||||
- VT100
|
||||
* - n/a
|
||||
- am
|
||||
- Soft wrap text at screen width.
|
||||
-
|
||||
* - n/a
|
||||
- xenl
|
||||
- Printing to the last column does not move the cursor to the next line.
|
||||
Verify this by running ``printf %0"$COLUMNS"d 0; sleep 3``
|
||||
-
|
||||
|
||||
Optional Commands
|
||||
-----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: auto
|
||||
:header-rows: 1
|
||||
|
||||
* - Sequence
|
||||
- TI
|
||||
- Description
|
||||
- Origin
|
||||
* - ``\t``
|
||||
- it
|
||||
- Move the cursor to the next tab stop (à 8 columns).
|
||||
This is mainly relevant if your prompt includes tabs.
|
||||
-
|
||||
|
||||
* - ``\e[m``
|
||||
- sgr0
|
||||
- Turn off bold/dim/italic/underline/reverse attribute modes and select default colors.
|
||||
-
|
||||
* - ``\e[1m``
|
||||
- bold
|
||||
- Enter bold mode.
|
||||
-
|
||||
* - ``\e[2m``
|
||||
- dim
|
||||
- Enter dim mode.
|
||||
-
|
||||
* - ``\e[3m``
|
||||
- sitm
|
||||
- Enter italic mode.
|
||||
-
|
||||
* - ``\e[4m``
|
||||
- smul
|
||||
- Enter underline mode.
|
||||
-
|
||||
* - ``\e[4:3m``
|
||||
- Su
|
||||
- Enter curly underline mode.
|
||||
- kitty
|
||||
* - ``\e[7m``
|
||||
- rev
|
||||
- Enter reverse video mode (swap foreground and background colors).
|
||||
-
|
||||
* - ``\e[23m``
|
||||
- ritm
|
||||
- Exit italic mode.
|
||||
-
|
||||
* - ``\e[24m``
|
||||
- rmul
|
||||
- Exit underline mode.
|
||||
-
|
||||
* - ``\e[38;5; Ps m``
|
||||
- setaf
|
||||
- Select foreground color Ps from the 256-color-palette.
|
||||
-
|
||||
* - ``\e[48;5; Ps m``
|
||||
- setab
|
||||
- Select background color Ps from the 256-color-palette.
|
||||
-
|
||||
* - ``\e[58:5: Ps m`` (note: colons not semicolons)
|
||||
- Su
|
||||
- Select underline color Ps from the 256-color-palette.
|
||||
- kitty
|
||||
* - ``\e[ Ps m``
|
||||
- setaf
|
||||
setab
|
||||
- Select foreground/background color. This uses a color in the aforementioned 256-color-palette, based on the range that contains the parameter:
|
||||
30-37 maps to foreground 0-7,
|
||||
40-47 maps to background 0-7,
|
||||
90-97 maps to foreground 8-15 and
|
||||
100-107 maps to background 8-15.
|
||||
-
|
||||
* - ``\e[38;2; Ps ; Ps ; Ps m``
|
||||
-
|
||||
- Select foreground color from 24-bit RGB colors.
|
||||
-
|
||||
* - ``\e[48;2; Ps ; Ps ; Ps m``
|
||||
-
|
||||
- Select background color from 24-bit RGB colors.
|
||||
-
|
||||
* - ``\e[49m``
|
||||
-
|
||||
- Reset background color to the terminal's default.
|
||||
-
|
||||
* - ``\e[58:2:: Ps : Ps : Ps m`` (note: colons not semicolons)
|
||||
- Su
|
||||
- Select underline color from 24-bit RGB colors.
|
||||
- kitty
|
||||
* - ``\e[59m``
|
||||
- Su
|
||||
- Reset underline color to the default (follow the foreground color).
|
||||
- kitty
|
||||
* - ``\e[ Ps S``
|
||||
- indn
|
||||
- Scroll forward Ps lines.
|
||||
-
|
||||
* - ``\e[= Ps u``, ``\e[? Ps u``
|
||||
- n/a
|
||||
- Enable the kitty keyboard protocol.
|
||||
- kitty
|
||||
* - ``\e[6n``
|
||||
- n/a
|
||||
- Request cursor position report.
|
||||
- VT100
|
||||
* - ``\e[ \x20 q``
|
||||
- Se
|
||||
- Reset cursor style to the terminal's default. This is not used as of today but may be
|
||||
in future.
|
||||
- VT520
|
||||
* - ``\e[ Ps \x20 q``
|
||||
- Ss
|
||||
- Set cursor style (DECSCUSR); Ps is 2, 4 or 6 for block, underscore or line shape.
|
||||
- VT520
|
||||
* - ``\e[ Ps q``
|
||||
- n/a
|
||||
- Request terminal name and version (XTVERSION).
|
||||
- XTerm
|
||||
* - ``\e[?25h``
|
||||
- cvvis
|
||||
- Enable cursor visibility (DECTCEM).
|
||||
- VT220
|
||||
* - ``\e[?1000l``
|
||||
- n/a
|
||||
- Disable mouse reporting.
|
||||
- XTerm
|
||||
* - ``\e[?1004h``
|
||||
- n/a
|
||||
- Enable focus reporting.
|
||||
-
|
||||
* - ``\e[?1004l``
|
||||
- n/a
|
||||
- Disable focus reporting.
|
||||
-
|
||||
* - ``\e[?1049h``
|
||||
- n/a
|
||||
- Enable alternate screen buffer.
|
||||
- XTerm
|
||||
* - ``\e[?1049l``
|
||||
- n/a
|
||||
- Disable alternate screen buffer.
|
||||
- XTerm
|
||||
* - ``\e[?2004h``
|
||||
-
|
||||
- Enable bracketed paste.
|
||||
- XTerm
|
||||
* - ``\e[?2004l``
|
||||
-
|
||||
- Disable bracketed paste.
|
||||
- XTerm
|
||||
* - ``\e]0; Pt \x07``
|
||||
- ts
|
||||
- Set window title (OSC 0).
|
||||
- XTerm
|
||||
* - ``\e]7;file:// Pt / Pt \x07``
|
||||
-
|
||||
- Report working directory (OSC 7).
|
||||
Since the terminal may be running on a different system than a (remote) shell,
|
||||
the hostname (first parameter) will *not* be ``localhost``.
|
||||
- iTerm2
|
||||
* - ``\e]8;; Pt \e\\``
|
||||
-
|
||||
- Create a `hyperlink (OSC 8) <https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda>`_.
|
||||
This is used in fish's man pages.
|
||||
- GNOME Terminal
|
||||
* - ``\e]52;c; Pt \x07``
|
||||
-
|
||||
- Copy to clipboard (OSC 52).
|
||||
- XTerm
|
||||
* - .. _click-events:
|
||||
|
||||
``\e]133;A; click_events=1\x07``
|
||||
-
|
||||
- Mark prompt start (OSC 133), with kitty's ``click_events`` extension.
|
||||
- FinalTerm, kitty
|
||||
* - ``\e]133;C; cmdline_url= Pt \x07``
|
||||
-
|
||||
- Mark command start (OSC 133), with kitty's ``cmdline_url`` extension whose parameter is the URL-encoded command line.
|
||||
- FinalTerm, kitty
|
||||
* - ``\e]133;D; Ps \x07``
|
||||
-
|
||||
- Mark command end (OSC 133); Ps is the exit status.
|
||||
- FinalTerm
|
||||
* - ``\eP+q Pt \e\\``
|
||||
-
|
||||
- Request terminfo capability (XTGETTCAP). The parameter is the capability's hex-encoded terminfo code.
|
||||
Specifically, fish asks for the ``indn`` string capability. At the time of writing string capabilities are supported by kitty and foot.
|
||||
- XTerm, kitty, foot
|
||||
@@ -650,9 +650,7 @@ This prompt would look like:
|
||||
:red:`/home/tutorial >` _
|
||||
|
||||
|
||||
See also :doc:`Writing your own prompt <prompt>`.
|
||||
|
||||
You can choose among sample prompts by running ``fish_config`` for a web UI or ``fish_config prompt`` for a simpler version inside your terminal.
|
||||
You can choose among some sample prompts by running ``fish_config`` for a web UI or ``fish_config prompt`` for a simpler version inside your terminal.
|
||||
|
||||
$PATH
|
||||
-----
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
#!/bin/bash
|
||||
|
||||
# This script is copied into the root directory of our Docker tests.
|
||||
# It is the entry point for running Docker-based tests.
|
||||
@@ -12,10 +10,10 @@ cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug /fish-source "$@"
|
||||
# Spawn a shell if FISH_RUN_SHELL_BEFORE_TESTS is set.
|
||||
if test -n "$FISH_RUN_SHELL_BEFORE_TESTS"
|
||||
then
|
||||
bash -i
|
||||
bash -i || exit
|
||||
fi
|
||||
|
||||
(set +e; ninja && ninja fish_run_tests)
|
||||
ninja && ninja fish_run_tests
|
||||
RES=$?
|
||||
|
||||
# Drop the user into a shell if FISH_RUN_SHELL_AFTER_TESTS is set.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
cat << EOF
|
||||
Usage: $(basename "$0") [--shell-before] [--shell-after] DOCKERFILE
|
||||
Usage: $(basename $0) [--shell-before] [--shell-after] DOCKERFILE
|
||||
Options:
|
||||
--shell-before Before the tests start, run a bash shell
|
||||
--shell-after After the tests end, run a bash shell
|
||||
@@ -18,7 +18,7 @@ export DOCKER_BUILDKIT=1
|
||||
set -e
|
||||
|
||||
# Get fish source directory.
|
||||
FISH_SRC_DIR=$(cd "$( dirname "$0" )"/.. >/dev/null && pwd)
|
||||
FISH_SRC_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null && pwd)
|
||||
|
||||
# Parse args.
|
||||
while [ $# -gt 1 ]; do
|
||||
@@ -36,7 +36,7 @@ while [ $# -gt 1 ]; do
|
||||
shift
|
||||
done
|
||||
|
||||
DOCKERFILE="$1"
|
||||
DOCKERFILE=${@:$OPTIND:1}
|
||||
test -n "$DOCKERFILE" || usage
|
||||
|
||||
# Construct a docker image.
|
||||
@@ -47,7 +47,6 @@ docker build \
|
||||
"$FISH_SRC_DIR"/docker/context/
|
||||
|
||||
# Run tests in it, allowing them to fail without failing this script.
|
||||
# shellcheck disable=SC2086 # $DOCKER_EXTRA_ARGS should have globbing and splitting applied.
|
||||
docker run -it \
|
||||
--mount type=bind,source="$FISH_SRC_DIR",target=/fish-source,readonly \
|
||||
$DOCKER_EXTRA_ARGS \
|
||||
|
||||
@@ -36,4 +36,5 @@ WORKDIR /home/fishuser
|
||||
|
||||
COPY fish_run_tests.sh /
|
||||
|
||||
|
||||
CMD /fish_run_tests.sh
|
||||
|
||||
@@ -38,4 +38,5 @@ WORKDIR /home/fishuser
|
||||
|
||||
COPY fish_run_tests.sh /
|
||||
|
||||
|
||||
CMD /fish_run_tests.sh
|
||||
|
||||
@@ -35,4 +35,5 @@ WORKDIR /home/fishuser
|
||||
|
||||
COPY fish_run_tests.sh /
|
||||
|
||||
|
||||
CMD /fish_run_tests.sh
|
||||
|
||||
12
fish.desktop
Normal file
12
fish.desktop
Normal file
@@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Terminal=true
|
||||
# This file is for use in appimages, which rewrite the path.
|
||||
# Other uses would have to replace these with the correct path.
|
||||
Exec=fish
|
||||
Name=fish
|
||||
Comment=The user-friendly command line shell
|
||||
Icon=fish
|
||||
# "Shell" would be the proper category, but it's reserved so we can't use it.
|
||||
Categories=ConsoleOnly;System;
|
||||
18
fish.spec.in
18
fish.spec.in
@@ -14,9 +14,10 @@ BuildRequires: cargo gettext gcc xz pcre2-devel
|
||||
BuildRequires: rust >= 1.70
|
||||
# Packaging guidelines say to use a BuildRequires: rust-packaging, but it adds no value for our package
|
||||
|
||||
BuildRequires: cmake >= 3.15
|
||||
BuildRequires: cmake >= 3.19
|
||||
|
||||
%if 0%{?suse_version}
|
||||
BuildRequires: update-desktop-files
|
||||
# for tests
|
||||
BuildRequires: groff
|
||||
%else
|
||||
@@ -30,15 +31,8 @@ BuildRequires: glibc-langpack-en
|
||||
%endif
|
||||
BuildRequires: python3 procps
|
||||
|
||||
%if 0%{?suse_version}
|
||||
Requires: terminfo-base
|
||||
%else
|
||||
Requires: ncurses-base
|
||||
%endif
|
||||
Requires: file
|
||||
Requires: python3
|
||||
Requires: man
|
||||
Requires: procps
|
||||
|
||||
# Although the build scripts mangle the version number to be RPM compatible
|
||||
# for continuous builds (transforming the output of `git describe`), Fedora 32+
|
||||
@@ -75,6 +69,10 @@ make %{?_smp_mflags}
|
||||
%make_install
|
||||
%endif
|
||||
%find_lang %{name}
|
||||
# OpenSUSE has strong opinions about categories which do not apply to other systems
|
||||
%if 0%{?suse_version}
|
||||
%suse_update_desktop_file fish "System;TerminalEmulator"
|
||||
%endif
|
||||
|
||||
%check
|
||||
# OpenSUSE does out-of-tree builds and defines __builddir
|
||||
@@ -125,3 +123,7 @@ fi
|
||||
|
||||
# pkgconfig
|
||||
%{_datadir}/pkgconfig/fish.pc
|
||||
|
||||
# FreeDesktop entry
|
||||
%{_datadir}/applications/fish.desktop
|
||||
%{_datadir}/pixmaps/fish.png
|
||||
|
||||
@@ -6,3 +6,4 @@
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ set -e
|
||||
|
||||
# Make sure we're run as root
|
||||
scriptname=$(basename "$0")
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if [ "$UID" -ne 0 ]; then
|
||||
echo "${scriptname} must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user