mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-24 05:41:14 -03:00
Compare commits
40 Commits
3.2.2
...
coverity_s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9da2f9c77 | ||
|
|
62b69532b1 | ||
|
|
2f1e8d9f8b | ||
|
|
64c8cee001 | ||
|
|
2ea6b8c128 | ||
|
|
ed844fa0ac | ||
|
|
b0bda695b5 | ||
|
|
e945a5f179 | ||
|
|
dfeccf2a1e | ||
|
|
593675e05e | ||
|
|
50a5460c17 | ||
|
|
172436f508 | ||
|
|
10a3eedcab | ||
|
|
53d8d9e0d9 | ||
|
|
642edbc434 | ||
|
|
d85bf9c0da | ||
|
|
37503f5f01 | ||
|
|
193dbe2a78 | ||
|
|
e95b9c16f0 | ||
|
|
d1bfea9ee5 | ||
|
|
c9c2cd069d | ||
|
|
c5409335ee | ||
|
|
db9259210d | ||
|
|
998b878dda | ||
|
|
32e2d36a7a | ||
|
|
37dc28f354 | ||
|
|
20ee1ce94b | ||
|
|
5c95da56a4 | ||
|
|
82325778a5 | ||
|
|
49d8e71e1f | ||
|
|
a9d1fb23da | ||
|
|
d8d194af63 | ||
|
|
85295488a6 | ||
|
|
7a8c5f53d5 | ||
|
|
bec4c374f5 | ||
|
|
d925862350 | ||
|
|
1f2a2de414 | ||
|
|
c21d880f34 | ||
|
|
e1dde5d7e1 | ||
|
|
66d7850b18 |
@@ -4,13 +4,12 @@ packages:
|
||||
- ninja
|
||||
- ncurses-dev
|
||||
- pcre2-dev
|
||||
- python3
|
||||
- py-pip
|
||||
- expect
|
||||
- python
|
||||
sources:
|
||||
- https://git.sr.ht/~faho/fish
|
||||
tasks:
|
||||
- build: |
|
||||
pip3 install pexpect
|
||||
cd fish
|
||||
mkdir build || :
|
||||
cd build
|
||||
|
||||
@@ -2,8 +2,8 @@ image: archlinux
|
||||
packages:
|
||||
- cmake
|
||||
- ninja
|
||||
- expect
|
||||
- python
|
||||
- python-pexpect
|
||||
sources:
|
||||
- https://git.sr.ht/~faho/fish
|
||||
tasks:
|
||||
|
||||
@@ -3,11 +3,11 @@ packages:
|
||||
- ncurses
|
||||
- gcc
|
||||
- gettext
|
||||
- expect
|
||||
- cmake
|
||||
- gmake
|
||||
- pcre2
|
||||
- python
|
||||
- py37-pexpect
|
||||
sources:
|
||||
- https://git.sr.ht/~faho/fish
|
||||
tasks:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-valist.Uninitialized,cert-*,performance-*,portability-*,-modernize-use-auto,modernize-loop-convert,modernize-use-bool-literals,modernize-use-using,hicpp-uppercase-literal-suffix,readability-make-member-function-const,readability-redundant-string-init,readability-inconsistent-declaration-parameter-name,readability-redundant-access-specifiers,-performance-noexcept-move-constructor,-cert-dcl37-c,-cert-dcl50-cpp,-cert-dcl51-cpp,-cert-str34-c,-cert-env33-c'
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,cert-*,performance-*,portability-*,modernize-use-auto,modernize-loop-convert,modernize-use-bool-literals,modernize-use-using,hicpp-uppercase-literal-suffix,readability-make-member-function-const,readability-redundant-string-init,readability-inconsistent-declaration-parameter-name,readability-redundant-access-specifiers'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
AnalyzeTemporaryDtors: false
|
||||
|
||||
@@ -10,6 +10,3 @@ varFuncNullUB
|
||||
unmatchedSuppression
|
||||
// Suppress this one because it reports assert(condition && "message"), which we use all over the place
|
||||
incorrectStringBooleanError
|
||||
|
||||
// This is of very little use and pops up *everywhere*.
|
||||
useStlAlgorithm
|
||||
6
.github/workflows/lockthreads.yml
vendored
6
.github/workflows/lockthreads.yml
vendored
@@ -2,7 +2,7 @@ name: 'Lock threads'
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 18 * * *'
|
||||
- cron: '0 * * * *'
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
@@ -11,6 +11,6 @@ jobs:
|
||||
- uses: dessant/lock-threads@v2
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-lock-inactive-days: '180'
|
||||
pr-lock-inactive-days: '180'
|
||||
issue-lock-inactive-days: '90'
|
||||
pr-lock-inactive-days: '90'
|
||||
issue-exclude-labels: 'question'
|
||||
|
||||
117
.github/workflows/main.yml
vendored
117
.github/workflows/main.yml
vendored
@@ -15,12 +15,8 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip
|
||||
sudo pip3 install pexpect
|
||||
sudo apt install expect gettext libncurses5-dev libpcre2-dev
|
||||
- name: cmake
|
||||
env:
|
||||
# Some warnings upgraded to errors to match Open Build Service platforms
|
||||
CXXFLAGS: "-Werror=address -Werror=return-type"
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
@@ -31,99 +27,22 @@ jobs:
|
||||
run: |
|
||||
make test
|
||||
|
||||
ubuntu-32bit-vendored-pcre2:
|
||||
# macos:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
# runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install gettext lib32ncurses5-dev python3-pip g++-multilib
|
||||
sudo pip3 install pexpect
|
||||
- name: cmake
|
||||
env:
|
||||
CXXFLAGS: "-m32 -Werror=address -Werror=return-type"
|
||||
CFLAGS: "-m32"
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
- name: make
|
||||
run: |
|
||||
make
|
||||
- name: make test
|
||||
run: |
|
||||
make test
|
||||
|
||||
ubuntu-asan:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip
|
||||
sudo pip3 install pexpect
|
||||
- name: cmake
|
||||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
CXXFLAGS: "-fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address"
|
||||
ASAN_OPTIONS: check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1
|
||||
UBSAN_OPTIONS: print_stacktrace=1:report_error_type=1:suppressions=$TRAVIS_BUILD_DIR/build_tools/ubsan.blacklist
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
- name: make
|
||||
run: |
|
||||
make
|
||||
- name: make test
|
||||
run: |
|
||||
make test
|
||||
|
||||
ubuntu-threadsan:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt install gettext libncurses5-dev libpcre2-dev python3-pip
|
||||
sudo pip3 install pexpect
|
||||
- name: cmake
|
||||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
CXXFLAGS: "-fsanitize=thread"
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
- name: make
|
||||
run: |
|
||||
make
|
||||
- name: make test
|
||||
run: |
|
||||
make test
|
||||
|
||||
macos:
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo pip3 install pexpect
|
||||
- name: cmake
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake -DWITH_GETTEXT=NO ..
|
||||
- name: make
|
||||
run: |
|
||||
make
|
||||
- name: make test
|
||||
run: |
|
||||
make test
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
# - name: Install deps
|
||||
# run: |
|
||||
# brew install pcre2
|
||||
# - name: cmake
|
||||
# run: |
|
||||
# mkdir build && cd build
|
||||
# cmake ..
|
||||
# - name: make
|
||||
# run: |
|
||||
# make
|
||||
# - name: make test
|
||||
# run: |
|
||||
# make test
|
||||
|
||||
122
.travis.yml
Normal file
122
.travis.yml
Normal file
@@ -0,0 +1,122 @@
|
||||
language: cpp
|
||||
dist: xenial
|
||||
sudo: required
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- expect
|
||||
- gettext
|
||||
- libncurses5-dev
|
||||
- libpcre2-dev
|
||||
- python3
|
||||
- python3-pip
|
||||
before_install:
|
||||
- sudo pip3 install pexpect
|
||||
env:
|
||||
# Some warnings upgraded to errors to match Open Build Service platforms
|
||||
- CXXFLAGS="-Werror=address -Werror=return-type"
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
packages: # Don't use libpcre2-dev here, so that one build uses the vendored code
|
||||
- expect
|
||||
- gettext
|
||||
- lib32ncurses5-dev
|
||||
- g++-multilib
|
||||
- python3
|
||||
- python3-pip
|
||||
before_install:
|
||||
- sudo pip3 install pexpect
|
||||
env:
|
||||
- CXXFLAGS="-m32 -Werror=address -Werror=return-type" CFLAGS="-m32"
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env:
|
||||
- CXXFLAGS="-fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address"
|
||||
- ASAN_OPTIONS=check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1
|
||||
- UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1:suppressions=$TRAVIS_BUILD_DIR/build_tools/ubsan.blacklist
|
||||
before_install:
|
||||
- sudo pip3 install pexpect
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- expect
|
||||
- gettext
|
||||
- libncurses5-dev
|
||||
- libpcre2-dev
|
||||
- python
|
||||
- python3
|
||||
- python3-pip
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env:
|
||||
- CXXFLAGS="-fsanitize=thread"
|
||||
before_install:
|
||||
- sudo pip3 install pexpect
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- expect
|
||||
- gettext
|
||||
- libncurses5-dev
|
||||
- libpcre2-dev
|
||||
- python3
|
||||
- python3-pip
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
coverity_scan:
|
||||
project:
|
||||
name: "fish-shell/fish-shell"
|
||||
description: "The friendly interactive shell"
|
||||
notification_email: corydoras@ridiculousfish.com
|
||||
build_command_prepend: "mkdir -p build; cd build; cmake -G Ninja .."
|
||||
build_command: "ninja"
|
||||
branch_pattern: coverity_scan_master
|
||||
apt:
|
||||
packages:
|
||||
- expect
|
||||
- gettext
|
||||
- libncurses5-dev
|
||||
- libpcre2-dev
|
||||
- python3
|
||||
- python3-pip
|
||||
before_install:
|
||||
- sudo pip3 install pexpect
|
||||
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
|
||||
env:
|
||||
- secure: "Q1AS5iEi17s+xsRaMwfkxmm62UDaV47uE39pvXsNL+DO9YWbMMuhTpIOeYhxLvFNL3LMUFU2TwVpVRYX2YFGhNNaMSmjQfyQ+7q7/oSEo0aSqvQkwelpK/pwuRAXdv1MU4aQ6FrCEQ4VMO45WRo0o5WD26pvxjqRyAQ6ry+serA="
|
||||
# Some warnings upgraded to errors to match Open Build Service platforms
|
||||
- CXXFLAGS="-Werror=address -Werror=return-type"
|
||||
- os: osx
|
||||
before_install:
|
||||
- sudo pip3 install pexpect
|
||||
fast_finish: true
|
||||
|
||||
script:
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=$HOME/prefix . || cat CMakeFiles/CMakeError.log &&
|
||||
make -j2 &&
|
||||
make install &&
|
||||
make test SHOW_INTERACTIVE_LOG=1
|
||||
|
||||
notifications:
|
||||
# Some items are encrypted so that notifications from other repositories
|
||||
# don't flood the official repositories.
|
||||
irc:
|
||||
channels:
|
||||
#- "irc.oftc.net#fish"
|
||||
secure: "eRk9KGZ5+mrlD2SoI8yg2Sp8OYrh7YPyGe3WCDQUwTnNgNDII34rbM9a6UOA/l7AeWSNY8joLq5xVLCU4wpFgUcJ11SYIpMnLosZK29OW4ubDOHmdBDvJ971rLgAVG9cXngZtIxEVVxN/jnS1Qr8GKZx4DjkaTMgz1pemb4WxCc="
|
||||
template:
|
||||
- "%{repository}#%{build_number} (%{commit} on %{branch} by %{author}): %{message} Details at %{build_url}"
|
||||
use_notice: true
|
||||
skip_join: true
|
||||
webhooks:
|
||||
urls:
|
||||
#- https://webhooks.gitter.im/e/61821cec3015bf0f8bb1
|
||||
secure: fPfOmxnC3MCsfR1oocVFeWLawGcRZkn+8fNHlSOeZ+SqqoZfcCHgQTvQ22TqmVl1yvkXbNlaXjo6dbVzTOAh7r7H0bRMEKBVh3dQS7wqjB1sKivpXd8PAS3BTj5MQpGeJzdHnDuwVlwDktGtfHfhGeq1Go/4IosOq8u+6RTe28g=
|
||||
12
BSDmakefile
12
BSDmakefile
@@ -20,22 +20,20 @@ _GENERATOR!=which ninja 2>/dev/null >/dev/null && echo Ninja || echo "Unix Makef
|
||||
GENERATOR?=$(_GENERATOR)
|
||||
|
||||
.if $(GENERATOR) == "Ninja"
|
||||
BUILDFILE=build.ninja
|
||||
BUILDFILE=build/build.ninja
|
||||
.else
|
||||
BUILDFILE=Makefile
|
||||
BUILDFILE=build/Makefile
|
||||
.endif
|
||||
|
||||
PREFIX?=/usr/local
|
||||
|
||||
.PHONY: build/fish
|
||||
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
|
||||
# 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):
|
||||
build:
|
||||
mkdir -p build
|
||||
|
||||
build/$(BUILDFILE): build
|
||||
cd build; $(CMAKE) .. -G "$(GENERATOR)" -DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1
|
||||
|
||||
.PHONY: install
|
||||
|
||||
1999
CHANGELOG.rst
1999
CHANGELOG.rst
File diff suppressed because it is too large
Load Diff
@@ -39,32 +39,30 @@ if (CMAKE_GENERATOR STREQUAL "Ninja" AND
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
||||
endif()
|
||||
|
||||
# Enable a whole bunch of warnings, but turn off:
|
||||
# - implicit fallthrough because that does not recognize some cases where it's desired (and I *really* want this one!)
|
||||
# - comment because we use a bunch of those, and they're not really all that harmful.
|
||||
# - address, because that occurs for our mkostemp check (weak-linking requires us to compare `&mkostemp == nullptr`).
|
||||
# - strict-aliasing, because on old GCCs (*Travis*) those are triggered by maybe.h, so you get it every time it is included.
|
||||
# - redundant-move, because we have one that is required on old libc
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra \
|
||||
-Wno-implicit-fallthrough \
|
||||
-Wno-comment \
|
||||
-Wno-address \
|
||||
-Wno-strict-aliasing \
|
||||
-Wno-redundant-move \
|
||||
")
|
||||
|
||||
# Disable exception handling.
|
||||
add_compile_options(-fno-exceptions)
|
||||
|
||||
# Prefer lld or the gold linker because they don't emit useless warnings about sys_nerr and
|
||||
# _sys_errlist. They're also faster (significantly so in the case of lld).
|
||||
if (UNIX)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version
|
||||
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
||||
if ("${LD_VERSION}" MATCHES "LLD ")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
|
||||
elseif (NOT APPLE)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
|
||||
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
||||
if ("${LD_VERSION}" MATCHES "GNU gold")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
||||
endif()
|
||||
endif()
|
||||
# Prefer the gold linker because it doesn't emit useless warnings about sys_nerr and _sys_errlist.
|
||||
if (UNIX AND NOT APPLE)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
|
||||
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
||||
if ("${LD_VERSION}" MATCHES "GNU gold")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Hide the CMake Rules directories in Xcode projects.
|
||||
@@ -99,31 +97,31 @@ endif()
|
||||
|
||||
# All objects that the system needs to build fish, except fish.cpp
|
||||
set(FISH_SRCS
|
||||
src/ast.cpp src/autoload.cpp src/builtin.cpp src/builtin_argparse.cpp
|
||||
src/builtin_bg.cpp src/builtin_bind.cpp src/builtin_block.cpp
|
||||
src/builtin_builtin.cpp src/builtin_cd.cpp src/builtin_command.cpp
|
||||
src/builtin_commandline.cpp src/builtin_complete.cpp src/builtin_contains.cpp
|
||||
src/builtin_disown.cpp src/builtin_echo.cpp src/builtin_emit.cpp
|
||||
src/builtin_eval.cpp src/builtin_exit.cpp src/builtin_fg.cpp
|
||||
src/builtin_function.cpp src/builtin_functions.cpp src/builtin_history.cpp
|
||||
src/builtin_jobs.cpp src/builtin_math.cpp src/builtin_printf.cpp
|
||||
src/builtin_pwd.cpp src/builtin_random.cpp src/builtin_read.cpp
|
||||
src/builtin_realpath.cpp src/builtin_return.cpp src/builtin_set.cpp
|
||||
src/builtin_set_color.cpp src/builtin_source.cpp src/builtin_status.cpp
|
||||
src/builtin_string.cpp src/builtin_test.cpp src/builtin_type.cpp src/builtin_ulimit.cpp
|
||||
src/builtin_wait.cpp src/color.cpp src/common.cpp src/complete.cpp src/env.cpp
|
||||
src/env_dispatch.cpp src/env_universal_common.cpp src/event.cpp src/exec.cpp
|
||||
src/expand.cpp src/fallback.cpp src/fd_monitor.cpp src/fish_version.cpp
|
||||
src/flog.cpp src/function.cpp src/future_feature_flags.cpp src/highlight.cpp
|
||||
src/history.cpp src/history_file.cpp src/input.cpp src/input_common.cpp
|
||||
src/intern.cpp src/io.cpp src/iothread.cpp src/job_group.cpp src/kill.cpp
|
||||
src/null_terminated_array.cpp src/operation_context.cpp src/output.cpp
|
||||
src/pager.cpp src/parse_execution.cpp src/parse_tree.cpp src/parse_util.cpp
|
||||
src/parser.cpp src/parser_keywords.cpp src/path.cpp src/postfork.cpp
|
||||
src/proc.cpp src/reader.cpp src/redirection.cpp src/sanity.cpp src/screen.cpp
|
||||
src/signal.cpp src/termsize.cpp src/timer.cpp src/tinyexpr.cpp
|
||||
src/tokenizer.cpp src/topic_monitor.cpp src/trace.cpp src/utf8.cpp src/util.cpp
|
||||
src/wcstringutil.cpp src/wgetopt.cpp src/wildcard.cpp src/wutil.cpp src/fds.cpp
|
||||
src/autoload.cpp src/builtin.cpp src/builtin_bg.cpp src/builtin_bind.cpp
|
||||
src/builtin_block.cpp src/builtin_builtin.cpp src/builtin_cd.cpp
|
||||
src/builtin_command.cpp src/builtin_commandline.cpp
|
||||
src/builtin_complete.cpp src/builtin_contains.cpp src/builtin_disown.cpp
|
||||
src/builtin_echo.cpp src/builtin_emit.cpp src/builtin_exit.cpp
|
||||
src/builtin_fg.cpp src/builtin_function.cpp src/builtin_functions.cpp
|
||||
src/builtin_argparse.cpp src/builtin_history.cpp src/builtin_jobs.cpp
|
||||
src/builtin_math.cpp src/builtin_printf.cpp src/builtin_pwd.cpp
|
||||
src/builtin_random.cpp src/builtin_read.cpp src/builtin_realpath.cpp
|
||||
src/builtin_return.cpp src/builtin_set.cpp src/builtin_set_color.cpp
|
||||
src/builtin_source.cpp src/builtin_status.cpp src/builtin_string.cpp
|
||||
src/builtin_test.cpp src/builtin_ulimit.cpp src/builtin_wait.cpp src/builtin_eval.cpp
|
||||
src/color.cpp src/common.cpp src/complete.cpp src/env.cpp src/env_dispatch.cpp
|
||||
src/env_universal_common.cpp src/event.cpp src/exec.cpp src/expand.cpp
|
||||
src/fallback.cpp src/fish_version.cpp src/function.cpp src/highlight.cpp
|
||||
src/history.cpp src/history_file.cpp src/input.cpp src/input_common.cpp src/intern.cpp
|
||||
src/io.cpp src/iothread.cpp src/kill.cpp src/output.cpp src/pager.cpp
|
||||
src/parse_execution.cpp src/parse_productions.cpp src/parse_tree.cpp
|
||||
src/parse_util.cpp src/parser.cpp src/parser_keywords.cpp src/path.cpp
|
||||
src/postfork.cpp src/proc.cpp src/reader.cpp src/sanity.cpp src/screen.cpp
|
||||
src/signal.cpp src/tinyexpr.cpp src/tnode.cpp src/tokenizer.cpp src/utf8.cpp src/util.cpp
|
||||
src/wcstringutil.cpp src/wgetopt.cpp src/wildcard.cpp src/wutil.cpp
|
||||
src/future_feature_flags.cpp src/redirection.cpp src/topic_monitor.cpp
|
||||
src/flog.cpp src/trace.cpp src/timer.cpp src/null_terminated_array.cpp
|
||||
src/operation_context.cpp src/fd_monitor.cpp src/termsize.cpp
|
||||
)
|
||||
|
||||
# Header files are just globbed.
|
||||
@@ -180,8 +178,6 @@ target_sources(fishlib PRIVATE ${FISH_HEADERS})
|
||||
target_link_libraries(fishlib
|
||||
${CURSES_LIBRARY} ${CURSES_EXTRA_LIBRARY} Threads::Threads ${CMAKE_DL_LIBS}
|
||||
${PCRE2_LIB} ${Intl_LIBRARIES} ${ATOMIC_LIBRARY})
|
||||
target_include_directories(fishlib PRIVATE
|
||||
${CURSES_INCLUDE_DIRS})
|
||||
|
||||
# Define fish.
|
||||
add_executable(fish src/fish.cpp)
|
||||
@@ -215,15 +211,6 @@ include(cmake/Install.cmake)
|
||||
# Mac app.
|
||||
include(cmake/MacApp.cmake)
|
||||
|
||||
# ThreadSanitizer likes to muck with signal handlers, which interferes
|
||||
# with fish_test_helper printing the ignored signal mask.
|
||||
# Ensure fish_test_helper does not use TSan.
|
||||
# Note the environment var is CXXFLAGS, but the CMake var is CMAKE_CXX_FLAGS.
|
||||
if (CMAKE_CXX_FLAGS MATCHES ".*-fsanitize=thread.*")
|
||||
target_compile_options(fish_test_helper PRIVATE "-fno-sanitize=all")
|
||||
target_link_libraries(fish_test_helper "-fno-sanitize=all")
|
||||
endif()
|
||||
|
||||
# Lint targets
|
||||
# This could be implemented as target properties, but the script has the useful feature of only
|
||||
# checking the currently-staged commands
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
|
||||
208
CONTRIBUTING.rst
208
CONTRIBUTING.rst
@@ -3,29 +3,63 @@ Guidelines For Developers
|
||||
|
||||
This document provides guidelines for making changes to the fish-shell
|
||||
project. This includes rules for how to format the code, naming
|
||||
conventions, et cetera.
|
||||
conventions, et cetera. Generally known as the style of the code. It
|
||||
also includes recommended best practices such as creating a Travis CI
|
||||
account so you can verify that your changes pass all the tests before
|
||||
making a pull request.
|
||||
|
||||
In short:
|
||||
See the bottom of this document for help on installing the linting and
|
||||
style reformatting tools discussed in the following sections.
|
||||
|
||||
- Be conservative in what you need (``C++11``, few dependencies)
|
||||
- Use automated tools to help you (including ``make test``, ``build_tools/style.fish`` and ``make lint``)
|
||||
Fish source should limit the C++ features it uses to those available in
|
||||
C++11. It should not use exceptions.
|
||||
|
||||
General
|
||||
-------
|
||||
Before introducing a new dependency, please make it optional with
|
||||
graceful failure if possible. Add any new dependencies to the README.rst
|
||||
under the *Running* and/or *Building* sections.
|
||||
|
||||
Fish uses C++11. Newer C++ features should not be used to make it possible to use on older systems.
|
||||
Versioning
|
||||
----------
|
||||
|
||||
It does not use exceptions, they are disabled at build time with ``-fno-exceptions``.
|
||||
The fish version is constructed by the *build_tools/git_version_gen.sh*
|
||||
script. For developers the version is the branch name plus the output of
|
||||
``git describe --always --dirty``. Normally the main part of the version
|
||||
will be the closest annotated tag. Which itself is usually the most
|
||||
recent release number (e.g., ``2.6.0``).
|
||||
|
||||
Don't introduce new dependencies unless absolutely necessary, and if you do,
|
||||
please make it optional with graceful failure if possible.
|
||||
Add any new dependencies to the README.rst under the *Running* and/or *Building* sections.
|
||||
Include What You Use
|
||||
--------------------
|
||||
|
||||
This also goes for completion scripts and functions - if at all possible, they should only use
|
||||
POSIX-compatible invocations of any tools, and no superfluous dependencies.
|
||||
You should not depend on symbols being visible to a ``*.cpp`` module
|
||||
from ``#include`` statements inside another header file. In other words
|
||||
if your module does ``#include "common.h"`` and that header does
|
||||
``#include "signal.h"`` your module should not assume the sub-include is
|
||||
present. It should instead directly ``#include "signal.h"`` if it needs
|
||||
any symbol from that header. That makes the actual dependencies much
|
||||
clearer. It also makes it easy to modify the headers included by a
|
||||
specific header file without having to worry that will break any module
|
||||
(or header) that includes a particular header.
|
||||
|
||||
E.g. some completions deal with JSON data. In those it's preferable to use python to handle it,
|
||||
as opposed to ``jq``, because fish already optionally uses python elsewhere. (It also happens to be quite a bit *faster*)
|
||||
To help enforce this rule the ``make lint`` (and ``make lint-all``)
|
||||
command will run the
|
||||
`include-what-you-use <https://include-what-you-use.org/>`__ tool. You
|
||||
can find the IWYU project on
|
||||
`github <https://github.com/include-what-you-use/include-what-you-use>`__.
|
||||
|
||||
To install the tool on OS X you’ll need to add a
|
||||
`formula <https://github.com/jasonmp85/homebrew-iwyu>`__ then install
|
||||
it:
|
||||
|
||||
::
|
||||
|
||||
brew tap jasonmp85/iwyu
|
||||
brew install iwyu
|
||||
|
||||
On Ubuntu you can install it via ``apt-get``:
|
||||
|
||||
::
|
||||
|
||||
sudo apt-get install iwyu
|
||||
|
||||
Lint Free Code
|
||||
--------------
|
||||
@@ -35,6 +69,10 @@ potential bugs or code that is extremely hard to understand. They also
|
||||
help ensure the code has a consistent style and that it avoids patterns
|
||||
that tend to confuse people.
|
||||
|
||||
Ultimately we want lint free code. However, at the moment a lot of
|
||||
cleanup is required to reach that goal. For now simply try to avoid
|
||||
introducing new lint.
|
||||
|
||||
To make linting the code easy there are two make targets: ``lint`` and
|
||||
``lint-all``. The latter does exactly what the name implies. The former
|
||||
will lint any modified but not committed ``*.cpp`` files. If there is no
|
||||
@@ -45,6 +83,8 @@ help catch mistakes such as using ``wcwidth()`` rather than
|
||||
``fish_wcwidth()``. Please add a new rule if you find similar mistakes
|
||||
being made.
|
||||
|
||||
Fish also depends on ``diff`` and ``expect`` for its tests.
|
||||
|
||||
Dealing With Lint Warnings
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -111,10 +151,10 @@ changes.
|
||||
Configuring Your Editor for Fish C++ Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Vim
|
||||
ViM
|
||||
^^^
|
||||
|
||||
As of Vim 7.4 it does not recognize triple-slash comments as used by
|
||||
As of ViM 7.4 it does not recognize triple-slash comments as used by
|
||||
Doxygen and the OS X Xcode IDE to flag comments that explain the
|
||||
following C symbol. This means the ``gq`` key binding to reformat such
|
||||
comments doesn’t behave as expected. You can fix that by adding the
|
||||
@@ -124,10 +164,15 @@ following to your vimrc:
|
||||
|
||||
autocmd Filetype c,cpp setlocal comments^=:///
|
||||
|
||||
If you use Vim I recommend the `vim-clang-format
|
||||
If you use ViM I recommend the `vim-clang-format
|
||||
plugin <https://github.com/rhysd/vim-clang-format>`__ by
|
||||
[@rhysd](https://github.com/rhysd).
|
||||
|
||||
You can also get ViM to provide reasonably correct behavior by
|
||||
installing
|
||||
|
||||
http://www.vim.org/scripts/script.php?script_id=2636
|
||||
|
||||
Emacs
|
||||
^^^^^
|
||||
|
||||
@@ -136,7 +181,7 @@ If you use Emacs: TBD
|
||||
Configuring Your Editor for Fish Scripts
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If you use Vim: Install `vim-fish <https://github.com/dag/vim-fish>`__,
|
||||
If you use ViM: Install `vim-fish <https://github.com/dag/vim-fish>`__,
|
||||
make sure you have syntax and filetype functionality in ``~/.vimrc``:
|
||||
|
||||
::
|
||||
@@ -172,8 +217,8 @@ made to run fish_indent via e.g.
|
||||
Suppressing Reformatting of C++ Code
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can tell ``clang-format`` to not reformat a block by enclosing it in
|
||||
comments like this:
|
||||
If you have a good reason for doing so you can tell ``clang-format`` to
|
||||
not reformat a block of code by enclosing it in comments like this:
|
||||
|
||||
::
|
||||
|
||||
@@ -181,6 +226,10 @@ comments like this:
|
||||
code to ignore
|
||||
// clang-format on
|
||||
|
||||
However, as I write this there are no places in the code where we use
|
||||
this and I can’t think of any legitimate reasons for exempting blocks of
|
||||
code from clang-format.
|
||||
|
||||
Fish Script Style Guide
|
||||
-----------------------
|
||||
|
||||
@@ -242,27 +291,16 @@ Testing
|
||||
-------
|
||||
|
||||
The source code for fish includes a large collection of tests. If you
|
||||
are making any changes to fish, running these tests is a good way to make
|
||||
are making any changes to fish, running these tests is mandatory to make
|
||||
sure the behaviour remains consistent and regressions are not
|
||||
introduced. Even if you don’t run the tests on your machine, they will
|
||||
still be run via Github Actions.
|
||||
still be run via the `Travis
|
||||
CI <https://travis-ci.org/fish-shell/fish-shell>`__ service.
|
||||
|
||||
You are strongly encouraged to add tests when changing the functionality
|
||||
of fish, especially if you are fixing a bug to help ensure there are no
|
||||
regressions in the future (i.e., we don’t reintroduce the bug).
|
||||
|
||||
The tests can be found in three places:
|
||||
|
||||
- src/fish_tests.cpp for tests to the core C++ code
|
||||
- tests/checks for script tests, run by `littlecheck <https://github.com/ridiculousfish/littlecheck>`__
|
||||
- tests/pexpects for interactive tests using `pexpect <https://pexpect.readthedocs.io/en/stable/>`__
|
||||
|
||||
When in doubt, the bulk of the tests should be added as a littlecheck test in tests/checks, as they are the easiest to modify and run, and much faster and more dependable than pexpect tests. The syntax is fairly self-explanatory. It's a fish script with the expected output in ``# CHECK:`` or ``# CHECKERR:`` (for stderr) comments.
|
||||
|
||||
fish_tests.cpp is mostly useful for unit tests - if you wish to test that a function does the correct thing for given input, use it.
|
||||
|
||||
The pexpects are written in python and can simulate input and output to/from a terminal, so they are needed for anything that needs actual interactivity. The runner is in build_tools/pexpect_helper.py, in case you need to modify something there.
|
||||
|
||||
Local testing
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@@ -273,6 +311,32 @@ The tests can be run on your local computer on all operating systems.
|
||||
cmake path/to/fish-shell
|
||||
make test
|
||||
|
||||
Travis CI Build and Test
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The Travis Continuous Integration services can be used to test your
|
||||
changes using multiple configurations. This is the same service that the
|
||||
fish-shell project uses to ensure new changes haven’t broken anything.
|
||||
Thus it is a really good idea that you leverage Travis CI before making
|
||||
a pull request to avoid potential embarrassment at breaking the build.
|
||||
|
||||
You will need to `fork the fish-shell repository on
|
||||
GitHub <https://help.github.com/articles/fork-a-repo/>`__, then setup
|
||||
Travis to test your changes before making a pull request.
|
||||
|
||||
1. `Sign in to Travis CI <https://travis-ci.org/auth>`__ with your
|
||||
GitHub account, accepting the GitHub access permissions confirmation.
|
||||
2. Once you’re signed in and your repositories are synchronized, go to
|
||||
your `profile page <https://travis-ci.org/profile>`__ and enable the
|
||||
fish-shell repository.
|
||||
3. Push your changes to GitHub.
|
||||
|
||||
You’ll receive an email when the tests are complete telling you whether
|
||||
or not any tests failed.
|
||||
|
||||
You’ll find the configuration used to control Travis in the
|
||||
``.travis.yml`` file.
|
||||
|
||||
Git hooks
|
||||
~~~~~~~~~
|
||||
|
||||
@@ -349,7 +413,7 @@ To install the lint checkers on Debian-based Linux distributions:
|
||||
sudo apt-get install oclint
|
||||
sudo apt-get install cppcheck
|
||||
|
||||
Installing the Formatting Tools
|
||||
Installing the Reformatting Tools
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Mac OS X:
|
||||
@@ -362,7 +426,15 @@ Debian-based:
|
||||
|
||||
::
|
||||
|
||||
sudo apt-get install clang-format
|
||||
apt-cache search clang-format
|
||||
|
||||
Above will list all the versions available. Pick the newest one
|
||||
available (3.9 for Ubuntu 16.10 as I write this) and install it:
|
||||
|
||||
::
|
||||
|
||||
sudo apt-get install clang-format-3.9
|
||||
sudo ln -s /usr/bin/clang-format-3.9 /usr/bin/clang-format
|
||||
|
||||
Message Translations
|
||||
--------------------
|
||||
@@ -404,19 +476,14 @@ stored in the ``po`` directory, named ``LANG.po``, where ``LANG`` is the
|
||||
two letter ISO 639-1 language code of the target language (eg ``de`` for
|
||||
German).
|
||||
|
||||
To create a new translation, for example for German:
|
||||
To create a new translation, for example for German: \* generate a
|
||||
``messages.pot`` file by running ``build_tools/fish_xgettext.fish`` from
|
||||
the source tree \* copy ``messages.pot`` to ``po/LANG.po`` ()
|
||||
|
||||
* generate a ``messages.pot`` file by running ``build_tools/fish_xgettext.fish`` from
|
||||
the source tree
|
||||
* copy ``messages.pot`` to ``po/LANG.po``
|
||||
|
||||
To update a translation:
|
||||
|
||||
* generate a ``messages.pot`` file by running
|
||||
``build_tools/fish_xgettext.fish`` from the source tree
|
||||
|
||||
* update the existing translation by running
|
||||
``msgmerge --update --no-fuzzy-matching po/LANG.po messages.pot``
|
||||
To update a translation: \* generate a ``messages.pot`` file by running
|
||||
``build_tools/fish_xgettext.fish`` from the source tree \* update the
|
||||
existing translation by running
|
||||
``msgmerge --update --no-fuzzy-matching po/LANG.po messages.pot``
|
||||
|
||||
Many tools are available for editing translation files, including
|
||||
command-line and graphical user interface programs.
|
||||
@@ -430,46 +497,3 @@ recommended deletions.
|
||||
Read the `translations
|
||||
wiki <https://github.com/fish-shell/fish-shell/wiki/Translations>`__ for
|
||||
more information.
|
||||
|
||||
Versioning
|
||||
----------
|
||||
|
||||
The fish version is constructed by the *build_tools/git_version_gen.sh*
|
||||
script. For developers the version is the branch name plus the output of
|
||||
``git describe --always --dirty``. Normally the main part of the version
|
||||
will be the closest annotated tag. Which itself is usually the most
|
||||
recent release number (e.g., ``2.6.0``).
|
||||
|
||||
Include What You Use
|
||||
--------------------
|
||||
|
||||
You should not depend on symbols being visible to a ``*.cpp`` module
|
||||
from ``#include`` statements inside another header file. In other words
|
||||
if your module does ``#include "common.h"`` and that header does
|
||||
``#include "signal.h"`` your module should not assume the sub-include is
|
||||
present. It should instead directly ``#include "signal.h"`` if it needs
|
||||
any symbol from that header. That makes the actual dependencies much
|
||||
clearer. It also makes it easy to modify the headers included by a
|
||||
specific header file without having to worry that will break any module
|
||||
(or header) that includes a particular header.
|
||||
|
||||
To help enforce this rule the ``make lint`` (and ``make lint-all``)
|
||||
command will run the
|
||||
`include-what-you-use <https://include-what-you-use.org/>`__ tool. You
|
||||
can find the IWYU project on
|
||||
`github <https://github.com/include-what-you-use/include-what-you-use>`__.
|
||||
|
||||
To install the tool on OS X you’ll need to add a
|
||||
`formula <https://github.com/jasonmp85/homebrew-iwyu>`__ then install
|
||||
it:
|
||||
|
||||
::
|
||||
|
||||
brew tap jasonmp85/iwyu
|
||||
brew install iwyu
|
||||
|
||||
On Ubuntu you can install it via ``apt-get``:
|
||||
|
||||
::
|
||||
|
||||
sudo apt-get install iwyu
|
||||
|
||||
2
COPYING
2
COPYING
@@ -12,7 +12,7 @@ published by the Free Software Foundation.
|
||||
fish also includes software licensed under the GNU Lesser General Public
|
||||
License version 2, the OpenBSD license, the ISC license, and the NetBSD license.
|
||||
|
||||
Full licensing information is contained in doc_src/license.rst.
|
||||
Full licensing information is contained in doc_src/license.hdr.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
|
||||
@@ -31,19 +31,16 @@ else
|
||||
|
||||
all: .begin build/fish
|
||||
|
||||
.PHONY: .begin
|
||||
PHONY: .begin
|
||||
.begin:
|
||||
@which $(CMAKE) > /dev/null 2> /dev/null || \
|
||||
(echo 'Please install CMake and then re-run the `make` command!' 1>&2 && false)
|
||||
|
||||
.PHONY: build/fish
|
||||
build/fish: build/$(BUILDFILE)
|
||||
$(CMAKE) --build build
|
||||
|
||||
# Use build as an order-only dependency. This prevents the target from always being outdated
|
||||
# after a make run, and more importantly, doesn't clobber manually specified CMake options.
|
||||
build/$(BUILDFILE): | build
|
||||
cd build; $(CMAKE) .. -G "$(GENERATOR)" \
|
||||
build/$(BUILDFILE): build
|
||||
cd build; $(CMAKE) .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -G "$(GENERATOR)" \
|
||||
-DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1
|
||||
|
||||
build:
|
||||
|
||||
19
README.rst
19
README.rst
@@ -92,9 +92,9 @@ Running fish requires:
|
||||
- some common \*nix system utilities (currently ``mktemp``), in
|
||||
addition to the basic POSIX utilities (``cat``, ``cut``, ``dirname``,
|
||||
``ls``, ``mkdir``, ``mkfifo``, ``rm``, ``sort``, ``tee``, ``tr``,
|
||||
``uname`` and ``sed`` at least, but the full coreutils plus ``find`` and
|
||||
``awk`` is preferred)
|
||||
- The gettext library, if compiled with
|
||||
``uname`` and ``sed`` at least, but the full coreutils plus find, sed
|
||||
and awk is preferred)
|
||||
- gettext (library and ``gettext`` command), if compiled with
|
||||
translation support
|
||||
|
||||
The following optional features also have specific requirements:
|
||||
@@ -102,8 +102,11 @@ The following optional features also have specific requirements:
|
||||
- builtin commands that have the ``--help`` option or print usage
|
||||
messages require ``ul`` and either ``nroff`` or ``mandoc`` for
|
||||
display
|
||||
- automated completion generation from manual pages requires Python 3.5+
|
||||
- the ``fish_config`` web configuration tool requires Python 3.5+ and a web browser
|
||||
- automated completion generation from manual pages requires Python
|
||||
(2.7+ or 3.3+) and possibly the ``backports.lzma`` module for Python
|
||||
2.7
|
||||
- the ``fish_config`` web configuration tool requires Python (2.7+ or
|
||||
3.3 +) and a web browser
|
||||
- system clipboard integration (with the default Ctrl-V and Ctrl-X
|
||||
bindings) require either the ``xsel``, ``xclip``,
|
||||
``wl-copy``/``wl-paste`` or ``pbcopy``/``pbpaste`` utilities
|
||||
@@ -155,8 +158,6 @@ Compiling fish requires:
|
||||
Sphinx is also optionally required to build the documentation from a
|
||||
cloned git repository.
|
||||
|
||||
Additionally, running the test suite requires Python 3.5+ and the pexpect package.
|
||||
|
||||
Building from source (all platforms) - Makefile generator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -231,7 +232,7 @@ questions (e.g., customizing colors, changing key bindings).
|
||||
Found a bug? Have an awesome idea? Please `open an
|
||||
issue <https://github.com/fish-shell/fish-shell/issues/new>`__.
|
||||
|
||||
.. |Build Status| image:: https://github.com/fish-shell/fish-shell/workflows/C/C++%20CI/badge.svg
|
||||
:target: https://github.com/fish-shell/fish-shell/actions
|
||||
.. |Build Status| image:: https://travis-ci.org/fish-shell/fish-shell.svg?branch=master
|
||||
:target: https://travis-ci.org/fish-shell/fish-shell
|
||||
.. |Try in browser| image:: https://cdn.rawgit.com/rootnroll/library/assets/try.svg
|
||||
:target: https://rootnroll.com/d/fish-shell/
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
for i in (seq 100000)
|
||||
math $i + $i
|
||||
end
|
||||
@@ -1,3 +1,3 @@
|
||||
for i in (seq 10000)
|
||||
for i in (seq 1000)
|
||||
echo $i
|
||||
end
|
||||
|
||||
@@ -1,29 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$#" -gt 2 -o "$#" -eq 0 ]; then
|
||||
echo "Usage: driver.sh /path/to/fish [/path/to/other/fish]"
|
||||
exit 1
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: driver.sh /path/to/fish"
|
||||
fi
|
||||
|
||||
FISH_PATH=$1
|
||||
FISH2_PATH=$2
|
||||
BENCHMARKS_DIR=$(dirname "$0")/benchmarks
|
||||
|
||||
for benchmark in "$BENCHMARKS_DIR"/*; do
|
||||
basename "$benchmark"
|
||||
[ -n "$FISH2_PATH" ] && echo "$FISH_PATH"
|
||||
${FISH_PATH} --print-rusage-self "$benchmark" > /dev/null
|
||||
if [ -n "$FISH2_PATH" ]; then
|
||||
echo "$FISH2_PATH"
|
||||
${FISH2_PATH} --print-rusage-self "$benchmark" > /dev/null
|
||||
fi
|
||||
|
||||
if command -v hyperfine >/dev/null 2>&1; then
|
||||
if [ -n "$FISH2_PATH" ]; then
|
||||
hyperfine "${FISH_PATH} $benchmark > /dev/null" "${FISH2_PATH} $benchmark > /dev/null"
|
||||
else
|
||||
hyperfine "${FISH_PATH} $benchmark > /dev/null"
|
||||
fi
|
||||
hyperfine "${FISH_PATH} $benchmark > /dev/null"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
mac_xar_116 is http://mackyle.github.io/xar/, compiled for Mac. It is used by mac_sign_package.sh as a replacement for productsign.
|
||||
Binary file not shown.
@@ -1,7 +1,3 @@
|
||||
#!/bin/sh
|
||||
#!/usr/local/bin/fish
|
||||
|
||||
cppcheck --std=posix --quiet \
|
||||
--suppressions-list=build_tools/cppcheck.suppressions --inline-suppr \
|
||||
--rule-file=build_tools/cppcheck.rules \
|
||||
--force \
|
||||
${@:---enable=all ./src/}
|
||||
cppcheck --enable=all --std=posix --quiet ./src/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env fish
|
||||
#
|
||||
# Tool to generate messages.pot
|
||||
# Extended to replace the old Makefile rule which did not port easily to CMake
|
||||
# Extended to replace the old Makefile rule which did not port easily to CMak
|
||||
|
||||
# This script was originally motivated to work around a quirk (or bug depending on your viewpoint)
|
||||
# of the xgettext command. See https://lists.gnu.org/archive/html/bug-gettext/2014-11/msg00006.html.
|
||||
@@ -22,39 +22,34 @@ set -l implicit_regex '(?:^| +)(?:complete|function).*? (?:-d|--description) (([
|
||||
# than messages which should be implicitly translated.
|
||||
set -l explicit_regex '.*\( *_ (([\'"]).+?(?<!\\\\)\\2) *\).*'
|
||||
|
||||
# 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
|
||||
rm -r /tmp/fish
|
||||
|
||||
mkdir -p $tmpdir/implicit/share/completions $tmpdir/implicit/share/functions
|
||||
mkdir -p $tmpdir/explicit/share/completions $tmpdir/explicit/share/functions
|
||||
mkdir -p /tmp/fish/implicit/share/completions /tmp/fish/implicit/share/functions
|
||||
mkdir -p /tmp/fish/explicit/share/completions /tmp/fish/explicit/share/functions
|
||||
|
||||
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 'echo $1' <$f | fish >$tmpdir/explicit/$f.tmp 2>/dev/null
|
||||
string replace --filter --regex $explicit_regex 'echo $1' <$f | fish >/tmp/fish/explicit/$f.tmp ^/dev/null
|
||||
while read description
|
||||
echo 'N_ "'(string replace --all '"' '\\"' -- $description)'"'
|
||||
end <$tmpdir/explicit/$f.tmp >$tmpdir/explicit/$f
|
||||
rm $tmpdir/explicit/$f.tmp
|
||||
end </tmp/fish/explicit/$f.tmp >/tmp/fish/explicit/$f
|
||||
rm /tmp/fish/explicit/$f.tmp
|
||||
|
||||
# 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 'echo $1' <$f | fish >$tmpdir/implicit/$f.tmp 2>/dev/null
|
||||
string replace --filter --regex $implicit_regex 'echo $1' <$f | fish >/tmp/fish/implicit/$f.tmp ^/dev/null
|
||||
while read description
|
||||
# We don't use `string escape` as shown in the next comment because it produces output that
|
||||
# is not parsed correctly by xgettext. Instead just escape double-quotes and quote the
|
||||
# resulting string.
|
||||
echo 'N_ "'(string replace --all '"' '\\"' -- $description)'"'
|
||||
end <$tmpdir/implicit/$f.tmp >$tmpdir/implicit/$f
|
||||
rm $tmpdir/implicit/$f.tmp
|
||||
end </tmp/fish/implicit/$f.tmp >/tmp/fish/implicit/$f
|
||||
rm /tmp/fish/implicit/$f.tmp
|
||||
end
|
||||
|
||||
xgettext -j -k -kN_ -LShell --from-code=UTF-8 -cDescription --no-wrap -o messages.pot $tmpdir/explicit/share/*/*.fish
|
||||
xgettext -j -k -kN_ -LShell --from-code=UTF-8 -cDescription --no-wrap -o messages.pot $tmpdir/implicit/share/*/*.fish
|
||||
xgettext -j -k -kN_ -LShell --from-code=UTF-8 -cDescription --no-wrap -o messages.pot /tmp/fish/explicit/share/*/*.fish
|
||||
xgettext -j -k -kN_ -LShell --from-code=UTF-8 -cDescription --no-wrap -o messages.pot /tmp/fish/implicit/share/*/*.fish
|
||||
|
||||
rm -r $tmpdir
|
||||
rm -r /tmp/fish
|
||||
|
||||
@@ -18,11 +18,11 @@ argparse a/all p/project= -- $argv
|
||||
# We only want -D and -I options to be passed thru to cppcheck.
|
||||
for arg in $argv
|
||||
if string match -q -- '-D*' $arg
|
||||
set -a cppcheck_args (string split -- ' ' $arg)
|
||||
set cppcheck_args $cppcheck_args $arg
|
||||
else if string match -q -- '-I*' $arg
|
||||
set -a cppcheck_args (string split -- ' ' $arg)
|
||||
set cppcheck_args $cppcheck_args $arg
|
||||
else if string match -q -- '-iquote*' $arg
|
||||
set -a cppcheck_args (string split -- ' ' $arg)
|
||||
set cppcheck_args $cppcheck_args $arg
|
||||
end
|
||||
end
|
||||
|
||||
@@ -83,7 +83,20 @@ if set -q c_files[1]
|
||||
echo ========================================
|
||||
echo Running cppcheck
|
||||
echo ========================================
|
||||
build_tools/cppcheck.sh --enable=$cppchecks $c_files 2>&1
|
||||
# The stderr to stdout redirection is because cppcheck, incorrectly IMHO, writes its
|
||||
# diagnostic messages to stderr. Anyone running this who wants to capture its output will
|
||||
# expect those messages to be written to stdout.
|
||||
set -l cn (set_color normal)
|
||||
set -l cb (set_color --bold)
|
||||
set -l cu (set_color --underline)
|
||||
set -l cm (set_color magenta)
|
||||
set -l cbrm (set_color brmagenta)
|
||||
set -l template "[$cb$cu{file}$cn$cb:{line}$cn] $cbrm{severity}$cm ({id}):$cn\n {message}"
|
||||
set cppcheck_args -q --verbose --std=c++11 --std=posix --language=c++ --template $template \
|
||||
--suppress=missingIncludeSystem --inline-suppr --enable=$cppchecks \
|
||||
--rule-file=.cppcheck.rules --suppressions-list=.cppcheck.suppressions $cppcheck_args
|
||||
|
||||
cppcheck $cppcheck_args $c_files 2>&1
|
||||
|
||||
echo
|
||||
echo ========================================
|
||||
|
||||
@@ -13,9 +13,7 @@ if not contains -- $TAG (git tag)
|
||||
end
|
||||
|
||||
set -l committers_to_tag (mktemp)
|
||||
or exit 1
|
||||
set -l committers_from_tag (mktemp)
|
||||
or exit 1
|
||||
|
||||
# You might think it would be better to case-insensitively sort/compare the names
|
||||
# to produce a more natural-looking list.
|
||||
|
||||
@@ -14,26 +14,15 @@ import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
try:
|
||||
from itertools import zip_longest
|
||||
except ImportError:
|
||||
from itertools import izip_longest as zip_longest
|
||||
from difflib import SequenceMatcher
|
||||
|
||||
# Directives can occur at the beginning of a line, or anywhere in a line that does not start with #.
|
||||
COMMENT_RE = r"^(?:[^#].*)?#\s*"
|
||||
|
||||
# A regex showing how to run the file.
|
||||
RUN_RE = re.compile(COMMENT_RE + r"RUN:\s+(.*)\n")
|
||||
REQUIRES_RE = re.compile(COMMENT_RE + r"REQUIRES:\s+(.*)\n")
|
||||
RUN_RE = re.compile(r"\s*#\s*RUN:\s+(.*)\n")
|
||||
|
||||
# A regex capturing lines that should be checked against stdout.
|
||||
CHECK_STDOUT_RE = re.compile(COMMENT_RE + r"CHECK:\s+(.*)\n")
|
||||
CHECK_STDOUT_RE = re.compile(r"\s*#\s*CHECK:\s+(.*)\n")
|
||||
|
||||
# A regex capturing lines that should be checked against stderr.
|
||||
CHECK_STDERR_RE = re.compile(COMMENT_RE + r"CHECKERR:\s+(.*)\n")
|
||||
CHECK_STDERR_RE = re.compile(r"\s*#\s*CHECKERR:\s+(.*)\n")
|
||||
|
||||
SKIP = object()
|
||||
|
||||
class Config(object):
|
||||
def __init__(self):
|
||||
@@ -43,6 +32,10 @@ class Config(object):
|
||||
self.colorize = False
|
||||
# Whether to show which file was tested.
|
||||
self.progress = False
|
||||
# How many after lines to print
|
||||
self.after = 5
|
||||
# How many before lines to print
|
||||
self.before = 5
|
||||
|
||||
def colors(self):
|
||||
""" Return a dictionary mapping color names to ANSI escapes """
|
||||
@@ -125,26 +118,6 @@ class Line(object):
|
||||
self.number = number
|
||||
self.file = file
|
||||
|
||||
def __hash__(self):
|
||||
# Chosen by fair diceroll
|
||||
# No, just kidding.
|
||||
# HACK: We pass this to the Sequencematcher, which puts the Checks into a dict.
|
||||
# To force it to match the regexes, we return a hash collision intentionally,
|
||||
# so it falls back on __eq__().
|
||||
#
|
||||
# CheckCmd has the same thing.
|
||||
return 0
|
||||
|
||||
def __eq__(self, other):
|
||||
if other is None:
|
||||
return False
|
||||
if isinstance(other, CheckCmd):
|
||||
return other.regex.match(self.text)
|
||||
if isinstance(other, Line):
|
||||
# We only compare the text here so SequenceMatcher can reshuffle these
|
||||
return self.text == other.text
|
||||
raise NotImplementedError
|
||||
|
||||
def subline(self, text):
|
||||
""" Return a substring of our line with the given text, preserving number and file. """
|
||||
return Line(text, self.number, self.file)
|
||||
@@ -156,16 +129,10 @@ class Line(object):
|
||||
def is_empty_space(self):
|
||||
return not self.text or self.text.isspace()
|
||||
|
||||
def escaped_text(self, for_formatting=False):
|
||||
ret = escape_string(self.text.rstrip("\n"))
|
||||
if for_formatting:
|
||||
ret = ret.replace("{", "{{").replace("}", "}}")
|
||||
return ret
|
||||
|
||||
|
||||
class RunCmd(object):
|
||||
"""A command to run on a given Checker.
|
||||
|
||||
""" A command to run on a given Checker.
|
||||
|
||||
Attributes:
|
||||
args: Unexpanded shell command as a string.
|
||||
"""
|
||||
@@ -182,16 +149,17 @@ class RunCmd(object):
|
||||
|
||||
|
||||
class TestFailure(object):
|
||||
def __init__(self, line, check, testrun, diff=None, lines=[], checks=[]):
|
||||
def __init__(self, line, check, testrun, before=None, after=None):
|
||||
self.line = line
|
||||
self.check = check
|
||||
self.testrun = testrun
|
||||
self.error_annotation_lines = None
|
||||
self.diff = diff
|
||||
self.lines = lines
|
||||
self.checks = checks
|
||||
self.error_annotation_line = None
|
||||
# The output that comes *after* the failure.
|
||||
self.after = after
|
||||
self.before = before
|
||||
|
||||
def message(self):
|
||||
afterlines = self.testrun.config.after
|
||||
fields = self.testrun.config.colors()
|
||||
fields["name"] = self.testrun.name
|
||||
fields["subbed_command"] = self.testrun.subbed_command
|
||||
@@ -200,7 +168,7 @@ class TestFailure(object):
|
||||
{
|
||||
"output_file": self.line.file,
|
||||
"output_lineno": self.line.number,
|
||||
"output_line": self.line.escaped_text(),
|
||||
"output_line": self.line.text.rstrip("\n"),
|
||||
}
|
||||
)
|
||||
if self.check:
|
||||
@@ -208,7 +176,7 @@ class TestFailure(object):
|
||||
{
|
||||
"input_file": self.check.line.file,
|
||||
"input_lineno": self.check.line.number,
|
||||
"input_line": self.check.line.escaped_text(),
|
||||
"input_line": self.check.line.text,
|
||||
"check_type": self.check.type,
|
||||
}
|
||||
)
|
||||
@@ -238,97 +206,24 @@ class TestFailure(object):
|
||||
" {BOLD}{output_line}{RESET}",
|
||||
"",
|
||||
]
|
||||
if self.error_annotation_lines:
|
||||
fields["error_annotation"] = " ".join(
|
||||
[x.text for x in self.error_annotation_lines]
|
||||
)
|
||||
fields["error_annotation_lineno"] = str(
|
||||
self.error_annotation_lines[0].number
|
||||
)
|
||||
if len(self.error_annotation_lines) > 1:
|
||||
fields["error_annotation_lineno"] += ":" + str(
|
||||
self.error_annotation_lines[-1].number
|
||||
)
|
||||
if self.error_annotation_line:
|
||||
fields["error_annotation"] = self.error_annotation_line.text
|
||||
fields["error_annotation_lineno"] = self.error_annotation_line.number
|
||||
fmtstrs += [
|
||||
" additional output on stderr:{error_annotation_lineno}:",
|
||||
" {BOLD}{error_annotation}{RESET}",
|
||||
]
|
||||
if self.diff:
|
||||
fmtstrs += [" Context:"]
|
||||
lasthi = 0
|
||||
lastcheckline = None
|
||||
for d in self.diff.get_grouped_opcodes():
|
||||
for op, alo, ahi, blo, bhi in d:
|
||||
color = "{BOLD}"
|
||||
if op == "replace" or op == "delete":
|
||||
color = "{RED}"
|
||||
# We got a new chunk, so we print a marker.
|
||||
if alo > lasthi:
|
||||
fmtstrs += [
|
||||
" [...] from line "
|
||||
+ str(self.checks[blo].line.number)
|
||||
+ " ("
|
||||
+ self.lines[alo].file
|
||||
+ ":"
|
||||
+ str(self.lines[alo].number)
|
||||
+ "):"
|
||||
]
|
||||
lasthi = ahi
|
||||
|
||||
# We print one "no more checks" after the last check and then skip any markers
|
||||
lastcheck = False
|
||||
for a, b in zip_longest(self.lines[alo:ahi], self.checks[blo:bhi]):
|
||||
# Clean up strings for use in a format string - double up the curlies.
|
||||
astr = (
|
||||
color + a.escaped_text(for_formatting=True) + "{RESET}"
|
||||
if a
|
||||
else ""
|
||||
)
|
||||
if b:
|
||||
bstr = (
|
||||
"'{BLUE}"
|
||||
+ b.line.escaped_text(for_formatting=True)
|
||||
+ "{RESET}'"
|
||||
+ " on line "
|
||||
+ str(b.line.number)
|
||||
)
|
||||
lastcheckline = b.line.number
|
||||
|
||||
if op == "equal":
|
||||
fmtstrs += [" " + astr]
|
||||
elif b and a:
|
||||
fmtstrs += [
|
||||
" "
|
||||
+ astr
|
||||
+ " <= does not match "
|
||||
+ b.type
|
||||
+ " "
|
||||
+ bstr
|
||||
]
|
||||
elif b:
|
||||
fmtstrs += [
|
||||
" "
|
||||
+ astr
|
||||
+ " <= nothing to match "
|
||||
+ b.type
|
||||
+ " "
|
||||
+ bstr
|
||||
]
|
||||
elif not b:
|
||||
string = " " + astr
|
||||
if bhi == len(self.checks):
|
||||
if not lastcheck:
|
||||
string += " <= no more checks"
|
||||
lastcheck = True
|
||||
elif lastcheckline is not None:
|
||||
string += (
|
||||
" <= no check matches this, previous check on line "
|
||||
+ str(lastcheckline)
|
||||
)
|
||||
else:
|
||||
string += " <= no check matches"
|
||||
fmtstrs.append(string)
|
||||
fmtstrs.append("")
|
||||
if self.before:
|
||||
fields["before_output"] = " ".join(self.before)
|
||||
fields["additional_output"] = " ".join(self.after[:afterlines])
|
||||
fmtstrs += [
|
||||
" Context:",
|
||||
" {BOLD}{before_output} {RED}{output_line}{RESET} <= does not match '{LIGHTBLUE}{input_line}{RESET}'",
|
||||
" {BOLD}{additional_output}{RESET}",
|
||||
]
|
||||
elif self.after:
|
||||
fields["additional_output"] = " ".join(self.after[:afterlines])
|
||||
fmtstrs += [" additional output:", " {BOLD}{additional_output}{RESET}"]
|
||||
fmtstrs += [" when running command:", " {subbed_command}"]
|
||||
return "\n".join(fmtstrs).format(**fields)
|
||||
|
||||
@@ -338,8 +233,8 @@ class TestFailure(object):
|
||||
|
||||
|
||||
def perform_substitution(input_str, subs):
|
||||
"""Perform the substitutions described by subs to str
|
||||
Return the substituted string.
|
||||
""" Perform the substitutions described by subs to str
|
||||
Return the substituted string.
|
||||
"""
|
||||
# Sort our substitutions into a list of tuples (key, value), descending by length.
|
||||
# It needs to be descending because we need to try longer substitutions first.
|
||||
@@ -359,20 +254,6 @@ def perform_substitution(input_str, subs):
|
||||
return re.sub(r"%(%|[a-zA-Z0-9_-]+)", subber, input_str)
|
||||
|
||||
|
||||
def runproc(cmd):
|
||||
""" Wrapper around subprocess.Popen to save typing """
|
||||
PIPE = subprocess.PIPE
|
||||
proc = subprocess.Popen(
|
||||
cmd,
|
||||
stdin=PIPE,
|
||||
stdout=PIPE,
|
||||
stderr=PIPE,
|
||||
shell=True,
|
||||
close_fds=True, # For Python 2.6 as shipped on RHEL 6
|
||||
)
|
||||
return proc
|
||||
|
||||
|
||||
class TestRun(object):
|
||||
def __init__(self, name, runcmd, checker, subs, config):
|
||||
self.name = name
|
||||
@@ -386,79 +267,67 @@ class TestRun(object):
|
||||
# Reverse our lines and checks so we can pop off the end.
|
||||
lineq = lines[::-1]
|
||||
checkq = checks[::-1]
|
||||
usedlines = []
|
||||
usedchecks = []
|
||||
mismatches = []
|
||||
# We keep the last couple of lines in a deque so we can show context.
|
||||
before = deque(maxlen=self.config.before)
|
||||
while lineq and checkq:
|
||||
line = lineq[-1]
|
||||
check = checkq[-1]
|
||||
if check == line:
|
||||
if check.regex.match(line.text):
|
||||
# This line matched this checker, continue on.
|
||||
usedlines.append(line)
|
||||
usedchecks.append(check)
|
||||
lineq.pop()
|
||||
checkq.pop()
|
||||
before.append(line)
|
||||
elif line.is_empty_space():
|
||||
# Skip all whitespace input lines.
|
||||
lineq.pop()
|
||||
else:
|
||||
usedlines.append(line)
|
||||
usedchecks.append(check)
|
||||
mismatches.append((line, check))
|
||||
# Failed to match.
|
||||
lineq.pop()
|
||||
checkq.pop()
|
||||
|
||||
# Drain empties
|
||||
line.text = escape_string(line.text.strip()) + "\n"
|
||||
# Add context, ignoring empty lines.
|
||||
return TestFailure(
|
||||
line,
|
||||
check,
|
||||
self,
|
||||
before=[escape_string(line.text.strip()) + "\n" for line in before],
|
||||
after=[
|
||||
escape_string(line.text.strip()) + "\n"
|
||||
for line in lineq[::-1]
|
||||
if not line.is_empty_space()
|
||||
],
|
||||
)
|
||||
# Drain empties.
|
||||
while lineq and lineq[-1].is_empty_space():
|
||||
lineq.pop()
|
||||
|
||||
# Store the remaining lines for the diff
|
||||
for i in lineq[::-1]:
|
||||
if not i.is_empty_space():
|
||||
usedlines.append(i)
|
||||
# Store remaining checks for the diff
|
||||
for i in checkq[::-1]:
|
||||
usedchecks.append(i)
|
||||
|
||||
# Do a SequenceMatch! This gives us a diff-like thing.
|
||||
diff = SequenceMatcher(a=usedlines, b=usedchecks, autojunk=False)
|
||||
# If there's a mismatch or still lines or checkers, we have a failure.
|
||||
# If there's still lines or checkers, we have a failure.
|
||||
# Otherwise it's success.
|
||||
if mismatches:
|
||||
return TestFailure(
|
||||
mismatches[0][0],
|
||||
mismatches[0][1],
|
||||
self,
|
||||
diff=diff,
|
||||
lines=usedlines,
|
||||
checks=usedchecks,
|
||||
)
|
||||
elif lineq:
|
||||
return TestFailure(
|
||||
lineq[-1], None, self, diff=diff, lines=usedlines, checks=usedchecks
|
||||
)
|
||||
if lineq:
|
||||
return TestFailure(lineq[-1], None, self)
|
||||
elif checkq:
|
||||
return TestFailure(
|
||||
None, checkq[-1], self, diff=diff, lines=usedlines, checks=usedchecks
|
||||
)
|
||||
return TestFailure(None, checkq[-1], self)
|
||||
else:
|
||||
# Success!
|
||||
return None
|
||||
|
||||
def run(self):
|
||||
""" Run the command. Return a TestFailure, or None. """
|
||||
|
||||
def split_by_newlines(s):
|
||||
"""Decode a string and split it by newlines only,
|
||||
retaining the newlines.
|
||||
""" Decode a string and split it by newlines only,
|
||||
retaining the newlines.
|
||||
"""
|
||||
return [s + "\n" for s in s.decode("utf-8").split("\n")]
|
||||
|
||||
PIPE = subprocess.PIPE
|
||||
if self.config.verbose:
|
||||
print(self.subbed_command)
|
||||
proc = runproc(self.subbed_command)
|
||||
proc = subprocess.Popen(
|
||||
self.subbed_command,
|
||||
stdin=PIPE,
|
||||
stdout=PIPE,
|
||||
stderr=PIPE,
|
||||
shell=True,
|
||||
close_fds=True, # For Python 2.6 as shipped on RHEL 6
|
||||
)
|
||||
stdout, stderr = proc.communicate()
|
||||
# HACK: This is quite cheesy: POSIX specifies that sh should return 127 for a missing command.
|
||||
# Technically it's also possible to return it in other conditions.
|
||||
@@ -466,13 +335,6 @@ class TestRun(object):
|
||||
status = proc.returncode
|
||||
if status == 127:
|
||||
raise CheckerError("Command could not be found: " + self.subbed_command)
|
||||
if status == 126:
|
||||
raise CheckerError("Command is not executable: " + self.subbed_command)
|
||||
|
||||
# If a test returns 125, we skip it and don't even attempt to compare output.
|
||||
# This is similar to what `git bisect run` does.
|
||||
if status == 125:
|
||||
return SKIP
|
||||
|
||||
outlines = [
|
||||
Line(text, idx + 1, "stdout")
|
||||
@@ -489,10 +351,7 @@ class TestRun(object):
|
||||
# non-matching or unmatched stderr text, then annotate the outfail
|
||||
# with it.
|
||||
if outfail and errfail and errfail.line:
|
||||
outfail.error_annotation_lines = errlines[errfail.line.number - 1 :]
|
||||
# Trim a trailing newline
|
||||
if outfail.error_annotation_lines[-1].text == "\n":
|
||||
del outfail.error_annotation_lines[-1]
|
||||
outfail.error_annotation_line = errfail.line
|
||||
return outfail if outfail else errfail
|
||||
|
||||
|
||||
@@ -502,28 +361,6 @@ class CheckCmd(object):
|
||||
self.type = checktype
|
||||
self.regex = regex
|
||||
|
||||
def __hash__(self):
|
||||
# HACK: We pass this to the Sequencematcher, which puts the Checks into a dict.
|
||||
# To force it to match the regexes, we return a hash collision intentionally,
|
||||
# so it falls back on __eq__().
|
||||
#
|
||||
# Line has the same thing.
|
||||
return 0
|
||||
|
||||
def __eq__(self, other):
|
||||
# "Magical" comparison with lines and strings.
|
||||
# Typically I wouldn't use this, but it allows us to check if a line matches any check in a dict or list via
|
||||
# the `in` operator.
|
||||
if other is None:
|
||||
return False
|
||||
if isinstance(other, CheckCmd):
|
||||
return self.regex == other.regex
|
||||
if isinstance(other, Line):
|
||||
return self.regex.match(other.text)
|
||||
if isinstance(other, str):
|
||||
return self.regex.match(other)
|
||||
raise NotImplementedError
|
||||
|
||||
@staticmethod
|
||||
def parse(line, checktype):
|
||||
# type: (Line) -> CheckCmd
|
||||
@@ -591,8 +428,6 @@ class Checker(object):
|
||||
else:
|
||||
raise CheckerError("No runlines ('# RUN') found")
|
||||
|
||||
self.requirecmds = [RunCmd.parse(sl) for sl in group1s(REQUIRES_RE)]
|
||||
|
||||
# Find check cmds.
|
||||
self.outchecks = [
|
||||
CheckCmd.parse(sl, "CHECK") for sl in group1s(CHECK_STDOUT_RE)
|
||||
@@ -607,19 +442,6 @@ def check_file(input_file, name, subs, config, failure_handler):
|
||||
success = True
|
||||
lines = Line.readfile(input_file, name)
|
||||
checker = Checker(name, lines)
|
||||
|
||||
# Run all the REQUIRES lines first,
|
||||
# if any of them fail it's a SKIP
|
||||
for reqcmd in checker.requirecmds:
|
||||
proc = runproc(
|
||||
perform_substitution(reqcmd.args, subs)
|
||||
)
|
||||
stdout, stderr = proc.communicate()
|
||||
status = proc.returncode
|
||||
if proc.returncode > 0:
|
||||
return SKIP
|
||||
|
||||
# Only then run the RUN lines.
|
||||
for runcmd in checker.runcmds:
|
||||
failure = TestRun(name, runcmd, checker, subs, config).run()
|
||||
if failure:
|
||||
@@ -634,8 +456,8 @@ def check_path(path, subs, config, failure_handler):
|
||||
|
||||
|
||||
def parse_subs(subs):
|
||||
"""Given a list of input substitutions like 'foo=bar',
|
||||
return a dictionary like {foo:bar}, or exit if invalid.
|
||||
""" Given a list of input substitutions like 'foo=bar',
|
||||
return a dictionary like {foo:bar}, or exit if invalid.
|
||||
"""
|
||||
result = {}
|
||||
for sub in subs:
|
||||
@@ -676,6 +498,22 @@ def get_argparse():
|
||||
default=False,
|
||||
)
|
||||
parser.add_argument("file", nargs="+", help="File to check")
|
||||
parser.add_argument(
|
||||
"-A",
|
||||
"--after",
|
||||
type=int,
|
||||
help="How many non-empty lines of output after a failure to print (default: 5)",
|
||||
action="store",
|
||||
default=5,
|
||||
)
|
||||
parser.add_argument(
|
||||
"-B",
|
||||
"--before",
|
||||
type=int,
|
||||
help="How many non-empty lines of output before a failure to print (default: 5)",
|
||||
action="store",
|
||||
default=5,
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
@@ -690,6 +528,12 @@ def main():
|
||||
config.colorize = sys.stdout.isatty()
|
||||
config.progress = args.progress
|
||||
fields = config.colors()
|
||||
config.after = args.after
|
||||
config.before = args.before
|
||||
if config.before < 0:
|
||||
raise ValueError("Before must be at least 0")
|
||||
if config.after < 0:
|
||||
raise ValueError("After must be at least 0")
|
||||
|
||||
for path in args.file:
|
||||
fields["path"] = path
|
||||
@@ -699,20 +543,14 @@ def main():
|
||||
subs = def_subs.copy()
|
||||
subs["s"] = path
|
||||
starttime = datetime.datetime.now()
|
||||
ret = check_path(path, subs, config, TestFailure.print_message)
|
||||
if not ret:
|
||||
if not check_path(path, subs, config, TestFailure.print_message):
|
||||
failure_count += 1
|
||||
elif config.progress:
|
||||
endtime = datetime.datetime.now()
|
||||
duration_ms = round((endtime - starttime).total_seconds() * 1000)
|
||||
reason = "ok"
|
||||
color = "{GREEN}"
|
||||
if ret is SKIP:
|
||||
reason = "SKIPPED"
|
||||
color = "{BLUE}"
|
||||
print(
|
||||
(color + "{reason}{RESET} ({duration} ms)").format(
|
||||
duration=duration_ms, reason=reason, **fields
|
||||
"{GREEN}ok{RESET} ({duration} ms)".format(
|
||||
duration=duration_ms, **fields
|
||||
)
|
||||
)
|
||||
sys.exit(failure_count)
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This codesigns a Mac .pkg (installer) file.
|
||||
# Normally we could use `productsign` but that no longer produces
|
||||
# installers compatible with 10.11.
|
||||
# See https://github.com/fish-shell/fish-shell/issues/7656
|
||||
#
|
||||
# So instead we use the flow described here:
|
||||
# http://users.wfu.edu/cottrell/productsign/productsign_linux.html
|
||||
#
|
||||
# This script expects the following:
|
||||
#
|
||||
# 1. A variable $MAC_PRODUCTSIGN_CERTS_DIR pointing at a directory containing files cert00, cert01, cert02
|
||||
# 2. A variable $MAC_PRODUCTSIGN_P12_FILE containing the "Mac Developer ID Installer" keychain item, exported as p12. See below.
|
||||
|
||||
die() { echo "$*" 1>&2 ; exit 1; }
|
||||
|
||||
# Exit on error.
|
||||
set -e
|
||||
|
||||
# Our input package file.
|
||||
INPUT_PKG=$(realpath $1)
|
||||
test -f "$INPUT_PKG" || die "${INPUT_PKG} not a valid package"
|
||||
|
||||
# Find where our mac_xar_116 binary is.
|
||||
XAR_116="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/bin/mac_xar_116
|
||||
|
||||
# Here's what we need to be set.
|
||||
test -f "${MAC_PRODUCTSIGN_P12_FILE}" || die "MAC_PRODUCTSIGN_P12_FILE not set or not a p12 file"
|
||||
test -d "${MAC_PRODUCTSIGN_CERTS_DIR}" || die "MAC_PRODUCTSIGN_CERTS_DIR not set or not a directory"
|
||||
test -f "${MAC_PRODUCTSIGN_CERTS_DIR}/cert00" \
|
||||
&& test -f "${MAC_PRODUCTSIGN_CERTS_DIR}/cert01" \
|
||||
&& test -f "${MAC_PRODUCTSIGN_CERTS_DIR}/cert02" \
|
||||
|| die "MAC_PRODUCTSIGN_CERTS_DIR does not contain cert00, cert01, cert02"
|
||||
test -x "${XAR_116}" || die "mac_xar_116 binary not found or executable at ${XAR_116}"
|
||||
|
||||
TMP=$(mktemp -d)
|
||||
KEYFILE="${TMP}/key.pem"
|
||||
DIGFILE="${TMP}/digestinfo.dat"
|
||||
SIGFILE="${TMP}/signature.dat"
|
||||
|
||||
set -x
|
||||
|
||||
openssl pkcs12 -in "${MAC_PRODUCTSIGN_P12_FILE}" -nodes | openssl rsa -out "${KEYFILE}"
|
||||
test -f "${KEYFILE}" || die "openssl did not create key.pem"
|
||||
SIGSIZE=$(openssl dgst -sign "${KEYFILE}" -binary < /dev/null | wc -c | xargs)
|
||||
|
||||
# Prepare data for signing.
|
||||
${XAR_116} --sign -f ${INPUT_PKG} --digestinfo-to-sign "${DIGFILE}" \
|
||||
--sig-size "${SIGSIZE}" \
|
||||
--cert-loc "${MAC_PRODUCTSIGN_CERTS_DIR}/cert00" \
|
||||
--cert-loc "${MAC_PRODUCTSIGN_CERTS_DIR}/cert01" \
|
||||
--cert-loc "${MAC_PRODUCTSIGN_CERTS_DIR}/cert02"
|
||||
|
||||
# Create the signature.
|
||||
openssl rsautl -sign -inkey "${KEYFILE}" -in "${DIGFILE}" -out "${SIGFILE}"
|
||||
|
||||
# Add it to the archive, in place, then move it back.
|
||||
${XAR_116} --inject-sig "${SIGFILE}" -f "${INPUT_PKG}"
|
||||
|
||||
# Remove all our junk.
|
||||
rm -rf "${TMP}"
|
||||
|
||||
# Check the signature!
|
||||
pkgutil --check-signature "${INPUT_PKG}"
|
||||
|
||||
# The following is taken from http://users.wfu.edu/cottrell/productsign/productsign_linux.html
|
||||
# Saved here for posterity.
|
||||
|
||||
# Signing a Mac OS X package on Linux
|
||||
|
||||
# Premises
|
||||
|
||||
# You are a software developer who's at home on Linux but you want to produce builds of your software for other platforms, including Mac OS X.
|
||||
# You've already figured out cross-compilation. And in regard to OS X you've figured out how to build a (flat) pkg file on Linux – or if not, you can do so quite quickly by looking at the bomutils doc: https://github.com/hogliux/bomutils.
|
||||
# You are grudgingly willing to pay the Apple tax (the fee for becoming a registered developer) so that you can get a certificate with which to sign your package, in order that your gentle users don't get off-putting messages from Gatekeeper.
|
||||
# But you're wondering how to sign your package without having to use Apple's productsign on a Mac.
|
||||
# If you match on all points, we're in business! Here's the drill as I have figured it out. You will need: openssl, recent xar (see below), and one-time access to an actual Mac.
|
||||
|
||||
# Procedure
|
||||
|
||||
# Step 0: Build your program and create an OS X pkg file (xar archive). This you will do (on Linux) whenever you want to create a new release or snapshot.
|
||||
|
||||
# Step 1: This is a one-time step to be performed on a Mac. There may be a way around it, but I'm not aware of one. Please let me know if you're cleverer than I when it comes to certificates and all that. But anyway, follow the Apple directions for installing your developer certificate(s) on OS X, and use productsign to sign your package on the Mac – just this once! (Copy it across from Linux.) And then, before leaving the Mac, open Keychain Access and find your developer cert, the one with "Developer ID Installer" in its title (it should have a private key tucked under it). Highlight it and select "Export items" under the File menu to save as a p12 file. Copy your signed package and the exported p12 file (let's say it's called certs.p12) to your Linux box.
|
||||
|
||||
# Step 2: Back on Linux you're going to need a reasonably recent version of xar, specifically 1.6.1 or higher to support signing. Arch Linux installs xar 1.6.1 if you do pacman -S xar. Fedora's dnf install xar gets version 1.5, which won't do the job. I don't know about other distros, but if need be you can find the source for xar 1.6.1 at http://mackyle.github.io/xar/. Anyway, here's another one-time step: you'll extract the certs you need from the pkg file that you signed on the Mac, and the private key from the p12 file you exported from Keychain Access. (You'll need the passphrase that you set on the p12 when exporting it, so I hope you haven't forgotten that.)
|
||||
|
||||
# I'll assume (unimaginatively) that your package is called foo.pkg.
|
||||
|
||||
# # extract the certs from signed foo.pkg
|
||||
# mkdir certs
|
||||
# xar -f foo.pkg --extract-certs certs
|
||||
# You should find certs00, certs01 and probably certs02 in the certs directory. Perhaps more.
|
||||
|
||||
# # extract the private key from certs.p12 (requires passphrase)
|
||||
# openssl pkcs12 -in certs.p12 -nodes | openssl rsa -out key.pem
|
||||
# At this point you have the materials to sign future versions of your package natively on Linux. I'll now assume that a new unsigned foo.pkg is sitting in a directory containing the key.pem generated above and also the certs subdirectory created above. So now (with many thanks to mackyle!) you do:
|
||||
|
||||
# PKG=foo.pkg
|
||||
|
||||
# # determine the size of the signature
|
||||
# : | openssl dgst -sign key.pem -binary | wc -c > siglen.txt
|
||||
|
||||
# # prepare data for signing -- may have to adjust depending
|
||||
# # on the contents of the certs subdir in your case
|
||||
# xar --sign -f $PKG --digestinfo-to-sign digestinfo.dat \
|
||||
# --sig-size `cat siglen.txt` \
|
||||
# --cert-loc certs/cert00 \
|
||||
# --cert-loc certs/cert01 \
|
||||
# --cert-loc certs/cert02
|
||||
|
||||
# # create the signature
|
||||
# openssl rsautl -sign -inkey key.pem -in digestinfo.dat \
|
||||
# -out signature.dat
|
||||
|
||||
# # stuff it into the archive
|
||||
# xar --inject-sig signature.dat -f $PKG
|
||||
|
||||
# # and clean up
|
||||
# rm -f signature.dat digestinfo.dat siglen.txt
|
||||
# From this point on, just build your package on Linux and sign it on Linux using xar along with the certs and key that you got from the Mac.
|
||||
|
||||
@@ -17,9 +17,10 @@ set -x
|
||||
#Exit on error
|
||||
set -e
|
||||
|
||||
# Respect MAC_CODESIGN_ID, or default for ad-hoc.
|
||||
# Respect MAC_CODESIGN_ID and MAC_PRODUCTSIGN_ID, or default for ad-hoc.
|
||||
# Note the :- means "or default" and the following - is the value.
|
||||
MAC_CODESIGN_ID=${MAC_CODESIGN_ID:--}
|
||||
MAC_PRODUCTSIGN_ID=${MAC_PRODUCTSIGN_ID:--}
|
||||
|
||||
PKGDIR=$(mktemp -d)
|
||||
|
||||
@@ -27,19 +28,10 @@ SRC_DIR=$PWD
|
||||
OUTPUT_PATH=${FISH_ARTEFACT_PATH:-~/fish_built}
|
||||
|
||||
mkdir -p "$PKGDIR/build" "$PKGDIR/root" "$PKGDIR/intermediates" "$PKGDIR/dst"
|
||||
{ cd "$PKGDIR/build" && cmake -DMAC_INJECT_GET_TASK_ALLOW=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_GETTEXT=OFF -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' -DMAC_CODESIGN_ID="${MAC_CODESIGN_ID}" "$SRC_DIR" && make VERBOSE=1 -j 12 && env DESTDIR="$PKGDIR/root/" make install; }
|
||||
{ cd "$PKGDIR/build" && cmake -DMAC_INJECT_GET_TASK_ALLOW=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMAC_CODESIGN_ID="${MAC_CODESIGN_ID}" "$SRC_DIR" && make -j 12 && env DESTDIR="$PKGDIR/root/" make install; }
|
||||
pkgbuild --scripts "$SRC_DIR/build_tools/osx_package_scripts" --root "$PKGDIR/root/" --identifier 'com.ridiculousfish.fish-shell-pkg' --version "$VERSION" "$PKGDIR/intermediates/fish.pkg"
|
||||
productbuild --package-path "$PKGDIR/intermediates" --distribution "$SRC_DIR/build_tools/osx_distribution.xml" --resources "$SRC_DIR/build_tools/osx_package_resources/" "$OUTPUT_PATH/fish-$VERSION.pkg"
|
||||
|
||||
# Here is the historical way to sign the installer package.
|
||||
# But when run on macOS 11.1, the resulting installers don't work on 10.11.
|
||||
# So we have our own script instead. See issue #7656.
|
||||
# Also see https://developer.apple.com/forums/thread/664842
|
||||
# If/when productsign is fixed to support 10.11, we can switch back to this.
|
||||
# MAC_PRODUCTSIGN_ID=${MAC_PRODUCTSIGN_ID:--}
|
||||
# productsign --sign "${MAC_PRODUCTSIGN_ID}" "$OUTPUT_PATH/fish-$VERSION.pkg" "$OUTPUT_PATH/fish-$VERSION-signed.pkg" && mv "$OUTPUT_PATH/fish-$VERSION-signed.pkg" "$OUTPUT_PATH/fish-$VERSION.pkg"
|
||||
|
||||
"$SRC_DIR/build_tools/mac_sign_package.sh" "$OUTPUT_PATH/fish-$VERSION.pkg"
|
||||
productsign --sign "${MAC_PRODUCTSIGN_ID}" "$OUTPUT_PATH/fish-$VERSION.pkg" "$OUTPUT_PATH/fish-$VERSION-signed.pkg" && mv "$OUTPUT_PATH/fish-$VERSION-signed.pkg" "$OUTPUT_PATH/fish-$VERSION.pkg"
|
||||
|
||||
# Make the app
|
||||
{ cd "$PKGDIR/build" && make signed_fish_macapp && zip -r "$OUTPUT_PATH/fish-$VERSION.app.zip" fish.app; }
|
||||
|
||||
@@ -26,19 +26,14 @@ import pexpect
|
||||
# Default timeout for failing to match.
|
||||
TIMEOUT_SECS = 5
|
||||
|
||||
UNEXPECTED_SUCCESS = object()
|
||||
|
||||
def get_prompt_re(counter):
|
||||
""" Return a regular expression for matching a with a given prompt counter. """
|
||||
return re.compile(
|
||||
r"""(?:\r\n?|^) # beginning of line
|
||||
(?:\x1b[\d\[KB(m]*)* # optional colors
|
||||
(?:\[.\]\ )? # optional vi mode prompt
|
||||
"""
|
||||
+ (r"prompt\ %d>" % counter) # prompt with counter
|
||||
+ r"""
|
||||
(?:\x1b[\d\[KB(m]*)* # optional colors
|
||||
""",
|
||||
+ (r"prompt\ %d>" % counter), # prompt with counter
|
||||
re.VERBOSE,
|
||||
)
|
||||
|
||||
@@ -75,14 +70,12 @@ def pexpect_error_type(err):
|
||||
return "EOF"
|
||||
elif isinstance(err, pexpect.TIMEOUT):
|
||||
return "timeout"
|
||||
elif err is UNEXPECTED_SUCCESS:
|
||||
return "unexpected success"
|
||||
else:
|
||||
return "unknown error"
|
||||
|
||||
|
||||
class Message(object):
|
||||
"""Some text either sent-to or received-from the spawned proc.
|
||||
""" Some text either sent-to or received-from the spawned proc.
|
||||
|
||||
Attributes:
|
||||
dir: the message direction, either DIR_INPUT or DIR_OUTPUT
|
||||
@@ -118,7 +111,7 @@ class Message(object):
|
||||
|
||||
|
||||
class SpawnedProc(object):
|
||||
"""A process, talking to our ptty. This wraps pexpect.spawn.
|
||||
""" A process, talking to our ptty. This wraps pexpect.spawn.
|
||||
|
||||
Attributes:
|
||||
colorize: whether error messages should have ANSI color escapes
|
||||
@@ -129,16 +122,16 @@ class SpawnedProc(object):
|
||||
function to ensure that each printed prompt is distinct.
|
||||
"""
|
||||
|
||||
def __init__(self, name="fish", timeout=TIMEOUT_SECS, env=os.environ.copy(), **kwargs):
|
||||
"""Construct from a name, timeout, and environment.
|
||||
def __init__(self, name="fish", timeout=TIMEOUT_SECS, env=os.environ.copy()):
|
||||
""" Construct from a name, timeout, and environment.
|
||||
|
||||
Args:
|
||||
name: the name of the executable to launch, as a key into the
|
||||
environment dictionary. By default this is 'fish' but may be
|
||||
other executables.
|
||||
timeout: A timeout to pass to pexpect. This indicates how long to wait
|
||||
before giving up on some expected output.
|
||||
env: a string->string dictionary, describing the environment variables.
|
||||
Args:
|
||||
name: the name of the executable to launch, as a key into the
|
||||
environment dictionary. By default this is 'fish' but may be
|
||||
other executables.
|
||||
timeout: A timeout to pass to pexpect. This indicates how long to wait
|
||||
before giving up on some expected output.
|
||||
env: a string->string dictionary, describing the environment variables.
|
||||
"""
|
||||
if name not in env:
|
||||
raise ValueError("'name' variable not found in environment" % name)
|
||||
@@ -146,9 +139,9 @@ class SpawnedProc(object):
|
||||
self.colorize = sys.stdout.isatty()
|
||||
self.messages = []
|
||||
self.start_time = None
|
||||
self.spawn = pexpect.spawn(exe_path, env=env, encoding="utf-8", timeout=timeout, **kwargs)
|
||||
self.spawn = pexpect.spawn(exe_path, env=env, encoding="utf-8", timeout=timeout)
|
||||
self.spawn.delaybeforesend = None
|
||||
self.prompt_counter = 0
|
||||
self.prompt_counter = 1
|
||||
|
||||
def time_since_first_message(self):
|
||||
""" Return a delta in seconds since the first message, or 0 if this is the first. """
|
||||
@@ -158,8 +151,8 @@ class SpawnedProc(object):
|
||||
return now - self.start_time
|
||||
|
||||
def send(self, s):
|
||||
"""Cover over pexpect.spawn.send().
|
||||
Send the given string to the tty, returning the number of bytes written.
|
||||
""" Cover over pexpect.spawn.send().
|
||||
Send the given string to the tty, returning the number of bytes written.
|
||||
"""
|
||||
res = self.spawn.send(s)
|
||||
when = self.time_since_first_message()
|
||||
@@ -167,41 +160,31 @@ class SpawnedProc(object):
|
||||
return res
|
||||
|
||||
def sendline(self, s):
|
||||
"""Cover over pexpect.spawn.sendline().
|
||||
Send the given string + linesep to the tty, returning the number of bytes written.
|
||||
""" Cover over pexpect.spawn.sendline().
|
||||
Send the given string + linesep to the tty, returning the number of bytes written.
|
||||
"""
|
||||
return self.send(s + os.linesep)
|
||||
|
||||
def expect_re(self, pat, pat_desc=None, unmatched=None, shouldfail=False, **kwargs):
|
||||
"""Cover over pexpect.spawn.expect().
|
||||
Consume all "new" output of self.spawn until the given pattern is matched, or
|
||||
the timeout is reached.
|
||||
Note that output between the current position and the location of the match is
|
||||
consumed as well.
|
||||
The pattern is typically a regular expression in string form, but may also be
|
||||
any of the types accepted by pexpect.spawn.expect().
|
||||
If the 'unmatched' parameter is given, it is printed as part of the error message
|
||||
of any failure.
|
||||
On failure, this prints an error and exits.
|
||||
def expect_re(self, pat, pat_desc=None, unmatched=None, **kwargs):
|
||||
""" Cover over pexpect.spawn.expect().
|
||||
Consume all "new" output of self.spawn until the given pattern is matched, or
|
||||
the timeout is reached.
|
||||
Note that output between the current position and the location of the match is
|
||||
consumed as well.
|
||||
The pattern is typically a regular expression in string form, but may also be
|
||||
any of the types accepted by pexpect.spawn.expect().
|
||||
If the 'unmatched' parameter is given, it is printed as part of the error message
|
||||
of any failure.
|
||||
On failure, this prints an error and exits.
|
||||
"""
|
||||
try:
|
||||
self.spawn.expect(pat, **kwargs)
|
||||
res = self.spawn.expect(pat, **kwargs)
|
||||
when = self.time_since_first_message()
|
||||
self.messages.append(
|
||||
Message.received_output(self.spawn.match.group(), when)
|
||||
)
|
||||
# When a match is found,
|
||||
# spawn.match is the MatchObject that produced it.
|
||||
# This can be used to check what exactly was matched.
|
||||
if shouldfail:
|
||||
err = UNEXPECTED_SUCCESS
|
||||
if not pat_desc:
|
||||
pat_desc = str(pat)
|
||||
self.report_exception_and_exit(pat_desc, unmatched, err)
|
||||
return self.spawn.match
|
||||
return res
|
||||
except pexpect.ExceptionPexpect as err:
|
||||
if shouldfail:
|
||||
return True
|
||||
if not pat_desc:
|
||||
pat_desc = str(pat)
|
||||
self.report_exception_and_exit(pat_desc, unmatched, err)
|
||||
@@ -210,31 +193,28 @@ class SpawnedProc(object):
|
||||
""" Cover over expect_re() which accepts a literal string. """
|
||||
return self.expect_re(re.escape(s), **kwargs)
|
||||
|
||||
def expect_prompt(self, *args, increment=True, **kwargs):
|
||||
"""Convenience function which matches some text and then a prompt.
|
||||
Match the given positional arguments as expect_re, and then look
|
||||
for a prompt.
|
||||
If increment is set, then this should be a new prompt and the prompt counter
|
||||
should be bumped; otherwise this is not a new prompt.
|
||||
Returns None on success, and exits on failure.
|
||||
Example:
|
||||
sp.sendline("echo hello world")
|
||||
sp.expect_prompt("hello world")
|
||||
def expect_prompt(self, *args, **kwargs):
|
||||
""" Convenience function which matches some text and then a prompt.
|
||||
Match the given positional arguments as expect_re, and then look
|
||||
for a prompt, bumping the prompt counter.
|
||||
Returns None on success, and exits on failure.
|
||||
Example:
|
||||
sp.sendline("echo hello world")
|
||||
sp.expect_prompt("hello world")
|
||||
"""
|
||||
if args:
|
||||
self.expect_re(*args, **kwargs)
|
||||
if increment:
|
||||
self.prompt_counter += 1
|
||||
self.expect_re(
|
||||
get_prompt_re(self.prompt_counter),
|
||||
pat_desc="prompt %d" % self.prompt_counter,
|
||||
)
|
||||
self.prompt_counter += 1
|
||||
|
||||
def report_exception_and_exit(self, pat, unmatched, err):
|
||||
"""Things have gone badly.
|
||||
We have an exception 'err', some pexpect.ExceptionPexpect.
|
||||
Report it to stdout, along with the offending call site.
|
||||
If 'unmatched' is set, print it to stdout.
|
||||
""" Things have gone badly.
|
||||
We have an exception 'err', some pexpect.ExceptionPexpect.
|
||||
Report it to stdout, along with the offending call site.
|
||||
If 'unmatched' is set, print it to stdout.
|
||||
"""
|
||||
colors = self.colors()
|
||||
failtype = pexpect_error_type(err)
|
||||
@@ -276,10 +256,10 @@ class SpawnedProc(object):
|
||||
|
||||
print("")
|
||||
|
||||
# Show the last 10 messages.
|
||||
print("Last 10 messages:")
|
||||
# Show the last 5 messages.
|
||||
print("Last 5 messages:")
|
||||
delta = None
|
||||
for m in self.messages[-10:]:
|
||||
for m in self.messages[-5:]:
|
||||
etext = escape(m.text)
|
||||
timestamp = m.when * 1000.0
|
||||
# Use relative timestamps and add a sign.
|
||||
|
||||
@@ -28,8 +28,8 @@ if test $all = yes
|
||||
exit 1
|
||||
end
|
||||
set c_files src/*.h src/*.cpp src/*.c
|
||||
set fish_files share/**.fish
|
||||
set python_files {doc_src,share,tests}/**.py
|
||||
set fish_files (printf '%s\n' share/***.fish)
|
||||
set python_files **.py
|
||||
else
|
||||
# We haven't been asked to reformat all the source. If there are uncommitted changes reformat
|
||||
# those using `git clang-format`. Else reformat the files in the most recent commit.
|
||||
|
||||
@@ -4,33 +4,15 @@
|
||||
# `wcstod_l` is a GNU-extension, sometimes hidden behind GNU-related defines.
|
||||
# This is the case for at least Cygwin and Newlib.
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if(APPLE)
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("-Werror=unguarded-availability" REQUIRES_UNGUARDED_AVAILABILITY)
|
||||
if(REQUIRES_UNGUARDED_AVAILABILITY)
|
||||
list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Werror=unguarded-availability")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# An unrecognized flag is usually a warning and not an error, which CMake apparently does
|
||||
# not pick up on. Combine it with -Werror to determine if it's actually supported.
|
||||
# This is not bulletproof; old versions of GCC only emit a warning about unrecognized warning
|
||||
# options when there are other warnings to emit :rolleyes:
|
||||
# See https://github.com/fish-shell/fish-shell/commit/fe2da0a9#commitcomment-47431659
|
||||
|
||||
# GCC supports -Wno-redundant-move from GCC9 onwards
|
||||
check_cxx_compiler_flag("-Werror=no-redundant-move" HAS_NO_REDUNDANT_MOVE)
|
||||
if (HAS_NO_REDUNDANT_MOVE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-redundant-move")
|
||||
endif()
|
||||
# Clang once supported -Wno-redundant-move but replaced it with a Wredundant-move option instead
|
||||
# (and it is functionally different from its older version of GCC's Wno-redundant-move).
|
||||
check_cxx_compiler_flag("-Werror=redundant-move" HAS_REDUNDANT_MOVE)
|
||||
if (HAS_REDUNDANT_MOVE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wredundant-move")
|
||||
endif()
|
||||
|
||||
# Try using CMake's own logic to locate curses/ncurses
|
||||
find_package(Curses)
|
||||
if(NOT ${CURSES_FOUND})
|
||||
@@ -43,16 +25,6 @@ if(NOT ${CURSES_FOUND})
|
||||
set(CURSES_CURSES_LIBRARY ${CURSES_LIBRARIES})
|
||||
set(CURSES_LIBRARY ${CURSES_LIBRARIES})
|
||||
endif()
|
||||
# Set up extra include directories for CheckIncludeFile
|
||||
list(APPEND CMAKE_REQUIRED_INCLUDES ${CURSES_INCLUDE_DIRS})
|
||||
|
||||
# Fix undefined reference to tparm on RHEL 6 and potentially others
|
||||
# If curses is found via CMake, it also links against tinfo if it exists. But if we use our
|
||||
# fallback pkg-config logic above, we need to do this manually.
|
||||
find_library(CURSES_TINFO tinfo)
|
||||
if (CURSES_TINFO)
|
||||
set(CURSES_LIBRARY ${CURSES_LIBRARY} ${CURSES_TINFO})
|
||||
endif()
|
||||
|
||||
# Get threads.
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
@@ -93,6 +65,7 @@ check_cxx_symbol_exists(getpwent pwd.h HAVE_GETPWENT)
|
||||
check_cxx_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
|
||||
check_cxx_symbol_exists(gettext libintl.h HAVE_GETTEXT)
|
||||
check_cxx_symbol_exists(killpg "sys/types.h;signal.h" HAVE_KILLPG)
|
||||
check_cxx_symbol_exists(lrand48_r stdlib.h HAVE_LRAND48_R)
|
||||
# mkostemp is in stdlib in glibc and FreeBSD, but unistd on macOS
|
||||
check_cxx_symbol_exists(mkostemp "stdlib.h;unistd.h" HAVE_MKOSTEMP)
|
||||
set(HAVE_CURSES_H ${CURSES_HAVE_CURSES_H})
|
||||
@@ -118,8 +91,6 @@ check_include_file_cxx(sys/select.h HAVE_SYS_SELECT_H)
|
||||
check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYS_SYSCTL_H)
|
||||
check_include_file_cxx(termios.h HAVE_TERMIOS_H) # Needed for TIOCGWINSZ
|
||||
|
||||
check_cxx_symbol_exists(eventfd sys/eventfd.h HAVE_EVENTFD)
|
||||
check_cxx_symbol_exists(pipe2 unistd.h HAVE_PIPE2)
|
||||
check_cxx_symbol_exists(wcscasecmp wchar.h HAVE_WCSCASECMP)
|
||||
check_cxx_symbol_exists(wcsdup wchar.h HAVE_WCSDUP)
|
||||
check_cxx_symbol_exists(wcslcpy wchar.h HAVE_WCSLCPY)
|
||||
@@ -228,23 +199,11 @@ int main () {
|
||||
check_cxx_source_compiles("
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
std::atomic<uint64_t> x (0);
|
||||
std::atomic<uint64_t> x;
|
||||
int main() {
|
||||
uint64_t i = x.load(std::memory_order_relaxed);
|
||||
return std::atomic_is_lock_free(&x);
|
||||
return x;
|
||||
}"
|
||||
LIBATOMIC_NOT_NEEDED)
|
||||
IF (NOT LIBATOMIC_NOT_NEEDED)
|
||||
set(ATOMIC_LIBRARY "atomic")
|
||||
endif()
|
||||
|
||||
IF (APPLE)
|
||||
# Check if mbrtowc implementation attempts to encode invalid UTF-8 sequences
|
||||
# Known culprits: at least some versions of macOS (confirmed Snow Leopard and Yosemite)
|
||||
try_run(mbrtowc_invalid_utf8_exit mbrtowc_invalid_utf8_compiles ${CMAKE_CURRENT_BINARY_DIR}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/checks/mbrtowc_invalid_utf8.cpp")
|
||||
IF ("${mbrtowc_invalid_utf8_compiles}" AND ("${mbrtowc_invalid_utf8_exit}" EQUAL 1))
|
||||
SET(HAVE_BROKEN_MBRTOWC_UTF8 1)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ set(SPHINX_MANPAGE_DIR "${SPHINX_ROOT_DIR}/man")
|
||||
# Prepend the output dir of fish_indent to PATH.
|
||||
add_custom_target(sphinx-docs
|
||||
mkdir -p ${SPHINX_HTML_DIR}/_static/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SPHINX_SRC_DIR}/_static/pygments.css ${SPHINX_HTML_DIR}/_static/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SPHINX_SRC_DIR}/_static/custom.css ${SPHINX_HTML_DIR}/_static/
|
||||
COMMAND env PATH="$<TARGET_FILE_DIR:fish_indent>:$$PATH"
|
||||
${SPHINX_EXECUTABLE}
|
||||
-q -b html
|
||||
|
||||
@@ -110,7 +110,7 @@ add_custom_command(OUTPUT fish.pc
|
||||
COMMAND printf "Version: " >> fish.pc
|
||||
COMMAND sed 's/FISH_BUILD_VERSION=//\;s/\"//g' ${FBVF} >> fish.pc
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS CHECK-FISH-BUILD-VERSION-FILE ${CMAKE_CURRENT_BINARY_DIR}/fish.pc.noversion)
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FBVF} ${CMAKE_CURRENT_BINARY_DIR}/fish.pc.noversion)
|
||||
|
||||
add_custom_target(build_fish_pc ALL DEPENDS fish.pc)
|
||||
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
|
||||
|
||||
# Code signing ID on Mac.
|
||||
# Code signing ID on Mac. A default '-' is ad-hoc codesign.
|
||||
# If this is falsey, codesigning is disabled.
|
||||
# '-' is ad-hoc codesign.
|
||||
set(MAC_CODESIGN_ID "" CACHE STRING "Mac code-signing identity")
|
||||
set(MAC_CODESIGN_ID "-" CACHE STRING "Mac code-signing identity")
|
||||
|
||||
# Whether to inject the "get-task-allow" entitlement, which permits debugging
|
||||
# on the Mac.
|
||||
set(MAC_INJECT_GET_TASK_ALLOW ON CACHE BOOL "Inject get-task-allow on Mac")
|
||||
|
||||
# When building a Mac build, it is common for fish to link against a
|
||||
# pcre2 built for the host platform (e.g. macOS 10.15) while fish wants
|
||||
# to link for macOS 10.9. This warning would be of interest for releases,
|
||||
# but is just noise for daily development. Unfortunately it has no flag
|
||||
# of its own, so suppress all linker warnings in debug builds.
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -w")
|
||||
|
||||
function(CODESIGN_ON_MAC target)
|
||||
if((APPLE) AND (MAC_CODESIGN_ID))
|
||||
execute_process(COMMAND sw_vers "-productVersion" OUTPUT_VARIABLE OSX_VERSION)
|
||||
|
||||
@@ -60,22 +60,13 @@ endif()
|
||||
|
||||
# Prep the environment for running the unit tests.
|
||||
add_custom_target(test_prep
|
||||
# Add directories hard-coded into the tests
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/data
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/data
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/temp
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/temp
|
||||
|
||||
# Add the XDG_* directories
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/xdg_data
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/xdg_data
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/xdg_config
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/xdg_config
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/xdg_runtime
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR}/xdg_runtime
|
||||
|
||||
DEPENDS tests_buildroot_target tests_dir
|
||||
USES_TERMINAL)
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/data
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/home
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR}/temp
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
${TEST_DIR}/data ${TEST_DIR}/home ${TEST_DIR}/temp
|
||||
DEPENDS tests_buildroot_target tests_dir
|
||||
USES_TERMINAL)
|
||||
|
||||
# Define our individual tests.
|
||||
# Each test is conceptually independent.
|
||||
@@ -83,37 +74,24 @@ add_custom_target(test_prep
|
||||
# So define both a normal target, and a serial variant which enforces ordering.
|
||||
foreach(TESTTYPE test serial_test)
|
||||
add_custom_target(${TESTTYPE}_low_level
|
||||
COMMAND env XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_data
|
||||
XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_config
|
||||
XDG_RUNTIME_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_runtime
|
||||
./fish_tests
|
||||
COMMAND env XDG_DATA_HOME=test/data XDG_CONFIG_HOME=test/home ./fish_tests
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS fish_tests
|
||||
USES_TERMINAL)
|
||||
|
||||
add_custom_target(${TESTTYPE}_fishscript
|
||||
COMMAND
|
||||
cd tests &&
|
||||
env XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_data
|
||||
XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_config
|
||||
XDG_RUNTIME_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_runtime
|
||||
${TEST_ROOT_DIR}/bin/fish test.fish
|
||||
COMMAND cd tests && ${TEST_ROOT_DIR}/bin/fish test.fish
|
||||
DEPENDS test_prep
|
||||
USES_TERMINAL)
|
||||
|
||||
add_custom_target(${TESTTYPE}_interactive
|
||||
COMMAND cd tests &&
|
||||
env XDG_DATA_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_data
|
||||
XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_config
|
||||
XDG_RUNTIME_HOME=${CMAKE_CURRENT_BINARY_DIR}/test/xdg_runtime
|
||||
${TEST_ROOT_DIR}/bin/fish interactive.fish
|
||||
COMMAND cd tests && ${TEST_ROOT_DIR}/bin/fish interactive.fish
|
||||
DEPENDS test_prep
|
||||
USES_TERMINAL)
|
||||
endforeach(TESTTYPE)
|
||||
|
||||
# Now add a dependency chain between the serial versions.
|
||||
# This ensures they run in order.
|
||||
add_dependencies(serial_test_low_level test_prep)
|
||||
add_dependencies(serial_test_fishscript serial_test_low_level)
|
||||
add_dependencies(serial_test_interactive serial_test_fishscript)
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
|
||||
// Check whether the runtime mbrtowc implementation attempts to encode
|
||||
// invalid UTF-8 values.
|
||||
|
||||
int main() {
|
||||
// TODO: I'm not sure how to enforce a UTF-8 locale without overriding the language
|
||||
char sample[] = "hello world";
|
||||
sample[0] |= 0xF8;
|
||||
wchar_t wsample[100] {};
|
||||
std::mbstate_t state = std::mbstate_t();
|
||||
int res = std::mbrtowc(wsample, sample, strlen(sample), &state);
|
||||
|
||||
return res < 0 ? 0 : 1;
|
||||
}
|
||||
@@ -43,6 +43,9 @@
|
||||
/* Define to 1 if you have the `killpg' function. */
|
||||
#cmakedefine HAVE_KILLPG 1
|
||||
|
||||
/* Define to 1 if you have the `lrand48_r' function. */
|
||||
#cmakedefine HAVE_LRAND48_R 1
|
||||
|
||||
/* Define to 1 if you have the `mkostemp' function. */
|
||||
#cmakedefine HAVE_MKOSTEMP 1
|
||||
|
||||
@@ -58,12 +61,6 @@
|
||||
/* Define to 1 if you have the <ncurses/term.h> header file. */
|
||||
#cmakedefine HAVE_NCURSES_TERM_H 1
|
||||
|
||||
/* Define to 1 if you have the 'eventfd' function. */
|
||||
#cmakedefine HAVE_EVENTFD 1
|
||||
|
||||
/* Define to 1 if you have the 'pipe2' function. */
|
||||
#cmakedefine HAVE_PIPE2 1
|
||||
|
||||
/* Define to 1 if you have the <siginfo.h> header file. */
|
||||
#cmakedefine HAVE_SIGINFO_H 1
|
||||
|
||||
@@ -173,10 +170,6 @@
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if mbrtowc attempts to convert invalid UTF-8 sequences */
|
||||
#cmakedefine HAVE_BROKEN_MBRTOWC_UTF8 1
|
||||
|
||||
/* Support __warn_unused on function return values. */
|
||||
#if __GNUC__ >= 3
|
||||
#ifndef __warn_unused
|
||||
#define __warn_unused __attribute__ ((warn_unused_result))
|
||||
@@ -184,26 +177,3 @@
|
||||
#else
|
||||
#define __warn_unused
|
||||
#endif
|
||||
|
||||
/* Like __warn_unused, but applies to a type.
|
||||
At the moment only clang supports this as a type attribute.
|
||||
|
||||
We need to check for __has_attribute being a thing before or old gcc fails - #7554.
|
||||
*/
|
||||
#ifndef __has_attribute
|
||||
#define __has_attribute(x) 0 // Compatibility with non-clang and old gcc compilers.
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && __has_attribute(warn_unused_result)
|
||||
#ifndef __warn_unused_type
|
||||
#define __warn_unused_type __attribute__ ((warn_unused_result))
|
||||
#endif
|
||||
#else
|
||||
#define __warn_unused_type
|
||||
#endif
|
||||
|
||||
#if __has_attribute(fallthrough)
|
||||
#define __fallthrough__ __attribute__ ((fallthrough));
|
||||
#else
|
||||
#define __fallthrough__
|
||||
#endif
|
||||
|
||||
2
debian/control
vendored
2
debian/control
vendored
@@ -25,7 +25,7 @@ Package: fish-common
|
||||
Architecture: all
|
||||
Multi-Arch: foreign
|
||||
Depends: ${misc:Depends}
|
||||
Recommends: fish, python3 (>= 3.5)
|
||||
Recommends: fish, python3 (>= 3.5), python3-distutils
|
||||
Suggests: xdg-utils
|
||||
Replaces: fish (<= 2.1.1.dfsg-2)
|
||||
Description: friendly interactive shell (architecture-independent files)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Release notes
|
||||
#############
|
||||
CHANGELOG
|
||||
#########
|
||||
|
||||
.. include:: ../CHANGELOG.rst
|
||||
10
doc_src/_static/custom.css
Normal file
10
doc_src/_static/custom.css
Normal file
@@ -0,0 +1,10 @@
|
||||
.sphinxsidebar ul.current > li.current { font-weight: bold }
|
||||
|
||||
kbd {
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #aaa;
|
||||
border-radius: .2em;
|
||||
box-shadow: 0.1em 0.1em 0.2em rgba(0,0,0,0.1);
|
||||
color: #000;
|
||||
padding: 0.1em 0.3em;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@import "pydoctheme.css";
|
||||
@import "nature.css";
|
||||
|
||||
.highlight .hll { background-color: #ffffcc }
|
||||
.highlight { background: #f8f8f8; }
|
||||
@@ -77,3 +77,8 @@
|
||||
.highlight .vi { color: #000000 } /* Name.Variable.Instance */
|
||||
.highlight .vm { color: #000000 } /* Name.Variable.Magic */
|
||||
.highlight .il { color: #0000cf; font-weight: bold } /* Literal.Number.Integer.Long */
|
||||
.purple { color: #551a8b }
|
||||
.yellow { color: #FFFF00 }
|
||||
.red { color: #FF0000 }
|
||||
.gray { color: #555555 }
|
||||
.underline { text-decoration: underline }
|
||||
@@ -9,7 +9,7 @@ Synopsis
|
||||
::
|
||||
|
||||
abbr --add [SCOPE] WORD EXPANSION
|
||||
abbr --erase WORD...
|
||||
abbr --erase WORD
|
||||
abbr --rename [SCOPE] OLD_WORD NEW_WORD
|
||||
abbr --show
|
||||
abbr --list
|
||||
@@ -35,7 +35,7 @@ The following options are available:
|
||||
|
||||
- ``-l`` or ``--list`` Lists all abbreviated words.
|
||||
|
||||
- ``-e WORD`` or ``--erase WORD...`` Erase the given abbreviations.
|
||||
- ``-e WORD`` or ``--erase WORD`` Erase the abbreviation WORD.
|
||||
|
||||
- ``-q`` or ``--query`` Return 0 (true) if one of the WORDs is an abbreviation.
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ The following code will create ``rmi``, which runs ``rm`` with additional argume
|
||||
rm -i $argv
|
||||
end
|
||||
|
||||
# This needs to have the spaces escaped or "Chrome.app..."
|
||||
# will be seen as an argument to "/Applications/Google":
|
||||
# This needs to have the spaces escaped or "Chrome.app..." will be seen as an argument to "/Applications/Google":
|
||||
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome banana'
|
||||
|
||||
|
||||
@@ -18,16 +18,16 @@ This command makes it easy for fish scripts and functions to handle arguments li
|
||||
|
||||
Each option specification (``OPTION_SPEC``) is written in the `domain specific language <#option-specifications>`__ described below. All OPTION_SPECs must appear after any argparse flags and before the ``--`` that separates them from the arguments to be parsed.
|
||||
|
||||
Each option that is seen in the ARG list will result in variables named ``_flag_X``, where ``X`` is the short flag letter and the long flag name (if they are defined). For example a ``--help`` option could cause argparse to define one variable called ``_flag_h`` and another called ``_flag_help``.
|
||||
Each option that is seen in the ARG list will result in a var name of the form ``_flag_X``, where ``X`` is the short flag letter and the long flag name. The OPTION_SPEC always requires a short flag even if it can't be used. So there will always be ``_flag_X`` var set using the short flag letter if the corresponding short or long flag is seen. The long flag name var (e.g., ``_flag_help``) will only be defined, obviously, if the OPTION_SPEC includes a long flag name.
|
||||
|
||||
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.
|
||||
For example ``_flag_h`` and ``_flag_help`` if ``-h`` or ``--help`` is seen. The var 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 var will not be set.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
The following ``argparse`` options are available. They must appear before all OPTION_SPECs:
|
||||
|
||||
- ``-n`` or ``--name`` is the command name for use in error messages. By default the current function name will be used, or ``argparse`` if run outside of a function.
|
||||
- ``-n`` or ``--name`` is the command name for use in error messages. By default the current function name will be used, or `argparse` if run outside of a function.
|
||||
|
||||
- ``-x`` or ``--exclusive`` should be followed by a comma separated list of short or long options that are mutually exclusive. You can use this more than once to define multiple sets of mutually exclusive options.
|
||||
|
||||
@@ -44,97 +44,89 @@ The following ``argparse`` options are available. They must appear before all OP
|
||||
Usage
|
||||
-----
|
||||
|
||||
To use this command, pass the option specifications (``OPTION_SPEC``), then a mandatory ``--``, and then the arguments you want to have parsed.
|
||||
Using this command requires first passing option specifications (``OPTION_SPEC`` below), then a mandatory ``--``, and then the arguments you want to have parsed. More about this below but here is a simple example that might be used in a function named ``my_function``:
|
||||
|
||||
A simple example::
|
||||
|
||||
|
||||
::
|
||||
|
||||
argparse --name=my_function 'h/help' 'n/name=' -- $argv
|
||||
or return
|
||||
|
||||
|
||||
If ``$argv`` is empty then there is nothing to parse and ``argparse`` returns zero to indicate success. If ``$argv`` is not empty then it is checked for flags ``-h``, ``--help``, ``-n`` and ``--name``. If they are found they are removed from the arguments and local variables called ``_flag_OPTION`` are set so the script can determine which options were seen. If ``$argv`` doesn't have any errors, like a missing mandatory value for an option, then ``argparse`` exits with a status of zero. Otherwise it writes appropriate error messages to stderr and exits with a status of one.
|
||||
If ``$argv`` is empty then there is nothing to parse and ``argparse`` returns zero to indicate success. If ``$argv`` is not empty then it is checked for flags ``-h``, ``--help``, ``-n`` and ``--name``. If they are found they are removed from the arguments and local variables are set so the script can determine which options were seen. Assuming ``$argv`` doesn't have any errors, such as a missing mandatory value for an option, then ``argparse`` exits with status zero. Otherwise it writes appropriate error messages to stderr and exits with a status of one.
|
||||
|
||||
The ``or return`` means that the function returns ``argparse``'s status if it failed, so if it goes on ``argparse`` succeeded.
|
||||
The ``--`` argument is required. You do not have to include any arguments after the ``--`` but you must include the ``--``. For example, this is acceptable:
|
||||
|
||||
The ``--`` argument is required. You do not have to include any arguments after the ``--`` but you must include the ``--``. For example, this is acceptable::
|
||||
|
||||
|
||||
::
|
||||
|
||||
set -l argv
|
||||
argparse 'h/help' 'n/name' -- $argv
|
||||
|
||||
|
||||
But this is not::
|
||||
But this is not:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
set -l argv
|
||||
argparse 'h/help' 'n/name' $argv
|
||||
|
||||
The first ``--`` seen is what allows the ``argparse`` command to reliably separate the option specifications and options to ``argparse`` itself (like ``--ignore-unknown``) from the command arguments, so it is required.
|
||||
|
||||
The first ``--`` seen is what allows the ``argparse`` command to reliably separate the option specifications from the command arguments.
|
||||
|
||||
Option Specifications
|
||||
---------------------
|
||||
|
||||
Each option specification consists of:
|
||||
Each option specification is a string composed of
|
||||
|
||||
- An optional alphanumeric short flag letter, followed by a ``/`` if the short flag can be used by someone invoking your command or, for backwards compatibility, a ``-`` if it should not be exposed as a valid short flag (in which case it will also not be exposed as a flag variable).
|
||||
- A short flag letter (which is mandatory). It must be an alphanumeric or "#". The "#" character is special and means that a flag of the form ``-123`` is valid. The short flag "#" must be followed by "-" (since the short name isn't otherwise valid since ``_flag_#`` is not a valid var name) and must be followed by a long flag name with no modifiers.
|
||||
|
||||
- An optional long flag name. If not present then only the short flag letter can be used, and if that is not present either it's an error.
|
||||
- A ``/`` if the short flag can be used by someone invoking your command else ``-`` if it should not be exposed as a valid short flag. If there is no long flag name these characters should be omitted. You can also specify a '#' to indicate the short and long flag names can be used and the value can be specified as an implicit int; i.e., a flag of the form ``-NNN``.
|
||||
|
||||
- Nothing if the flag is a boolean that takes no argument or is an integer flag, or
|
||||
- A long flag name which is optional. If not present then only the short flag letter can be used.
|
||||
|
||||
- ``=`` if it requires a value and only the last instance of the flag is saved, or
|
||||
- Nothing if the flag is a boolean that takes no argument or is an implicit int flag, else
|
||||
|
||||
- ``=?`` it takes an optional value and only the last instance of the flag is saved, or
|
||||
- ``=`` if it requires a value and only the last instance of the flag is saved, else
|
||||
|
||||
- ``=?`` it takes an optional value and only the last instance of the flag is saved, else
|
||||
|
||||
- ``=+`` if it requires a value and each instance of the flag is saved.
|
||||
|
||||
- Optionally a ``!`` followed by fish script to validate the value. Typically this will be a function to run. If the exit status is zero the value for the flag is valid. If non-zero the value is invalid. Any error messages should be written to stdout (not stderr). See the section on :ref:`Flag Value Validation <flag-value-validation>` for more information.
|
||||
- Optionally a ``!`` followed by fish script to validate the value. Typically this will be a function to run. If the exit status is zero the value for the flag is valid. If non-zero the value is invalid. Any error messages should be written to stdout (not stderr). See the section on `Flag Value Validation <#flag-value-validation>`__ for more information.
|
||||
|
||||
See the :ref:`fish_opt <cmd-fish_opt>` command for a friendlier but more verbose way to create option specifications.
|
||||
|
||||
If a flag is not seen when parsing the arguments then the corresponding _flag_X var(s) will not be set.
|
||||
|
||||
Integer flag
|
||||
------------
|
||||
|
||||
Sometimes commands take numbers directly as options, like ``foo -55``. To allow this one option spec can have the ``#`` modifier so that any integer will be understood as this flag, and the last number will be given as its value (as if ``=`` was used).
|
||||
|
||||
The ``#`` must follow the short flag letter (if any), and other modifiers like ``=`` are not allowed, except for ``-`` (for backwards compatibility)::
|
||||
|
||||
m#maximum
|
||||
|
||||
This does not read numbers given as ``+NNN``, only those that look like flags - ``-NNN``.
|
||||
In the following examples if a flag is not seen when parsing the arguments then the corresponding _flag_X var(s) will not be set.
|
||||
|
||||
Note: Optional arguments
|
||||
------------------------
|
||||
|
||||
An option defined with ``=?`` can take optional arguments. Optional arguments have to be *directly attached* to the option they belong to.
|
||||
|
||||
That means the argument will only be used for the option if you use it like::
|
||||
That means you can only call::
|
||||
|
||||
cmd --flag=value
|
||||
# or
|
||||
cmd -fvalue
|
||||
|
||||
but not if used like::
|
||||
but not::
|
||||
|
||||
cmd --flag value
|
||||
# "value" here will be used as a positional argument
|
||||
# and "--flag" won't have an argument.
|
||||
# "value" here will be used as a positional argument and "--flag" won't have an argument.
|
||||
|
||||
If this weren't the case, using an option without an optional argument would be difficult if you also wanted to use positional arguments.
|
||||
|
||||
For example::
|
||||
|
||||
grep --color auto
|
||||
# Here "auto" will be used as the search string,
|
||||
# "color" will not have an argument and will fall back to the default,
|
||||
# which also *happens to be* auto.
|
||||
grep --color always
|
||||
# Here grep will still only use color "auto"matically
|
||||
# and search for the string "always".
|
||||
# Here "auto" will be used as the search string, "color" will not have an argument and will fall back to the default
|
||||
|
||||
This isn't specific to argparse but common to all things using ``getopt(3)`` (if they have optional arguments at all). That ``grep`` example is how GNU grep actually behaves.
|
||||
|
||||
.. _flag-value-validation:
|
||||
This isn't specific to argparse but common to all things using ``getopt(3)`` (if they have optional arguments at all).
|
||||
|
||||
Flag Value Validation
|
||||
---------------------
|
||||
@@ -160,26 +152,24 @@ Some OPTION_SPEC examples:
|
||||
|
||||
- ``h/help`` means that both ``-h`` and ``--help`` are valid. The flag is a boolean and can be used more than once. If either flag is used then ``_flag_h`` and ``_flag_help`` will be set to the count of how many times either flag was seen.
|
||||
|
||||
- ``help`` means that only ``--help`` is valid. The flag is a boolean and can be used more than once. If it is used then ``_flag_help`` will be set to the count of how many times the long flag was seen. Also ``h-help`` (with an arbitrary short letter) for backwards compatibility.
|
||||
|
||||
- ``longonly=`` is a flag ``--longonly`` that requires an option, there is no short flag or even short flag variable.
|
||||
- ``h-help`` means that only ``--help`` is valid. The flag is a boolean and can be used more than once. If the long flag is used then ``_flag_h`` and ``_flag_help`` will be set to the count of how many times the long flag was seen.
|
||||
|
||||
- ``n/name=`` means that both ``-n`` and ``--name`` are valid. It requires a value and can be used at most once. If the flag is seen then ``_flag_n`` and ``_flag_name`` will be set with the single mandatory value associated with the flag.
|
||||
|
||||
- ``n/name=?`` means that both ``-n`` and ``--name`` are valid. It accepts an optional value and can be used at most once. If the flag is seen then ``_flag_n`` and ``_flag_name`` will be set with the value associated with the flag if one was provided else it will be set with no values.
|
||||
|
||||
- ``name=+`` means that only ``--name`` is valid. It requires a value and can be used more than once. If the flag is seen then ``_flag_name`` will be set with the values associated with each occurrence.
|
||||
- ``n-name=+`` means that only ``--name`` is valid. It requires a value and can be used more than once. If the flag is seen then ``_flag_n`` and ``_flag_name`` will be set with the values associated with each occurrence of the flag.
|
||||
|
||||
- ``x`` means that only ``-x`` is valid. It is a boolean that can be used more than once. If it is seen then ``_flag_x`` will be set to the count of how many times the flag was seen.
|
||||
|
||||
- ``x=``, ``x=?``, and ``x=+`` are similar to the n/name examples above but there is no long flag alternative to the short flag ``-x``.
|
||||
|
||||
- ``#max`` (or ``#-max``) means that flags matching the regex "^--?\\d+$" are valid. When seen they are assigned to the variable ``_flag_max``. This allows any valid positive or negative integer to be specified by prefixing it with a single "-". Many commands support this idiom. For example ``head -3 /a/file`` to emit only the first three lines of /a/file.
|
||||
- ``x-`` is not valid since there is no long flag name and therefore the short flag, ``-x``, has to be usable.
|
||||
|
||||
- ``n#max`` means that flags matching the regex "^--?\\d+$" are valid. When seen they are assigned to the variables ``_flag_n`` and ``_flag_max``. This allows any valid positive or negative integer to be specified by prefixing it with a single "-". Many commands support this idiom. For example ``head -3 /a/file`` to emit only the first three lines of /a/file. You can also specify the value using either flag: ``-n NNN`` or ``--max NNN`` in this example.
|
||||
- ``#-max`` means that flags matching the regex "^--?\d+$" are valid. When seen they are assigned to the variable ``_flag_max``. This allows any valid positive or negative integer to be specified by prefixing it with a single "-". Many commands support this idiom. For example ``head -3 /a/file`` to emit only the first three lines of /a/file.
|
||||
|
||||
- ``#longonly`` causes the last integer option to be stored in ``_flag_longonly``.
|
||||
- ``n#max`` means that flags matching the regex "^--?\d+$" are valid. When seen they are assigned to the variables ``_flag_n`` and ``_flag_max``. This allows any valid positive or negative integer to be specified by prefixing it with a single "-". Many commands support this idiom. For example ``head -3 /a/file`` to emit only the first three lines of /a/file. You can also specify the value using either flag: ``-n NNN`` or ``--max NNN`` in this example.
|
||||
|
||||
After parsing the arguments the ``argv`` variable is set with local scope to any values not already consumed during flag processing. If there are no unbound values the variable is set but ``count $argv`` will be zero.
|
||||
After parsing the arguments the ``argv`` var is set with local scope to any values not already consumed during flag processing. If there are not unbound values the var is set but ``count $argv`` will be zero.
|
||||
|
||||
If an error occurs during argparse processing it will exit with a non-zero status and print error messages to stderr.
|
||||
|
||||
@@ -15,22 +15,18 @@ Description
|
||||
|
||||
``bg`` sends :ref:`jobs <syntax-job-control>` to the background, resuming them if they are stopped.
|
||||
|
||||
A background job is executed simultaneously with fish, and does not have access to the keyboard. If no job is specified, the last job to be used is put in the background. If ``PID`` is specified, the jobs containing the specified process IDs are put in the background.
|
||||
A background job is executed simultaneously with fish, and does not have access to the keyboard. If no job is specified, the last job to be used is put in the background. If PID is specified, the jobs with the specified process group IDs are put in the background.
|
||||
|
||||
For compatibility with other shells, job expansion syntax is supported for ``bg``. A PID of the format ``%1`` will be interpreted as the PID of job 1. Job numbers can be seen in the output of :ref:`jobs <cmd-jobs>`.
|
||||
|
||||
When at least one of the arguments isn't a valid job specifier,
|
||||
When at least one of the arguments isn't a valid job specifier (i.e. PID),
|
||||
``bg`` will print an error without backgrounding anything.
|
||||
|
||||
When all arguments are valid job specifiers, ``bg`` will background all matching jobs that exist.
|
||||
When all arguments are valid job specifiers, bg will background all matching jobs that exist.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
``bg 123 456 789`` will background the jobs that contain processes 123, 456 and 789.
|
||||
``bg 123 456 789`` will background 123, 456 and 789.
|
||||
|
||||
If only 123 and 789 exist, it will still background them and print an error about 456.
|
||||
|
||||
``bg 123 banana`` or ``bg banana 123`` will complain that "banana" is not a valid job specifier.
|
||||
|
||||
``bg %1`` will background job 1.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
bind - handle fish key bindings
|
||||
===============================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
@@ -27,11 +28,9 @@ The generic key binding that matches if no other binding does can be set by spec
|
||||
|
||||
If the ``-k`` switch is used, the name of a key (such as 'down', 'up' or 'backspace') is used instead of a sequence. The names used are the same as the corresponding curses variables, but without the 'key\_' prefix. (See ``terminfo(5)`` for more information, or use ``bind --key-names`` for a list of all available named keys). Normally this will print an error if the current ``$TERM`` entry doesn't have a given key, unless the ``-s`` switch is given.
|
||||
|
||||
To find out what sequence a key combination sends, you can use :ref:`fish_key_reader <cmd-fish_key_reader>`.
|
||||
|
||||
``COMMAND`` can be any fish command, but it can also be one of a set of special input functions. These include functions for moving the cursor, operating on the kill-ring, performing tab completion, etc. Use ``bind --function-names`` for a complete list of these input functions.
|
||||
|
||||
When ``COMMAND`` is a shellscript command, it is a good practice to put the actual code into a :ref:`function <syntax-function>` and simply bind to the function name. This way it becomes significantly easier to test the function while editing, and the result is usually more readable as well.
|
||||
When ``COMMAND`` is a shellscript command, it is a good practice to put the actual code into a `function <#function>`__ and simply bind to the function name. This way it becomes significantly easier to test the function while editing, and the result is usually more readable as well.
|
||||
|
||||
If a script produces output, it should finish by calling ``commandline -f repaint`` to tell fish that a repaint is in order.
|
||||
|
||||
@@ -99,8 +98,6 @@ The following special input functions are available:
|
||||
|
||||
- ``cancel``, cancel the current commandline and replace it with a new empty one
|
||||
|
||||
- ``cancel-commandline``, cancel the current commandline and replace it with a new empty one, leaving the old one in place with a marker to show that it was cancelled
|
||||
|
||||
- ``capitalize-word``, make the current word begin with a capital letter
|
||||
|
||||
- ``complete``, guess the remainder of the current token
|
||||
@@ -123,18 +120,16 @@ The following special input functions are available:
|
||||
|
||||
- ``end-selection``, end selecting text
|
||||
|
||||
- ``expand-abbr``, expands any abbreviation currently under the cursor
|
||||
- ``expand-abbr`` expands any abbreviation currently under the cursor
|
||||
|
||||
- ``execute``, run the current commandline
|
||||
- ``execute`` run the current commandline
|
||||
|
||||
- ``exit``, exit the shell
|
||||
- ``force-repaint`` reexecute the prompt functions without coalescing
|
||||
|
||||
- ``forward-bigword``, move one whitespace-delimited word to the right
|
||||
|
||||
- ``forward-char``, move one character to the right
|
||||
|
||||
- ``forward-single-char``, move one character to the right; if an autosuggestion is available, only take a single char from it
|
||||
|
||||
- ``forward-word``, move one word to the right
|
||||
|
||||
- ``history-search-backward``, search the history for the previous match
|
||||
@@ -165,30 +160,24 @@ The following special input functions are available:
|
||||
|
||||
- ``kill-word``, move the next word to the killring
|
||||
|
||||
- ``or``, only execute the next function if the previous succeeded (note: only some functions report success)
|
||||
|
||||
- ``pager-toggle-search``, toggles the search field if the completions pager is visible.
|
||||
|
||||
- ``repaint``, reexecutes the prompt functions and redraws the prompt (also ``force-repaint`` for backwards-compatibility)
|
||||
- ``repaint`` reexecutes the prompt functions and redraws the prompt. Multiple successive repaints are coalesced.
|
||||
|
||||
- ``repaint-mode``, reexecutes the :ref:`fish_mode_prompt <cmd-fish_mode_prompt>` and redraws the prompt. This is useful for vi-mode. If no ``fish_mode_prompt`` exists or it prints nothing, it acts like a normal repaint.
|
||||
- ``repaint-mode`` reexecutes the :ref:`fish_mode_prompt <cmd-fish_mode_prompt>` and redraws the prompt. This is useful for vi-mode. If no ``fish_mode_prompt`` exists, it acts like a normal repaint.
|
||||
|
||||
- ``self-insert``, inserts the matching sequence into the command line
|
||||
|
||||
- ``self-insert-notfirst``, inserts the matching sequence into the command line, unless the cursor is at the beginning
|
||||
|
||||
- ``suppress-autosuggestion``, remove the current autosuggestion. Returns true if there was a suggestion to remove.
|
||||
- ``suppress-autosuggestion``, remove the current autosuggestion
|
||||
|
||||
- ``swap-selection-start-stop``, go to the other end of the highlighted text without changing the selection
|
||||
|
||||
- ``transpose-chars``, transpose two characters to the left of the cursor
|
||||
- ``transpose-chars``, transpose two characters to the left of the cursor
|
||||
|
||||
- ``transpose-words``, transpose two words to the left of the cursor
|
||||
|
||||
- ``insert-line-under``, add a new line under the current line
|
||||
|
||||
- ``insert-line-over``, add a new line over the current line
|
||||
|
||||
- ``up-line``, move up one line
|
||||
|
||||
- ``undo`` and ``redo``, revert or redo the most recent edits on the command line
|
||||
@@ -202,23 +191,34 @@ The following special input functions are available:
|
||||
Examples
|
||||
--------
|
||||
|
||||
Exit the shell when :kbd:`Control`\ +\ :kbd:`D` is pressed::
|
||||
::
|
||||
|
||||
bind \cd 'exit'
|
||||
|
||||
Perform a history search when :kbd:`Page Up` is pressed::
|
||||
Causes ``fish`` to exit when :kbd:`Control`\ +\ :kbd:`D` is pressed.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
bind -k ppage history-search-backward
|
||||
|
||||
Turn on Vi key bindings and rebind :kbd:`Control`\ +\ :kbd:`C` to clear the input line::
|
||||
Performs a history search when the :kbd:`Page Up` key is pressed.
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
set -g fish_key_bindings fish_vi_key_bindings
|
||||
bind -M insert \cc kill-whole-line repaint
|
||||
bind -M insert \cc kill-whole-line force-repaint
|
||||
|
||||
Launch ``git diff`` and repaint the commandline afterwards when :kbd:`Control`\ +\ :kbd:`G` is pressed::
|
||||
Turns on Vi key bindings and rebinds :kbd:`Control`\ +\ :kbd:`C` to clear the input line.
|
||||
|
||||
::
|
||||
bind \cg 'git diff; commandline -f repaint'
|
||||
|
||||
Causes :kbd:`Control`\ +\ :kbd:`G` to launch ``git diff`` and repaint the commandline afterwards.
|
||||
|
||||
.. _cmd-bind-termlimits:
|
||||
|
||||
Terminal Limitations
|
||||
@@ -231,7 +231,7 @@ For instance, the control key modifies a character by setting the top three bits
|
||||
- Many characters + control are indistinguishable from other keys. :kbd:`Control`\ +\ :kbd:`I` *is* tab, :kbd:`Control`\ +\ :kbd:`J` *is* newline (`\n`).
|
||||
- Control and shift don't work simultaneously
|
||||
|
||||
Other keys don't have a direct encoding, and are sent as escape sequences. For example :kbd:`→` (Right) often sends ``\e\[C``. These can differ from terminal to terminal, and the mapping is typically available in `terminfo(5)`. Sometimes however a terminal identifies as e.g. ``xterm-256color`` for compatibility, but then implements xterm's sequences incorrectly.
|
||||
Other keys don't have a direct encoding, and are sent as escape sequences. For example :kbd:`→` (Right) often sends `\e\[C`. These can differ from terminal to terminal, and the mapping is typically available in `terminfo(5)`. Sometimes however a terminal identifies as e.g. `xterm-256color` for compatibility, but then implements xterm's sequences incorrectly.
|
||||
|
||||
.. _cmd-bind-escape:
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ The following options are available:
|
||||
|
||||
- ``-a`` or ``--all`` returns all the external COMMANDNAMEs that are found in ``$PATH`` in the order they are found.
|
||||
|
||||
- ``-q`` or ``--query``, silences the output and prints nothing, setting only the exit status. Implies ``--search``. For compatibility with old fish versions this is also ``--quiet`` (but this is deprecated).
|
||||
- ``-q`` or ``--quiet``, silences the output and prints nothing, setting only the exit status. Implies ``--search``.
|
||||
|
||||
- ``-s`` or ``--search`` returns the name of the external command that would be executed, or nothing if no file with the specified name could be found in the ``$PATH``.
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ The following options change what part of the commandline is printed or updated:
|
||||
|
||||
- ``-b`` or ``--current-buffer`` select the entire buffer, including any displayed autosuggestion (default)
|
||||
|
||||
- ``-j`` or ``--current-job`` select the current job - a `job` here is one pipeline. It stops at logical operators or terminators (``;``, ``&`` or newlines).
|
||||
- ``-j`` or ``--current-job`` select the current job - a `job` here is one pipeline. It stops at logical operators or terminators (`;`, `&` or newlines).
|
||||
|
||||
- ``-p`` or ``--current-process`` select the current process - a `process` here is one simple command. It stops at logical operators, terminators or pipes.
|
||||
|
||||
@@ -77,11 +77,11 @@ If the commandline contains
|
||||
|
||||
(with the cursor on the "o" of "flounder")
|
||||
|
||||
The ``echo $flounder >&`` is the first process, ``less`` the second and ``and echo $catfish`` the third.
|
||||
The `echo $flounder >&` is the first process, `less` the second and `and echo $catfish` the third.
|
||||
|
||||
``echo $flounder >&2 | less`` is the first job, ``and echo $catfish`` the second.
|
||||
`echo $flounder >&2 | less` is the first job, `and echo $catfish` the second.
|
||||
|
||||
``$flounder`` is the current token.
|
||||
`$flounder` is the current token.
|
||||
|
||||
More examples:
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Synopsis
|
||||
|
||||
::
|
||||
|
||||
complete [( -c | --command | -p | --path )] COMMAND
|
||||
complete ( -c | --command | -p | --path ) COMMAND
|
||||
[( -c | --command | -p | --path ) COMMAND]...
|
||||
[( -e | --erase )]
|
||||
[( -s | --short-option ) SHORT_OPTION]...
|
||||
@@ -27,14 +27,22 @@ Synopsis
|
||||
Description
|
||||
-----------
|
||||
|
||||
``complete`` defines, removes or lists completions for a command.
|
||||
|
||||
For an introduction to writing your own completions, see :ref:`Writing your own completions <completion-own>` in
|
||||
For an introduction to specifying completions, see :ref:`Writing your own completions <completion-own>` in
|
||||
the fish manual.
|
||||
|
||||
- ``-c COMMAND`` or ``--command COMMAND`` specifies that ``COMMAND`` is the name of the command. If there is no ``-c`` or ``-p``, one non-option argument will be used as the command.
|
||||
- ``COMMAND`` is the name of the command for which to add a completion.
|
||||
|
||||
- ``-p COMMAND`` or ``--path COMMAND`` specifies that ``COMMAND`` is the absolute path of the command (optionally containing wildcards).
|
||||
- ``SHORT_OPTION`` is a one character option for the command.
|
||||
|
||||
- ``LONG_OPTION`` is a multi character option for the command.
|
||||
|
||||
- ``OPTION_ARGUMENTS`` is parameter containing a space-separated list of possible option-arguments, which may contain command substitutions.
|
||||
|
||||
- ``DESCRIPTION`` is a description of what the option and/or option arguments do.
|
||||
|
||||
- ``-c COMMAND`` or ``--command COMMAND`` specifies that ``COMMAND`` is the name of the command.
|
||||
|
||||
- ``-p COMMAND`` or ``--path COMMAND`` specifies that ``COMMAND`` is the absolute path of the program (optionally containing wildcards).
|
||||
|
||||
- ``-e`` or ``--erase`` deletes the specified completion.
|
||||
|
||||
@@ -46,57 +54,66 @@ the fish manual.
|
||||
|
||||
- ``-a OPTION_ARGUMENTS`` or ``--arguments=OPTION_ARGUMENTS`` adds the specified option arguments to the completions list.
|
||||
|
||||
- ``-k`` or ``--keep-order`` keeps the order of the ``OPTION_ARGUMENTS`` instead of sorting alphabetically. Multiple ``complete`` calls with ``-k`` result in arguments of the later ones displayed first.
|
||||
- ``-k`` or ``--keep-order`` preserves the order of the ``OPTION_ARGUMENTS`` specified via ``-a`` or ``--arguments`` instead of sorting alphabetically. Multiple ``complete`` calls with ``-k`` result in arguments of the later ones displayed first.
|
||||
|
||||
- ``-f`` or ``--no-files`` says that this completion may not be followed by a filename.
|
||||
- ``-f`` or ``--no-files`` says that the options specified by this completion may not be followed by a filename.
|
||||
|
||||
- ``-F`` or ``--force-files`` says that this completion may be followed by a filename, even if another applicable ``complete`` specified ``--no-files``.
|
||||
- ``-F`` or ``--force-files`` says that the options specified by this completion may be followed by a filename, even if another applicable ``complete`` specified ``--no-files``.
|
||||
|
||||
- ``-r`` or ``--require-parameter`` says that this completion must have an option argument, i.e. may not be followed by another option.
|
||||
- ``-r`` or ``--require-parameter`` says that the options specified by this completion must have an option argument, i.e. may not be followed by another option.
|
||||
|
||||
- ``-x`` or ``--exclusive`` is short for ``-r`` and ``-f``.
|
||||
- ``-x`` or ``--exclusive`` implies both ``-r`` and ``-f``.
|
||||
|
||||
- ``-w WRAPPED_COMMAND`` or ``--wraps=WRAPPED_COMMAND`` causes the specified command to inherit completions from the wrapped command (See below for details).
|
||||
|
||||
- ``-n CONDITION`` or ``--condition CONDITION`` specifies that this completion should only be used if the CONDITION (a shell command) returns 0. This makes it possible to specify completions that should only be used in some cases.
|
||||
- ``-n`` or ``--condition`` specifies a shell command that must return 0 if the completion is to be used. This makes it possible to specify completions that should only be used in some cases.
|
||||
|
||||
- ``-C STRING`` or ``--do-complete=STRING`` makes complete try to find all possible completions for the specified string. If there is no STRING, the current commandline is used instead.
|
||||
- ``-CSTRING`` or ``--do-complete=STRING`` makes complete try to find all possible completions for the specified string.
|
||||
|
||||
Command specific tab-completions in ``fish`` are based on the notion of options and arguments. An option is a parameter which begins with a hyphen, such as ``-h``, ``-help`` or ``--help``. Arguments are parameters that do not begin with a hyphen. Fish recognizes three styles of options, the same styles as the GNU getopt library. These styles are:
|
||||
- ``-C`` or ``--do-complete`` with no argument makes complete try to find all possible completions for the current command line buffer. If the shell is not in interactive mode, an error is returned.
|
||||
|
||||
- Short options, like ``-a``. Short options are a single character long, are preceded by a single hyphen and can be grouped together (like ``-la``, which is equivalent to ``-l -a``). Option arguments may be specified in the following parameter (``-w 32``) or by appending the option with the value (``-w32``).
|
||||
- ``-A`` and ``--authoritative`` no longer do anything and are silently ignored.
|
||||
|
||||
- Old style long options, like ``-Wall`` or ``-name``. Old style long options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified in the following parameter (``-ao null``).
|
||||
- ``-u`` and ``--unauthoritative`` no longer do anything and are silently ignored.
|
||||
|
||||
- GNU style long options, like ``--colors``. GNU style long options can be more than one character long, are preceded by two hyphens, and can't be grouped together. Option arguments may be specified in the following parameter (``--quoting-style shell``) or after a ``=`` (``--quoting-style=shell``).
|
||||
Command specific tab-completions in ``fish`` are based on the notion of options and arguments. An option is a parameter which begins with a hyphen, such as ``-h``, ``-help`` or ``--help``. Arguments are parameters that do not begin with a hyphen. Fish recognizes three styles of options, the same styles as the GNU version of the getopt library. These styles are:
|
||||
|
||||
Multiple commands and paths can be given in one call to define the same completions for multiple commands.
|
||||
- Short options, like ``-a``. Short options are a single character long, are preceded by a single hyphen and may be grouped together (like ``-la``, which is equivalent to ``-l -a``). Option arguments may be specified in the following parameter (``-w 32``) or by appending the option with the value (``-w32``).
|
||||
|
||||
Multiple command switches and wrapped commands can also be given to define multiple completions in one call.
|
||||
- Old style long options, like ``-Wall``. Old style long options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified in the following parameter (``-ao null``).
|
||||
|
||||
- GNU style long options, like ``--colors``. GNU style long options can be more than one character long, are preceded by two hyphens, and may not be grouped together. Option arguments may be specified in the following parameter (``--quoting-style shell``) or by appending the option with a ``=`` and the value (``--quoting-style=shell``). GNU style long options may be abbreviated so long as the abbreviation is unique (``--h``) is equivalent to ``--help`` if help is the only long option beginning with an 'h').
|
||||
|
||||
The options for specifying command name and command path may be used multiple times to define the same completions for multiple commands.
|
||||
|
||||
The options for specifying command switches and wrapped commands may be used multiple times to define multiple completions for the command(s) in a single call.
|
||||
|
||||
Invoking ``complete`` multiple times for the same command adds the new definitions on top of any existing completions defined for the command.
|
||||
|
||||
When ``-a`` or ``--arguments`` is specified in conjunction with long, short, or old style options, the specified arguments are only completed as arguments for any of the specified options. If ``-a`` or ``--arguments`` is specified without any long, short, or old style options, the specified arguments are used when completing any argument to the command (except when completing an option argument that was specified with ``-r`` or ``--require-parameter``).
|
||||
When ``-a`` or ``--arguments`` is specified in conjunction with long, short, or old style options, the specified arguments are only used as completions when attempting to complete an argument for any of the specified options. If ``-a`` or ``--arguments`` is specified without any long, short, or old style options, the specified arguments are used when completing any argument to the command (except when completing an option argument that was specified with ``-r`` or ``--require-parameter``).
|
||||
|
||||
Command substitutions found in ``OPTION_ARGUMENTS`` should return a newline-separated list of arguments, and each argument may optionally have a tab character followed by the argument description. Description given this way override a description given with ``-d`` or ``--description``.
|
||||
Command substitutions found in ``OPTION_ARGUMENTS`` are not expected to return a space-separated list of arguments. Instead they must return a newline-separated list of arguments, and each argument may optionally have a tab character followed by the argument description. Any description provided in this way overrides a description given with ``-d`` or ``--description``.
|
||||
|
||||
The ``-w`` or ``--wraps`` options causes the specified command to inherit completions from another command, "wrapping" the other command. The wrapping command can also have additional completions. A command can wrap multiple commands, and wrapping is transitive: if A wraps B, and B wraps C, then A automatically inherits all of C's completions. Wrapping can be removed using the ``-e`` or ``--erase`` options. Wrapping only works for completions specified with ``-c`` or ``--command`` and are ignored when specifying completions with ``-p`` or ``--path``.
|
||||
The ``-w`` or ``--wraps`` options causes the specified command to inherit completions from another command. The inheriting command is said to "wrap" the inherited command. The wrapping command may have its own completions in addition to inherited ones. A command may wrap multiple commands, and wrapping is transitive: if A wraps B, and B wraps C, then A automatically inherits all of C's completions. Wrapping can be removed using the ``-e`` or ``--erase`` options. Note that wrapping only works for completions specified with ``-c`` or ``--command`` and are ignored when specifying completions with ``-p`` or ``--path``.
|
||||
|
||||
When erasing completions, it is possible to either erase all completions for a specific command by specifying ``complete -c COMMAND -e``, or by specifying a specific completion option to delete.
|
||||
When erasing completions, it is possible to either erase all completions for a specific command by specifying ``complete -c COMMAND -e``, or by specifying a specific completion option to delete by specifying either a long, short or old style option.
|
||||
|
||||
When ``complete`` is called without anything that would define or erase completions (options, arguments, wrapping, ...), it shows matching completions instead. So ``complete`` without any arguments shows all loaded completions, ``complete -c foo`` shows all loaded completions for ``foo``. Since completions are :ref:`autoloaded <syntax-function-autoloading>`, you will have to trigger them first.
|
||||
|
||||
Examples
|
||||
--------
|
||||
Example
|
||||
-------
|
||||
|
||||
The short style option ``-o`` for the ``gcc`` command requires that a file follows it. This can be done using writing:
|
||||
|
||||
|
||||
The short style option ``-o`` for the ``gcc`` command needs a file argument:
|
||||
|
||||
::
|
||||
|
||||
complete -c gcc -s o -r
|
||||
|
||||
|
||||
The short style option ``-d`` for the ``grep`` command requires one of ``read``, ``skip`` or ``recurse``:
|
||||
The short style option ``-d`` for the ``grep`` command requires that one of the strings ``read``, ``skip`` or ``recurse`` is used. This can be specified writing:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
@@ -105,6 +122,8 @@ The short style option ``-d`` for the ``grep`` command requires one of ``read``,
|
||||
|
||||
The ``su`` command takes any username as an argument. Usernames are given as the first colon-separated field in the file /etc/passwd. This can be specified as:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
complete -x -c su -d "Username" -a "(cat /etc/passwd | cut -d : -f 1)"
|
||||
@@ -114,6 +133,8 @@ The ``rpm`` command has several different modes. If the ``-e`` or ``--erase`` fl
|
||||
|
||||
This can be written as:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
complete -c rpm -n "__fish_contains_opt -s e erase" -l nodeps -d "Don't check dependencies"
|
||||
@@ -130,10 +151,5 @@ To implement an alias, use the ``-w`` or ``--wraps`` option:
|
||||
complete -c hub -w git
|
||||
|
||||
|
||||
Now hub inherits all of the completions from git. Note this can also be specified in a function declaration (``function thing -w otherthing``).
|
||||
Now hub inherits all of the completions from git. Note this can also be specified in a function declaration.
|
||||
|
||||
::
|
||||
|
||||
complete -c git
|
||||
|
||||
Show all completions for ``git``.
|
||||
|
||||
@@ -34,8 +34,7 @@ Example
|
||||
# Returns the number of directories in the users PATH variable.
|
||||
|
||||
count *.txt
|
||||
# Returns the number of files in the current working directory
|
||||
# ending with the suffix '.txt'.
|
||||
# Returns the number of files in the current working directory ending with the suffix '.txt'.
|
||||
|
||||
git ls-files --others --exclude-standard | count
|
||||
# Returns the number of untracked files in a git repository
|
||||
|
||||
@@ -25,8 +25,6 @@ The following options are available:
|
||||
|
||||
- ``-e``, Enable interpretation of backslash escapes
|
||||
|
||||
Unlike other shells, this echo accepts ``--`` to signal the end of the options.
|
||||
|
||||
Escape Sequences
|
||||
----------------
|
||||
|
||||
@@ -61,15 +59,15 @@ Example
|
||||
|
||||
::
|
||||
|
||||
> echo 'Hello World'
|
||||
Hello World
|
||||
echo 'Hello World'
|
||||
|
||||
> echo -e 'Top\nBottom'
|
||||
Top
|
||||
Bottom
|
||||
Print hello world to stdout
|
||||
|
||||
> echo -- -n
|
||||
-n
|
||||
::
|
||||
|
||||
echo -e 'Top\\nBottom'
|
||||
|
||||
Print Top and Bottom on separate lines, using an escape sequence
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
@@ -13,13 +13,10 @@ Synopsis
|
||||
Description
|
||||
-----------
|
||||
|
||||
``fg`` brings the specified :ref:`job <syntax-job-control>` to the foreground, resuming it if it is stopped. While a foreground job is executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If ``PID`` is specified, the job containing a process with the specified process ID is put in the foreground.
|
||||
``fg`` brings the specified :ref:`job <syntax-job-control>` to the foreground, resuming it if it is stopped. While a foreground job is executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If PID is specified, the job with the specified group ID is put in the foreground.
|
||||
|
||||
For compatibility with other shells, job expansion syntax is supported for ``fg``. A ``PID`` of the format ``%1`` will foreground job 1. Job numbers can be seen in the output of :ref:`jobs <cmd-jobs>`.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
``fg`` will put the last job in the foreground.
|
||||
|
||||
``fg %3`` will put job 3 into the foreground.
|
||||
|
||||
@@ -8,7 +8,7 @@ Synopsis
|
||||
|
||||
::
|
||||
|
||||
fish [OPTIONS] [-c command] [FILE] [ARGUMENTS...]
|
||||
fish [OPTIONS] [-c command] [FILE [ARGUMENTS...]]
|
||||
|
||||
Description
|
||||
-----------
|
||||
@@ -17,7 +17,7 @@ fish is a command-line shell written mainly with interactive use in mind. This p
|
||||
|
||||
The following options are available:
|
||||
|
||||
- ``-c`` or ``--command=COMMANDS`` evaluate the specified commands instead of reading from the commandline, passing any additional positional arguments via :ref:`$argv <variables-argv>`. Note that, unlike other shells, the first argument is *not* the name of the program (``$0``), but simply the first normal argument.
|
||||
- ``-c`` or ``--command=COMMANDS`` evaluate the specified commands instead of reading from the commandline
|
||||
|
||||
- ``-C`` or ``--init-command=COMMANDS`` evaluate the specified commands after reading the configuration, before running the command specified by ``-c`` or reading interactive input
|
||||
|
||||
@@ -31,9 +31,7 @@ The following options are available:
|
||||
|
||||
- ``-n`` or ``--no-execute`` do not execute any commands, only perform syntax checking
|
||||
|
||||
- ``-p`` or ``--profile=PROFILE_FILE`` when fish exits, output timing information on all executed commands to the specified file. This excludes time spent starting up and reading the configuration.
|
||||
|
||||
- ``--profile-startup=PROFILE_FILE`` will write timing information for fish's startup to the specified file. This is useful to profile your configuration.
|
||||
- ``-p`` or ``--profile=PROFILE_FILE`` when fish exits, output timing information on all executed commands to the specified file
|
||||
|
||||
- ``-P`` or ``--private`` enables :ref:`private mode <private-mode>`, so fish will not access old or store new history.
|
||||
|
||||
@@ -43,6 +41,8 @@ The following options are available:
|
||||
|
||||
- ``-v`` or ``--version`` display version and exit
|
||||
|
||||
- ``-D`` or ``--debug-stack-frames=DEBUG_LEVEL`` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
|
||||
|
||||
- ``-f`` or ``--features=FEATURES`` enables one or more :ref:`feature flags <featureflags>` (separated by a comma). These are how fish stages changes that might break scripts.
|
||||
|
||||
The fish exit status is generally the :ref:`exit status of the last foreground command <variables-status>`.
|
||||
@@ -63,7 +63,3 @@ Available categories are listed by ``fish --print-debug-categories``. The ``--de
|
||||
Debug messages output to stderr by default. Note that if ``fish_trace`` is set, execution tracing also outputs to stderr by default. You can output to a file using the ``--debug-output`` option::
|
||||
|
||||
> fish --debug='complete,*history*' --debug-output=/tmp/fish.log --init-command='set fish_trace on'
|
||||
|
||||
These options can also be changed via the $FISH_DEBUG and $FISH_DEBUG_OUTPUT variables. The categories enabled via ``--debug`` are *added* to the ones enabled by $FISH_DEBUG, so they can be disabled by prefixing them with ``-`` (``reader-*,-ast*`` enables reader debugging and disables ast debugging).
|
||||
|
||||
The file given in ``--debug-output`` takes precedence over the file in $FISH_DEBUG_OUTPUT.
|
||||
|
||||
@@ -20,7 +20,7 @@ Description
|
||||
|
||||
It is (by default) safe to use ``fish_add_path`` in config.fish, or it can be used once, interactively, and the paths will stay in future because of :ref:`universal variables <variables-universal>`. This is a "do what I mean" style command, if you need more control, consider modifying the variable yourself.
|
||||
|
||||
Components are normalized by :ref:`realpath <cmd-realpath>`. This means that trailing slashes are ignored and relative paths are made absolute (but symlinks are not resolved). If a component already exists, it is not added again and stays in the same place unless the ``--move`` switch is given.
|
||||
Components are normalized by :ref:`realpath <cmd-realpath>`. This means that trailing slashes are ignored and symlinks are resolved, and relative paths are made absolute. If a component already exists, it is not added again and stays in the same place unless the ``--move`` switch is given.
|
||||
|
||||
Components are added in the order they are given, and they are prepended to the path unless ``--append`` is given (if $fish_user_paths is used, that means they are last in $fish_user_paths, which is itself prepended to $PATH, so they still stay ahead of the system paths).
|
||||
|
||||
@@ -50,20 +50,17 @@ Example
|
||||
::
|
||||
|
||||
# I just installed mycoolthing and need to add it to the path to use it.
|
||||
> fish_add_path /opt/mycoolthing/bin
|
||||
fish_add_path /opt/mycoolthing/bin
|
||||
|
||||
# I want my ~/.local/bin to be checked first.
|
||||
> fish_add_path -m ~/.local/bin
|
||||
fish_add_path -m ~/.local/bin
|
||||
|
||||
# I prefer using a global fish_user_paths
|
||||
> fish_add_path -g ~/.local/bin ~/.otherbin /usr/local/sbin
|
||||
fish_add_path -g ~/.local/bin ~/.otherbin /usr/local/sbin
|
||||
|
||||
# I want to append to the entire $PATH because this directory contains fallbacks
|
||||
> fish_add_path -aP /opt/fallback/bin
|
||||
fish_add_path -aP /opt/fallback/bin
|
||||
|
||||
# I want to add the bin/ directory of my current $PWD (say /home/nemo/)
|
||||
> fish_add_path -v bin/
|
||||
set fish_user_paths /home/nemo/bin /usr/bin /home/nemo/.local/bin
|
||||
|
||||
# I have installed ruby via homebrew
|
||||
> fish_add_path /usr/local/opt/ruby/bin
|
||||
|
||||
@@ -16,7 +16,7 @@ Synopsis
|
||||
Description
|
||||
-----------
|
||||
|
||||
``fish_breakpoint_prompt`` is the prompt function when asking for input in response to a :ref:`breakpoint <cmd-breakpoint>` command.
|
||||
By defining the ``fish_breakpoint_prompt`` function, the user can choose a custom prompt when asking for input in response to a :ref:`breakpoint <cmd-breakpoint>` command. The ``fish_breakpoint_prompt`` function is executed when the prompt is to be shown, and the output is used as a prompt.
|
||||
|
||||
The exit status of commands within ``fish_breakpoint_prompt`` will not modify the value of :ref:`$status <variables-status>` outside of the ``fish_breakpoint_prompt`` function.
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
.. _cmd-fish_cmd_not_found:
|
||||
|
||||
fish_command_not_found - what to do when a command wasn't found
|
||||
===============================================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
function fish_command_not_found
|
||||
...
|
||||
end
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
When fish tries to execute a command and can't find it, it invokes this function.
|
||||
|
||||
It can print a message to tell you about it, and it often also checks for a missing package that would include the command.
|
||||
|
||||
Fish ships multiple handlers for various operating systems and chooses from them when this function is loaded,
|
||||
or you can define your own.
|
||||
|
||||
It receives the full commandline as one argument per token, so $argv[1] contains the missing command.
|
||||
|
||||
When you leave ``fish_command_not_found`` undefined (e.g. by adding an empty function file) or explicitly call ``__fish_default_command_not_found_handler``, fish will just print a simple error.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
A simple handler:
|
||||
|
||||
::
|
||||
|
||||
function fish_command_not_found
|
||||
echo Did not find command $argv[1]
|
||||
end
|
||||
|
||||
> flounder
|
||||
Did not find command flounder
|
||||
|
||||
Or the handler for OpenSUSE's command-not-found::
|
||||
|
||||
function fish_command_not_found
|
||||
/usr/bin/command-not-found $argv[1]
|
||||
end
|
||||
|
||||
Or the simple default handler::
|
||||
|
||||
function fish_command_not_found
|
||||
__fish_default_command_not_found_handler $argv
|
||||
end
|
||||
|
||||
Backwards compatibility
|
||||
-----------------------
|
||||
|
||||
This command was introduced in fish 3.2.0. Previous versions of fish used the "fish_command_not_found" :ref:`event <event>` instead.
|
||||
|
||||
To define a handler that works in older versions of fish as well, define it the old way::
|
||||
|
||||
function __fish_command_not_found_handler --on-event fish_command_not_found
|
||||
echo COMMAND WAS NOT FOUND MY FRIEND $argv[1]
|
||||
end
|
||||
|
||||
in which case fish will define a ``fish_command_not_found`` that calls it,
|
||||
or define a wrapper::
|
||||
|
||||
function fish_command_not_found
|
||||
echo "G'day mate, could not find your command: $argv"
|
||||
end
|
||||
|
||||
function __fish_command_not_found_handler --on-event fish_command_not_found
|
||||
fish_command_not_found $argv
|
||||
end
|
||||
@@ -9,7 +9,7 @@ Synopsis
|
||||
::
|
||||
|
||||
function fish_prompt
|
||||
printf '%s' $PWD (fish_git_prompt) ' $ '
|
||||
echo -n (pwd)(fish_git_prompt) '$ '
|
||||
end
|
||||
|
||||
Description
|
||||
@@ -19,9 +19,9 @@ The ``fish_git_prompt`` function displays information about the current git repo
|
||||
|
||||
`Git <https://git-scm.com>`_ must be installed.
|
||||
|
||||
There are numerous customization options, which can be controlled with git options or fish variables. git options, where available, take precedence over the fish variable with the same function. git options can be set on a per-repository or global basis. git options can be set with the ``git config`` command, while fish variables can be set as usual with the :ref:`set <cmd-set>` command.
|
||||
There are numerous customization options, which can be controlled with git options or fish variables. git options, where available, take precedence over the fish variable with the same function. git options can be set on a per-repository or global basis. git options can be set with the `git config` command, while fish variables can be set as usual with the :ref:`set <cmd-set>` command.
|
||||
|
||||
- ``$__fish_git_prompt_show_informative_status`` or the git option ``bash.showInformativeStatus`` can be set to enable the "informative" display, which will show a large amount of information - the number of untracked files, dirty files, unpushed/unpulled commits, and more. In large repositories, this can take a lot of time, so it you may wish to disable it in these repositories with ``git config --local bash.showInformativeStatus false``. It also changes the characters the prompt uses to less plain ones (``✚`` instead of ``*`` for the dirty state for example) , and if you are only interested in that, set ``$__fish_git_prompt_use_informative_chars`` instead.
|
||||
- ``$__fish_git_prompt_show_informative_status`` or the git option ``bash.showInformativeStatus`` can be set to enable the "informative" display, which will show a large amount of information - the number of untracked files, dirty files, unpushed/unpulled commits, and more. In large repositories, this can take a lot of time, so it you may wish to disable it in these repositories with ``git config --local bash.showInformativeStatus false``.
|
||||
|
||||
- ``$__fish_git_prompt_showdirtystate`` or the git option ``bash.showDirtyState`` can be set to show if the repository is "dirty", i.e. has uncommitted changes.
|
||||
|
||||
@@ -57,31 +57,29 @@ There are numerous customization options, which can be controlled with git optio
|
||||
``describe``
|
||||
relative to older annotated tag, such as ``(v1.6.3.1-13-gdd42c2f)``
|
||||
``default``
|
||||
an exactly matching tag (``(develop)``)
|
||||
|
||||
If none of these apply, the commit SHA shortened to 8 characters is used.
|
||||
exactly matching tag
|
||||
|
||||
- ``$__fish_git_prompt_showcolorhints`` can be set to enable coloring for the branch name and status symbols.
|
||||
|
||||
A number of variables set characters and color used as indicators. Many of these have a different default if used with informative status enabled, or ``$__fish_git_prompt_use_informative_chars`` set. The usual default is given first, then the informative default (if it is different). If no default for the colors is given, they default to ``$__fish_git_prompt_color``.
|
||||
|
||||
- ``$__fish_git_prompt_char_stateseparator`` (' ', ``|``) - the character to be used between the state characters
|
||||
- ``$__fish_git_prompt_color`` (no default)
|
||||
- ``$__fish_git_prompt_color_prefix`` - the color of the ``(`` prefix
|
||||
- ``$__fish_git_prompt_color_suffix`` - the color of the ``)`` suffix
|
||||
- ``$__fish_git_prompt_color_bare`` - the color to use for a bare repository - one without a working tree
|
||||
- ``$__fish_git_prompt_color_merging`` - the color when a merge/rebase/revert/bisect or cherry-pick is in progress
|
||||
- ``$__fish_git_prompt_char_stateseparator`` (' ', `|`)
|
||||
- ``$__fish_git_prompt_color`` ('')
|
||||
- ``$__fish_git_prompt_color_prefix``
|
||||
- ``$__fish_git_prompt_color_suffix``
|
||||
- ``$__fish_git_prompt_color_bare``
|
||||
- ``$__fish_git_prompt_color_merging``
|
||||
|
||||
Some variables are only used in some modes, like when informative status is enabled:
|
||||
|
||||
- ``$__fish_git_prompt_char_cleanstate`` (✔) - the character to be used when nothing else applies
|
||||
- ``$__fish_git_prompt_char_cleanstate`` (✔)
|
||||
- ``$__fish_git_prompt_color_cleanstate``
|
||||
|
||||
Variables used with ``showdirtystate``:
|
||||
|
||||
- ``$__fish_git_prompt_char_dirtystate`` (`*`, ✚) - the number of "dirty" changes, i.e. unstaged files with changes
|
||||
- ``$__fish_git_prompt_char_invalidstate`` (#, ✖) - the number of "unmerged" changes, e.g. additional changes to already added files
|
||||
- ``$__fish_git_prompt_char_stagedstate`` (+, ●) - the number of staged files without additional changes
|
||||
- ``$__fish_git_prompt_char_dirtystate`` (`*`, ✚)
|
||||
- ``$__fish_git_prompt_char_invalidstate`` (#, ✖)
|
||||
- ``$__fish_git_prompt_char_stagedstate`` (+, ●)
|
||||
- ``$__fish_git_prompt_color_dirtystate`` (red with showcolorhints, same as color_flags otherwise)
|
||||
- ``$__fish_git_prompt_color_invalidstate``
|
||||
- ``$__fish_git_prompt_color_stagedstate`` (green with showcolorhints, color_flags otherwise)
|
||||
@@ -93,23 +91,23 @@ Variables used with ``showstashstate``:
|
||||
|
||||
Variables used with ``showuntrackedfiles``:
|
||||
|
||||
- ``$__fish_git_prompt_char_untrackedfiles`` (%, …) - the symbol for untracked files
|
||||
- ``$__fish_git_prompt_char_untrackedfiles`` (%, …)
|
||||
- ``$__fish_git_prompt_color_untrackedfiles`` (same as color_flags)
|
||||
|
||||
Variables used with ``showupstream`` (also implied by informative status):
|
||||
|
||||
- ``$__fish_git_prompt_char_upstream_ahead`` (>, ↑) - the character for the commits this repository is ahead of upstream
|
||||
- ``$__fish_git_prompt_char_upstream_behind`` (<, ↓) - the character for the commits this repository is behind upstream
|
||||
- ``$__fish_git_prompt_char_upstream_diverged`` (<>) - the symbol if this repository is both ahead and behind upstream
|
||||
- ``$__fish_git_prompt_char_upstream_equal`` (=) - the symbol if this repo is equal to upstream
|
||||
- ``$__fish_git_prompt_char_upstream_ahead`` (>, ↑)
|
||||
- ``$__fish_git_prompt_char_upstream_behind`` (<, ↓)
|
||||
- ``$__fish_git_prompt_char_upstream_diverged`` (<>)
|
||||
- ``$__fish_git_prompt_char_upstream_equal`` (=)
|
||||
- ``$__fish_git_prompt_char_upstream_prefix`` ('')
|
||||
- ``$__fish_git_prompt_color_upstream``
|
||||
|
||||
Colors used with ``showcolorhints``:
|
||||
|
||||
- ``$__fish_git_prompt_color_branch`` (green) - the color of the branch
|
||||
- ``$__fish_git_prompt_color_branch_detached`` (red) the color of the branch if it's detached (e.g. a commit is checked out)
|
||||
- ``$__fish_git_prompt_color_flags`` (--bold blue) - the default color for dirty/staged/stashed/untracked state
|
||||
- ``$__fish_git_prompt_color_branch`` (green)
|
||||
- ``$__fish_git_prompt_color_branch_detached`` (red)
|
||||
- ``$__fish_git_prompt_color_flags`` (--bold blue)
|
||||
|
||||
Note that all colors can also have a corresponding ``_done`` color. For example, the contents of ``$__fish_git_prompt_color_upstream_done`` is printed right _after_ the upstream.
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
.. _cmd-fish_greeting:
|
||||
|
||||
fish_greeting - display a welcome message in interactive shells
|
||||
===============================================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
function fish_greeting
|
||||
...
|
||||
end
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
When an interactive fish starts, it executes fish_greeting and displays its output.
|
||||
|
||||
The default fish_greeting is a function that prints a variable of the same name (``$fish_greeting``), so you can also just change that if you just want to change the text.
|
||||
|
||||
While you could also just put ``echo`` calls into config.fish, fish_greeting takes care of only being used in interactive shells, so it won't be used e.g. with ``scp`` (which executes a shell), which prevents some errors.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
A simple greeting:
|
||||
|
||||
::
|
||||
|
||||
function fish_greeting
|
||||
echo Hello friend!
|
||||
echo The time is (set_color yellow; date +%T; set_color normal) and this machine is called $hostname
|
||||
end
|
||||
@@ -9,7 +9,7 @@ Synopsis
|
||||
::
|
||||
|
||||
function fish_prompt
|
||||
printf '%s' $PWD (fish_hg_prompt) ' $ '
|
||||
echo -n (pwd)(fish_hg_prompt) '$ '
|
||||
end
|
||||
|
||||
Description
|
||||
@@ -19,7 +19,7 @@ The fish_hg_prompt function displays information about the current Mercurial rep
|
||||
|
||||
`Mercurial <https://www.mercurial-scm.org/>`_ (``hg``) must be installed.
|
||||
|
||||
By default, only the current branch is shown because ``hg status`` can be slow on a large repository. You can enable a more informative prompt by setting the variable ``$fish_prompt_hg_show_informative_status``, for example::
|
||||
By default, only the current branch is shown because ``hg status`` can take be slow on large repository. You can enable a more informative prompt by setting the variable ``$fish_prompt_hg_show_informative_status``, for example::
|
||||
|
||||
set --universal fish_prompt_hg_show_informative_status
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Synopsis
|
||||
Description
|
||||
-----------
|
||||
|
||||
``fish_indent`` is used to indent a piece of fish code. ``fish_indent`` reads commands from standard input or the given filenames and outputs them to standard output or a specified file (if ``-w`` is given).
|
||||
``fish_indent`` is used to indent a piece of fish code. ``fish_indent`` reads commands from standard input or the given filenames and outputs them to standard output or a specified file (if `-w` is given).
|
||||
|
||||
The following options are available:
|
||||
|
||||
@@ -22,16 +22,14 @@ The following options are available:
|
||||
|
||||
- ``-i`` or ``--no-indent`` do not indent commands; only reformat to one job per line.
|
||||
|
||||
- ``-c`` or ``--check`` do not indent, only return 0 if the code is already indented as fish_indent would, the number of failed files otherwise. Also print the failed filenames if not reading from stdin.
|
||||
|
||||
- ``-v`` or ``--version`` displays the current fish version and then exits.
|
||||
|
||||
- ``--ansi`` colorizes the output using ANSI escape sequences, appropriate for the current $TERM, using the colors defined in the environment (such as ``$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``.
|
||||
|
||||
- ``-d`` or ``--debug=DEBUG_CATEGORIES`` enable debug output and specify a pattern for matching debug categories. See :ref:`Debugging <debugging-fish>` in :ref:`fish(1) <cmd-fish>` for details.
|
||||
- ``-d`` or ``--debug-level=DEBUG_LEVEL`` enables debug output and specifies a verbosity level. Defaults to 0.
|
||||
|
||||
- ``-o`` or ``--debug-output=DEBUG_FILE`` specify a file path to receive the debug output, including categories and ``fish_trace``. The default is stderr.
|
||||
- ``-D`` or ``--debug-stack-frames=DEBUG_LEVEL`` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
|
||||
|
||||
- ``--dump-parse-tree`` dumps information about the parsed statements to stderr. This is likely to be of interest only to people working on the fish source code.
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
.. _cmd-fish_is_root_user:
|
||||
|
||||
fish_is_root_user - check if the current user is root
|
||||
=====================================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
fish_is_root_user
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``fish_is_root_user`` will check if the current user is root. It can be useful
|
||||
for the prompt to display something different if the user is root, for example.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
A simple example:
|
||||
|
||||
::
|
||||
|
||||
function example --description 'Just an example'
|
||||
if fish_is_root_user
|
||||
do_something_different
|
||||
end
|
||||
end
|
||||
@@ -16,7 +16,7 @@ Synopsis
|
||||
Description
|
||||
-----------
|
||||
|
||||
The ``fish_prompt`` function is executed when the prompt is to be shown, and the output is used as a prompt.
|
||||
By defining the ``fish_prompt`` function, the user can choose a custom prompt. The ``fish_prompt`` function is executed when the prompt is to be shown, and the output is used as a prompt.
|
||||
|
||||
The exit status of commands within ``fish_prompt`` will not modify the value of :ref:`$status <variables-status>` outside of the ``fish_prompt`` function.
|
||||
|
||||
@@ -33,11 +33,8 @@ A simple prompt:
|
||||
::
|
||||
|
||||
function fish_prompt -d "Write out the prompt"
|
||||
# This shows up as USER@HOST /home/user/ >, with the directory colored
|
||||
# $USER and $hostname are set by fish, so you can just use them
|
||||
# instead of using `whoami` and `hostname`
|
||||
printf '%s@%s %s%s%s > ' $USER $hostname \
|
||||
(set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
|
||||
printf '%s@%s%s%s%s> ' (whoami) (hostname | cut -d . -f 1) \
|
||||
(set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
.. _cmd-fish_status_to_signal:
|
||||
|
||||
fish_status_to_signal - Convert exit codes to human-friendly signals
|
||||
====================================================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
function fish_prompt
|
||||
echo -n (fish_status_to_signal $pipestatus | string join '|') (prompt_pwd) '$ '
|
||||
end
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``fish_status_to_signal`` converts exit codes to their corresponding human-friendly signals if one exists.
|
||||
This is likely to be useful for prompts in conjunction with the ``$status`` and ``$pipestatus`` variables.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
::
|
||||
|
||||
>_ sleep 5
|
||||
^C⏎
|
||||
>_ fish_status_to_signal $status
|
||||
SIGINT
|
||||
@@ -9,7 +9,7 @@ Synopsis
|
||||
::
|
||||
|
||||
function fish_prompt
|
||||
printf '%s' $PWD (fish_svn_prompt) ' $ '
|
||||
echo -n (pwd)(fish_svn_prompt) '$ '
|
||||
end
|
||||
|
||||
Description
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
.. _cmd-fish_title:
|
||||
|
||||
fish_title - define the terminal's title
|
||||
========================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
function fish_title
|
||||
...
|
||||
end
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The ``fish_title`` function is executed before and after a new command is executed or put into the foreground and the output is used as a titlebar message.
|
||||
|
||||
The first argument to fish_title contains the most recently executed foreground command as a string, if any.
|
||||
|
||||
This requires that your terminal supports programmable titles and the feature is turned on.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
A simple title:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
function fish_title
|
||||
set -q argv[1]; or set argv fish
|
||||
# Looks like ~/d/fish: git log
|
||||
# or /e/apt: fish
|
||||
echo (fish_prompt_pwd_dir_length=1 prompt_pwd): $argv;
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ Synopsis
|
||||
::
|
||||
|
||||
function fish_prompt
|
||||
printf '%s' $PWD (fish_vcs_prompt) ' $ '
|
||||
echo -n (pwd)(fish_vcs_prompt) '$ '
|
||||
end
|
||||
|
||||
Description
|
||||
|
||||
@@ -28,7 +28,7 @@ The following options are available:
|
||||
|
||||
- ``-e`` or ``--on-event EVENT_NAME`` tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt.
|
||||
|
||||
- ``-v`` or ``--on-variable VARIABLE_NAME`` tells fish to run this function when the variable VARIABLE_NAME changes value. Note that the function will not necessarily be run for each change; rather, it will be run when the variable has changed at least once.
|
||||
- ``-v`` or ``--on-variable VARIABLE_NAME`` tells fish to run this function when the variable VARIABLE_NAME changes value.
|
||||
|
||||
- ``-j PGID`` or ``--on-job-exit PGID`` tells fish to run this function when the job with group ID PGID exits. Instead of PGID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.
|
||||
|
||||
@@ -50,6 +50,8 @@ By using one of the event handler switches, a function can be made to run automa
|
||||
|
||||
- ``fish_prompt``, which is emitted whenever a new fish prompt is about to be displayed.
|
||||
|
||||
- ``fish_command_not_found``, which is emitted whenever a command lookup failed.
|
||||
|
||||
- ``fish_preexec``, which is emitted right before executing an interactive command. The commandline is passed as the first parameter. Not emitted if command is empty.
|
||||
|
||||
- ``fish_posterror``, which is emitted right after executing a command with syntax errors. The commandline is passed as the first parameter.
|
||||
|
||||
@@ -49,7 +49,7 @@ You should not assume that only five lines will be written since we may add addi
|
||||
|
||||
- ``-t`` or ``--handlers-type TYPE`` will show all event handlers matching the given type
|
||||
|
||||
The default behavior of ``functions``, when called with no arguments, is to print the names of all defined functions. Unless the ``-a`` option is given, no functions starting with underscores are included in the output.
|
||||
The default behavior of ``functions``, when called with no arguments, is to print the names of all defined functions. Unless the ``-a`` option is given, no functions starting with underscores are not included in the output.
|
||||
|
||||
If any non-option parameters are given, the definition of the specified functions are printed.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Synopsis
|
||||
|
||||
::
|
||||
|
||||
history [ search ] [ --show-time ] [ --case-sensitive ] [ --exact | --prefix | --contains ] [ --max=n ] [ --null ] [ -R | --reverse ] [ "search string"... ]
|
||||
history search [ --show-time ] [ --case-sensitive ] [ --exact | --prefix | --contains ] [ --max=n ] [ --null ] [ -R | --reverse ] [ "search string"... ]
|
||||
history delete [ --show-time ] [ --case-sensitive ] [ --exact | --prefix | --contains ] "search string"...
|
||||
history merge
|
||||
history save
|
||||
|
||||
@@ -15,7 +15,7 @@ Description
|
||||
|
||||
``isatty`` tests if a file descriptor is a terminal (as opposed to a file). The name is derived from the system call of the same name, which for historical reasons refers to a teletypewriter (TTY).
|
||||
|
||||
``FILE DESCRIPTOR`` may be either the number of a file descriptor, or one of the strings ``stdin``, ``stdout``, or ``stderr``. If not specified, zero is assumed.
|
||||
``FILE DESCRIPTOR`` may be either the number of a file descriptor, or one of the strings ``stdin``, ``stdout``, or ``stderr``.
|
||||
|
||||
If the specified file descriptor is a terminal device, the exit status of the command is zero. Otherwise, the exit status is non-zero. No messages are printed to standard error.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ Synopsis
|
||||
|
||||
::
|
||||
|
||||
jobs [OPTIONS] [ PID | %JOBID ]
|
||||
jobs [OPTIONS] [PID]
|
||||
|
||||
|
||||
Description
|
||||
@@ -26,23 +26,17 @@ jobs accepts the following switches:
|
||||
|
||||
- ``-p`` or ``--pid`` prints the process ID for each process in all jobs.
|
||||
|
||||
- ``-q`` or ``--query`` prints no output for evaluation of jobs by exit status only. For compatibility with old fish versions this is also ``--quiet`` (but this is deprecated).
|
||||
- ``-q`` or ``--quiet`` prints no output for evaluation of jobs by exit status only.
|
||||
|
||||
On systems that supports this feature, jobs will print the CPU usage of each job since the last command was executed. The CPU usage is expressed as a percentage of full CPU activity. Note that on multiprocessor systems, the total activity may be more than 100\%.
|
||||
|
||||
Arguments of the form ``PID`` or ``%JOBID`` restrict the output to jobs with the selected process identifiers or job numbers respectively.
|
||||
|
||||
If the output of ``jobs`` is redirected or if it is part of a command substitution, the column header that is usually printed is omitted, making it easier to parse.
|
||||
|
||||
The exit status of ``jobs`` is ``0`` if there are running background jobs and ``1`` otherwise.
|
||||
|
||||
no output.
|
||||
----------
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
``jobs`` outputs a summary of the current jobs, such as two long-running tasks in this example:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
Job Group State Command
|
||||
2 26012 running nc -l 55232 < /dev/random &
|
||||
1 26011 running python tests/test_11.py &
|
||||
``jobs`` outputs a summary of the current jobs.
|
||||
|
||||
@@ -8,17 +8,17 @@ Synopsis
|
||||
|
||||
::
|
||||
|
||||
math [-sN | --scale=N] [-bBASE | --base=BASE] [--] EXPRESSION
|
||||
math [-sN | --scale=N] [--] EXPRESSION
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``math`` performs mathematical calculations. It supports simple operations such as addition, subtraction, and so on, as well as functions like ``abs()``, ``sqrt()`` and ``ln()``.
|
||||
``math`` is used to perform mathematical calculations. It supports all the usual operations such as addition, subtraction, etc. As well as functions like ``abs()``, ``sqrt()`` and ``log2()``.
|
||||
|
||||
By default, the output is a floating-point number with trailing zeroes trimmed. To get a fixed representation, the ``--scale`` option can be used, including ``--scale=0`` for integer output.
|
||||
By default, the output is as a float with trailing zeroes trimmed. To get a fixed representation, the ``--scale`` option can be used, including ``--scale=0`` for integer output.
|
||||
|
||||
Keep in mind that parameter expansion happens before expressions are evaluated. This can be very useful in order to perform calculations involving shell variables or the output of command substitutions, but it also means that parenthesis (``()``) and the asterisk (``*``) glob character have to be escaped or quoted. ``x`` can also be used to denote multiplication, but it needs to be followed by whitespace to distinguish it from hexadecimal numbers.
|
||||
Keep in mind that parameter expansion takes before expressions are evaluated. This can be very useful in order to perform calculations involving shell variables or the output of command substitutions, but it also means that parenthesis (``()``) and the asterisk (``*``) glob character have to be escaped or quoted. ``x`` can also be used to denote multiplication, but it needs to be followed by whitespace to distinguish it from hexadecimal numbers.
|
||||
|
||||
``math`` ignores whitespace between arguments and takes its input as multiple arguments (internally joined with a space), so ``math 2 +2`` and ``math "2 + 2"`` work the same. ``math 2 2`` is an error.
|
||||
|
||||
@@ -26,8 +26,6 @@ The following options are available:
|
||||
|
||||
- ``-sN`` or ``--scale=N`` sets the scale of the result. ``N`` must be an integer or the word "max" for the maximum scale. A scale of zero causes results to be rounded down to the nearest integer. So ``3/2`` returns ``1`` rather than ``2`` which ``1.5`` would normally round to. This is for compatibility with ``bc`` which was the basis for this command prior to fish 3.0.0. Scale values greater than zero causes the result to be rounded using the usual rules to the specified number of decimal places.
|
||||
|
||||
- ``-b BASE`` or ``--base BASE`` sets the numeric base used for output (``math`` always understands hexadecimal numbers as input). It currently understands "hex" or "16" for hexadecimal and "octal" or "8" for octal and implies a scale of 0 (other scales cause an error), so it will truncate the result down to an integer. This might change in the future. Hex numbers will be printed with a ``0x`` prefix. Octal numbers will have a prefix of ``0`` and aren't understood by ``math`` as input.
|
||||
|
||||
Return Values
|
||||
-------------
|
||||
|
||||
@@ -38,7 +36,7 @@ Syntax
|
||||
|
||||
``math`` knows some operators, constants, functions and can (obviously) read numbers.
|
||||
|
||||
For numbers, ``.`` is always the radix character regardless of locale - ``2.5``, not ``2,5``. Scientific notation (``10e5``) and hexadecimal (``0xFF``) are also available.
|
||||
For numbers, ``.`` is always the radix character regardless of locale - ``2.5``, not ``2,5``. Scientific notation (``10e5``) is also available.
|
||||
|
||||
Operators
|
||||
---------
|
||||
@@ -63,8 +61,7 @@ Constants
|
||||
``math`` knows the following constants:
|
||||
|
||||
- ``e`` - Euler's number.
|
||||
- ``pi`` - π. You know this one. Half of Tau.
|
||||
- ``tau``. Equivalent to 2π, or the number of radians in a circle.
|
||||
- ``pi`` - You know that one. Half of Tau. (Tau is not implemented)
|
||||
|
||||
Use them without a leading ``$`` - ``pi - 3`` should be about 0.
|
||||
|
||||
@@ -73,31 +70,30 @@ Functions
|
||||
|
||||
``math`` supports the following functions:
|
||||
|
||||
- ``abs`` - the absolute value, with positive sign
|
||||
- ``acos`` - arc cosine
|
||||
- ``asin`` - arc sine
|
||||
- ``atan`` - arc tangent
|
||||
- ``atan2`` - arc tangent of two variables
|
||||
- ``bitand``, ``bitor`` and ``bitxor`` to perform bitwise operations. These will throw away any non-integer parts and interpret the rest as an int.
|
||||
- ``ceil`` - round number up to nearest integer
|
||||
- ``cos`` - the cosine
|
||||
- ``cosh`` - hyperbolic cosine
|
||||
- ``abs``
|
||||
- ``acos``
|
||||
- ``asin``
|
||||
- ``atan``
|
||||
- ``atan2``
|
||||
- ``ceil``
|
||||
- ``cos``
|
||||
- ``cosh``
|
||||
- ``exp`` - the base-e exponential function
|
||||
- ``fac`` - factorial - also known as ``x!`` (``x * (x - 1) * (x - 2) * ... * 1``)
|
||||
- ``floor`` - round number down to nearest integer
|
||||
- ``ln`` - the base-e logarithm
|
||||
- ``fac`` - factorial
|
||||
- ``floor``
|
||||
- ``ln``
|
||||
- ``log`` or ``log10`` - the base-10 logarithm
|
||||
- ``ncr`` - "from n choose r" combination function - how many subsets of size r can be taken from n (order doesn't matter)
|
||||
- ``npr`` - the number of subsets of size r that can be taken from a set of n elements (including different order)
|
||||
- ``ncr``
|
||||
- ``npr``
|
||||
- ``pow(x,y)`` returns x to the y (and can be written as ``x ^ y``)
|
||||
- ``round`` - rounds to the nearest integer, away from 0
|
||||
- ``sin`` - the sine function
|
||||
- ``sinh`` - the hyperbolic sine
|
||||
- ``sqrt`` - the square root - (can also be written as ``x ^ 0.5``)
|
||||
- ``tan`` - the tangent
|
||||
- ``tanh`` - the hyperbolic tangent
|
||||
- ``sin``
|
||||
- ``sinh``
|
||||
- ``sqrt``
|
||||
- ``tan``
|
||||
- ``tanh``
|
||||
|
||||
All of the trigonometric functions use radians (the pi-based scale, not 360°).
|
||||
All of the trigonometric functions use radians.
|
||||
|
||||
Examples
|
||||
--------
|
||||
@@ -118,17 +114,9 @@ Examples
|
||||
|
||||
``math 0xFF`` outputs 255, ``math 0 x 3`` outputs 0 (because it computes 0 multiplied by 3).
|
||||
|
||||
``math "bitand(0xFE, 0x2e)"`` outputs 46.
|
||||
|
||||
``math "bitor(9,2)"`` outputs 11.
|
||||
|
||||
``math --base=hex 192`` prints ``0xc0``.
|
||||
|
||||
``math 'ncr(49,6)'`` prints 13983816 - that's the number of possible picks in 6-from-49 lotto.
|
||||
|
||||
Compatibility notes
|
||||
-------------------
|
||||
|
||||
Fish 1.x and 2.x releases relied on the ``bc`` command for handling ``math`` expressions. Starting with fish 3.0.0 fish uses the tinyexpr library and evaluates the expression without the involvement of any external commands.
|
||||
|
||||
You don't need to use ``--`` before the expression, even if it begins with a minus sign which might otherwise be interpreted as an invalid option. If you do insert ``--`` before the expression, it will cause option scanning to stop just like for every other command and it won't be part of the expression.
|
||||
You don't need to use ``--`` before the expression even if it begins with a minus sign which might otherwise be interpreted as an invalid option. If you do insert ``--`` before the expression it will cause option scanning to stop just like for every other command and it won't be part of the expression.
|
||||
|
||||
@@ -42,9 +42,7 @@ Valid format specifiers are taken from the C library function ``printf(3)``:
|
||||
|
||||
``%%`` signifies a literal "%".
|
||||
|
||||
Conversion can fail, e.g. "102.234" can't losslessly convert to an integer, causing printf to print an error. If you are okay with losing information, silence errors with ``2>/dev/null``.
|
||||
|
||||
A number between the ``%`` and the format letter specifies the width. The result will be left-padded with spaces.
|
||||
Conversion can fail, e.g. "102.234" can't losslessly convert to an integer, causing printf to print an error. If you are okay with losing information, silence errors with `2>/dev/null`.
|
||||
|
||||
Backslash Escapes
|
||||
-----------------
|
||||
@@ -68,7 +66,7 @@ printf also knows a number of backslash escapes:
|
||||
|
||||
Errors and Return Status
|
||||
------------------------
|
||||
If the given argument doesn't work for the given format (like when you try to convert a number like 3.141592 to an integer), printf prints an error, to stderr. printf will then also return non-zero, but will still try to print as much as it can.
|
||||
If the given argument doesn't work for the given format (like when you try to convert a number like `3.141592` to an integer), printf prints an error, to stderr. printf will then also return non-zero, but will still try to print as much as it can.
|
||||
|
||||
It will also return non-zero if no argument at all was given, in which case it will print nothing.
|
||||
|
||||
@@ -79,7 +77,7 @@ Example
|
||||
|
||||
::
|
||||
|
||||
printf '%s\t%s\n' flounder fish
|
||||
printf '%s\\t%s\\n' flounder fish
|
||||
|
||||
Will print "flounder fish" (separated with a tab character), followed by a newline character. This is useful for writing completions, as fish expects completion scripts to output the option followed by the description, separated with a tab character.
|
||||
|
||||
@@ -87,7 +85,7 @@ Will print "flounder fish" (separated with a tab character), followed by a newli
|
||||
|
||||
printf '%s: %d' "Number of bananas in my pocket" 42
|
||||
|
||||
Will print "Number of bananas in my pocket: 42", `without` a newline.
|
||||
Will print "Number of bananas in my pocket: 42", _without_ a newline.
|
||||
|
||||
See Also
|
||||
--------
|
||||
@@ -96,4 +94,4 @@ See Also
|
||||
|
||||
Footnotes
|
||||
---------
|
||||
.. [#] (in fact while fish's ``echo`` supports ``--``, POSIX forbids it, so other implementations can't be used if the input contains anything starting with ``-``)
|
||||
.. [#] (in fact while fish's ``echo`` supports ``--``, POSIX forbids it, so other implementations can't be used if the input contains anything starting with `-`)
|
||||
|
||||
@@ -17,23 +17,20 @@ Synopsis
|
||||
Description
|
||||
-----------
|
||||
|
||||
``random`` generates a pseudo-random integer from a uniform distribution. The
|
||||
range (inclusive) depends on the arguments.
|
||||
No arguments indicate a range of 0 to 32767 (inclusive).
|
||||
|
||||
``RANDOM`` generates a pseudo-random integer from a uniform distribution. The
|
||||
range (inclusive) is dependent on the arguments passed.
|
||||
No arguments indicate a range of [0; 32767].
|
||||
If one argument is specified, the internal engine will be seeded with the
|
||||
argument for future invocations of ``random`` and no output will be produced.
|
||||
|
||||
Two arguments indicate a range from START to END (both START and END included).
|
||||
|
||||
Three arguments indicate a range from START to END with a spacing of STEP
|
||||
argument for future invocations of ``RANDOM`` and no output will be produced.
|
||||
Two arguments indicate a range of [START; END].
|
||||
Three arguments indicate a range of [START; END] with a spacing of STEP
|
||||
between possible outputs.
|
||||
``random choice`` will select one random item from the succeeding arguments.
|
||||
``RANDOM choice`` will select one random item from the succeeding arguments.
|
||||
|
||||
Note that seeding the engine will NOT give the same result across different
|
||||
systems.
|
||||
|
||||
You should not consider ``random`` cryptographically secure, or even
|
||||
You should not consider ``RANDOM`` cryptographically secure, or even
|
||||
statistically accurate.
|
||||
|
||||
Example
|
||||
@@ -41,8 +38,10 @@ Example
|
||||
|
||||
The following code will count down from a random even number between 10 and 20 to 1:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
for i in (seq (random 10 2 20) -1 1)
|
||||
echo $i
|
||||
end
|
||||
@@ -50,15 +49,9 @@ The following code will count down from a random even number between 10 and 20 t
|
||||
|
||||
And this will open a random picture from any of the subdirectories:
|
||||
|
||||
|
||||
|
||||
::
|
||||
|
||||
open (random choice **.jpg)
|
||||
open (random choice **jpg)
|
||||
|
||||
|
||||
Or, to only get even numbers from 2 to 20::
|
||||
|
||||
random 2 2 20
|
||||
|
||||
Or odd numbers from 1 to 3::
|
||||
|
||||
random 1 2 3 # or 1 2 4
|
||||
|
||||
@@ -30,9 +30,9 @@ The following options are available:
|
||||
- ``-n NCHARS`` or ``--nchars=NCHARS`` makes ``read`` return after reading NCHARS characters or the end of
|
||||
the line, whichever comes first.
|
||||
|
||||
- ``-p PROMPT_CMD`` or ``--prompt=PROMPT_CMD`` uses the output of the shell command ``PROMPT_CMD`` as the prompt for the interactive mode. The default prompt command is ``set_color green; echo read; set_color normal; echo "> "``
|
||||
- ``-p PROMPT_CMD`` or ``--prompt=PROMPT_CMD`` uses the output of the shell command ``PROMPT_CMD`` as the prompt for the interactive mode. The default prompt command is `set_color green; echo read; set_color normal; echo "> "`
|
||||
|
||||
- ``-P PROMPT_STR`` or ``--prompt-str=PROMPT_STR`` uses the string as the prompt for the interactive mode. It is equivalent to ``echo PROMPT_STR`` and is provided solely to avoid the need to frame the prompt as a command. All special characters in the string are automatically escaped before being passed to the :ref:`echo <cmd-echo>` command.
|
||||
- ``-P PROMPT_STR`` or ``--prompt-str=PROMPT_STR`` uses the string as the prompt for the interactive mode. It is equivalent to `echo PROMPT_STR` and is provided solely to avoid the need to frame the prompt as a command. All special characters in the string are automatically escaped before being passed to the :ref:`echo <cmd-echo>` command.
|
||||
|
||||
- ``-R RIGHT_PROMPT_CMD`` or ``--right-prompt=RIGHT_PROMPT_CMD`` uses the output of the shell command ``RIGHT_PROMPT_CMD`` as the right prompt for the interactive mode. There is no default right prompt command.
|
||||
|
||||
@@ -58,9 +58,9 @@ 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 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 data that should be provided via a command line argument from the console instead of hardcoding it in the command itself, allowing the command to both be reused as-is in various contexts with different input values and preventing possibly sensitive text from being included in the shell 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 data that should be provided via a command line argument from the console instead of hardcoding it in the command itself, allowing the command to both be reused as-is in various contexts with different input values and preventing possibly sensitive text from being included in the shell history:
|
||||
|
||||
mysql -uuser -p(read)
|
||||
``mysql -uuser -p(read)``
|
||||
|
||||
When running in this mode, ``read`` does not split the input in any way and text is redirected to standard output without any further processing or manipulation.
|
||||
|
||||
@@ -76,6 +76,11 @@ maximum of 100 MiB (104857600 bytes); if the terminator is not reached before th
|
||||
is set to empty and the exit status is set to 122. This limit can be altered with the
|
||||
``fish_read_limit`` variable. If set to 0 (zero), the limit is removed.
|
||||
|
||||
Using another read history file
|
||||
-------------------------------
|
||||
|
||||
The ``read`` command supported the ``-m`` and ``--mode-name`` flags in fish versions prior to 2.7.0 to specify an alternative read history file. Those flags are now deprecated and ignored. Instead, set the ``fish_history`` variable to specify a history session ID. That will affect both the ``read`` history file and the fish command history file. You can set it to an empty string to specify that no history should be read or written. This is useful for presentations where you do not want possibly private or sensitive history to be exposed to the audience but do want history relevant to the presentation to be available.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
||||
@@ -15,10 +15,6 @@ Description
|
||||
|
||||
``realpath`` resolves a path to its absolute path.
|
||||
|
||||
fish provides a ``realpath`` builtin as a fallback for systems where there is no ``realpath`` command, your OS might provide a version with more features.
|
||||
fish provides a ``realpath`` builtin as a fallback for systems where there is no ``realpath`` command. fish's implementation always resolves its first argument, and does not support any options.
|
||||
|
||||
If a ``realpath`` command exists, it will be preferred, so if you want to use the builtin you should use ``builtin realpath`` explicitly.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- ``-s`` or ``--no-symlinks``: Don't resolve symlinks, only make paths absolute, squash multiple slashes and remove trailing slashes.
|
||||
If the operation fails, an error will be reported.
|
||||
|
||||
@@ -12,7 +12,7 @@ Synopsis
|
||||
set [OPTIONS] VARIABLE_NAME VALUES...
|
||||
set [OPTIONS] VARIABLE_NAME[INDICES]... VALUES...
|
||||
set ( -q | --query ) [SCOPE_OPTIONS] VARIABLE_NAMES...
|
||||
set ( -e | --erase ) [SCOPE_OPTIONS] VARIABLE_NAME...
|
||||
set ( -e | --erase ) [SCOPE_OPTIONS] VARIABLE_NAME
|
||||
set ( -e | --erase ) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]...
|
||||
set ( -S | --show ) [VARIABLE_NAME]...
|
||||
|
||||
@@ -47,9 +47,9 @@ The following options control variable scope:
|
||||
|
||||
The following options are available:
|
||||
|
||||
- ``-e`` or ``--erase`` causes the specified shell variables to be erased
|
||||
- ``-e`` or ``--erase`` causes the specified shell variable to be erased
|
||||
|
||||
- ``-q`` or ``--query`` test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined, or 255 if more than 255 variables are not defined.
|
||||
- ``-q`` or ``--query`` test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
|
||||
|
||||
- ``-n`` or ``--names`` List only the names of all defined variables, not their value. The names are guaranteed to be sorted.
|
||||
|
||||
@@ -86,14 +86,7 @@ In erase mode, if variable indices are specified, only the specified slices of t
|
||||
|
||||
``set`` requires all options to come before any other arguments. For example, ``set flags -l`` will have the effect of setting the value of the variable ``flags`` to '-l', not making the variable local.
|
||||
|
||||
Exit status
|
||||
-----------
|
||||
|
||||
In assignment mode, ``set`` does not modify the exit status, but passes along whatever $status was set, including by command substitutions. This allows capturing the output and exit status of a subcommand, like in ``if set output (command)``.
|
||||
|
||||
In query mode, the exit status is the number of variables that were not found.
|
||||
|
||||
In erase mode, ``set`` exits with a zero exit status in case of success, with a non-zero exit status if the commandline was invalid, if any of the variables did not exist or was a :ref:`special read-only variable <variables-special>`.
|
||||
In assignment mode, ``set`` does not modify the exit status. This allows simultaneous capture of the output and exit status of a subcommand, e.g. ``if set output (command)``. In query mode, the exit status is the number of variables that were not found. In erase mode, ``set`` exits with a zero exit status in case of success, with a non-zero exit status if the commandline was invalid, if the variable was write-protected or if the variable did not exist.
|
||||
|
||||
|
||||
Examples
|
||||
@@ -126,16 +119,7 @@ Examples
|
||||
echo "Python is at $python_path"
|
||||
end
|
||||
|
||||
# Setting a variable doesn't modify $status!
|
||||
false
|
||||
set foo bar
|
||||
echo $status # prints 1, because of the "false" above.
|
||||
|
||||
true
|
||||
set foo banana (false)
|
||||
echo $status # prints 1, because of the "(false)" above.
|
||||
|
||||
# Like other shells, pass a variable to just one command:
|
||||
# Like other shells, fish 3.1 supports this syntax for passing a variable to just one command:
|
||||
# Run fish with a temporary home directory.
|
||||
HOME=(mktemp -d) fish
|
||||
# Which is essentially the same as:
|
||||
|
||||
@@ -37,11 +37,11 @@ Examples
|
||||
|
||||
::
|
||||
|
||||
>_ echo \x07 | string escape
|
||||
\cg
|
||||
>_ echo \\x07 | string escape
|
||||
cg
|
||||
|
||||
>_ string escape --style=var 'a1 b2'\u6161
|
||||
a1_20_b2_E6_85_A1_
|
||||
>_ string escape --style=var 'a1 b2'\\u6161
|
||||
a1_20b2__c_E6_85_A1
|
||||
|
||||
|
||||
.. END EXAMPLES
|
||||
|
||||
@@ -34,6 +34,6 @@ Examples
|
||||
>_ set str foo
|
||||
>_ string length -q $str; echo $status
|
||||
0
|
||||
# Equivalent to test -n "$str"
|
||||
# Equivalent to test -n $str
|
||||
|
||||
.. END EXAMPLES
|
||||
|
||||
@@ -27,8 +27,6 @@ If ``--index`` or ``-n`` is given, each match is reported as a 1-based start pos
|
||||
|
||||
If ``--regex`` or ``-r`` is given, PATTERN is interpreted as a Perl-compatible regular expression, which does not have to match the entire STRING. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. With this, only the matching part of the STRING will be reported, unless ``--entire`` is given.
|
||||
|
||||
When matching via regular expressions, ``string match`` automatically sets variables for all named capturing groups (``(?<name>expression)``). It will create a variable with the name of the group, in the default scope, for each named capturing group, and set it to the value of the capturing group in the first matched argument. If a named capture group matched an empty string, the variable will be set to the empty string (like ``set var ""``). If it did not match, the variable will be set to nothing (like ``set var``). When ``--regex`` is used with ``--all``, this behavior changes. Each named variable will contain a list of matches, with the first match contained in the first element, the second match in the second, and so on. If the group was empty or did not match, the corresponding element will be an empty string.
|
||||
|
||||
If ``--invert`` or ``-v`` is used the selected lines will be only those which do not match the given glob pattern or regular expression.
|
||||
|
||||
Exit status: 0 if at least one match was found, or 1 otherwise.
|
||||
@@ -54,7 +52,7 @@ Match Glob Examples
|
||||
>_ string match -i 'a??B' Axxb
|
||||
Axxb
|
||||
|
||||
>_ echo 'ok?' | string match '*\?'
|
||||
>_ echo 'ok?' | string match '*\\?'
|
||||
ok?
|
||||
|
||||
# Note that only the second STRING will match here.
|
||||
@@ -68,6 +66,7 @@ Match Glob Examples
|
||||
|
||||
>_ string match 'foo?' 'foo1' 'foo' 'foo2'
|
||||
foo1
|
||||
foo
|
||||
foo2
|
||||
|
||||
Match Regex Examples
|
||||
@@ -86,13 +85,13 @@ Match Regex Examples
|
||||
cat4
|
||||
dog4
|
||||
|
||||
>_ string match -r '(\d\d?):(\d\d):(\d\d)' 2:34:56
|
||||
>_ string match -r '(\\d\\d?):(\\d\\d):(\\d\\d)' 2:34:56
|
||||
2:34:56
|
||||
2
|
||||
34
|
||||
56
|
||||
|
||||
>_ string match -r '^(\w{2,4})\1$' papa mud murmur
|
||||
>_ string match -r '^(\\w{{2,4}})\\g1$' papa mud murmur
|
||||
papa
|
||||
pa
|
||||
murmur
|
||||
@@ -103,24 +102,7 @@ Match Regex Examples
|
||||
4 2
|
||||
6 2
|
||||
|
||||
>_ string match -r -i '0x[0-9a-f]{1,8}' 'int magic = 0xBadC0de;'
|
||||
>_ string match -r -i '0x[0-9a-f]{{1,8}}' 'int magic = 0xBadC0de;'
|
||||
0xBadC0de
|
||||
|
||||
>_ echo $version
|
||||
3.1.2-1575-ga2ff32d90
|
||||
>_ string match -rq '(?<major>\d+).(?<minor>\d+).(?<revision>\d+)' -- $version
|
||||
>_ echo "You are using fish $major!"
|
||||
You are using fish 3!
|
||||
|
||||
>_ string match -raq ' *(?<sentence>[^.!?]+)(?<punctuation>[.!?])?' "hello, friend. goodbye"
|
||||
>_ printf "%s\n" -- $sentence
|
||||
hello, friend
|
||||
goodbye
|
||||
>_ printf "%s\n" -- $punctuation
|
||||
.
|
||||
|
||||
>_ string match -rq '(?<word>hello)' 'hi'
|
||||
>_ count $word
|
||||
0
|
||||
|
||||
.. END EXAMPLES
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
string-pad - pad strings to a fixed width
|
||||
=========================================
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. BEGIN SYNOPSIS
|
||||
|
||||
::
|
||||
|
||||
string pad [(-r | --right)] [(-c | --char) CHAR] [(-w | --width) INTEGER] [STRING...]
|
||||
|
||||
.. END SYNOPSIS
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
.. BEGIN DESCRIPTION
|
||||
|
||||
``string pad`` extends each STRING to the given width by adding CHAR to the left.
|
||||
|
||||
If ``-r`` or ``--right`` is given, add the padding after a string.
|
||||
|
||||
If ``-c`` or ``--char`` is given, pad with CHAR instead of whitespace.
|
||||
|
||||
The output is padded to the maximum width of all input strings. If ``-w`` or ``--width`` is given, use at least that.
|
||||
|
||||
.. END DESCRIPTION
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. BEGIN EXAMPLES
|
||||
|
||||
::
|
||||
|
||||
>_ string pad -w 10 abc abcdef
|
||||
abc
|
||||
abcdef
|
||||
|
||||
>_ string pad --right --char=🐟 "fish are pretty" "rich. "
|
||||
fish are pretty
|
||||
rich. 🐟🐟🐟🐟
|
||||
|
||||
>_ string pad -w$COLUMNS (date)
|
||||
# Prints the current time on the right edge of the screen.
|
||||
|
||||
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
- The :ref:`printf <cmd-printf>` command can do simple padding, for example ``printf %10s\n`` works like ``string pad -w10``.
|
||||
|
||||
.. END EXAMPLES
|
||||
@@ -53,13 +53,13 @@ Replace Regex Examples
|
||||
|
||||
::
|
||||
|
||||
>_ string replace -r -a '[^\d.]+' ' ' '0 one two 3.14 four 5x'
|
||||
>_ string replace -r -a '[^\\d.]+' ' ' '0 one two 3.14 four 5x'
|
||||
0 3.14 5
|
||||
|
||||
>_ string replace -r '(\w+)\s+(\w+)' '$2 $1 $$' 'left right'
|
||||
>_ string replace -r '(\\w+)\\s+(\\w+)' '$2 $1 $$' 'left right'
|
||||
right left $
|
||||
|
||||
>_ string replace -r '\s*newline\s*' '\n' 'put a newline here'
|
||||
>_ string replace -r '\\s*newline\\s*' '\\n' 'put a newline here'
|
||||
put a
|
||||
here
|
||||
|
||||
|
||||
@@ -66,9 +66,9 @@ NUL Delimited Examples
|
||||
42
|
||||
|
||||
>_ # Sort a list of elements which may contain newlines
|
||||
>_ set foo beta alpha\ngamma
|
||||
>_ set foo beta alpha\\ngamma
|
||||
>_ set foo (string join0 $foo | sort -z | string split0)
|
||||
>_ string escape $foo[1]
|
||||
alpha\ngamma
|
||||
alpha\\ngamma
|
||||
|
||||
.. END EXAMPLES
|
||||
|
||||
@@ -15,7 +15,6 @@ Synopsis
|
||||
string length [(-q | --quiet)] [STRING...]
|
||||
string lower [(-q | --quiet)] [STRING...]
|
||||
string match [(-a | --all)] [(-e | --entire)] [(-i | --ignore-case)] [(-r | --regex)] [(-n | --index)] [(-q | --quiet)] [(-v | --invert)] PATTERN [STRING...]
|
||||
string pad [(-r | --right)] [(-c | --char) CHAR] [(-w | --width) INTEGER] [STRING...]
|
||||
string repeat [(-n | --count) COUNT] [(-m | --max) MAX] [(-N | --no-newline)] [(-q | --quiet)] [STRING...]
|
||||
string replace [(-a | --all)] [(-f | --filter)] [(-i | --ignore-case)] [(-r | --regex)] [(-q | --quiet)] PATTERN REPLACEMENT [STRING...]
|
||||
string split [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)] SEP [STRING...]
|
||||
@@ -34,7 +33,7 @@ STRING arguments are taken from the command line unless standard input is connec
|
||||
|
||||
Arguments beginning with ``-`` are normally interpreted as switches; ``--`` causes the following arguments not to be treated as switches even if they begin with ``-``. Switches and required arguments are recognized only on the command line.
|
||||
|
||||
Most subcommands accept a ``-q`` or ``--quiet`` switch, which suppresses the usual output but exits with the documented status. In this case these commands will quit early, without reading all of the available input.
|
||||
Most subcommands accept a ``-q`` or ``--quiet`` switch, which suppresses the usual output but exits with the documented status.
|
||||
|
||||
The following subcommands are available.
|
||||
|
||||
@@ -142,21 +141,6 @@ Examples
|
||||
:start-after: BEGIN EXAMPLES
|
||||
:end-before: END EXAMPLES
|
||||
|
||||
"pad" subcommand
|
||||
------------------
|
||||
|
||||
.. include:: string-pad.rst
|
||||
:start-after: BEGIN SYNOPSIS
|
||||
:end-before: END SYNOPSIS
|
||||
|
||||
.. include:: string-pad.rst
|
||||
:start-after: BEGIN DESCRIPTION
|
||||
:end-before: END DESCRIPTION
|
||||
|
||||
.. include:: string-pad.rst
|
||||
:start-after: BEGIN EXAMPLES
|
||||
:end-before: END EXAMPLES
|
||||
|
||||
"repeat" subcommand
|
||||
-------------------
|
||||
|
||||
@@ -326,8 +310,8 @@ If you are familiar with these, it is useful to know how ``string`` differs from
|
||||
|
||||
In contrast to these classics, ``string`` reads input either from stdin or as arguments. ``string`` also does not deal with files, so it requires redirections to be used with them.
|
||||
|
||||
In contrast to ``grep``, ``string``'s ``match`` defaults to glob-mode, while ``replace`` defaults to literal matching. If set to regex-mode, they use PCRE regular expressions, which is comparable to ``grep``'s ``-P`` option. ``match`` defaults to printing just the match, which is like ``grep`` with ``-o`` (use ``--entire`` to enable grep-like behavior).
|
||||
In contrast to ``grep``, ``string``\ s `match` defaults to glob-mode, while `replace` defaults to literal matching. If set to regex-mode, they use PCRE regular expressions, which is comparable to ``grep``\ s `-P` option. `match` defaults to printing just the match, which is like ``grep`` with `-o` (use `--entire` to enable grep-like behavior).
|
||||
|
||||
Like ``sed``'s ``s/old/new/`` command, ``string replace`` still prints strings that don't match. ``sed``'s ``-n`` in combination with a ``/p`` modifier or command is like ``string replace -f``.
|
||||
Like ``sed``\ s `s/` command, ``string replace`` still prints strings that don't match. ``sed``\ s `-n` in combination with a `/p` modifier or command is like ``string replace -f``.
|
||||
|
||||
``string split somedelimiter`` is a replacement for ``tr somedelimiter \n``.
|
||||
``string split somedelimiter`` is a replacement for ``tr somedelimiter \\n``.
|
||||
|
||||
@@ -17,7 +17,7 @@ Description
|
||||
|
||||
For checking timing after a command has completed, check :ref:`$CMD_DURATION <variables-special>`.
|
||||
|
||||
Your system most likely also has a ``time`` command. To use that use something like ``command time``, as in ``command time sleep 10``. Because it's not inside fish, it won't have access to fish functions and won't be able to time blocks and such.
|
||||
Your system most likely also has a `time` command. To use that use something like `command time`, as in `command time sleep 10`. Because it's not inside fish, it won't have access to fish functions and won't be able to time blocks and such.
|
||||
|
||||
Example
|
||||
-------
|
||||
@@ -39,12 +39,3 @@ Example
|
||||
Executed in 3,01 secs fish external
|
||||
usr time 9,16 millis 2,94 millis 6,23 millis
|
||||
sys time 0,23 millis 0,00 millis 0,23 millis
|
||||
|
||||
Inline variable assignments need to follow the ``time`` keyword::
|
||||
|
||||
>_ time a_moment=1.5m sleep $a_moment
|
||||
|
||||
________________________________________________________
|
||||
Executed in 90.00 secs fish external
|
||||
usr time 4.62 millis 4.62 millis 0.00 millis
|
||||
sys time 2.35 millis 0.41 millis 1.95 millis
|
||||
|
||||
@@ -30,7 +30,7 @@ The following options are available:
|
||||
|
||||
- ``-P`` or ``--force-path`` returns the path to the executable file ``NAME``, presuming ``NAME`` is found in ``$PATH``, or nothing otherwise. ``--force-path`` explicitly resolves only the path to executable files in ``$PATH``, regardless of whether ``$NAME`` is shadowed by a function or builtin with the same name.
|
||||
|
||||
- ``-q`` or ``--query`` suppresses all output; this is useful when testing the exit status. For compatibility with old fish versions this is also ``--quiet``.
|
||||
- ``-q`` or ``--quiet`` suppresses all output; this is useful when testing the exit status.
|
||||
|
||||
The ``-q``, ``-p``, ``-t`` and ``-P`` flags (and their long flag aliases) are mutually exclusive. Only one can be specified at a time.
|
||||
|
||||
|
||||
@@ -28,6 +28,5 @@ Example
|
||||
::
|
||||
|
||||
while test -f foo.txt; or test -f bar.txt ; echo file exists; sleep 10; end
|
||||
# outputs 'file exists' at 10 second intervals,
|
||||
# as long as the file foo.txt or bar.txt exists.
|
||||
# outputs 'file exists' at 10 second intervals as long as the file foo.txt or bar.txt exists.
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ As a more comprehensive example, here's a commented excerpt of the completions f
|
||||
# Note that this can be undone by using "-F".
|
||||
#
|
||||
# File completions also need to be disabled
|
||||
# if you want to have more control over what files are offered
|
||||
# (e.g. just directories, or just files ending in ".mp3").
|
||||
# if you want to have more control over what files are offered (e.g. just directories, or just files ending in ".mp3").
|
||||
complete -c timedatectl -f
|
||||
|
||||
# This line offers the subcommands
|
||||
@@ -43,26 +42,22 @@ As a more comprehensive example, here's a commented excerpt of the completions f
|
||||
# For more complex uses, you can write your own function.
|
||||
# See e.g. the git completions for an example.
|
||||
#
|
||||
complete -c timedatectl -n "not __fish_seen_subcommand_from $commands" \
|
||||
-a "status set-time set-timezone list-timezones"
|
||||
complete -c timedatectl -n "not __fish_seen_subcommand_from $commands" -a "status set-time set-timezone list-timezones"
|
||||
|
||||
# If the "set-timezone" subcommand is used,
|
||||
# offer the output of `timedatectl list-timezones` as completions.
|
||||
# Each line of output is used as a separate candidate,
|
||||
# and anything after a tab is taken as the description.
|
||||
# It's often useful to transform command output with `string` into that form.
|
||||
complete -c timedatectl -n "__fish_seen_subcommand_from set-timezone" \
|
||||
-a "(timedatectl list-timezones)"
|
||||
complete -c timedatectl -n "__fish_seen_subcommand_from set-timezone" -a "(timedatectl list-timezones)"
|
||||
|
||||
# Completion candidates can also be described via `-d`,
|
||||
# which is useful if the description is constant.
|
||||
# Try to keep these short, because that means the user gets to see more at once.
|
||||
complete -c timedatectl -n "not __fish_seen_subcommand_from $commands" \
|
||||
-a "set-local-rtc" -d "Maintain RTC in local time"
|
||||
complete -c timedatectl -n "not __fish_seen_subcommand_from $commands" -a "set-local-rtc" -d "Maintain RTC in local time"
|
||||
|
||||
# We can also limit options to certain subcommands by using conditions.
|
||||
complete -c timedatectl -n "__fish_seen_subcommand_from set-local-rtc" \
|
||||
-l adjust-system-clock -d 'Synchronize system clock from the RTC'
|
||||
complete -c timedatectl -n "__fish_seen_subcommand_from set-local-rtc" -l adjust-system-clock -d 'Synchronize system clock from the RTC'
|
||||
|
||||
# These are simple options that can be used everywhere.
|
||||
complete -c timedatectl -s h -l help -d 'Print a short help text and exit'
|
||||
@@ -88,7 +83,7 @@ Functions beginning with the string ``__fish_print_`` print a newline separated
|
||||
|
||||
- ``__fish_complete_pids`` prints a list of all processes IDs with the command name as description.
|
||||
|
||||
- ``__fish_complete_suffix SUFFIX`` performs file completion but sorts files ending in SUFFIX first. This is useful in conjunction with ``complete --keep-order``.
|
||||
- ``__fish_complete_suffix SUFFIX`` performs file completion allowing only files ending in SUFFIX, with an optional description.
|
||||
|
||||
- ``__fish_complete_users`` prints a list of all users with their full name as description.
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import os.path
|
||||
import pygments
|
||||
import subprocess
|
||||
from sphinx.errors import SphinxError, SphinxWarning
|
||||
from docutils import nodes, utils
|
||||
|
||||
# -- Helper functions --------------------------------------------------------
|
||||
|
||||
@@ -21,29 +20,8 @@ def strip_ext(path):
|
||||
return os.path.splitext(path)[0]
|
||||
|
||||
|
||||
# A :issue: role to link to github issues.
|
||||
# Used like :issue:`2364`
|
||||
def issue_role(name, rawtext, text, lineno, inliner, options=None, content=None):
|
||||
options = options or {}
|
||||
config = inliner.document.settings.env.app.config
|
||||
try:
|
||||
issue_num = int(text.strip())
|
||||
if issue_num <= 0:
|
||||
raise ValueError
|
||||
except ValueError:
|
||||
msg = inliner.reporter.error('Invalid issue number: "%s"' % text, line=lineno)
|
||||
prb = inliner.problematic(rawtext, rawtext, msg)
|
||||
return [prb], [msg]
|
||||
template = issue_url + "/{n}"
|
||||
ref = template.format(n=issue_num)
|
||||
issue_text = "#{issue_no}".format(issue_no=issue_num)
|
||||
link = nodes.reference(text=issue_text, refuri=ref, **options)
|
||||
return [link], []
|
||||
|
||||
|
||||
# -- Load our extensions -------------------------------------------------
|
||||
# -- Load our Pygments lexer -------------------------------------------------
|
||||
def setup(app):
|
||||
# Our own pygments lexer
|
||||
from sphinx.highlighting import lexers
|
||||
|
||||
this_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
@@ -51,9 +29,11 @@ def setup(app):
|
||||
os.path.join(this_dir, "fish_indent_lexer.py"), lexername="FishIndentLexer"
|
||||
)
|
||||
lexers["fish-docs-samples"] = fish_indent_lexer
|
||||
|
||||
app.add_config_value("issue_url", default=None, rebuild="html")
|
||||
app.add_role("issue", issue_role)
|
||||
# add_css_file only appears in Sphinx 1.8.0
|
||||
if hasattr(app, "add_css_file"):
|
||||
app.add_css_file("custom.css")
|
||||
else:
|
||||
app.add_stylesheet("custom.css")
|
||||
|
||||
|
||||
# The default language to assume
|
||||
@@ -75,7 +55,6 @@ highlight_language = "fish-docs-samples"
|
||||
project = "fish-shell"
|
||||
copyright = "2020, fish-shell developers"
|
||||
author = "fish-shell developers"
|
||||
issue_url = "https://github.com/fish-shell/fish-shell/issues"
|
||||
|
||||
# Parsing FISH-BUILD-VERSION-FILE is possible but hard to ensure that it is in the right place
|
||||
# fish_indent is guaranteed to be on PATH for the Pygments highlighter anyway
|
||||
@@ -132,12 +111,8 @@ pygments_style = None
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
# !!! If you change this you also need to update the @import at the top
|
||||
# of _static/pygments.css
|
||||
html_theme_path = ["."]
|
||||
html_theme = "python_docs_theme"
|
||||
|
||||
# Don't add a weird "_sources" directory
|
||||
html_copy_source = False
|
||||
# of _static/fish-syntax-style.css
|
||||
html_theme = "nature"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
@@ -148,7 +123,7 @@ html_copy_source = False
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
# html_static_path = ["_static"]
|
||||
html_static_path = ["_static"]
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
@@ -216,15 +191,8 @@ def get_command_description(path, name):
|
||||
man_pages = [
|
||||
(master_doc, "fish-doc", "fish-shell Documentation", [author], 1),
|
||||
("tutorial", "fish-tutorial", "fish-shell tutorial", [author], 1),
|
||||
("relnotes", "fish-releasenotes", "fish-shell release notes", [author], 1),
|
||||
("CHANGELOG", "fish-changelog", "fish-shell changelog", [author], 1),
|
||||
("completions", "fish-completions", "Writing fish completions", [author], 1),
|
||||
(
|
||||
"fish_for_bash_users",
|
||||
"fish-for-bash-users",
|
||||
"A quick fish primer for those coming from bash",
|
||||
[author],
|
||||
1,
|
||||
),
|
||||
("faq", "fish-faq", "fish-shell faq", [author], 1),
|
||||
]
|
||||
for path in sorted(glob.glob("cmds/*")):
|
||||
|
||||
@@ -20,6 +20,7 @@ The law of orthogonality
|
||||
The shell language should have a small set of orthogonal features. Any situation where two features are related but not identical, one of them should be removed, and the other should be made powerful and general enough to handle all common use cases of either feature.
|
||||
|
||||
Rationale:
|
||||
|
||||
Related features make the language larger, which makes it harder to learn. It also increases the size of the source code, making the program harder to maintain and update.
|
||||
|
||||
Examples:
|
||||
@@ -69,10 +70,10 @@ The law of user focus
|
||||
When designing a program, one should first think about how to make an intuitive and powerful program. Implementation issues should only be considered once a user interface has been designed.
|
||||
|
||||
Rationale:
|
||||
|
||||
This design rule is different than the others, since it describes how one should go about designing new features, not what the features should be. The problem with focusing on what can be done, and what is easy to do, is that too much of the implementation is exposed. This means that the user must know a great deal about the underlying system to be able to guess how the shell works, it also means that the language will often be rather low-level.
|
||||
|
||||
Examples:
|
||||
|
||||
- There should only be one type of input to the shell, lists of commands. Loops, conditionals and variable assignments are all performed through regular commands.
|
||||
|
||||
- The differences between built-in commands and shellscript functions should be made as small as possible. Built-ins and shellscript functions should have exactly the same types of argument expansion as other commands, should be possible to use in any position in a pipeline, and should support any I/O redirection.
|
||||
@@ -92,7 +93,6 @@ A program whose features are discoverable turns a new user into an expert in a s
|
||||
The main benefit of a graphical program over a command-line-based program is discoverability. In a graphical program, one can discover all the common features by simply looking at the user interface and guessing what the different buttons, menus and other widgets do. The traditional way to discover features in command-line programs is through manual pages. This requires both that the user starts to use a different program, and then they remember the new information until the next time they use the same program.
|
||||
|
||||
Examples:
|
||||
|
||||
- Everything should be tab-completable, and every tab completion should have a description.
|
||||
|
||||
- Every syntax error and error in a built-in command should contain an error message describing what went wrong and a relevant help page. Whenever possible, errors should be flagged red by the syntax highlighter.
|
||||
|
||||
333
doc_src/faq.rst
333
doc_src/faq.rst
@@ -1,16 +1,11 @@
|
||||
Frequently asked questions
|
||||
==========================
|
||||
|
||||
What is the equivalent to this thing from bash (or other shells)?
|
||||
-----------------------------------------------------------------
|
||||
|
||||
See :ref:`Fish for bash users <fish_for_bash_users>`
|
||||
|
||||
How do I set or clear an environment variable?
|
||||
----------------------------------------------
|
||||
Use the :ref:`set <cmd-set>` command::
|
||||
|
||||
set -x key value # typically set -gx key value
|
||||
set -x key value
|
||||
set -e key
|
||||
|
||||
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::
|
||||
@@ -18,7 +13,115 @@ Since fish 3.1 you can set an environment variable for just one command using th
|
||||
key=value echo $key
|
||||
begin; set -lx key value; echo $key; end
|
||||
|
||||
Note that "exported" is not a :ref:`scope <variables-scope>`, but an additional bit of state. A variable can be global and exported or local and exported or even universal and exported. Typically it makes sense to make an exported variable global.
|
||||
How do I run a command every login? What's fish's equivalent to .bashrc or .profile?
|
||||
------------------------------------------------------------------------------------
|
||||
Edit the file ``~/.config/fish/config.fish`` [#]_, creating it if it does not exist (Note the leading period).
|
||||
|
||||
|
||||
.. [#] The "~/.config" part of this can be set via $XDG_CONFIG_HOME, that's just the default.
|
||||
|
||||
How do I set my prompt?
|
||||
-----------------------
|
||||
The prompt is the output of the ``fish_prompt`` function. Put it in ``~/.config/fish/functions/fish_prompt.fish``. For example, a simple prompt is::
|
||||
|
||||
function fish_prompt
|
||||
set_color $fish_color_cwd
|
||||
echo -n (prompt_pwd)
|
||||
set_color normal
|
||||
echo -n ' > '
|
||||
end
|
||||
|
||||
|
||||
You can also use the Web configuration tool, :ref:`fish_config <cmd-fish_config>`, to preview and choose from a gallery of sample prompts.
|
||||
|
||||
If you want to modify your existing prompt, you can use :ref:`funced <cmd-funced>` and :ref:`funcsave <cmd-funcsave>` like::
|
||||
|
||||
>_ funced fish_prompt
|
||||
# this opens up your editor (set in $EDITOR), modify the function, save the file, repeat to your liking
|
||||
# once you are happy with it:
|
||||
>_ funcsave fish_prompt
|
||||
|
||||
This also applies to :ref:`fish_right_prompt <cmd-fish_right_prompt>` and :ref:`fish_mode_prompt <cmd-fish_mode_prompt>`.
|
||||
|
||||
Why does my prompt show a `[I]`?
|
||||
--------------------------------
|
||||
|
||||
That's the :ref:`fish_mode_prompt <cmd-fish_mode_prompt>`. It is displayed by default when you've activated vi mode using ``fish_vi_key_bindings``.
|
||||
|
||||
If you haven't activated vi mode on purpose, you might have installed a third-party theme that does it.
|
||||
|
||||
If you want to change or disable this display, modify the `fish_mode_prompt` function, for instance via :ref:`funced <cmd-funced>`.
|
||||
|
||||
How do I run a command from history?
|
||||
------------------------------------
|
||||
Type some part of the command, and then hit the :kbd:`↑` (up) or :kbd:`↓` (down) arrow keys to navigate through history matches. Additional default key bindings include :kbd:`Control`\ +\ :kbd:`P` (up) and :kbd:`Control`\ +\ :kbd:`N` (down).
|
||||
|
||||
|
||||
How do I run a subcommand? The backtick doesn't work!
|
||||
-----------------------------------------------------
|
||||
``fish`` uses parentheses for subcommands. For example::
|
||||
|
||||
for i in (ls)
|
||||
echo $i
|
||||
end
|
||||
|
||||
|
||||
My command (pkg-config) gives its output as a single long string?
|
||||
-----------------------------------------------------------------
|
||||
Unlike other shells, fish splits command substitutions only on newlines, not spaces or tabs or the characters in $IFS.
|
||||
|
||||
That means if you run
|
||||
|
||||
::
|
||||
|
||||
echo x(printf '%s ' a b c)x
|
||||
|
||||
|
||||
It will print ``xa b c x``, because the "a b c " is used in one piece. But if you do
|
||||
|
||||
::
|
||||
|
||||
echo x(printf '%s\n' a b c)x
|
||||
|
||||
|
||||
it will print ``xax xbx xcx``.
|
||||
|
||||
In the overwhelming majority of cases, splitting on spaces is unwanted, so this is an improvement.
|
||||
|
||||
However sometimes, especially with ``pkg-config`` and related tools, splitting on spaces is needed.
|
||||
|
||||
In these cases use ``string split " "`` like::
|
||||
|
||||
g++ example_01.cpp (pkg-config --cflags --libs gtk+-2.0 | string split " ")
|
||||
|
||||
|
||||
How do I get the exit status of a command?
|
||||
------------------------------------------
|
||||
Use the ``$status`` variable. This replaces the ``$?`` variable used in some other shells.
|
||||
|
||||
::
|
||||
|
||||
somecommand
|
||||
if test $status -eq 7
|
||||
echo "That's my lucky number!"
|
||||
end
|
||||
|
||||
|
||||
If you are just interested in success or failure, you can run the command directly as the if-condition::
|
||||
|
||||
if somecommand
|
||||
echo "Command succeeded"
|
||||
else
|
||||
echo "Command failed"
|
||||
end
|
||||
|
||||
|
||||
Or if you just want to do one command in case the first succeeded or failed, use ``and`` or ``or``::
|
||||
|
||||
somecommand
|
||||
or someothercommand
|
||||
|
||||
See the documentation for :ref:`test <cmd-test>` and :ref:`if <cmd-if>` for more information.
|
||||
|
||||
How do I check whether a variable is defined?
|
||||
---------------------------------------------
|
||||
@@ -69,62 +172,36 @@ add a statement to your :ref:`user initialization file <initialization>` (usuall
|
||||
|
||||
set -gx EDITOR vim
|
||||
|
||||
How do I run a command every login? What's fish's equivalent to .bashrc or .profile?
|
||||
------------------------------------------------------------------------------------
|
||||
Edit the file ``~/.config/fish/config.fish`` [#]_, creating it if it does not exist (Note the leading period).
|
||||
|
||||
|
||||
.. [#] The "~/.config" part of this can be set via $XDG_CONFIG_HOME, that's just the default.
|
||||
|
||||
How do I set my prompt?
|
||||
-----------------------
|
||||
The prompt is the output of the ``fish_prompt`` function. Put it in ``~/.config/fish/functions/fish_prompt.fish``. For example, a simple prompt is::
|
||||
|
||||
function fish_prompt
|
||||
set_color $fish_color_cwd
|
||||
echo -n (prompt_pwd)
|
||||
set_color normal
|
||||
echo -n ' > '
|
||||
end
|
||||
|
||||
|
||||
You can also use the Web configuration tool, :ref:`fish_config <cmd-fish_config>`, to preview and choose from a gallery of sample prompts.
|
||||
|
||||
If you want to modify your existing prompt, you can use :ref:`funced <cmd-funced>` and :ref:`funcsave <cmd-funcsave>` like::
|
||||
|
||||
>_ funced fish_prompt
|
||||
# This opens up your editor (set in $EDITOR).
|
||||
# Modify the function,
|
||||
# save the file and repeat to your liking.
|
||||
# Once you are happy with it:
|
||||
>_ funcsave fish_prompt
|
||||
|
||||
This also applies to :ref:`fish_right_prompt <cmd-fish_right_prompt>` and :ref:`fish_mode_prompt <cmd-fish_mode_prompt>`.
|
||||
|
||||
Why does my prompt show a ``[I]``?
|
||||
----------------------------------
|
||||
|
||||
That's the :ref:`fish_mode_prompt <cmd-fish_mode_prompt>`. It is displayed by default when you've activated vi mode using ``fish_vi_key_bindings``.
|
||||
|
||||
If you haven't activated vi mode on purpose, you might have installed a third-party theme that does it.
|
||||
|
||||
If you want to change or disable this display, modify the ``fish_mode_prompt`` function, for instance via :ref:`funced <cmd-funced>`.
|
||||
|
||||
How do I customize my syntax highlighting colors?
|
||||
-------------------------------------------------
|
||||
Use the web configuration tool, :ref:`fish_config <cmd-fish_config>`, or alter the :ref:`fish_color family of environment variables <variables-color>`.
|
||||
Use the web configuration tool, :ref:`fish_config <cmd-fish_config>`, or alter the `fish_color family of environment variables <index#variables-color>`__.
|
||||
|
||||
How do I change the greeting message?
|
||||
-------------------------------------
|
||||
Change the value of the variable ``fish_greeting`` or create a ``fish_greeting`` function. For example, to remove the greeting use::
|
||||
I accidentally entered a directory path and fish changed directory. What happened?
|
||||
----------------------------------------------------------------------------------
|
||||
If fish is unable to locate a command with a given name, and it starts with ``.``, ``/`` or ``~``, fish will test if a directory of that name exists. If it does, it is implicitly assumed that you want to change working directory. For example, the fastest way to switch to your home directory is to simply press ``~`` and enter.
|
||||
|
||||
set -U fish_greeting
|
||||
The open command doesn't work.
|
||||
------------------------------
|
||||
The ``open`` command uses the MIME type database and the ``.desktop`` files used by Gnome and KDE to identify filetypes and default actions. If at least one of these environments is installed, but the open command is not working, this probably means that the relevant files are installed in a non-standard location. Consider `asking for more help <index#more-help>`__.
|
||||
|
||||
Or if you prefer not to use a universal variable, use::
|
||||
How do I make fish my default shell?
|
||||
------------------------------------
|
||||
If you installed fish manually (e.g. by compiling it, not by using a package manager), you first need to add fish to the list of shells by executing the following command (assuming you installed fish in /usr/local)::
|
||||
|
||||
set -g fish_greeting
|
||||
echo /usr/local/bin/fish | sudo tee -a /etc/shells
|
||||
|
||||
|
||||
If you installed a prepackaged version of fish, the package manager should have already done this for you.
|
||||
|
||||
In order to change your default shell, type::
|
||||
|
||||
chsh -s /usr/local/bin/fish
|
||||
|
||||
|
||||
You may need to adjust the above path to e.g. ``/usr/bin/fish``. Use the command ``which fish`` if you are unsure of where fish is installed.
|
||||
|
||||
Unfortunately, there is no way to make the changes take effect at once. You will need to log out and back in again.
|
||||
|
||||
in config.fish.
|
||||
|
||||
I'm seeing weird output before each prompt when using screen. What's wrong?
|
||||
---------------------------------------------------------------------------
|
||||
@@ -143,15 +220,17 @@ Fish is trying to set the titlebar message of your terminal. While screen itself
|
||||
|
||||
Note that fish has a default titlebar message, which will be used if the fish_title function is undefined. So simply unsetting the fish_title function will not work.
|
||||
|
||||
How do I run a command from history?
|
||||
------------------------------------
|
||||
Type some part of the command, and then hit the :kbd:`↑` (up) or :kbd:`↓` (down) arrow keys to navigate through history matches. Additional default key bindings include :kbd:`Control`\ +\ :kbd:`P` (up) and :kbd:`Control`\ +\ :kbd:`N` (down).
|
||||
How do I change the greeting message?
|
||||
-------------------------------------
|
||||
Change the value of the variable ``fish_greeting`` or create a ``fish_greeting`` function. For example, to remove the greeting use::
|
||||
|
||||
set fish_greeting
|
||||
|
||||
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 just press :kbd:`Alt`\ +\ :kbd:`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`\ +\ :kbd:`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:
|
||||
|
||||
@@ -159,7 +238,7 @@ In general, fish's history recall works like this:
|
||||
|
||||
- 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.
|
||||
|
||||
- :kbd:`Alt`\ +\ :kbd:`↑` recalls individual arguments, starting from the last argument in the last executed line. A single press replaces "!$", later presses replace "!!:4" and such. As an alternate key binding, :kbd:`Alt`\ +\ :kbd:`.` can be used.
|
||||
- :kbd:`Alt`\ +\ :kbd:`↑` recalls individual arguments, starting from the last argument in the last executed line. A single press replaces "!$", later presses replace "!!:4" and such. An alternate key binding is :kbd:`Alt`\ +\ :kbd:`.`.
|
||||
|
||||
- If the argument you want is far back in history (e.g. 2 lines back - that's a lot of words!), type any part of it and then press :kbd:`Alt`\ +\ :kbd:`↑`. This will show only arguments containing that part and you will get what you want much faster. Try it out, this is very convenient!
|
||||
|
||||
@@ -167,72 +246,11 @@ In general, fish's history recall works like this:
|
||||
|
||||
See :ref:`documentation <editor>` for more details about line editing in fish.
|
||||
|
||||
How do I run a subcommand? The backtick doesn't work!
|
||||
-----------------------------------------------------
|
||||
``fish`` uses parentheses for subcommands. For example::
|
||||
How can I use ``-`` as a shortcut for ``cd -``?
|
||||
-----------------------------------------------
|
||||
In fish versions prior to 2.5.0 it was possible to create a function named ``-`` that would do ``cd -``. Changes in the 2.5.0 release included several bug fixes that enforce the rule that a bare hyphen is not a valid function (or variable) name. However, you can achieve the same effect via an abbreviation::
|
||||
|
||||
for i in (ls)
|
||||
echo $i
|
||||
end
|
||||
|
||||
|
||||
My command (pkg-config) gives its output as a single long string?
|
||||
-----------------------------------------------------------------
|
||||
Unlike other shells, fish splits command substitutions only on newlines, not spaces or tabs or the characters in $IFS.
|
||||
|
||||
That means if you run
|
||||
|
||||
::
|
||||
|
||||
echo x(printf '%s ' a b c)x
|
||||
|
||||
|
||||
It will print ``xa b c x``, because the "a b c " is used in one piece. But if you do
|
||||
|
||||
::
|
||||
|
||||
echo x(printf '%s\n' a b c)x
|
||||
|
||||
|
||||
it will print ``xax xbx xcx``.
|
||||
|
||||
In the overwhelming majority of cases, splitting on spaces is unwanted, so this is an improvement.
|
||||
|
||||
However sometimes, especially with ``pkg-config`` and related tools, splitting on spaces is needed.
|
||||
|
||||
In these cases use ``string split -n " "`` like::
|
||||
|
||||
g++ example_01.cpp (pkg-config --cflags --libs gtk+-2.0 | string split -n " ")
|
||||
|
||||
The ``-n`` is so empty elements are removed like POSIX shells would do.
|
||||
|
||||
How do I get the exit status of a command?
|
||||
------------------------------------------
|
||||
Use the ``$status`` variable. This replaces the ``$?`` variable used in some other shells.
|
||||
|
||||
::
|
||||
|
||||
somecommand
|
||||
if test $status -eq 7
|
||||
echo "That's my lucky number!"
|
||||
end
|
||||
|
||||
|
||||
If you are just interested in success or failure, you can run the command directly as the if-condition::
|
||||
|
||||
if somecommand
|
||||
echo "Command succeeded"
|
||||
else
|
||||
echo "Command failed"
|
||||
end
|
||||
|
||||
|
||||
Or if you just want to do one command in case the first succeeded or failed, use ``and`` or ``or``::
|
||||
|
||||
somecommand
|
||||
or someothercommand
|
||||
|
||||
See the documentation for :ref:`test <cmd-test>` and :ref:`if <cmd-if>` for more information.
|
||||
abbr -a -- - 'cd -'
|
||||
|
||||
My command prints "No matches for wildcard" but works in bash
|
||||
-------------------------------------------------------------
|
||||
@@ -264,15 +282,14 @@ or
|
||||
|
||||
apt install postgres-*
|
||||
|
||||
appear to work, because most of the time the string doesn't match and so it passes along the ``string-*``, which is then interpreted by the receiving program.
|
||||
appear to work, because most of the time the string doesn't match and so it passes along the `string-*`, which is then interpreted by the receiving program.
|
||||
|
||||
But it also means that these commands can stop working at any moment once a matching file is encountered (because it has been created or the command is executed in a different working directory), and to deal with that bash needs workarounds like
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
for f in ./*.mpg; do
|
||||
# We need to test if the file really exists because
|
||||
# the wildcard might have failed to match.
|
||||
# We need to test if the file really exists because the wildcard might have failed to match.
|
||||
test -f "$f" || continue
|
||||
mympgviewer "$f"
|
||||
done
|
||||
@@ -283,42 +300,6 @@ For these reasons, fish does not do this, and instead expects asterisks to be qu
|
||||
|
||||
This is similar to bash's "failglob" option.
|
||||
|
||||
I accidentally entered a directory path and fish changed directory. What happened?
|
||||
----------------------------------------------------------------------------------
|
||||
If fish is unable to locate a command with a given name, and it starts with ``.``, ``/`` or ``~``, fish will test if a directory of that name exists. If it does, it is implicitly assumed that you want to change working directory. For example, the fastest way to switch to your home directory is to simply press ``~`` and enter.
|
||||
|
||||
How can I use ``-`` as a shortcut for ``cd -``?
|
||||
-----------------------------------------------
|
||||
In fish versions prior to 2.5.0 it was possible to create a function named ``-`` that would do ``cd -``. Changes in the 2.5.0 release included several bug fixes that enforce the rule that a bare hyphen is not a valid function (or variable) name. However, you can achieve the same effect via an abbreviation::
|
||||
|
||||
abbr -a -- - 'cd -'
|
||||
|
||||
The open command doesn't work.
|
||||
------------------------------
|
||||
The ``open`` command uses the MIME type database and the ``.desktop`` files used by Gnome and KDE to identify filetypes and default actions. If at least one of these environments is installed, but the open command is not working, this probably means that the relevant files are installed in a non-standard location. Consider :ref:`asking for more help <more-help>`.
|
||||
.. _faq-ssh-interactive:
|
||||
|
||||
Why won't SSH/SCP/rsync connect properly when fish is my login shell?
|
||||
---------------------------------------------------------------------
|
||||
|
||||
This problem may show up as messages like "``Received message too long``", "``open terminal
|
||||
failed: not a terminal``", "``Bad packet length``", or "``Connection refused``" with strange output
|
||||
in ``ssh_exchange_identification`` messages in the debug log.
|
||||
|
||||
This usually happens because fish reads the :ref:`user configuration file <initialization>` (``~/.config/fish/config.fish``) *always*,
|
||||
whether it's in an interactive or login or non-interactive or non-login shell.
|
||||
|
||||
This simplifies matters, but it also means when config.fish generates output, it will do that even in non-interactive shells like the one ssh/scp/rsync start when they connect.
|
||||
|
||||
Anything in config.fish that produces output should be guarded with ``status is-interactive`` (or ``status is-login`` if you prefer)::
|
||||
|
||||
|
||||
if status is-interactive
|
||||
...
|
||||
end
|
||||
|
||||
The same applies for example when you start ``tmux`` in config.fish without guards, which will cause a message like ``sessions should be nested with care, unset $TMUX to force``.
|
||||
|
||||
.. _faq-unicode:
|
||||
|
||||
I'm getting weird graphical glitches (a staircase effect, ghost characters,...)?
|
||||
@@ -339,31 +320,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.
|
||||
|
||||
How do I make fish my default shell?
|
||||
------------------------------------
|
||||
If you installed fish manually (e.g. by compiling it, not by using a package manager), you first need to add fish to the list of shells by executing the following command (assuming you installed fish in /usr/local)::
|
||||
|
||||
echo /usr/local/bin/fish | sudo tee -a /etc/shells
|
||||
|
||||
|
||||
If you installed a prepackaged version of fish, the package manager should have already done this for you.
|
||||
|
||||
In order to change your default shell, type::
|
||||
|
||||
chsh -s /usr/local/bin/fish
|
||||
|
||||
|
||||
You may need to adjust the above path to e.g. ``/usr/bin/fish``. Use the command ``which fish`` if you are unsure of where fish is installed.
|
||||
|
||||
Unfortunately, there is no way to make the changes take effect at once. You will need to log out and back in again.
|
||||
|
||||
.. _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.
|
||||
Should you wish to uninstall fish, first ensure 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, just use that package manager's uninstall function. If you built fish yourself, assuming you installed it to /usr/local, do this::
|
||||
Next, do the following (assuming fish was installed to /usr/local)::
|
||||
|
||||
rm -Rf /usr/local/etc/fish /usr/local/share/fish ~/.config/fish
|
||||
rm /usr/local/share/man/man1/fish*.1
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
.. _fish_for_bash_users:
|
||||
|
||||
Fish for bash users
|
||||
###################
|
||||
|
||||
This is to give you a quick overview if you come from bash (or to a lesser extent other shells like zsh or ksh) and want to know how fish differs. Fish is intentionally not POSIX-compatible and as such some of the things you are used to work differently.
|
||||
This is to give you a quick overview if you come from bash (or to a lesser extent other shells zsh or ksh) and want to know how fish differs. Fish is intentionally not POSIX-compatible and as such some of the things you are used to work differently.
|
||||
|
||||
Many things are similar - they both fundamentally expand commandlines to execute commands, have pipes, redirections, variables, globs, use command output in various ways. This document is there to quickly show you the differences.
|
||||
|
||||
@@ -23,10 +21,8 @@ Variables
|
||||
|
||||
Fish sets and erases variables with :ref:`set <cmd-set>` instead of ``VAR=VAL`` and ``declare`` and ``unset`` and ``export``. ``set`` takes options to determine the scope and exportedness of a variable::
|
||||
|
||||
# Define $PAGER global and exported, so this is like ``export PAGER=less``
|
||||
set -gx PAGER less
|
||||
|
||||
# Define $alocalvariable only locally - like ``local alocalvariable=foo``
|
||||
set -l alocalvariable foo
|
||||
|
||||
or to erase variables::
|
||||
@@ -39,22 +35,7 @@ or to erase variables::
|
||||
PAGER=cat git log
|
||||
|
||||
|
||||
Fish does not perform word splitting. Once a variable has been set to a value, that value stays as it is, so double-quoting variable expansions isn't the necessity it is in bash. [#]_
|
||||
|
||||
For instance, here's bash
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
> foo="bar baz"
|
||||
> printf '"%s"\n' $foo # will print two lines, because we didn't double-quote, so the variable is split
|
||||
"bar"
|
||||
"baz"
|
||||
|
||||
And here is fish::
|
||||
|
||||
> set foo "bar baz"
|
||||
> printf '"%s"\n' $foo # foo was set as one element, so it will be passed as one element, so this is one line
|
||||
"bar baz"
|
||||
Fish does not perform word splitting. Once a variable has been set to a value, that value stays as it is, so double-quoting variable expansions isn't the necessity it is in bash.
|
||||
|
||||
All variables are "arrays" (we use the term "lists"), and expanding a variable expands to all its elements, with each element as its own argument (like bash's ``"${var[@]}"``::
|
||||
|
||||
@@ -67,8 +48,6 @@ Specific elements of a list can be selected::
|
||||
|
||||
echo $list[5..7]
|
||||
|
||||
.. [#] zsh also does not perform word splitting by default (the SH_WORD_SPLIT option controls this)
|
||||
|
||||
Wildcards (globs)
|
||||
-----------------
|
||||
|
||||
@@ -112,21 +91,11 @@ Some bash variables and their closest fish equivalent:
|
||||
- ``$0``: ``status filename``
|
||||
- ``$-``: Mostly ``status is-interactive`` and ``status is-login``
|
||||
|
||||
Process substitution
|
||||
Parameter substitution
|
||||
----------------------
|
||||
|
||||
Instead of ``<(command)`` fish uses ``(command | psub)``. There is no equivalent to ``>(command)``.
|
||||
|
||||
Note that both of these are bashisms, and most things can easily be expressed without. E.g. instead of::
|
||||
|
||||
source (command | psub)
|
||||
|
||||
just use::
|
||||
|
||||
command | source
|
||||
|
||||
as fish's :ref:`source <cmd-source>` can read from stdin.
|
||||
|
||||
Heredocs
|
||||
--------
|
||||
|
||||
@@ -170,34 +139,7 @@ It can handle floating point numbers::
|
||||
Prompts
|
||||
-------
|
||||
|
||||
Fish does not use the ``$PS1``, ``$PS2`` and so on variables. Instead the prompt is the output of the :ref:`fish_prompt <cmd-fish_prompt>` function, plus the :ref:`fish_mode_prompt <cmd-fish_mode_prompt>` function if vi-mode is enabled and the :ref:`fish_right_prompt <cmd-fish_right_prompt>` function for the right prompt.
|
||||
|
||||
As an example, here's a relatively simple bash prompt:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# <$HOSTNAME> <$PWD in blue> <Prompt Sign in Yellow> <Rest in default light white>
|
||||
export PS1='\h\[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] '
|
||||
|
||||
and a rough fish equivalent::
|
||||
|
||||
function fish_prompt
|
||||
set -l prompt_symbol '$'
|
||||
fish_is_root_user; and set prompt_symbol '#'
|
||||
|
||||
echo -s $hostname (set_color blue) (prompt_pwd) \
|
||||
(set_color yellow) $prompt_symbol (set_color normal)
|
||||
end
|
||||
|
||||
This shows a few differences:
|
||||
|
||||
- Fish provides :ref:`set_color <cmd-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 simply a function, so you can use variables like ``$hostname``.
|
||||
- Fish offers helper functions for adding things to the prompt, like :ref:`fish_vcs_prompt <cmd-fish_vcs_prompt>` for adding a display for common version control systems (git, mercurial, svn) and :ref:`prompt_pwd <cmd-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``.
|
||||
|
||||
Fish does not have ``$PS2`` for continuation lines, instead it leaves the lines indented to show that the commandline isn't complete yet.
|
||||
Fish does not use the ``$PS1``, ``$PS2`` and so on variables. Instead the prompt is the output of the ``fish_prompt`` function, plus the ``fish_mode_prompt`` function if vi-mode is enabled and the ``fish_right_prompt`` function for the right prompt.
|
||||
|
||||
Blocks and loops
|
||||
----------------
|
||||
@@ -262,15 +204,13 @@ Fish's blocking constructs look a little different. They all start with a word,
|
||||
|
||||
Fish does not have an ``until``. Use ``while not`` or ``while !``.
|
||||
|
||||
Builtins and other commands
|
||||
---------------------------
|
||||
Builtins
|
||||
--------
|
||||
|
||||
By now it has become apparent that fish puts much more of a focus on its builtins and external commands rather than its syntax. So here are some helpful builtins and their rough equivalent in bash:
|
||||
By now it has become apparent that fish puts much more of a focus on its builtins rather than its syntax. So here are some helpful builtins and their rough equivalent in bash:
|
||||
|
||||
- :ref:`string <cmd-string>` - this replaces most of the string transformation (``${i%foo}`` et al) and can also be used instead of ``grep`` and ``sed`` and such.
|
||||
- :ref:`math <cmd-math>` - this replaces ``$((i + 1))`` arithmetic and can also do floats and some simple functions (sine and friends).
|
||||
- :ref:`argparse <cmd-argparse>` - this can handle a script's option parsing, for which bash would probably use ``getopt`` (zsh provides ``zparseopts``).
|
||||
- :ref:`count <cmd-count>` can be used to count things and therefore replaces ``$#`` and can be used instead of ``wc``.
|
||||
- :ref:`status <cmd-status>` provides information about the shell status, e.g. if it's interactive or what the current linenumber is. This replaces ``$-`` and ``$BASH_LINENO`` and other variables.
|
||||
|
||||
- ``seq(1)`` can be used as a replacement for ``{1..10}`` range expansion. If your OS doesn't ship a ``seq`` fish includes a replacement function.
|
||||
|
||||
@@ -34,7 +34,6 @@ ROLE_TO_TOKEN = {
|
||||
"normal": Name.Variable,
|
||||
"error": Generic.Error,
|
||||
"command": Name.Function,
|
||||
"keyword": Keyword,
|
||||
"statement_terminator": Punctuation,
|
||||
"param": Name.Constant,
|
||||
"comment": Comment,
|
||||
@@ -63,9 +62,9 @@ ROLE_TO_TOKEN = {
|
||||
|
||||
|
||||
def token_for_text_and_role(text, role):
|
||||
"""Return the pygments token for some input text and a fish role
|
||||
|
||||
This applies any special cases of ROLE_TO_TOKEN.
|
||||
""" Return the pygments token for some input text and a fish role
|
||||
|
||||
This applies any special cases of ROLE_TO_TOKEN.
|
||||
"""
|
||||
if text.isspace():
|
||||
# Here fish will return 'normal' or 'statement_terminator' for newline.
|
||||
@@ -78,13 +77,13 @@ def token_for_text_and_role(text, role):
|
||||
|
||||
|
||||
def tokenize_fish_command(code, offset):
|
||||
"""Tokenize some fish code, offset in a parent string, by shelling
|
||||
out to fish_indent.
|
||||
""" Tokenize some fish code, offset in a parent string, by shelling
|
||||
out to fish_indent.
|
||||
|
||||
fish_indent will output a list of csv lines: start,end,type.
|
||||
|
||||
fish_indent will output a list of csv lines: start,end,type.
|
||||
|
||||
This function returns a list of (start, tok, value) tuples, as
|
||||
Pygments expects.
|
||||
This function returns a list of (start, tok, value) tuples, as
|
||||
Pygments expects.
|
||||
"""
|
||||
proc = subprocess.Popen(
|
||||
["fish_indent", "--pygments"],
|
||||
@@ -109,11 +108,11 @@ class FishIndentLexer(Lexer):
|
||||
filenames = ["*.fish"]
|
||||
|
||||
def get_tokens_unprocessed(self, input_text):
|
||||
"""Return a list of (start, tok, value) tuples.
|
||||
""" Return a list of (start, tok, value) tuples.
|
||||
|
||||
start is the index into the string
|
||||
tok is the token type (as above)
|
||||
value is the string contents of the token
|
||||
start is the index into the string
|
||||
tok is the token type (as above)
|
||||
value is the string contents of the token
|
||||
"""
|
||||
result = []
|
||||
if not any(s.startswith(">") for s in input_text.splitlines()):
|
||||
|
||||
1364
doc_src/index.rst
1364
doc_src/index.rst
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,6 @@
|
||||
License
|
||||
========
|
||||
|
||||
License for fish
|
||||
----------------
|
||||
|
||||
``fish`` Copyright © 2005-2009 Axel Liljencrantz, 2009-2020 fish-shell contributors. ``fish`` is released under the GNU General Public License, version 2.
|
||||
|
||||
``fish`` includes other code licensed under the GNU General Public License, version 2, including GNU ``printf``.
|
||||
@@ -106,8 +103,9 @@ The precise terms and conditions for copying, distribution and modification foll
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
License for PCRE2
|
||||
-----------------
|
||||
----
|
||||
|
||||
**License for PCRE2**
|
||||
|
||||
``fish`` contains code from the [PCRE2](http://www.pcre.org) library to support regular expressions. This code, created by Philip Hazel, is distributed under the terms of the BSD license. Copyright © 1997-2015 University of Cambridge.
|
||||
|
||||
@@ -122,56 +120,3 @@ Redistribution and use in source and binary forms, with or without modification,
|
||||
- Neither the name of the University of Cambridge nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
License for the Python docs theme
|
||||
---------------------------------
|
||||
|
||||
In doc_src/python_docs_theme/, taken from https://pypi.org/project/python-docs-theme/2020.1/.
|
||||
|
||||
**PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2**
|
||||
|
||||
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
||||
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
||||
otherwise using this software ("Python") in source or binary form and
|
||||
its associated documentation.
|
||||
|
||||
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
||||
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
||||
analyze, test, perform and/or display publicly, prepare derivative works,
|
||||
distribute, and otherwise use Python alone or in any derivative version,
|
||||
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
||||
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
2011, 2012, 2013, 2014, 2015, 2016, 2017 Python Software Foundation; All Rights
|
||||
Reserved" are retained in Python alone or in any derivative version prepared by
|
||||
Licensee.
|
||||
|
||||
3. In the event Licensee prepares a derivative work that is based on
|
||||
or incorporates Python or any part thereof, and wants to make
|
||||
the derivative work available to others as provided herein, then
|
||||
Licensee hereby agrees to include in any such work a brief summary of
|
||||
the changes made to Python.
|
||||
|
||||
4. PSF is making Python available to Licensee on an "AS IS"
|
||||
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
||||
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
||||
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
||||
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
||||
INFRINGE ANY THIRD PARTY RIGHTS.
|
||||
|
||||
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
||||
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
||||
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
||||
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
||||
|
||||
6. This License Agreement will automatically terminate upon a material
|
||||
breach of its terms and conditions.
|
||||
|
||||
7. Nothing in this License Agreement shall be deemed to create any
|
||||
relationship of agency, partnership, or joint venture between PSF and
|
||||
Licensee. This License Agreement does not grant permission to use PSF
|
||||
trademarks or trade name in a trademark sense to endorse or promote
|
||||
products or services of Licensee, or any third party.
|
||||
|
||||
8. By copying, installing or otherwise using Python, Licensee
|
||||
agrees to be bound by the terms and conditions of this License
|
||||
Agreement.
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import os
|
||||
|
||||
|
||||
def setup(app):
|
||||
current_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
app.add_html_theme("python_docs_theme", current_dir)
|
||||
|
||||
return {
|
||||
"parallel_read_safe": True,
|
||||
"parallel_write_safe": True,
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{#
|
||||
basic/globaltoc.html
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sphinx sidebar template: global table of contents.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
#}
|
||||
<div>
|
||||
<h3><a href="{{ pathto(master_doc)|e }}">{{ _('Documents') }}</a></h3>
|
||||
{{ toctree(includehidden=theme_globaltoc_includehidden, collapse=theme_globaltoc_collapse, maxdepth=theme_globaltoc_maxdepth) }}
|
||||
</div>
|
||||
@@ -1,60 +0,0 @@
|
||||
{% extends "basic/layout.html" %}
|
||||
{# Remove broken "genindex" link - unfortunately this takes with it the acceptable "next" and "previous" links, but they're not super necessary. #}
|
||||
{% set rellinks = [] %}
|
||||
|
||||
{% block rootrellink %}
|
||||
<li><img src="{{ pathto('_static/' + theme_root_icon, 1) }}" alt=""
|
||||
style="width: 80px; vertical-align: middle; margin-top: -1px"/></li>
|
||||
<li><a href="{{theme_root_url}}">{{theme_root_name}}</a>{{ reldelim1 }}</li>
|
||||
{% if theme_root_include_title %}
|
||||
<a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{%- macro searchbox() %}
|
||||
{# modified from sphinx/themes/basic/searchbox.html #}
|
||||
{%- if builder != "htmlhelp" %}
|
||||
<div class="inline-search" style="display: none" role="search">
|
||||
<form class="inline-search" action="{{ pathto('search') }}" method="get">
|
||||
<input placeholder="{{ _('Quick search') }}" type="text" name="q" />
|
||||
<input type="submit" value="{{ _('Go') }}" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">$('.inline-search').show(0);</script>
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% block header %}<div id="fmain">{% endblock %}
|
||||
{% block relbar1 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %}
|
||||
{% block relbar2 %} {% if builder != 'qthelp' %} {{ relbar() }} {% endif %} {% endblock %}
|
||||
{% block relbaritems %}
|
||||
{%- if pagename != "search" and builder != "singlehtml" and builder != "htmlhelp" %}
|
||||
<li class="right">
|
||||
{{ searchbox() }}
|
||||
</li>
|
||||
{%- endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar1 %}{{ sidebar() }}{% endblock %}
|
||||
{% block sidebar2 %} {% endblock %}
|
||||
{% block extrahead %}
|
||||
<link rel="shortcut icon" type="image/png" href="{{ pathto('_static/' + theme_root_icon, 1) }}" />
|
||||
{{ super() }}
|
||||
{% endblock %}
|
||||
|
||||
{% block footer %}
|
||||
<div class="footer">
|
||||
© {% trans %}Copyright{% endtrans %} {{ copyright|e }}.
|
||||
<br />
|
||||
{%- if last_updated %}
|
||||
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
|
||||
{%- endif %}
|
||||
{% if theme_issues_url %}{% trans pathto_bugs=theme_issues_url %}<a href="{{ theme_issues_url }}">Found a bug</a>?{% endtrans %}{% endif %}
|
||||
<br />
|
||||
|
||||
{% trans sphinx_version=sphinx_version|e %}Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,13 +0,0 @@
|
||||
{#
|
||||
basic/localtoc.html
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Sphinx sidebar template: local table of contents.
|
||||
|
||||
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
#}
|
||||
<div>
|
||||
<h4><a href="{{ pathto(master_doc)|e }}">{{ _('Sections') }}</a></h4>
|
||||
{{ toc }}
|
||||
</div>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user