mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-10 01:21:16 -03:00
Compare commits
7 Commits
faster-git
...
test-drive
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc63404c96 | ||
|
|
5507bcc425 | ||
|
|
c3442602ef | ||
|
|
3437d63507 | ||
|
|
695ae02aa5 | ||
|
|
e1059b5e43 | ||
|
|
f1cf64fba0 |
@@ -1,8 +0,0 @@
|
||||
# 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
|
||||
|
||||
[resolver]
|
||||
# Make cargo 1.84+ respect MSRV (rust-version in Cargo.toml)
|
||||
incompatible-rust-versions = "fallback"
|
||||
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:
|
||||
|
||||
52
.github/workflows/main.yml
vendored
52
.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:
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@1.70
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libpcre2-dev python3-pexpect python3-sphinx tmux
|
||||
sudo apt install gettext libpcre2-dev python3-pexpect tmux
|
||||
# Generate a locale that uses a comma as decimal separator.
|
||||
sudo locale-gen fr_FR.UTF-8
|
||||
- name: cmake
|
||||
@@ -28,21 +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
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: translation updates
|
||||
run: |
|
||||
# Required for our custom xgettext implementation.
|
||||
cargo install --locked --version 1.0.106 cargo-expand
|
||||
# Generate PO files. This should not result it a change in the repo if all translations are
|
||||
# up to date.
|
||||
# Ensure that fish is available as an executable.
|
||||
PATH="$PWD/build:$PATH" build_tools/update_translations.fish --no-mo
|
||||
# Show diff output. Fail if there is any.
|
||||
git --no-pager diff --exit-code || { echo 'There are uncommitted changes after regenerating the gettext PO files. Make sure to update them via `build_tools/update_translations.fish --no-mo` after changing source files.'; exit 1; }
|
||||
make VERBOSE=1 test
|
||||
|
||||
ubuntu-32bit-static-pcre2:
|
||||
|
||||
@@ -65,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:
|
||||
|
||||
@@ -93,19 +82,18 @@ jobs:
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libpcre2-dev python3-pexpect tmux
|
||||
sudo apt install llvm # for llvm-symbolizer
|
||||
- name: cmake
|
||||
env:
|
||||
CC: clang
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
# Rust's ASAN requires the build system to explicitly pass a --target triple. We read that
|
||||
# value from CMake variable Rust_CARGO_TARGET.
|
||||
# value from CMake variable Rust_CARGO_TARGET (shared with corrosion).
|
||||
cmake .. -DASAN=1 -DRust_CARGO_TARGET=x86_64-unknown-linux-gnu -DCMAKE_BUILD_TYPE=Debug
|
||||
- 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
|
||||
@@ -116,10 +104,10 @@ jobs:
|
||||
# UPDATE: this can cause spurious leak reports for __cxa_thread_atexit_impl() under glibc.
|
||||
LSAN_OPTIONS: verbosity=0:log_threads=0:use_tls=1:print_suppressions=0
|
||||
run: |
|
||||
set -x
|
||||
export ASAN_SYMBOLIZER_PATH=$(command -v /usr/bin/llvm-symbolizer* | sort -n | head -1)
|
||||
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
|
||||
@@ -145,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:
|
||||
|
||||
@@ -172,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
|
||||
|
||||
23
.github/workflows/staticbuild.yml
vendored
23
.github/workflows/staticbuild.yml
vendored
@@ -32,20 +32,22 @@ jobs:
|
||||
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
|
||||
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
|
||||
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/
|
||||
FISHDIR=target/x86_64-unknown-linux-musl/release/ tests/test_driver.sh tests/test.fish
|
||||
FISHDIR=target/x86_64-unknown-linux-musl/release/ tests/test_driver.sh tests/interactive.fish
|
||||
- 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
|
||||
tar -cazf fish-amd64.tar.xz -C target/x86_64-unknown-linux-musl/release/ fish{,_indent,_key_reader}
|
||||
tar -cazf fish-aarch64.tar.xz -C target/aarch64-unknown-linux-musl/release/ fish{,_indent,_key_reader}
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fish-static-linux
|
||||
path: |
|
||||
fish-*.tar.xz
|
||||
fish-amd64.tar.xz
|
||||
fish-aarch64.tar.xz
|
||||
retention-days: 14
|
||||
staticbuilds-macos:
|
||||
|
||||
@@ -66,15 +68,16 @@ jobs:
|
||||
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
|
||||
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target aarch64-apple-darwin
|
||||
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-apple-darwin
|
||||
- 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
|
||||
tar -cazf fish-macos-aarch64.tar.xz -C target/aarch64-apple-darwin/release/ fish{,_indent,_key_reader}
|
||||
tar -cazf fish-macos-amd64.tar.xz -C target/x86_64-apple-darwin/release/ fish{,_indent,_key_reader}
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fish-static-macos
|
||||
path: |
|
||||
fish-macos-*.tar.xz
|
||||
fish-macos-amd64.tar.xz
|
||||
fish-macos-aarch64.tar.xz
|
||||
retention-days: 14
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -38,8 +38,7 @@ Desktop.ini
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
po/template.po
|
||||
*.mo
|
||||
messages.pot
|
||||
.directory
|
||||
.fuse_hidden*
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
225
CHANGELOG.rst
225
CHANGELOG.rst
@@ -1,148 +1,54 @@
|
||||
fish 4.1.0 (released ???)
|
||||
=========================
|
||||
|
||||
.. ignore for 4.1: 10929 10940 10948 10955 10965 10975 10989 10990 10998 11028 11052 11055 11069 11071 11079 11092 11098 11104 11106 11110 11140 11146 11148 11150 11214 11218 11259 11288 11299 11328 11350 11373 11395 11417 11419
|
||||
|
||||
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.
|
||||
|
||||
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}`` or ``{ 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.
|
||||
- Autosuggestions are now also provided in multi-line command lines. Like `ctrl-r`, autosuggestions operate only on the current line.
|
||||
- New feature flag ``buffered-enter-noexec`` with the following effect:
|
||||
when typing a command and :kbd:`enter` while the previous one is still running, the new one will no longer execute immediately. Similarly, keys that are bound to shell commands will be ignored.
|
||||
This mitigates a security issue where a command like ``cat malicious-file.txt`` could write terminal escape codes prompting the terminal to write arbitrary text to fish's standard input.
|
||||
Such a malicious file can still potentially insert arbitrary text into the command line but can no longer execute it directly (:issue:`10987`).
|
||||
|
||||
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-Ä`).
|
||||
- :kbd:`ctrl-l` no longer clears the screen but only pushes to the terminal's scrollback all text above the prompt (via a new special input function ``scrollback-push``).
|
||||
This feature depends on the terminal advertising via XTGETTCAP support for the ``indn`` and ``cuu`` terminfo capabilities,
|
||||
and on the terminal supporting Synchronized Output (which is used by fish to detect features).
|
||||
If any is missing, the binding falls back to ``clear-screen``.
|
||||
|
||||
Completions
|
||||
^^^^^^^^^^^
|
||||
- ``git`` completions now show the remote url as a description when completing remotes.
|
||||
- ``systemctl`` completions no longer print escape codes if ``SYSTEMD_COLORS`` is set (:issue:`11465`).
|
||||
|
||||
Improved terminal support
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
- Support for double, curly, dotted and dashed 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 4.0b1 (released December 17, 2024)
|
||||
=======================================
|
||||
|
||||
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.
|
||||
These are the draft release notes for fish 4.0.0. Like this release of fish itself, they are in beta and are not complete. Please report any issues you find.
|
||||
|
||||
.. ignore: 751 2037 2037 3017 3018 3162 3299 4770 4865 5284 5991 6981 6996 7172 9332 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9542 9544 9554 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9751 9754 9765 9767 9768 9771 9777 9778 9786 9816 9818 9821 9839 9845 9856 9859 9861 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10588 10591 10594 10595 10596 10609 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10707 10708 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10858 10863 10864 10873 10874 10880 10885 10891 10894 10907
|
||||
|
||||
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.
|
||||
Packagers should see the :ref:`For Distributors <rust-packaging>` section at the end.
|
||||
|
||||
Notable backwards-incompatible changes
|
||||
--------------------------------------
|
||||
@@ -150,7 +56,10 @@ 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`)
|
||||
- Terminals that fail to ignore unrecognized OSC or CSI sequences may display garbage. We know cool-retro-term and emacs' ansi-term are affected,
|
||||
most mainstream terminals are not.
|
||||
- :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. The old word behavior has been moved to :kbd:`ctrl-backspace`. If your terminal doesn't support `ctrl-backspace`, consider using :kbd:`ctrl-w`, or :kbd:`alt-b` + :kbd:`alt-d`.
|
||||
- ``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.
|
||||
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`).
|
||||
@@ -165,9 +74,8 @@ Notable backwards-incompatible changes
|
||||
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.
|
||||
- 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.
|
||||
|
||||
Notable improvements and fixes
|
||||
------------------------------
|
||||
@@ -184,30 +92,23 @@ 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.
|
||||
The first time it runs interactively, it will extract all the data files to ``~/.local/share/fish/install/``. 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 ``for mode in (bind --list-modes); bind -M $mode ctrl-c cancel-commandline-traditional; end`` (: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 (:issue:`3031`).
|
||||
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.
|
||||
- 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^'
|
||||
@@ -237,7 +138,6 @@ Deprecations and removed features
|
||||
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
|
||||
----------------------
|
||||
@@ -264,8 +164,6 @@ Scripting improvements
|
||||
- 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`).
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
@@ -285,19 +183,11 @@ Interactive improvements
|
||||
- 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 no longer adopts TTY modes of failed commands (:issue:`10603`).
|
||||
- ``complete -e cmd`` now prevents autoloading completions for ``cmd`` (:issue:`6716`).
|
||||
- `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`).
|
||||
|
||||
New or improved bindings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -305,8 +195,8 @@ New or improved bindings
|
||||
- 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.
|
||||
- :kbd:`ctrl-Z` (also known as :kbd:`ctrl-shift-z`) is now bound to redo.
|
||||
- :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 command line 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``.
|
||||
- Multiline commands are indented before being sent to the editor, which matches how they are displayed in fish.
|
||||
@@ -315,30 +205,23 @@ New or improved bindings
|
||||
- :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>`:
|
||||
|
||||
- :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-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`).
|
||||
- ``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 (:issue:`10608`).
|
||||
- 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`).
|
||||
|
||||
@@ -348,16 +231,13 @@ Completions
|
||||
- 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.
|
||||
- Historically, file name completions are provided after the last ``:`` or ``=`` within a token.
|
||||
This helps commands like ``rsync --files-from=``.
|
||||
This special meaning can now disabled by escaping these separators as ``\:`` and ``\=``.
|
||||
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.
|
||||
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
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -373,14 +253,10 @@ Improved terminal support
|
||||
|
||||
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`` 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`).
|
||||
|
||||
.. _rust-packaging:
|
||||
|
||||
@@ -389,23 +265,10 @@ 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).
|
||||
|
||||
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`).
|
||||
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`)
|
||||
|
||||
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.
|
||||
|
||||
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`).
|
||||
|
||||
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>`_.
|
||||
|
||||
--------------
|
||||
|
||||
fish 3.7.1 (released March 19, 2024)
|
||||
@@ -664,7 +527,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
|
||||
@@ -760,7 +623,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`).
|
||||
@@ -989,7 +852,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`).
|
||||
|
||||
@@ -1098,7 +961,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."
|
||||
@@ -1121,7 +984,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`).
|
||||
@@ -1627,7 +1490,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`).
|
||||
@@ -2181,7 +2044,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`).
|
||||
@@ -3123,7 +2986,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
|
||||
@@ -3252,9 +3115,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.
|
||||
|
||||
@@ -7,6 +7,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
set(DEFAULT_BUILD_TYPE "RelWithDebInfo")
|
||||
|
||||
# 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}'")
|
||||
set(CMAKE_BUILD_TYPE "${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(
|
||||
|
||||
104
CONTRIBUTING.rst
104
CONTRIBUTING.rst
@@ -43,14 +43,14 @@ 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``)
|
||||
- Use automated tools to help you (including ``make test`` and ``build_tools/style.fish``)
|
||||
|
||||
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.
|
||||
@@ -198,10 +198,9 @@ The tests can be found in three places:
|
||||
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.
|
||||
Tests are run in a temporary $HOME, but that is shared among the tests by default. If you need a temporary directory for your test, you should create one (e.g. with ``mktemp``).
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
@@ -213,18 +212,16 @@ The tests can be run on your local computer on all operating systems.
|
||||
::
|
||||
|
||||
cmake path/to/fish-shell
|
||||
make fish_run_tests
|
||||
make test
|
||||
|
||||
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
|
||||
FISHDIR=target/debug tests/test_driver.sh tests/test.fish # script tests, the checks
|
||||
FISHDIR=target/debug tests/test_driver.sh tests/interactive.fish # interactive tests, the pexpects
|
||||
|
||||
Here, the first argument to test_driver.py refers to a directory with ``fish``, ``fish_indent`` and ``fish_key_reader`` in it.
|
||||
Here, ``FISHDIR`` 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.
|
||||
|
||||
Git hooks
|
||||
---------
|
||||
@@ -252,7 +249,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 +259,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.
|
||||
|
||||
@@ -286,68 +283,37 @@ Contributing Translations
|
||||
Fish uses the GNU gettext library to translate messages from English to
|
||||
other languages.
|
||||
|
||||
Translation sources are
|
||||
Creating and updating translations requires the Gettext tools, including
|
||||
``xgettext``, ``msgfmt`` and ``msgmerge``. Translation sources are
|
||||
stored in the ``po`` directory, named ``LANG.po``, where ``LANG`` is the
|
||||
two letter ISO 639-1 language code of the target language (e.g. ``de`` for
|
||||
German). A region specifier can also be used (e.g. ``pt_BR`` for Brazilian Portuguese).
|
||||
two letter ISO 639-1 language code of the target language (eg ``de`` for
|
||||
German).
|
||||
|
||||
Adding translations for a new language
|
||||
--------------------------------------
|
||||
To create a new translation:
|
||||
|
||||
Creating new translations requires the Gettext tools.
|
||||
More specifically, you will need ``msguniq`` and ``msgmerge`` for creating translations for a new
|
||||
language.
|
||||
In addition, the ``cargo-expand`` tool is required.
|
||||
If you have ``cargo`` installed, run::
|
||||
* generate a ``messages.pot`` file by running ``build_tools/fish_xgettext.fish`` from
|
||||
the source tree
|
||||
* copy ``messages.pot`` to ``po/LANG.po``
|
||||
|
||||
cargo install --locked --version 1.0.106 cargo-expand
|
||||
To update a translation:
|
||||
|
||||
to install ``cargo-expand`` (Note that other versions might not work correctly with our scripts).
|
||||
To create a new translation, run::
|
||||
* generate a ``messages.pot`` file by running
|
||||
``build_tools/fish_xgettext.fish`` from the source tree
|
||||
|
||||
build_tools/update_translations.fish po/LANG.po
|
||||
* update the existing translation by running
|
||||
``msgmerge --update --no-fuzzy-matching po/LANG.po messages.pot``
|
||||
|
||||
By default, this also creates ``mo`` files, which contain the information from the ``po`` files in a
|
||||
binary format.
|
||||
Fish uses these files for translating at runtime.
|
||||
They are not tracked in version control, but they can help translators check if their translations
|
||||
show up correctly.
|
||||
If you build fish locally (``cargo build``), and then run the resulting binary,
|
||||
it will make use of the ``mo`` files generated by the script.
|
||||
Use the ``LANG`` environment variable to tell fish which language to use, e.g.::
|
||||
|
||||
LANG=pt_BR.utf8 target/debug/fish
|
||||
|
||||
If you do not care about the ``mo`` files you can pass the ``--no-mo`` flag to the
|
||||
``update_translations.fish`` script.
|
||||
|
||||
Modifying existing translations
|
||||
-------------------------------
|
||||
|
||||
If you want to work on translations for a language which already has a corresponding ``po`` file, it
|
||||
is sufficient to edit this file. No other changes are necessary.
|
||||
|
||||
To see your translations in action you can run::
|
||||
|
||||
build_tools/update_translations.fish --only-mo po/LANG.po
|
||||
|
||||
to update the binary ``mo`` used by fish. Check the information for adding new languages for a
|
||||
description on how you can get fish to use these files.
|
||||
Running this script requires a fish executable and the gettext ``msgfmt`` tool.
|
||||
|
||||
Editing PO files
|
||||
----------------
|
||||
The ``--no-fuzzy-matching`` is important as we have had terrible experiences with gettext's "fuzzy" translations in the past.
|
||||
|
||||
Many tools are available for editing translation files, including
|
||||
command-line and graphical user interface programs. For simple use, you can use your text editor.
|
||||
command-line and graphical user interface programs. For simple use, you can just use your text editor.
|
||||
|
||||
Open up the po file, for example ``po/sv.po``, and you'll see something like::
|
||||
|
||||
msgid "%ls: No suitable job\n"
|
||||
msgstr ""
|
||||
msgstr ""
|
||||
|
||||
The ``msgid`` here is the "name" of the string to translate, typically the English string to translate.
|
||||
The second line (``msgstr``) is where your translation goes.
|
||||
The ``msgid`` here is the "name" of the string to translate, typically the english string to translate. The second line (``msgstr``) is where your translation goes.
|
||||
|
||||
For example::
|
||||
|
||||
@@ -360,17 +326,11 @@ Also any escaped characters, like that ``\n`` newline at the end, should be kept
|
||||
|
||||
Our tests run ``msgfmt --check-format /path/to/file``, so they would catch mismatched placeholders - otherwise fish would crash at runtime when the string is about to be used.
|
||||
|
||||
Be cautious about blindly updating an existing translation file.
|
||||
``msgid`` strings should never be updated manually, only by running the appropriate script.
|
||||
|
||||
Modifications to strings in source files
|
||||
----------------------------------------
|
||||
|
||||
If a string changes in the sources, the old translations will no longer work.
|
||||
They will be preserved in the ``po`` files, but commented-out (starting with ``#~``).
|
||||
If you add/remove/change a translatable strings in a source file,
|
||||
run ``build_tools/update_translations.fish`` to propagate this to all translation files (``po/*.po``).
|
||||
This is only relevant for developers modifying the source files of fish or fish scripts.
|
||||
Be cautious about blindly updating an existing translation file. Trivial
|
||||
changes to an existing message (eg changing the punctuation) will cause
|
||||
existing translations to be removed, since the tools do literal string
|
||||
matching. Therefore, in general, you need to carefully review any
|
||||
recommended deletions.
|
||||
|
||||
Setting Code Up For Translations
|
||||
--------------------------------
|
||||
|
||||
80
Cargo.lock
generated
80
Cargo.lock
generated
@@ -31,9 +31,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.7"
|
||||
version = "1.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7"
|
||||
checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
@@ -89,9 +89,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.11"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
|
||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
@@ -99,7 +99,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fish"
|
||||
version = "4.1.0-alpha0"
|
||||
version = "4.0.0-beta.1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
@@ -117,7 +117,6 @@ dependencies = [
|
||||
"rust-embed",
|
||||
"serial_test",
|
||||
"terminfo",
|
||||
"unix_path",
|
||||
"widestring",
|
||||
]
|
||||
|
||||
@@ -126,8 +125,6 @@ name = "fish-printf"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
"widestring",
|
||||
]
|
||||
|
||||
@@ -175,9 +172,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.172"
|
||||
version = "0.2.169"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
@@ -197,9 +194,9 @@ 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",
|
||||
]
|
||||
@@ -218,9 +215,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.30.1"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
|
||||
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
@@ -298,18 +295,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",
|
||||
@@ -317,9 +314,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",
|
||||
@@ -327,9 +324,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",
|
||||
]
|
||||
@@ -503,9 +500,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"
|
||||
@@ -515,9 +512,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.95"
|
||||
version = "2.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
|
||||
checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -548,33 +545,6 @@ version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
|
||||
[[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"
|
||||
@@ -593,9 +563,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "widestring"
|
||||
version = "1.2.0"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d"
|
||||
checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
|
||||
28
Cargo.toml
28
Cargo.toml
@@ -3,7 +3,7 @@ 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.
|
||||
# To build revisions that use Corrosion (those before 2024-01), CMake 3.19 and Rustc 1.78 seem to work.
|
||||
rust-version = "1.70"
|
||||
edition = "2021"
|
||||
|
||||
@@ -17,7 +17,7 @@ debug = true
|
||||
|
||||
[package]
|
||||
name = "fish"
|
||||
version = "4.1.0-alpha0"
|
||||
version = "4.0.0-beta.1"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
default-run = "fish"
|
||||
@@ -39,8 +39,8 @@ libc = "0.2"
|
||||
# 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"
|
||||
nix = { version = "0.30.1", default-features = false, features = [
|
||||
lru = "0.12.3"
|
||||
nix = { version = "0.29.0", default-features = false, features = [
|
||||
"event",
|
||||
"inotify",
|
||||
"resource",
|
||||
@@ -54,7 +54,7 @@ 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 }
|
||||
@@ -71,9 +71,6 @@ serial_test = { version = "3", default-features = false }
|
||||
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,15 +88,15 @@ name = "fish_key_reader"
|
||||
path = "src/bin/fish_key_reader.rs"
|
||||
|
||||
[features]
|
||||
default = ["embed-data"]
|
||||
default = ["installable"]
|
||||
benchmark = []
|
||||
embed-data = ["dep:rust-embed"]
|
||||
installable = ["dep:rust-embed"]
|
||||
|
||||
# The following features are auto-detected by the build-script and should not be enabled manually.
|
||||
asan = []
|
||||
tsan = []
|
||||
|
||||
[workspace.lints]
|
||||
[lints]
|
||||
rust.non_camel_case_types = "allow"
|
||||
rust.non_upper_case_globals = "allow"
|
||||
rust.unknown_lints = "allow"
|
||||
@@ -107,12 +104,3 @@ 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"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -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
|
||||
|
||||
23
README.rst
23
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
|
||||
|
||||
@@ -75,7 +75,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 +87,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``,
|
||||
@@ -157,9 +159,6 @@ CMake 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.
|
||||
|
||||
- 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.
|
||||
@@ -167,19 +166,19 @@ In addition to the normal CMake build options (like ``CMAKE_INSTALL_PREFIX``), f
|
||||
- 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)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Building fish as self-installable (experimental)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can also build fish with the data files embedded.
|
||||
You can also build fish as a self-installing binary.
|
||||
|
||||
This will include all the datafiles like the included functions or web configuration tool in the main ``fish`` binary.
|
||||
|
||||
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).
|
||||
On the first interactive run, and whenever it notices they are out of date, it will extract the datafiles to ~/.local/share/fish/install/ (currently, subject to change). You can do this manually by running ``fish --install``.
|
||||
|
||||
To install fish with embedded files, just use ``cargo``, like::
|
||||
To install fish as self-installable, just use ``cargo``, like::
|
||||
|
||||
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 --tag 4.0 # to build from git once 4.0 is released
|
||||
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.
|
||||
|
||||
35
SECURITY.md
35
SECURITY.md
@@ -1,35 +0,0 @@
|
||||
# Security Reporting
|
||||
|
||||
If you wish to report a security vulnerability privately, we appreciate your diligence. Please follow the guidelines below to submit your report.
|
||||
|
||||
## Reporting
|
||||
|
||||
To report a security vulnerability, please provide the following information:
|
||||
|
||||
1. **PROJECT**
|
||||
|
||||
- Include the URL of the project repository - Example: <https://github.com/fish-shell/fish-shell>
|
||||
|
||||
2. **PUBLIC**
|
||||
|
||||
- Indicate whether this vulnerability has already been publicly discussed or disclosed.
|
||||
- If so, provide relevant links.
|
||||
|
||||
3. **DESCRIPTION**
|
||||
- Provide a detailed description of the security vulnerability.
|
||||
- Include as much information as possible to help us understand and address the issue.
|
||||
|
||||
Send this information, along with any additional relevant details, to <rf@fishshell.com>.
|
||||
|
||||
## Confidentiality
|
||||
|
||||
We kindly ask you to keep the report confidential until a public announcement is made.
|
||||
|
||||
## Notes
|
||||
|
||||
- Vulnerabilities will be handled on a best-effort basis.
|
||||
- You may request an advance copy of the patched release, but we cannot guarantee early access before the public release.
|
||||
- You will be notified via email simultaneously with the public announcement.
|
||||
- We will respond within a few weeks to confirm whether your report has been accepted or rejected.
|
||||
|
||||
Thank you for helping to improve the security of our project!
|
||||
@@ -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
|
||||
|
||||
48
build.rs
48
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();
|
||||
@@ -41,28 +41,14 @@ fn main() {
|
||||
|
||||
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(feature = "installable")]
|
||||
#[cfg(not(clippy))]
|
||||
{
|
||||
let cman = std::fs::canonicalize(env!("CARGO_MANIFEST_DIR")).unwrap();
|
||||
let targetman = cman.as_path().join("target").join("man");
|
||||
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::rebuild_if_path_changed("src/libc.c");
|
||||
cc::Build::new()
|
||||
.file("src/libc.c")
|
||||
.include(build_dir)
|
||||
@@ -102,9 +88,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 +123,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")))
|
||||
}
|
||||
|
||||
fn detect_cygwin(_: &Target) -> Result<bool, Box<dyn Error>> {
|
||||
// Cygwin target is usually cross-compiled.
|
||||
Ok(std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "cygwin")
|
||||
}
|
||||
|
||||
/// Detect if we're being compiled for a BSD-derived OS, allowing targeting code conditionally with
|
||||
/// `#[cfg(bsd)]`.
|
||||
///
|
||||
@@ -224,14 +199,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,11 +227,6 @@ 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 {
|
||||
let mut var = PathBuf::from(env::var(name).unwrap_or(default.to_string()));
|
||||
if var.is_relative() {
|
||||
@@ -357,7 +327,7 @@ fn get_git_hash() -> Result<String, Box<dyn std::error::Error>> {
|
||||
// .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();
|
||||
let headref = headstr.split(' ').collect::<Vec<_>>()[1].trim();
|
||||
|
||||
// .git/refs/heads/branch contains the SHA
|
||||
let refpath = gitdir.join(headref);
|
||||
@@ -390,7 +360,7 @@ fn get_git_hash() -> Result<String, Box<dyn std::error::Error>> {
|
||||
get_git_hash().expect("Could not get a version. Either set $FISH_BUILD_VERSION or install git.")
|
||||
}
|
||||
|
||||
#[cfg(feature = "embed-data")]
|
||||
#[cfg(feature = "installable")]
|
||||
// disable clippy because otherwise it would panic without sphinx
|
||||
#[cfg(not(clippy))]
|
||||
fn build_man(build_dir: &Path) {
|
||||
|
||||
14
build_tools/diff_profiles.fish
Executable file → Normal file
14
build_tools/diff_profiles.fish
Executable file → Normal file
@@ -5,12 +5,6 @@
|
||||
#
|
||||
# Usage: ./diff_profiles.fish profile1.log profile2.log > profile_diff.log
|
||||
|
||||
if test (count $argv) -ne 2;
|
||||
echo "Incorrect number of arguments."
|
||||
echo "Usage: "(status filename)" profile1.log profile2.log"
|
||||
exit 1
|
||||
end
|
||||
|
||||
set -l profile1 (cat $argv[1])
|
||||
set -l profile2 (cat $argv[2])
|
||||
|
||||
@@ -21,13 +15,13 @@ while set -l next_line_no (math $line_no + 1) && set -q profile1[$next_line_no]
|
||||
set -l line1 $profile1[$line_no]
|
||||
set -l line2 $profile2[$line_no]
|
||||
|
||||
if not string match -qr '^\s*\d+\s+\d+' $line1
|
||||
if not string match -qr '^\d+\t\d+' $line1
|
||||
echo $line1
|
||||
continue
|
||||
end
|
||||
|
||||
set -l results1 (string match -r '^\s*(\d+)\s+(\d+)\s+(.*)' $line1)
|
||||
set -l results2 (string match -r '^\s*(\d+)\s+(\d+)\s+(.*)' $line2)
|
||||
set -l results1 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line1)
|
||||
set -l results2 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line2)
|
||||
|
||||
# times from both files
|
||||
set -l time1 $results1[2..3]
|
||||
@@ -48,5 +42,5 @@ while set -l next_line_no (math $line_no + 1) && set -q profile1[$next_line_no]
|
||||
set diff[1] (math $time1[1] - $time2[1])
|
||||
set diff[2] (math $time1[2] - $time2[2])
|
||||
|
||||
printf '%10d %10d %s\n' $diff[1] $diff[2] $remainder1
|
||||
echo $diff[1] $diff[2] $remainder1
|
||||
end
|
||||
|
||||
@@ -1,101 +1,68 @@
|
||||
#!/usr/bin/env fish
|
||||
#
|
||||
# Tool to generate gettext messages template file.
|
||||
# Writes to stdout.
|
||||
# Tool to generate messages.pot
|
||||
|
||||
begin
|
||||
# Write header. This is required by msguniq.
|
||||
# Note that this results in the file being overwritten.
|
||||
# This is desired behavior, to get rid of the results of prior invocations
|
||||
# of this script.
|
||||
begin
|
||||
echo 'msgid ""'
|
||||
echo 'msgstr ""'
|
||||
echo '"Content-Type: text/plain; charset=UTF-8\n"'
|
||||
echo ""
|
||||
end
|
||||
# Create temporary directory for these operations. OS X `mktemp` is somewhat restricted, so this block
|
||||
# works around that - based on share/functions/funced.fish.
|
||||
set -q TMPDIR
|
||||
or set -l TMPDIR /tmp
|
||||
set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX)
|
||||
or exit 1
|
||||
|
||||
set -l cargo_expanded_file (mktemp)
|
||||
# This is a gigantic crime.
|
||||
# We use cargo-expand to get all our wgettext invocations.
|
||||
# This might be replaced once we have a tool which properly handles macro expansions.
|
||||
begin
|
||||
cargo expand --lib
|
||||
for f in fish fish_indent fish_key_reader
|
||||
cargo expand --bin $f
|
||||
end
|
||||
end >$cargo_expanded_file
|
||||
# This is a gigantic crime.
|
||||
# xgettext still does not support rust *at all*, so we use cargo-expand to get all our wgettext invocations.
|
||||
set -l expanded (cargo expand --lib; for f in fish{,_indent,_key_reader}; cargo expand --bin $f; end)
|
||||
|
||||
set -l rust_string_file (mktemp)
|
||||
# Extract any gettext call
|
||||
set -l strs (printf '%s\n' $expanded | grep -A1 wgettext_static_str |
|
||||
grep 'widestring::internals::core::primitive::str =' |
|
||||
string match -rg '"(.*)"' | string match -rv '^%ls$|^$' |
|
||||
# escaping difference between gettext and cargo-expand: single-quotes
|
||||
string replace -a "\'" "'" | sort -u)
|
||||
|
||||
# Extract any gettext call
|
||||
grep -A1 wgettext_static_str <$cargo_expanded_file |
|
||||
grep 'widestring::internals::core::primitive::str =' |
|
||||
string match -rg '"(.*)"' |
|
||||
string match -rv '^%ls$|^$' |
|
||||
# escaping difference between gettext and cargo-expand: single-quotes
|
||||
string replace -a "\'" "'" >$rust_string_file
|
||||
# Extract any constants
|
||||
set -a strs (string match -rv 'BUILD_VERSION:|PACKAGE_NAME' -- $expanded |
|
||||
string match -rg 'const [A-Z_]*: &str = "(.*)"' | string replace -a "\'" "'")
|
||||
|
||||
# Extract any constants
|
||||
grep -Ev 'BUILD_VERSION:|PACKAGE_NAME' <$cargo_expanded_file |
|
||||
grep -E 'const [A-Z_]*: &str = "(.*)"' |
|
||||
sed -E -e 's/^.*const [A-Z_]*: &str = "(.*)".*$/\1/' -e "s_\\\'_'_g" >>$rust_string_file
|
||||
# We construct messages.pot ourselves instead of forcing this into msgmerge or whatever.
|
||||
# The escaping so far works out okay.
|
||||
for str in $strs
|
||||
# grep -P needed for string escape to be compatible (PCRE-style),
|
||||
# -H gives the filename, -n the line number.
|
||||
# If you want to run this on non-GNU grep: Don't.
|
||||
echo "#:" (grep -PHn -r -- (string escape --style=regex -- $str) src/ |
|
||||
head -n1 | string replace -r ':\s.*' '')
|
||||
echo "msgid \"$str\""
|
||||
echo 'msgstr ""'
|
||||
end >messages.pot
|
||||
|
||||
rm $cargo_expanded_file
|
||||
# This regex handles descriptions for `complete` and `function` statements. These messages are not
|
||||
# particularly important to translate. Hence the "implicit" label.
|
||||
set -l implicit_regex '(?:^| +)(?:complete|function).*? (?:-d|--description) (([\'"]).+?(?<!\\\\)\\2).*'
|
||||
|
||||
# Sort the extracted strings and remove duplicates.
|
||||
# Then, transform them into the po format.
|
||||
# If a string contains a '%' it is considered a format string and marked with a '#, c-format'.
|
||||
# This allows msgfmt to identify issues with translations whose format string does not match the
|
||||
# original.
|
||||
sort -u $rust_string_file |
|
||||
sed -E -e '/%/ i\
|
||||
#, c-format
|
||||
' -e 's/^(.*)$/msgid "\1"\nmsgstr ""\n/'
|
||||
# This regex handles explicit requests to translate a message. These are more important to translate
|
||||
# than messages which should be implicitly translated.
|
||||
set -l explicit_regex '.*\( *_ (([\'"]).+?(?<!\\\\)\\2) *\).*'
|
||||
|
||||
rm $rust_string_file
|
||||
mkdir -p $tmpdir/implicit/share/completions $tmpdir/implicit/share/functions
|
||||
mkdir -p $tmpdir/explicit/share/completions $tmpdir/explicit/share/functions
|
||||
|
||||
function extract_fish_script_messages --argument-names regex
|
||||
for f in share/config.fish share/completions/*.fish share/functions/*.fish
|
||||
# Extract explicit attempts to translate a message. That is, those that are of the form
|
||||
# `(_ "message")`.
|
||||
string replace --filter --regex $explicit_regex '$1' <$f | string unescape \
|
||||
| string replace --all '"' '\\"' | string replace -r '(.*)' 'N_ "$1"' >$tmpdir/explicit/$f
|
||||
|
||||
# Using xgettext causes more trouble than it helps.
|
||||
# This is due to handling of escaping in fish differing from formats xgettext understands
|
||||
# (e.g. POSIX shell strings).
|
||||
# We work around this issue by manually writing the file content.
|
||||
# Handle `complete` / `function` description messages. The `| fish` is subtle. It basically
|
||||
# avoids the need to use `source` with a command substitution that could affect the current
|
||||
# shell.
|
||||
string replace --filter --regex $implicit_regex '$1' <$f | string unescape \
|
||||
| string replace --all '"' '\\"' | string replace -r '(.*)' 'N_ "$1"' >$tmpdir/implicit/$f
|
||||
end
|
||||
|
||||
# Steps:
|
||||
# 1. We extract strings to be translated from the relevant files and drop the rest. This step
|
||||
# depends on the regex matching the entire line, and the first capture group matching the
|
||||
# string.
|
||||
# 2. We unescape. This gets rid of some escaping necessary in fish strings.
|
||||
# 3. The resulting strings are sorted alphabetically. This step is optional. Not sorting would
|
||||
# result in strings from the same file appearing together. Removing duplicates is also
|
||||
# optional, since msguniq takes care of that later on as well.
|
||||
# 4. Single backslashes are replaced by double backslashes. This results in the backslashes
|
||||
# being interpreted as literal backslashes by gettext tooling.
|
||||
# 5. Double quotes are escaped, such that they are not interpreted as the start or end of
|
||||
# a msgid.
|
||||
# 6. We transform the string into the format expected in a PO file.
|
||||
cat share/config.fish share/completions/*.fish share/functions/*.fish |
|
||||
string replace --filter --regex $regex '$1' |
|
||||
string unescape |
|
||||
sort -u |
|
||||
sed -E -e 's_\\\\_\\\\\\\\_g' -e 's_"_\\\\"_g' -e 's_^(.*)$_msgid "\1"\nmsgstr ""\n_'
|
||||
end
|
||||
xgettext -j -k -kN_ -LShell --from-code=UTF-8 -cDescription --no-wrap -o messages.pot $tmpdir/{ex,im}plicit/share/*/*.fish
|
||||
|
||||
# This regex handles explicit requests to translate a message. These are more important to translate
|
||||
# than messages which should be implicitly translated.
|
||||
set -l explicit_regex '.*\( *_ (([\'"]).+?(?<!\\\\)\\2) *\).*'
|
||||
extract_fish_script_messages $explicit_regex
|
||||
# Remove the tmpdir from the location to avoid churn
|
||||
sed -i 's_^#: /.*/share/_#: share/_' messages.pot
|
||||
|
||||
# This regex handles descriptions for `complete` and `function` statements. These messages are not
|
||||
# particularly important to translate. Hence the "implicit" label.
|
||||
set -l implicit_regex '^(?:\s|and |or )*(?:complete|function).*? (?:-d|--description) (([\'"]).+?(?<!\\\\)\\2).*'
|
||||
extract_fish_script_messages $implicit_regex
|
||||
end |
|
||||
# At this point, all extracted strings have been written to stdout,
|
||||
# starting with the ones taken from the Rust sources,
|
||||
# followed by strings explicitly marked for translation in fish scripts,
|
||||
# and finally the strings from fish scripts which get translated implicitly.
|
||||
# Because we do not eliminate duplicates across these categories,
|
||||
# we do it here, since other gettext tools expect no duplicates.
|
||||
msguniq --no-wrap
|
||||
rm -r $tmpdir
|
||||
|
||||
@@ -47,7 +47,7 @@ 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
|
||||
|
||||
@@ -67,4 +67,4 @@ test "$VN" = "$VC" || {
|
||||
|
||||
# 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,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
|
||||
@@ -145,7 +145,7 @@ fi
|
||||
# Make the app's /usr/local/bin binaries universal. Note fish.app/Contents/MacOS/fish already is, courtesy 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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
# Updates the files used for gettext translations.
|
||||
# By default, the whole xgettext, msgmerge, msgfmt pipeline runs,
|
||||
# which extracts the messages from the source files into $template_file,
|
||||
# updates the PO files for each language from that
|
||||
# (changed line numbers, added messages, removed messages),
|
||||
# and finally generates a machine-readable MO file for each language,
|
||||
# which is stored in share/locale/$LANG/LC_MESSAGES/fish.mo (relative to the repo root).
|
||||
#
|
||||
# Use cases:
|
||||
# For developers:
|
||||
# - Run with args `--no-mo` to update all PO files after making changes to Rust/fish
|
||||
# sources.
|
||||
# For translators:
|
||||
# - Run with `--no-mo` first, to ensure that the strings you are translating are up to date.
|
||||
# - Specify the language you want to work on as an argument, which must be a file in the po/
|
||||
# directory. You can specify a language which does not have translations yet by specifying the
|
||||
# name of a file which does not yet exist. Make sure to follow the naming convention.
|
||||
|
||||
# The sort utility is locale-sensitive.
|
||||
# Ensure that sorting output is consistent by setting LC_ALL here.
|
||||
set -gx LC_ALL C.UTF-8
|
||||
|
||||
set -l build_tools (status dirname)
|
||||
set -l template_file $build_tools/../po/template.po
|
||||
set -l po_dir $build_tools/../po
|
||||
|
||||
set -l extract
|
||||
set -l po
|
||||
set -l mo
|
||||
|
||||
argparse --exclusive 'no-mo,only-mo' 'no-mo' 'only-mo' -- $argv
|
||||
or exit $status
|
||||
|
||||
if test -z $argv[1]
|
||||
# Update everything if not specified otherwise.
|
||||
set -g po_files $po_dir/*.po
|
||||
else
|
||||
set -l po_dir_id (stat --format='%d:%i' -- $po_dir)
|
||||
for arg in $argv
|
||||
set -l arg_dir_id (stat --format='%d:%i' -- (dirname $arg))
|
||||
if test $po_dir_id != $arg_dir_id
|
||||
echo "Argument $arg is not a file in the directory $(realpath $po_dir)."
|
||||
echo "Non-option arguments must specify paths to files in this directory."
|
||||
echo ""
|
||||
echo "If you want to add a new language to the translations not the following:"
|
||||
echo "The filename must identify a language, with a two letter ISO 639-1 language code of the target language (e.g. 'pt' for Portuguese), and use the file extension '.po'."
|
||||
echo "Optionally, you can specify a regional variant (e.g. 'pt_BR')."
|
||||
echo "So valid filenames are of the shape 'll.po' or 'll_CC.po'."
|
||||
exit 1
|
||||
end
|
||||
if not basename $arg | grep -qE '^[a-z]{2}(_[A-Z]{2})?\.po$'
|
||||
echo "Filename does not match the expected format ('ll.po' or 'll_CC.po')."
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
set -g po_files $argv
|
||||
end
|
||||
|
||||
if set -l --query _flag_no_mo
|
||||
set -l --erase mo
|
||||
end
|
||||
if set -l --query _flag_only_mo
|
||||
set -l --erase extract
|
||||
set -l --erase po
|
||||
end
|
||||
|
||||
if set -l --query extract
|
||||
$build_tools/fish_xgettext.fish >$template_file
|
||||
or exit 1
|
||||
end
|
||||
|
||||
for po_file in $po_files
|
||||
if set -l --query po
|
||||
if test -e $po_file
|
||||
msgmerge --update --no-fuzzy-matching --no-wrap --backup=none $po_file $template_file
|
||||
else
|
||||
cp $template_file $po_file
|
||||
end
|
||||
end
|
||||
if set -l --query mo
|
||||
set -l locale_dir $build_tools/../share/locale
|
||||
set -l out_dir $locale_dir/(basename $po_file .po)/LC_MESSAGES
|
||||
mkdir -p $out_dir
|
||||
msgfmt --check-format --output-file=$out_dir/fish.mo $po_file
|
||||
end
|
||||
end
|
||||
@@ -1,18 +1,286 @@
|
||||
#[=======================================================================[.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\\.]+")
|
||||
# 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 +289,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 +777,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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -22,7 +26,7 @@ set(rust_profile $<IF:$<CONFIG:Debug>,debug,$<IF:$<CONFIG:RelWithDebInfo>,releas
|
||||
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,11 +38,16 @@ 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"
|
||||
@@ -48,7 +57,7 @@ set(VARS_FOR_CARGO
|
||||
"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,85 @@ 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
|
||||
POST_BUILD
|
||||
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
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_SOURCE_DIR}/tests/ ${CMAKE_BINARY_DIR}/tests/
|
||||
COMMENT "Copying test files to binary dir"
|
||||
VERBATIM)
|
||||
endif()
|
||||
|
||||
# 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
|
||||
# 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)
|
||||
|
||||
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}
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.py ${CMAKE_CURRENT_BINARY_DIR}
|
||||
checks/${CHECK}.fish
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
||||
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 +113,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}
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/test_driver.py ${CMAKE_CURRENT_BINARY_DIR}
|
||||
pexpects/${PEXPECT}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
||||
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)
|
||||
|
||||
5
debian/control
vendored
5
debian/control
vendored
@@ -20,13 +20,14 @@ 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,
|
||||
# for col and lock
|
||||
Depends: bsdextrautils,
|
||||
file,
|
||||
# for the gettext command
|
||||
gettext-base,
|
||||
# for nroff and preconv
|
||||
groff-base,
|
||||
man-db,
|
||||
# for terminal definitions
|
||||
ncurses-base,
|
||||
# for kill
|
||||
|
||||
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
|
||||
|
||||
@@ -13,7 +13,6 @@ allow = [
|
||||
"MPL-2.0",
|
||||
"PSF-2.0",
|
||||
"Unicode-DFS-2016",
|
||||
"Unicode-3.0",
|
||||
"WTFPL",
|
||||
"Zlib",
|
||||
]
|
||||
|
||||
@@ -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`.
|
||||
|
||||
|
||||
@@ -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-``, ``alt-`` 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,9 +170,6 @@ 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.
|
||||
|
||||
@@ -250,7 +240,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,12 +261,6 @@ 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
|
||||
|
||||
@@ -425,24 +409,6 @@ Launch ``git diff`` and repaint the commandline afterwards when :kbd:`ctrl-g` is
|
||||
|
||||
bind ctrl-g 'git diff' repaint
|
||||
|
||||
Swap :kbd:`tab` and :kbd:`shift-tab`, making tab focus the search field.
|
||||
But if the search field is already active, keep the behavior (:kbd:`tab` cycles forward, :kbd:`shift-tab` backward).::
|
||||
|
||||
bind tab '
|
||||
if commandline --search-field >/dev/null
|
||||
commandline -f complete
|
||||
else
|
||||
commandline -f complete-and-search
|
||||
end
|
||||
'
|
||||
bind shift-tab '
|
||||
if commandline --search-field >/dev/null
|
||||
commandline -f complete-and-search
|
||||
else
|
||||
commandline -f complete
|
||||
end
|
||||
'
|
||||
|
||||
.. _cmd-bind-termlimits:
|
||||
|
||||
Terminal Limitations
|
||||
|
||||
@@ -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,10 +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.
|
||||
|
||||
**--input=INPUT**
|
||||
Operate on this string instead of the commandline. Useful for using options like **--tokens-expanded**.
|
||||
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:
|
||||
|
||||
@@ -90,7 +86,10 @@ The following options change the way ``commandline`` prints the current commandl
|
||||
Perform argument expansion on the selection and print one argument per line.
|
||||
Command substitutions are not expanded but forwarded as-is.
|
||||
|
||||
**-o**, **tokenize**, **--tokens-raw**
|
||||
**--tokens-raw**
|
||||
Print arguments in the selection as they appear on the command line, one per line.
|
||||
|
||||
**-o** or **tokenize**
|
||||
Deprecated; do not use.
|
||||
|
||||
If ``commandline`` is called during a call to complete a given string using ``complete -C STRING``, ``commandline`` will consider the specified string to be the current contents of the command line.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,12 +34,18 @@ 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.
|
||||
|
||||
**--install[=PATH]**
|
||||
When built as self-installable (via cargo), this will unpack fish's datafiles and place them in ~/.local/share/fish/install/.
|
||||
Fish will also ask to do this automatically when run interactively.
|
||||
If PATH is given, fish will install itself into a relocatable directory tree rooted at that path.
|
||||
That means it will install the datafiles to PATH/share/fish and copy itself to PATH/bin/fish.
|
||||
|
||||
**-l** or **--login**
|
||||
Act as if invoked as a login shell.
|
||||
|
||||
@@ -101,33 +106,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
|
||||
--------
|
||||
|
||||
@@ -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``.
|
||||
|
||||
@@ -22,7 +22,7 @@ Description
|
||||
|
||||
The ``fish_mode_prompt`` function outputs the mode indicator for use in vi mode.
|
||||
|
||||
The default ``fish_mode_prompt`` function will output indicators about the current vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. The ``$fish_bind_mode variable`` can be used to determine the current mode. It will be one of ``default``, ``insert``, ``replace_one``, ``replace``, or ``visual``.
|
||||
The default ``fish_mode_prompt`` function will output indicators about the current vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. The ``$fish_bind_mode variable`` can be used to determine the current mode. It will be one of ``default``, ``insert``, ``replace_one``, or ``visual``.
|
||||
|
||||
You can also define an empty ``fish_mode_prompt`` function to remove the vi mode indicators::
|
||||
|
||||
@@ -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
|
||||
-------
|
||||
|
||||
@@ -51,9 +49,6 @@ Example
|
||||
case replace_one
|
||||
set_color --bold green
|
||||
echo 'R'
|
||||
case replace
|
||||
set_color --bold bryellow
|
||||
echo 'R'
|
||||
case visual
|
||||
set_color --bold brmagenta
|
||||
echo 'V'
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,16 +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), **double**, **curly**, **dotted** and **dashed**.
|
||||
**-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.
|
||||
@@ -80,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
|
||||
@@ -31,8 +30,6 @@ Synopsis
|
||||
status features
|
||||
status test-feature FEATURE
|
||||
status buildinfo
|
||||
status get-file FILE
|
||||
status list-files [PATH]
|
||||
|
||||
Description
|
||||
-----------
|
||||
@@ -53,9 +50,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`.
|
||||
|
||||
@@ -108,15 +102,6 @@ The following operations (subcommands) are available:
|
||||
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
|
||||
-----
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ Synopsis
|
||||
|
||||
.. synopsis::
|
||||
|
||||
string join [-q | --quiet] [-n | --no-empty] [--] SEP [STRING ...]
|
||||
string join0 [-q | --quiet] [-n | --no-empty] [--] [STRING ...]
|
||||
string join [-q | --quiet] SEP [STRING ...]
|
||||
string join0 [-q | --quiet] [STRING ...]
|
||||
|
||||
.. END SYNOPSIS
|
||||
|
||||
@@ -18,28 +18,11 @@ Description
|
||||
|
||||
.. BEGIN DESCRIPTION
|
||||
|
||||
Joins its *STRING* arguments into a single string separated by *SEP* (for ``string join``) or by the
|
||||
zero byte (NUL) (for ``string join0``).
|
||||
Exit status: 0 if at least one join was performed, or 1 otherwise.
|
||||
``string join`` joins its *STRING* arguments into a single string separated by *SEP*, which can be an empty string. Exit status: 0 if at least one join was performed, or 1 otherwise. If ``-n`` or ``--no-empty`` is specified, empty strings are excluded from consideration (e.g. ``string join -n + a b "" c`` would expand to ``a+b+c`` not ``a+b++c``).
|
||||
|
||||
**-n**, **--no-empty**
|
||||
Exclude empty strings from consideration (e.g. ``string join -n + a b "" c`` would expand to ``a+b+c`` not ``a+b++c``).
|
||||
``string join0`` joins its *STRING* arguments into a single string separated by the zero byte (NUL), and adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as ``sort -z``. Exit status: 0 if at least one join was performed, or 1 otherwise.
|
||||
|
||||
**-q**, **--quiet**
|
||||
Do not print the strings, only set the exit status as described above.
|
||||
|
||||
**WARNING**:
|
||||
Insert a ``--`` before positional arguments to prevent them from being interpreted as flags.
|
||||
Otherwise, any strings starting with ``-`` will be treated as flag arguments, meaning they will most likely result in the command failing.
|
||||
This is also true if you specify a variable which expands to such a string instead of a literal string.
|
||||
If you don't need to append flag arguments at the end of the command,
|
||||
just always use ``--`` to avoid unwelcome surprises.
|
||||
|
||||
``string join0`` adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as ``sort -z``.
|
||||
|
||||
Because Unix uses NUL as the string terminator, passing the output of ``string join0`` as an *argument* to a command (via a :ref:`command substitution <expand-command-substitution>`) won't actually work.
|
||||
Fish will pass the correct bytes along, but the command won't be able to tell where the argument ends.
|
||||
This is a limitation of Unix' argument passing.
|
||||
Because Unix uses NUL as the string terminator, passing the output of ``string join0`` as an *argument* to a command (via a :ref:`command substitution <expand-command-substitution>`) won't actually work. Fish will pass the correct bytes along, but the command won't be able to tell where the argument ends. This is a limitation of Unix' argument passing.
|
||||
|
||||
.. END DESCRIPTION
|
||||
|
||||
@@ -60,14 +43,4 @@ Examples
|
||||
>_ string join '' a b c
|
||||
abc
|
||||
|
||||
>_ set -l markdown_list '- first' '- second' '- third'
|
||||
# Strings with leading hyphens (also in variable expansions) are interpreted as flag arguments by default.
|
||||
>_ string join \n $markdown_list
|
||||
string join: - first: unknown option
|
||||
# Use '--' to prevent this.
|
||||
>_ string join -- \n $markdown_list
|
||||
- first
|
||||
- second
|
||||
- third
|
||||
|
||||
.. END EXAMPLES
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ Synopsis
|
||||
string collect [-a | --allow-empty] [-N | --no-trim-newlines] [STRING ...]
|
||||
string escape [-n | --no-quoted] [--style=] [STRING ...]
|
||||
string join [-q | --quiet] [-n | --no-empty] SEP [STRING ...]
|
||||
string join0 [-q | --quiet] [-n | --no-empty] [STRING ...]
|
||||
string join0 [-q | --quiet] [STRING ...]
|
||||
string length [-q | --quiet] [STRING ...]
|
||||
string lower [-q | --quiet] [STRING ...]
|
||||
string match [-a | --all] [-e | --entire] [-i | --ignore-case]
|
||||
@@ -27,7 +27,7 @@ Synopsis
|
||||
[-r | --regex] [-q | --quiet] PATTERN REPLACE [STRING ...]
|
||||
string shorten [(-c | --char) CHARS] [(-m | --max) INTEGER]
|
||||
[-N | --no-newline] [-l | --left] [-q | --quiet] [STRING ...]
|
||||
string split [(-f | --fields) FIELDS] [(-m | --max) MAX] [-n | --no-empty]
|
||||
string split [(-f | --fields) FIELDS] [(-m | --max) MAX] [-n | --no-empty]
|
||||
[-q | --quiet] [-r | --right] SEP [STRING ...]
|
||||
string split0 [(-f | --fields) FIELDS] [(-m | --max) MAX] [-n | --no-empty]
|
||||
[-q | --quiet] [-r | --right] [STRING ...]
|
||||
|
||||
@@ -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:
|
||||
|
||||
::
|
||||
|
||||
|
||||
@@ -195,7 +195,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
|
||||
@@ -162,11 +162,11 @@ 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.
|
||||
|
||||
@@ -174,7 +174,7 @@ In general, fish's history recall works like this:
|
||||
|
||||
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,13 +325,11 @@ 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:`ctrl-delete` moves the next word (or next argument on macOS) to the :ref:`killring`.
|
||||
- :kbd:`alt-d` or :kbd:`ctrl-delete` moves the next word 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:`alt-delete` moves the next argument to the :ref:`killring`.
|
||||
|
||||
- :kbd:`shift-delete` removes the current history item or autosuggestion from the command history.
|
||||
|
||||
@@ -354,7 +339,7 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit
|
||||
|
||||
- :kbd:`alt-o` opens the file at the cursor in a pager. If the cursor is in command position and the command is a script, it will instead open that script in your editor. The editor is chosen from the first available of the ``$VISUAL`` or ``$EDITOR`` variables.
|
||||
|
||||
- :kbd:`alt-p` adds the string ``&| less;`` to the end of the job under the cursor. The result is that the output of the command will be paged. If you set the ``PAGER`` variable, its value is used instead of ``less``.
|
||||
- :kbd:`alt-p` adds the string ``&| less;`` to the end of the job under the cursor. The result is that the output of the command will be paged.
|
||||
|
||||
- :kbd:`alt-w` prints a short description of the command under the cursor.
|
||||
|
||||
@@ -379,14 +364,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.
|
||||
|
||||
@@ -498,7 +480,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 +501,6 @@ Insert mode
|
||||
|
||||
- :kbd:`backspace` removes one character to the left.
|
||||
|
||||
- :kbd:`ctrl-n` accepts the autosuggestion.
|
||||
|
||||
.. _vi-mode-visual:
|
||||
|
||||
Visual mode
|
||||
@@ -560,12 +539,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 +596,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 +626,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
|
||||
@@ -281,7 +281,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 +314,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 +408,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 +436,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 +460,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 +530,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 +567,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 +620,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 +658,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 +788,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 +859,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 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.
|
||||
|
||||
.. [#] One exception: Setting ``$IFS`` to empty will disable line splitting. This is deprecated, use :doc:`string split <cmds/string-split>` instead.
|
||||
|
||||
@@ -908,7 +909,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::
|
||||
|
||||
@@ -917,12 +918,6 @@ If there is nothing between a brace and a comma or two commas, it's interpreted
|
||||
|
||||
To use a "," as an element, :ref:`quote <quotes>` or :ref:`escape <escapes>` it.
|
||||
|
||||
The very first character of a command token is never interpreted as expanding brace, because it's the beginning of a :ref:`compound statement <cmd-begin>`::
|
||||
|
||||
> {echo hello, && echo world}
|
||||
hello,
|
||||
world
|
||||
|
||||
.. _cartesian-product:
|
||||
|
||||
Combining lists
|
||||
@@ -1331,7 +1326,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:
|
||||
|
||||
@@ -1374,7 +1369,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``::
|
||||
|
||||
@@ -1384,7 +1379,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
|
||||
|
||||
@@ -1446,7 +1441,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"` .
|
||||
@@ -1571,12 +1566,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
|
||||
|
||||
@@ -1590,10 +1586,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.
|
||||
@@ -1723,7 +1715,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
|
||||
|
||||
@@ -1733,6 +1725,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.
|
||||
@@ -1956,7 +1954,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:
|
||||
|
||||
@@ -2024,19 +2022,19 @@ 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
|
||||
buffered-enter-noexec off 4.1 enter typed while executing will not execute
|
||||
|
||||
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.
|
||||
- ``buffered-enter-noexec`` typing enter during command execution will insert a newline into the next commandline instead of executing it.
|
||||
|
||||
|
||||
These changes are introduced off by default. They can be enabled on a per session basis::
|
||||
@@ -2057,6 +2055,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
|
||||
@@ -2120,14 +2124,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
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
@@ -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
|
||||
---------------
|
||||
|
||||
|
||||
@@ -1,286 +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:2m``
|
||||
- Su
|
||||
- Enter double underline mode.
|
||||
- kitty
|
||||
* - ``\e[4:3m``
|
||||
- Su
|
||||
- Enter curly underline mode.
|
||||
- kitty
|
||||
* - ``\e[4:4m``
|
||||
- Su
|
||||
- Enter dotted underline mode.
|
||||
- kitty
|
||||
* - ``\e[4:5m``
|
||||
- Su
|
||||
- Enter dashed 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
|
||||
@@ -115,7 +115,7 @@ These colors, and many more, can be changed by running ``fish_config``, or by mo
|
||||
|
||||
For example, if you want to disable (almost) all coloring::
|
||||
|
||||
fish_config theme choose None
|
||||
fish_config theme choose none
|
||||
|
||||
This picks the "none" theme. To see all themes::
|
||||
|
||||
@@ -631,12 +631,12 @@ You can define your own prompt from the command line:
|
||||
|
||||
Then, if you are happy with it, you can save it to disk by typing ``funcsave fish_prompt``. This saves the prompt in ``~/.config/fish/functions/fish_prompt.fish``. (Or, if you want, you can create that file manually from the start.)
|
||||
|
||||
Multiple lines are OK. Colors can be set via :doc:`set_color <cmds/set_color>` by passing it named ANSI colors, or hex RGB values::
|
||||
Multiple lines are OK. Colors can be set via :doc:`set_color <cmds/set_color>`, passing it named ANSI colors, or hex RGB values::
|
||||
|
||||
function fish_prompt
|
||||
set_color purple
|
||||
date "+%m/%d/%y"
|
||||
set_color FF0000
|
||||
set_color F00
|
||||
echo (pwd) '>' (set_color normal)
|
||||
end
|
||||
|
||||
@@ -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 \
|
||||
|
||||
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;
|
||||
14
fish.spec.in
14
fish.spec.in
@@ -17,6 +17,7 @@ BuildRequires: rust >= 1.70
|
||||
BuildRequires: cmake >= 3.15
|
||||
|
||||
%if 0%{?suse_version}
|
||||
BuildRequires: update-desktop-files
|
||||
# for tests
|
||||
BuildRequires: groff
|
||||
%else
|
||||
@@ -31,12 +32,13 @@ BuildRequires: glibc-langpack-en
|
||||
BuildRequires: python3 procps
|
||||
|
||||
%if 0%{?suse_version}
|
||||
Requires: terminfo-base groff
|
||||
Requires: terminfo-base
|
||||
%else
|
||||
Requires: ncurses-base groff-base
|
||||
Requires: ncurses-base
|
||||
%endif
|
||||
Requires: file
|
||||
Requires: python3
|
||||
Requires: man
|
||||
Requires: procps
|
||||
|
||||
# Although the build scripts mangle the version number to be RPM compatible
|
||||
@@ -74,6 +76,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
|
||||
@@ -124,3 +130,7 @@ fi
|
||||
|
||||
# pkgconfig
|
||||
%{_datadir}/pkgconfig/fish.pc
|
||||
|
||||
# FreeDesktop entry
|
||||
%{_datadir}/applications/fish.desktop
|
||||
%{_datadir}/pixmaps/fish.png
|
||||
|
||||
@@ -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
|
||||
|
||||
180286
po/pt_BR.po
180286
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
182404
po/zh_CN.po
182404
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,6 @@
|
||||
[package]
|
||||
name = "fish-printf"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
edition = "2021"
|
||||
version = "0.2.1"
|
||||
repository = "https://github.com/fish-shell/fish-shell"
|
||||
description = "printf implementation, based on musl"
|
||||
@@ -10,8 +9,3 @@ license = "MIT"
|
||||
[dependencies]
|
||||
libc = "0.2.155"
|
||||
widestring = { version = "1.0.2", optional = true }
|
||||
unicode-segmentation = "1.12.0"
|
||||
unicode-width = "0.2.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
allow-print-in-tests = true
|
||||
@@ -139,12 +139,6 @@ fn to_arg(self) -> Arg<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToArg<'a> for &'a std::io::Error {
|
||||
fn to_arg(self) -> Arg<'a> {
|
||||
Arg::String(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToArg<'a> for f32 {
|
||||
fn to_arg(self) -> Arg<'a> {
|
||||
Arg::Float(self.into())
|
||||
|
||||
@@ -221,7 +221,7 @@ pub fn round_to_fractional_digits(&mut self, desired_frac_digits: i32) {
|
||||
// Round up if necessary.
|
||||
if self.should_round_up(last_digit_idx, remainder_to_round, mod_base) {
|
||||
self[last_digit_idx] += mod_base;
|
||||
// Propagate carry.
|
||||
// Propogate carry.
|
||||
while self[last_digit_idx] >= DIGIT_BASE {
|
||||
self[last_digit_idx] = 0;
|
||||
last_digit_idx -= 1;
|
||||
|
||||
@@ -279,7 +279,6 @@ fn format_a(mut y: f64, params: FormatParams<'_, impl Write>) -> Result<usize, E
|
||||
|
||||
// Compute the number of hex digits in the mantissa after the decimal.
|
||||
// -1 for leading 1 bit (we are to the range [1, 2)), then divide by 4, rounding up.
|
||||
#[allow(clippy::manual_div_ceil)]
|
||||
const MANTISSA_HEX_DIGITS: usize = (MANTISSA_BITS - 1 + 3) / 4;
|
||||
if had_prec && prec < MANTISSA_HEX_DIGITS {
|
||||
// Decide how many least-significant bits to round off the mantissa.
|
||||
|
||||
@@ -32,12 +32,13 @@ macro_rules! sprintf {
|
||||
// Write to a newly allocated String, and return it.
|
||||
// This panics if the format string or arguments are invalid.
|
||||
(
|
||||
$fmt:expr // Format string, which should implement FormatString.
|
||||
$(, $($arg:expr),*)? // arguments
|
||||
$fmt:expr, // Format string, which should implement FormatString.
|
||||
$($arg:expr),* // arguments
|
||||
$(,)? // optional trailing comma
|
||||
) => {
|
||||
{
|
||||
let mut target = String::new();
|
||||
$crate::sprintf!(=> &mut target, $fmt $(, $($arg),*)?);
|
||||
$crate::sprintf!(=> &mut target, $fmt, $($arg),*);
|
||||
target
|
||||
}
|
||||
};
|
||||
@@ -46,8 +47,9 @@ macro_rules! sprintf {
|
||||
// The target should implement std::fmt::Write.
|
||||
(
|
||||
=> $target:expr, // target string
|
||||
$fmt:expr // format string
|
||||
$(, $($arg:expr),*)? // arguments
|
||||
$fmt:expr, // format string
|
||||
$($arg:expr),* // arguments
|
||||
$(,)? // optional trailing comma
|
||||
) => {
|
||||
{
|
||||
// May be no args!
|
||||
@@ -56,7 +58,7 @@ macro_rules! sprintf {
|
||||
$crate::printf_c_locale(
|
||||
$target,
|
||||
$fmt,
|
||||
&mut [$( $($arg.to_arg()),* )?],
|
||||
&mut [$($arg.to_arg()),*],
|
||||
).unwrap()
|
||||
}
|
||||
};
|
||||
@@ -71,7 +73,7 @@ macro_rules! sprintf {
|
||||
/// - `args`: Iterator over the arguments to format.
|
||||
///
|
||||
/// # Returns
|
||||
/// A `Result` which is `Ok` containing the width of the string written on success, or an `Error`.
|
||||
/// A `Result` which is `Ok` containing the number of characters written on success, or an `Error`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
use std::fmt::{self, Write};
|
||||
use std::mem;
|
||||
use std::result::Result;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
#[cfg(feature = "widestring")]
|
||||
use widestring::Utf32Str as wstr;
|
||||
@@ -384,7 +382,7 @@ pub fn sprintf_locale(
|
||||
}
|
||||
|
||||
// Read field width. We do not support $.
|
||||
let desired_width = if s.at(0) == Some('*') {
|
||||
let width = if s.at(0) == Some('*') {
|
||||
let arg_width = args.next().ok_or(Error::MissingArg)?.as_sint()?;
|
||||
s.advance_by(1);
|
||||
if arg_width < 0 {
|
||||
@@ -399,7 +397,7 @@ pub fn sprintf_locale(
|
||||
};
|
||||
|
||||
// Optionally read precision. We do not support $.
|
||||
let mut desired_precision: Option<usize> = if s.at(0) == Some('.') && s.at(1) == Some('*') {
|
||||
let mut prec: Option<usize> = if s.at(0) == Some('.') && s.at(1) == Some('*') {
|
||||
// "A negative precision is treated as though it were missing."
|
||||
// Here we assume the precision is always signed.
|
||||
s.advance_by(2);
|
||||
@@ -412,7 +410,7 @@ pub fn sprintf_locale(
|
||||
None
|
||||
};
|
||||
// Disallow precisions larger than i32::MAX, in keeping with C.
|
||||
if desired_precision.unwrap_or(0) > i32::MAX as usize {
|
||||
if prec.unwrap_or(0) > i32::MAX as usize {
|
||||
return Err(Error::Overflow);
|
||||
}
|
||||
|
||||
@@ -431,7 +429,7 @@ pub fn sprintf_locale(
|
||||
// "If a precision is given with a numeric conversion (d, i, o, u, i, x, and X),
|
||||
// the 0 flag is ignored." p is included here.
|
||||
let spec_is_numeric = matches!(conv_spec, CS::d | CS::u | CS::o | CS::p | CS::x | CS::X);
|
||||
if spec_is_numeric && desired_precision.is_some() {
|
||||
if spec_is_numeric && prec.is_some() {
|
||||
flags.zero_pad = false;
|
||||
}
|
||||
|
||||
@@ -445,22 +443,13 @@ pub fn sprintf_locale(
|
||||
CS::e | CS::f | CS::g | CS::a | CS::E | CS::F | CS::G | CS::A => {
|
||||
// Floating point types handle output on their own.
|
||||
let float = arg.as_float()?;
|
||||
let len = format_float(
|
||||
f,
|
||||
float,
|
||||
desired_width,
|
||||
desired_precision,
|
||||
flags,
|
||||
locale,
|
||||
conv_spec,
|
||||
buf,
|
||||
)?;
|
||||
let len = format_float(f, float, width, prec, flags, locale, conv_spec, buf)?;
|
||||
out_len = out_len.checked_add(len).ok_or(Error::Overflow)?;
|
||||
continue 'main;
|
||||
}
|
||||
CS::p => {
|
||||
const PTR_HEX_DIGITS: usize = 2 * mem::size_of::<*const u8>();
|
||||
desired_precision = desired_precision.map(|p| p.max(PTR_HEX_DIGITS));
|
||||
prec = prec.map(|p| p.max(PTR_HEX_DIGITS));
|
||||
let uint = arg.as_uint()?;
|
||||
if uint != 0 {
|
||||
prefix = "0x";
|
||||
@@ -490,8 +479,8 @@ pub fn sprintf_locale(
|
||||
if uint != 0 {
|
||||
write!(buf, "{:o}", uint)?;
|
||||
}
|
||||
if flags.alt_form && desired_precision.unwrap_or(0) <= buf.len() + 1 {
|
||||
desired_precision = Some(buf.len() + 1);
|
||||
if flags.alt_form && prec.unwrap_or(0) <= buf.len() + 1 {
|
||||
prec = Some(buf.len() + 1);
|
||||
}
|
||||
buf
|
||||
}
|
||||
@@ -525,38 +514,10 @@ pub fn sprintf_locale(
|
||||
CS::s => {
|
||||
// also 'S'
|
||||
let s = arg.as_str(buf)?;
|
||||
let p = prec.unwrap_or(s.len()).min(s.len());
|
||||
prec = Some(p);
|
||||
flags.zero_pad = false;
|
||||
match desired_precision {
|
||||
Some(precision) => {
|
||||
// from man printf(3)
|
||||
// "the maximum number of characters to be printed from a string"
|
||||
// We interpret this to mean the maximum width when printed, as defined by
|
||||
// Unicode grapheme cluster width.
|
||||
let mut byte_len = 0;
|
||||
let mut width = 0;
|
||||
let mut graphemes = s.graphemes(true);
|
||||
// Iteratively add single grapheme clusters as long as the fit within the
|
||||
// width limited by precision.
|
||||
while width < precision {
|
||||
match graphemes.next() {
|
||||
Some(grapheme) => {
|
||||
let grapheme_width = grapheme.width();
|
||||
if width + grapheme_width <= precision {
|
||||
byte_len += grapheme.len();
|
||||
width += grapheme_width;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
let p = precision.min(width);
|
||||
desired_precision = Some(p);
|
||||
&s[..byte_len]
|
||||
}
|
||||
None => s,
|
||||
}
|
||||
&s[..p]
|
||||
}
|
||||
};
|
||||
// Numeric output should be empty iff the value is 0.
|
||||
@@ -567,26 +528,23 @@ pub fn sprintf_locale(
|
||||
// Decide if we want to apply thousands grouping to the body, and compute its size.
|
||||
// Note we have already errored out if grouped is set and this is non-numeric.
|
||||
let wants_grouping = flags.grouped && locale.thousands_sep.is_some();
|
||||
let body_width = match wants_grouping {
|
||||
// We assume that text representing numbers is ASCII, so len == width.
|
||||
let body_len = match wants_grouping {
|
||||
true => body.len() + locale.separator_count(body.len()),
|
||||
false => body.width(),
|
||||
false => body.len(),
|
||||
};
|
||||
|
||||
// Resolve the precision.
|
||||
// In the case of a non-numeric conversion, update the precision to at least the
|
||||
// length of the string.
|
||||
let desired_precision = if !spec_is_numeric {
|
||||
desired_precision.unwrap_or(body_width)
|
||||
let prec = if !spec_is_numeric {
|
||||
prec.unwrap_or(body_len)
|
||||
} else {
|
||||
desired_precision.unwrap_or(1).max(body_width)
|
||||
prec.unwrap_or(1).max(body_len)
|
||||
};
|
||||
|
||||
let prefix_width = prefix.width();
|
||||
let unpadded_width = prefix_width
|
||||
.checked_add(desired_precision)
|
||||
.ok_or(Error::Overflow)?;
|
||||
let width = desired_width.max(unpadded_width);
|
||||
let prefix_len = prefix.len();
|
||||
let unpadded_width = prefix_len.checked_add(prec).ok_or(Error::Overflow)?;
|
||||
let width = width.max(unpadded_width);
|
||||
|
||||
// Pad on the left with spaces to the desired width?
|
||||
if !flags.left_adj && !flags.zero_pad {
|
||||
@@ -602,8 +560,7 @@ pub fn sprintf_locale(
|
||||
}
|
||||
|
||||
// Pad on the left to the given precision?
|
||||
// TODO: why pad with 0 here?
|
||||
pad(f, '0', desired_precision, body_width)?;
|
||||
pad(f, '0', prec, body_len)?;
|
||||
|
||||
// Output the actual value, perhaps with grouping.
|
||||
if wants_grouping {
|
||||
|
||||
@@ -13,7 +13,6 @@ macro_rules! sprintf_check {
|
||||
$(,)? // optional trailing comma
|
||||
) => {
|
||||
{
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
let mut target = String::new();
|
||||
let mut args = [$($arg.to_arg()),*];
|
||||
let len = $crate::printf_c_locale(
|
||||
@@ -21,7 +20,7 @@ macro_rules! sprintf_check {
|
||||
$fmt.as_ref() as &str,
|
||||
&mut args,
|
||||
).expect("printf failed");
|
||||
assert_eq!(len, target.width(), "Wrong length returned");
|
||||
assert!(len == target.len(), "Wrong length returned: {} vs {}", len, target.len());
|
||||
target
|
||||
}
|
||||
};
|
||||
@@ -660,18 +659,6 @@ fn test_crate_macros() {
|
||||
|
||||
target = crate::sprintf!("%d ok %d", 3, 4);
|
||||
assert_eq!(target, "3 ok 4");
|
||||
|
||||
let target = crate::sprintf!("noargs1");
|
||||
assert_eq!(target, "noargs1");
|
||||
let target = crate::sprintf!("noargs1",);
|
||||
assert_eq!(target, "noargs1");
|
||||
|
||||
let mut target = String::new();
|
||||
crate::sprintf!(=> &mut target, "noargs2");
|
||||
assert_eq!(target, "noargs2");
|
||||
let mut target = String::new();
|
||||
crate::sprintf!(=> &mut target, "noargs2", );
|
||||
assert_eq!(target, "noargs2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -736,18 +723,6 @@ fn test_huge_precision_g() {
|
||||
sprintf_err!("%.2147483648g", f => Error::Overflow);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_ascii() {
|
||||
assert_fmt!("%3s", "ö" => " ö");
|
||||
assert_fmt!("%3s", "🇺🇳" => " 🇺🇳");
|
||||
assert_fmt!("%.3s", "🇺🇳🇺🇳" => "🇺🇳");
|
||||
assert_fmt!("%.3s", "a🇺🇳" => "a🇺🇳");
|
||||
assert_fmt!("%.3s", "aa🇺🇳" => "aa");
|
||||
assert_fmt!("%3.3s", "aa🇺🇳" => " aa");
|
||||
assert_fmt!("%.1s", "𒈙a" => "𒈙");
|
||||
assert_fmt!("%3.3s", "👨👨👧👧" => " 👨👨👧👧");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_errors() {
|
||||
use Error::*;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
complete -c VBoxSDL -l startvm -x -d "Set virtual machine to start" -a "(__fish_print_VBox_vms)"
|
||||
|
||||
complete -c VBoxSDL -l separate -d "Run separate VM process or attach to a running VM"
|
||||
complete -c VBoxSDL -l seperate -d "Run separate VM process or attach to a running VM"
|
||||
complete -c VBoxSDL -l hda -f -d "Set temporary first hard disk"
|
||||
complete -c VBoxSDL -l fda -f -d "Set temporary first floppy disk"
|
||||
complete -c VBoxSDL -l cdrom -r -d "Set temporary CDROM/DVD" -a "none\tunmount"
|
||||
@@ -18,7 +18,7 @@ complete -c VBoxSDL -l nograbonclick -d "Disable mouse/keyboard grabbing on mous
|
||||
complete -c VBoxSDL -l detecthostkey -d "Get hostkey identifier and modifier state"
|
||||
complete -c VBoxSDL -l hostkey -r -d "Set host key to values obtained using --detecthostkey"
|
||||
complete -c VBoxSDL -l termacpi -d "Send APCI power button when closing window"
|
||||
complete -c VBoxSDL -l vrdp -d "Listen for VRDP connections on if one of specified"
|
||||
complete -c VBoxSDL -l vrdp -d "Listen for VRDP connexions on if one of specified"
|
||||
complete -c VBoxSDL -l discardstate -d "Discard saved state (if present) and revert to last snapshot (if present)"
|
||||
complete -c VBoxSDL -l settingspw -x -d "Specify settings password"
|
||||
complete -c VBoxSDL -l settingspwfile -f -d "Specify file containing setting password"
|
||||
|
||||
@@ -14,7 +14,7 @@ complete -c acpi -s A -l without-ac-adapter -d 'Suppress ac-adapter information'
|
||||
complete -c acpi -s V -l everything -d 'Show every device, overrides above options'
|
||||
complete -c acpi -s s -l show-empty -d 'Show non-operational devices'
|
||||
complete -c acpi -s S -l hide-empty -d 'Hide non-operational devices'
|
||||
complete -c acpi -s c -l cooling -d 'Show cooling device information'
|
||||
complete -c acpi -s c -l celcius -d 'Use celsius as the temperature unit'
|
||||
complete -c acpi -s f -l fahrenheit -d 'Use fahrenheit as the temperature unit'
|
||||
complete -c acpi -s k -l kelvin -d 'Use kelvin as the temperature unit'
|
||||
complete -c acpi -s d -l directory -d '<dir> path to ACPI info (/proc/acpi)'
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
function __fish_apt_no_subcommand -d 'Test if apt has yet to be given the subcommand'
|
||||
for i in (commandline -xpc)
|
||||
if contains -- $i update upgrade dselect-upgrade dist-upgrade install remove purge autoremove autopurge source build-dep check clean autoclean changelog
|
||||
if contains -- $i update upgrade dselect-upgrade dist-upgrade install remove purge source build-dep check clean autoclean changelog
|
||||
return 1
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@ end
|
||||
|
||||
function __fish_apt_use_package -d 'Test if apt command should have packages as potential completion'
|
||||
for i in (commandline -xpc)
|
||||
if contains -- $i contains install remove purge autoremove autopurge build-dep changelog
|
||||
if contains -- $i contains install remove purge build-dep changelog
|
||||
return 0
|
||||
end
|
||||
end
|
||||
@@ -34,8 +34,7 @@ complete -f -n __fish_apt_no_subcommand -c apt-get -a build-dep -d 'Install/remo
|
||||
complete -f -n __fish_apt_no_subcommand -c apt-get -a check -d 'Update cache and check dependencies'
|
||||
complete -f -n __fish_apt_no_subcommand -c apt-get -a clean -d 'Clean local caches and packages'
|
||||
complete -f -n __fish_apt_no_subcommand -c apt-get -a autoclean -d 'Clean packages no longer be downloaded'
|
||||
complete -f -n __fish_apt_no_subcommand -c apt-get -a autoremove -d 'Remove packages no longer needed as dependencies'
|
||||
complete -f -n __fish_apt_no_subcommand -c apt-get -a autopurge -d 'Remove packages no longer needed as dependencies and delete their config files'
|
||||
complete -f -n __fish_apt_no_subcommand -c apt-get -a autoremove -d 'Remove automatically installed packages'
|
||||
complete -c apt-get -l no-install-recommends -d 'Do not install recommended packages'
|
||||
complete -c apt-get -l no-install-suggests -d 'Do not install suggested packages'
|
||||
complete -c apt-get -s d -l download-only -d 'Download Only'
|
||||
@@ -64,7 +63,7 @@ complete -c apt-get -l no-remove -d 'Abort if any packages are to be removed'
|
||||
complete -c apt-get -l only-source -d 'Only accept source packages'
|
||||
complete -c apt-get -l diff-only -d 'Download only diff file'
|
||||
complete -c apt-get -l tar-only -d 'Download only tar file'
|
||||
complete -c apt-get -l arch-only -d 'Only process arch-dependent build-dependencies'
|
||||
complete -c apt-get -l arch-only -d 'Only process arch-dependant build-dependencies'
|
||||
complete -c apt-get -l allow-unauthenticated -d 'Ignore non-authenticated packages'
|
||||
complete -c apt-get -s v -l version -d 'Display version and exit'
|
||||
complete -r -c apt-get -s c -l config-file -d 'Specify a config file'
|
||||
|
||||
@@ -6,8 +6,8 @@ if [ "$(uname -s)" = Darwin -a "$(command -s apt)" = /usr/bin/apt ]
|
||||
exit 1
|
||||
end
|
||||
|
||||
set -l all_subcmds update upgrade full-upgrade search list install show remove edit-sources purge changelog autoremove autopurge depends rdepends
|
||||
set -l pkg_subcmds install upgrade full-upgrade show search purge changelog policy depends rdepends autoremove autopurge
|
||||
set -l all_subcmds update upgrade full-upgrade search list install show remove edit-sources purge changelog autoremove depends rdepends
|
||||
set -l pkg_subcmds install upgrade full-upgrade show search purge changelog policy depends rdepends autoremove
|
||||
set -l installed_pkg_subcmds remove
|
||||
set -l handle_file_pkg_subcmds install
|
||||
|
||||
@@ -114,7 +114,7 @@ __fish_apt_subcommand changelog -r -d 'Download and display package changelog'
|
||||
# Autoremove
|
||||
__fish_apt_subcommand autoremove -d 'Remove packages no longer needed as dependencies'
|
||||
|
||||
# Autopurge
|
||||
# Autoremove
|
||||
__fish_apt_subcommand autopurge -d 'Remove packages no longer needed as dependencies and delete their config files'
|
||||
|
||||
# Clean
|
||||
|
||||
@@ -11,7 +11,7 @@ end
|
||||
|
||||
function __fish_apt_use_package -d 'Test if aptitude command should have packages as potential completion'
|
||||
for i in (commandline -xpc)
|
||||
if contains -- $i changelog full-upgrade download forbid-version hold install keep-all markauto purge reinstall remove show showrc unhold unmarkauto why why-not versions
|
||||
if contains -- $i changelog full-upgrade download forbid-version hold install keep-all markauto purge reinstall remove show unhold unmarkauto
|
||||
return 0
|
||||
end
|
||||
end
|
||||
@@ -38,19 +38,15 @@ complete -f -n __fish_apt_no_subcommand -c aptitude -a markauto -d 'Mark package
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a purge -d 'Remove and delete all associated configuration and data files'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a reinstall -d 'Reinstall the packages'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a remove -d 'Remove the packages'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a showsrc -d 'Display detailed information about the source packages (apt wrapper)'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a show -d 'Display detailed information about the packages'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a unhold -d 'Consider the packages by future upgrade commands'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a unmarkauto -d 'Mark packages as manually installed'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a search -d 'Search for packages matching one of the patterns'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a help -d 'Display brief summary of the available commands and options'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a why -d 'Explain why a particular package should be installed'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a why-not -d 'Explain why a particular package cannot be installed'
|
||||
complete -f -n __fish_apt_no_subcommand -c aptitude -a versions -d 'Displays the versions of specified packages'
|
||||
|
||||
complete -c aptitude -s D -l show-deps -d 'Show explanations of automatic installations and removals'
|
||||
complete -c aptitude -s d -l download-only -d 'Download only'
|
||||
complete -c aptitude -s f -l fix-broken -d 'Aggressively try to fix broken packages'
|
||||
complete -c aptitude -s d -l download-only -d 'Download Only'
|
||||
complete -c aptitude -s f -l fix-broken -d 'Correct broken dependencies'
|
||||
complete -c aptitude -l purge-unused -d 'Purge packages that are not required by any installed package'
|
||||
complete -c aptitude -s P -l prompt -d 'Always display a prompt'
|
||||
complete -c aptitude -s R -l without-recommends -d 'Do not treat recommendations as dependencies'
|
||||
@@ -64,7 +60,6 @@ complete -c aptitude -l version -d 'Display the version of aptitude and compile
|
||||
complete -c aptitude -l visual-preview -d 'Start up the visual interface and display its preview screen'
|
||||
complete -c aptitude -s y -l assume-yes -d 'Assume the answer yes for all question prompts'
|
||||
complete -c aptitude -s Z -d 'Show how much disk space will be used or freed'
|
||||
complete -c aptitude -s u -d 'Download new package lists on startup (terminal interface only)'
|
||||
complete -r -c aptitude -s F -l display-format -d 'Specify the format to be used by the search command'
|
||||
complete -r -c aptitude -s t -l target-release -d 'Set the release from which packages should be installed'
|
||||
complete -r -c aptitude -s O -l sort -d 'Specify the order for the output from the search command'
|
||||
|
||||
@@ -33,9 +33,9 @@ end
|
||||
### Global options
|
||||
complete -f -c arc -n __fish_arc_needs_command -l trace -d 'Debugging command'
|
||||
complete -f -c arc -n __fish_arc_needs_command -l no-ansi -d 'Don\'t use color or style for output'
|
||||
complete -f -c arc -n __fish_arc_needs_command -l ansi -d 'Always use formatting'
|
||||
complete -f -c arc -n __fish_arc_needs_command -l ansi -d 'Always use fromatting'
|
||||
complete -f -c arc -n __fish_arc_needs_command -l no-ansi -d 'Don\'t use color or style for output'
|
||||
complete -f -c arc -n __fish_arc_needs_command -l load-phutil-library -d 'Specify which libraries to load'
|
||||
complete -f -c arc -n __fish_arc_needs_command -l load-phutil-library -d 'Specify which libraies to load'
|
||||
complete -f -c arc -n __fish_arc_needs_command -l conduit-uri -d 'Specify the Conduit URI'
|
||||
complete -f -c arc -n __fish_arc_needs_command -l conduit-token -d 'Specify the Conduit token'
|
||||
complete -f -c arc -n __fish_arc_needs_command -l conduit-version -d 'Force a version'
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
argocd completion fish | source
|
||||
@@ -5,7 +5,7 @@ complete -c ark -s o -l destination -d 'Specify an extraction directory'
|
||||
complete -c ark -s c -l add -d 'Add files and directories to an archive interactively'
|
||||
complete -c ark -s t -l add-to -d 'Add files and directories to an archive'
|
||||
complete -c ark -s p -l changetofirstpath -d 'Use a first argument as input path'
|
||||
complete -c ark -s f -l autofilename -d 'Specify suffix for automatically chosen filename'
|
||||
complete -c ark -s f -l autofilename -d 'Specify suffix for automatically choosen filename'
|
||||
|
||||
complete -c ark -s b -l batch -d 'Use a batch interface'
|
||||
complete -c ark -s e -l autodestination -d 'Use a first argument as output path'
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user