mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-09 17:01:16 -03:00
Compare commits
7 Commits
Integratio
...
Integratio
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e68508b0c | ||
|
|
2aac8e5dde | ||
|
|
209d8b7f2f | ||
|
|
26663e042f | ||
|
|
55986120aa | ||
|
|
aea9ad4965 | ||
|
|
216d32055d |
19
.gitattributes
vendored
19
.gitattributes
vendored
@@ -1,21 +1,4 @@
|
||||
.gitattributes export-ignore
|
||||
.gitignore export-ignore
|
||||
.travis.yml export-ignore
|
||||
/build_tools/make_svn_completions.fish export-ignore
|
||||
/build_tools/description-pak export-ignore
|
||||
/build_tools/make_hg_completions.fish export-ignore
|
||||
/build_tools/make_vcs_completions.fish export-ignore
|
||||
/build_tools/make_vcs_completions_generic.fish export-ignore
|
||||
/build_tools/osx_package_resources export-ignore
|
||||
/build_tools/osx_package_resources/terminal_logo.png export-ignore
|
||||
/build_tools/osx_package_resources/welcome.rtf export-ignore
|
||||
/build_tools/make_csv_completions.fish export-ignore
|
||||
/build_tools/osx_distribution.xml export-ignore
|
||||
/build_tools/make_tarball.sh export-ignore
|
||||
/build_tools/make_deb.sh export-ignore
|
||||
/build_tools/osx_package_scripts export-ignore
|
||||
/build_tools/osx_package_scripts/add-shell export-ignore
|
||||
/build_tools/osx_package_scripts/postinstall export-ignore
|
||||
/build_tools/make_pkg.sh export-ignore
|
||||
/build_tools/make_darcs_completions.fish export-ignore
|
||||
/build_tools export-ignore
|
||||
|
||||
|
||||
17
.gitignore
vendored
17
.gitignore
vendored
@@ -1,29 +1,27 @@
|
||||
*.o
|
||||
*~
|
||||
*.exe
|
||||
*.xccheckout
|
||||
|
||||
.DS_Store
|
||||
Doxyfile.help
|
||||
Makefile
|
||||
autom4te.cache/
|
||||
build/
|
||||
command_list.txt
|
||||
command_list_toc.txt
|
||||
confdefs.h
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
doc/
|
||||
doc.h
|
||||
doc_src/commands.hdr
|
||||
doc_src/index.hdr
|
||||
po/*.gmo
|
||||
fish
|
||||
fish.spec
|
||||
fish_indent
|
||||
fish_pager
|
||||
fish_tests
|
||||
fish.pc
|
||||
fishd
|
||||
mimedb
|
||||
seq
|
||||
set_color
|
||||
@@ -34,10 +32,3 @@ user_doc/
|
||||
xcuserdata
|
||||
tests/*tmp.*
|
||||
tests/foo.txt
|
||||
FISH-BUILD-VERSION-FILE
|
||||
version
|
||||
messages.pot
|
||||
lexicon.txt
|
||||
lexicon_filter
|
||||
lexicon.log
|
||||
|
||||
|
||||
27
.travis.yml
27
.travis.yml
@@ -1,27 +0,0 @@
|
||||
language: cpp
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
install:
|
||||
- sudo apt-get install --no-install-recommends bc doxygen expect gettext libncurses5-dev
|
||||
script:
|
||||
- autoreconf
|
||||
- ./configure
|
||||
- make -j2
|
||||
- sudo make install
|
||||
- make test SHOW_INTERACTIVE_LOG=1
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
- "irc.oftc.net#fish"
|
||||
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
|
||||
matrix:
|
||||
fast_finish: true
|
||||
3
CHANGELOG
Normal file
3
CHANGELOG
Normal file
@@ -0,0 +1,3 @@
|
||||
24-01-2012 Jan Kanis
|
||||
* Added a changelog file
|
||||
* removed unescaping if the 'commandline' builtin is called without the -o (tokenise) flag
|
||||
19
COPYING
19
COPYING
@@ -1,19 +0,0 @@
|
||||
Fish is a smart and user-friendly command line shell.
|
||||
|
||||
Copyright (C) 2005-2009 Axel Liljencrantz
|
||||
|
||||
fish is free software.
|
||||
|
||||
Most of fish is licensed under the GNU General Public License version 2, and
|
||||
you can redistribute it and/or modify it under the terms of the GNU GPL as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
fish also includes software licensed under the GNU Lesser General Public
|
||||
License version 2, the OpenBSD license and the ISC license.
|
||||
|
||||
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
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
19
Dockerfile
19
Dockerfile
@@ -1,19 +0,0 @@
|
||||
FROM centos:latest
|
||||
|
||||
# Build dependency
|
||||
RUN yum update -y &&\
|
||||
yum install -y autoconf automake bc clang gcc-c++ make ncurses-devel &&\
|
||||
yum clean all
|
||||
|
||||
# Test dependency
|
||||
RUN yum install -y expect vim-common
|
||||
|
||||
ADD . /src
|
||||
WORKDIR /src
|
||||
|
||||
# Build fish
|
||||
RUN autoreconf &&\
|
||||
./configure &&\
|
||||
make &&\
|
||||
make install
|
||||
|
||||
2414
Doxyfile.help
2414
Doxyfile.help
File diff suppressed because it is too large
Load Diff
2240
Doxyfile.user
2240
Doxyfile.user
File diff suppressed because it is too large
Load Diff
641
Makefile.in
641
Makefile.in
File diff suppressed because it is too large
Load Diff
36
README.md
36
README.md
@@ -1,27 +1,21 @@
|
||||
[fish](http://fishshell.com/) - the friendly interactive shell [](https://travis-ci.org/fish-shell/fish-shell)
|
||||
[fish](http://ridiculousfish.com/shell/) - the friendly interactive shell
|
||||
================================================
|
||||
|
||||
fish is a smart and user-friendly command line shell for OS X, Linux, and the rest of the family. fish includes features like syntax highlighting, autosuggest-as-you-type, and fancy tab completions that just work, with no configuration required.
|
||||
|
||||
For more on fish's design philosophy, see the [design document](http://fishshell.com/docs/current/design.html).
|
||||
For more on fish's design philosophy, see the [design document](http://ridiculousfish.com/shell/user_doc/html/design.html).
|
||||
|
||||
## Quick Start
|
||||
|
||||
fish generally works like other shells, like bash or zsh. A few important differences can be found at <http://fishshell.com/docs/current/tutorial.html> by searching for the magic phrase 'unlike other shells'.
|
||||
fish generally works like other shells, like bash or zsh. A few important differences are documented at <http://ridiculousfish.com/shell/faq.html>
|
||||
|
||||
Detailed user documentation is available by running `help` within fish, and also at <http://fishshell.com/docs/current/index.html>
|
||||
Detailed user documentation is available by running `help` within fish, and also at <http://ridiculousfish.com/shell/user_doc/html/>
|
||||
|
||||
## Building
|
||||
|
||||
fish is written in a sane subset of C++98, with a few components from C++TR1. It builds successfully with g++ 4.2 or later, and with clang. It also will build as C++11.
|
||||
|
||||
fish can be built using autotools or Xcode. autoconf 2.60 or later is required.
|
||||
|
||||
fish depends on a curses implementation, such as ncurses. The headers and libraries are required for building.
|
||||
|
||||
fish requires gettext for translation support.
|
||||
|
||||
Building the documentation requires Doxygen 1.8.7 or newer.
|
||||
fish can be built using autotools or Xcode.
|
||||
|
||||
### Autotools Build
|
||||
|
||||
@@ -46,27 +40,15 @@ If fish reports that it could not find curses, try installing a curses developme
|
||||
|
||||
On Debian or Ubuntu you want:
|
||||
|
||||
sudo apt-get install build-essential ncurses-dev libncurses5-dev gettext
|
||||
sudo apt-get install libncurses5-dev libncursesw5-dev
|
||||
|
||||
On RedHat, CentOS, or Amazon EC2:
|
||||
on RedHat, CentOS, or Amazon EC2:
|
||||
|
||||
sudo yum install ncurses-devel
|
||||
|
||||
## Runtime Dependencies
|
||||
|
||||
fish requires a curses implementation, such as ncurses, to run.
|
||||
|
||||
fish requires a number of utilities to operate, which should be present on any Unix, GNU/Linux or OS X system. These include (but are not limited to) hostname, grep, awk, sed, which, and getopt. fish also requires the bc program.
|
||||
|
||||
Translation support requires the gettext program.
|
||||
|
||||
Some optional features of fish, such as the manual page completion parser and the web configuration tool, require Python.
|
||||
|
||||
In order to generate completions from man pages compressed with either lzma or xz, you may need to install an extra Python package. Python versions prior to 2.6 are not supported. For Python versions 2.6 to 3.2 you need to install the module `backports.lzma`. How to install it depends on your system and how you installed Python. Most Linux distributions should include it as a package named `backports-lzma` (or similar). From version 3.3 onwards, Python already includes the required module.
|
||||
|
||||
## Packages for Linux
|
||||
|
||||
Instructions on how to find builds for several Linux distros are at <https://github.com/fish-shell/fish-shell/wiki/Nightly-builds>
|
||||
Nightly builds for several Linux distros can be downloaded from <http://download.opensuse.org/repositories/home:/siteshwar/>
|
||||
|
||||
## Switching to fish
|
||||
|
||||
@@ -84,6 +66,6 @@ Substitute /bin/bash with /bin/tcsh or /bin/zsh as appropriate.
|
||||
|
||||
## Contact Us
|
||||
|
||||
Questions, comments, rants and raves can be posted to the official fish mailing list at <https://lists.sourceforge.net/lists/listinfo/fish-users> or join us on our IRC channel [#fish at irc.oftc.net](https://webchat.oftc.net/?channels=fish).
|
||||
Questions, comments, rants and raves can be posted to the official fish mailing list at <https://lists.sourceforge.net/lists/listinfo/fish-users> or join us on our IRC channel #fish at irc.oftc.net
|
||||
|
||||
Found a bug? Have an awesome idea? Please open an issue on this github page.
|
||||
|
||||
39
autoload.cpp
39
autoload.cpp
@@ -19,7 +19,7 @@ static const int kAutoloadStalenessInterval = 15;
|
||||
file_access_attempt_t access_file(const wcstring &path, int mode)
|
||||
{
|
||||
//printf("Touch %ls\n", path.c_str());
|
||||
file_access_attempt_t result = {};
|
||||
file_access_attempt_t result = {0};
|
||||
struct stat statbuf;
|
||||
if (wstat(path, &statbuf))
|
||||
{
|
||||
@@ -48,7 +48,9 @@ autoload_t::autoload_t(const wcstring &env_var_name_var, const builtin_script_t
|
||||
lock(),
|
||||
env_var_name(env_var_name_var),
|
||||
builtin_scripts(scripts),
|
||||
builtin_script_count(script_count)
|
||||
builtin_script_count(script_count),
|
||||
last_path(),
|
||||
is_loading_set()
|
||||
{
|
||||
pthread_mutex_init(&lock, NULL);
|
||||
}
|
||||
@@ -64,7 +66,7 @@ void autoload_t::node_was_evicted(autoload_function_t *node)
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
|
||||
// Tell ourselves that the command was removed if it was loaded
|
||||
if (node->is_loaded)
|
||||
if (! node->is_loaded)
|
||||
this->command_removed(node->key);
|
||||
delete node;
|
||||
}
|
||||
@@ -92,34 +94,33 @@ int autoload_t::load(const wcstring &cmd, bool reload)
|
||||
if (path_var != this->last_path)
|
||||
{
|
||||
this->last_path = path_var;
|
||||
this->last_path_tokenized.clear();
|
||||
tokenize_variable_array(this->last_path, this->last_path_tokenized);
|
||||
|
||||
scoped_lock locker(lock);
|
||||
this->evict_all_nodes();
|
||||
}
|
||||
|
||||
/* Mark that we're loading this. Hang onto the iterator for fast erasing later. Note that std::set has guarantees about not invalidating iterators, so this is safe to do across the callouts below. */
|
||||
typedef std::set<wcstring>::iterator set_iterator_t;
|
||||
std::pair<set_iterator_t, bool> insert_result = is_loading_set.insert(cmd);
|
||||
set_iterator_t where = insert_result.first;
|
||||
bool inserted = insert_result.second;
|
||||
|
||||
/** Warn and fail on infinite recursion. It's OK to do this because this function is only called on the main thread. */
|
||||
if (! inserted)
|
||||
if (this->is_loading(cmd))
|
||||
{
|
||||
/* We failed to insert */
|
||||
debug(0,
|
||||
_(L"Could not autoload item '%ls', it is already being autoloaded. "
|
||||
L"This is a circular dependency in the autoloading scripts, please remove it."),
|
||||
cmd.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Mark that we're loading this */
|
||||
is_loading_set.insert(cmd);
|
||||
|
||||
/* Get the list of paths from which we will try to load */
|
||||
std::vector<wcstring> path_list;
|
||||
tokenize_variable_array(path_var, path_list);
|
||||
|
||||
/* Try loading it */
|
||||
res = this->locate_file_and_maybe_load_it(cmd, true, reload, this->last_path_tokenized);
|
||||
res = this->locate_file_and_maybe_load_it(cmd, true, reload, path_list);
|
||||
|
||||
/* Clean up */
|
||||
is_loading_set.erase(where);
|
||||
bool erased = !! is_loading_set.erase(cmd);
|
||||
assert(erased);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -194,6 +195,7 @@ autoload_function_t *autoload_t::get_autoloaded_function_with_creation(const wcs
|
||||
bool autoload_t::locate_file_and_maybe_load_it(const wcstring &cmd, bool really_load, bool reload, const wcstring_list_t &path_list)
|
||||
{
|
||||
/* Note that we are NOT locked in this function! */
|
||||
size_t i;
|
||||
bool reloaded = 0;
|
||||
|
||||
/* Try using a cached function. If we really want the function to be loaded, require that it be really loaded. If we're not reloading, allow stale functions. */
|
||||
@@ -232,7 +234,6 @@ bool autoload_t::locate_file_and_maybe_load_it(const wcstring &cmd, bool really_
|
||||
/* If we can use this function, return whether we were able to access it */
|
||||
if (use_cached)
|
||||
{
|
||||
assert(func != NULL);
|
||||
return func->is_internalized || func->access.accessible;
|
||||
}
|
||||
}
|
||||
@@ -275,7 +276,7 @@ bool autoload_t::locate_file_and_maybe_load_it(const wcstring &cmd, bool really_
|
||||
if (! has_script_source)
|
||||
{
|
||||
/* Iterate over path searching for suitable completion files */
|
||||
for (size_t i=0; i<path_list.size(); i++)
|
||||
for (i=0; i<path_list.size(); i++)
|
||||
{
|
||||
wcstring next = path_list.at(i);
|
||||
wcstring path = next + L"/" + cmd + L".fish";
|
||||
@@ -297,7 +298,7 @@ bool autoload_t::locate_file_and_maybe_load_it(const wcstring &cmd, bool really_
|
||||
|
||||
/* Generate the script source */
|
||||
wcstring esc = escape_string(path, 1);
|
||||
script_source = L"source " + esc;
|
||||
script_source = L". " + esc;
|
||||
has_script_source = true;
|
||||
|
||||
/* Remove any loaded command because we are going to reload it. Note that this will deadlock if command_removed calls back into us. */
|
||||
|
||||
@@ -65,15 +65,17 @@ class autoload_t : private lru_cache_t<autoload_function_t>
|
||||
/** The path from which we most recently autoloaded */
|
||||
wcstring last_path;
|
||||
|
||||
/** That path, tokenized (split on separators) */
|
||||
wcstring_list_t last_path_tokenized;
|
||||
|
||||
/**
|
||||
A table containing all the files that are currently being
|
||||
loaded. This is here to help prevent recursion.
|
||||
*/
|
||||
std::set<wcstring> is_loading_set;
|
||||
|
||||
bool is_loading(const wcstring &name) const
|
||||
{
|
||||
return is_loading_set.find(name) != is_loading_set.end();
|
||||
}
|
||||
|
||||
void remove_all_functions(void)
|
||||
{
|
||||
this->evict_all_nodes();
|
||||
|
||||
@@ -20,8 +20,10 @@ else
|
||||
fi
|
||||
|
||||
# Determine which man pages we don't want to generate.
|
||||
# Don't make a test man page. fish's test is conforming, so the system man pages
|
||||
# are applicable and generally better.
|
||||
# on OS X, don't make a man page for open, since we defeat fish's open function on OS X.
|
||||
CONDEMNED_PAGES=
|
||||
CONDEMNED_PAGES=test.1
|
||||
if test `uname` = 'Darwin'; then
|
||||
CONDEMNED_PAGES="$CONDEMNED_PAGES open.1"
|
||||
fi
|
||||
@@ -37,12 +39,10 @@ resolve_path()
|
||||
# Expand relative paths
|
||||
DOXYFILE=`resolve_path "$DOXYFILE"`
|
||||
INPUTDIR=`resolve_path "$INPUTDIR"`
|
||||
INPUTFILTER=`resolve_path "$INPUT_FILTER"`
|
||||
OUTPUTDIR=`resolve_path "$OUTPUTDIR"`
|
||||
|
||||
echo " doxygen file: $DOXYFILE"
|
||||
echo " input directory: $INPUTDIR"
|
||||
echo " input filter: $INPUTFILTER"
|
||||
echo " output directory: $OUTPUTDIR"
|
||||
echo " skipping: $CONDEMNED_PAGES"
|
||||
|
||||
@@ -68,12 +68,6 @@ if test -z "$DOXYGENPATH"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check we have the lexicon filter
|
||||
if test -z "$INPUT_FILTER"; then
|
||||
echo >&2 "Lexicon filter is not available. Continuing without."
|
||||
INPUTFILTER=''
|
||||
fi
|
||||
|
||||
# Determine where our output should go
|
||||
if ! mkdir -p "${OUTPUTDIR}" ; then
|
||||
echo "Could not create output directory '${OUTPUTDIR}'"
|
||||
@@ -94,8 +88,7 @@ done
|
||||
# Input is kept as . because we cd to the input directory beforehand
|
||||
# This prevents doxygen from generating "documentation" for intermediate directories
|
||||
DOXYPARAMS=$(cat <<EOF
|
||||
PROJECT_NUMBER=$PROJECT_NUMBER
|
||||
INPUT_FILTER=$INPUTFILTER
|
||||
PROJECT_NUMBER=2.0.0
|
||||
INPUT=.
|
||||
OUTPUT_DIRECTORY=$OUTPUTDIR
|
||||
QUIET=YES
|
||||
@@ -109,7 +102,7 @@ find "${OUTPUTDIR}" -name "*.1" -delete
|
||||
|
||||
# Run doxygen
|
||||
cd "$TMPLOC"
|
||||
(cat "${DOXYFILE}" ; echo "$DOXYPARAMS";) | "$DOXYGENPATH" -
|
||||
(cat "${DOXYFILE}" ; echo "$DOXYPARAMS";) | "$DOXYGENPATH" -
|
||||
|
||||
# Remember errors
|
||||
RESULT=$?
|
||||
@@ -119,16 +112,15 @@ if test "$RESULT" = 0 ; then
|
||||
|
||||
# Postprocess the files
|
||||
for i in "$INPUTDIR"/*.txt; do
|
||||
# It would be nice to use -i here for edit in place, but that is not portable
|
||||
# It would be nice to use -i here for edit in place, but that is not portable
|
||||
CMD_NAME=`basename "$i" .txt`;
|
||||
sed < ${CMD_NAME}.1 > ${CMD_NAME}.1.tmp \
|
||||
-e "/.SH \"$CMD_NAME/d" \
|
||||
-e "s/^$CMD_NAME * \\\- \([^ ]*\) /\\\fB\1\\\fP -/"
|
||||
sed -e "s/\(.\)\\.SH/\1/" -e "s/$CMD_NAME *\\\\- *\"\(.*\)\"/\1/" "${CMD_NAME}.1" > "${CMD_NAME}.1.tmp"
|
||||
mv "${CMD_NAME}.1.tmp" "${CMD_NAME}.1"
|
||||
done
|
||||
|
||||
|
||||
# Erase condemned pages
|
||||
rm -f $CONDEMNED_PAGES
|
||||
|
||||
fi
|
||||
|
||||
# Destroy TMPLOC
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Originally from the git sources (GIT-VERSION-GEN)
|
||||
# Presumably (C) Junio C Hamano <junkio@cox.net>
|
||||
# Reused under GPL v2.0
|
||||
# Modified for fish by David Adam <zanchey@ucc.gu.uwa.edu.au>
|
||||
|
||||
FBVF=FISH-BUILD-VERSION-FILE
|
||||
DEF_VER=unknown
|
||||
|
||||
# First see if there is a version file (included in release tarballs),
|
||||
# then try git-describe, then default.
|
||||
if test -f version
|
||||
then
|
||||
VN=$(cat version) || VN="$DEF_VER"
|
||||
elif ! VN=$(git describe --always --dirty 2>/dev/null); then
|
||||
VN="$DEF_VER"
|
||||
fi
|
||||
|
||||
if test -r $FBVF
|
||||
then
|
||||
VC=$(sed -e 's/^FISH_BUILD_VERSION = //' <$FBVF)
|
||||
else
|
||||
VC=unset
|
||||
fi
|
||||
test "$VN" = "$VC" || {
|
||||
echo >&2 "FISH_BUILD_VERSION = $VN"
|
||||
echo "FISH_BUILD_VERSION = $VN" >$FBVF
|
||||
}
|
||||
@@ -21,10 +21,3 @@ xcodebuild install -scheme install_tree -configuration Release DSTROOT=/tmp/fish
|
||||
pkgbuild --scripts build_tools/osx_package_scripts --root /tmp/fish_pkg/root/ --identifier 'com.ridiculousfish.fish-shell-pkg' --version "$VERSION" /tmp/fish_pkg/intermediates/fish.pkg
|
||||
|
||||
productbuild --package-path /tmp/fish_pkg/intermediates --distribution build_tools/osx_distribution.xml --resources build_tools/osx_package_resources/ ~/fish_built/fish.pkg
|
||||
|
||||
|
||||
# Make the app
|
||||
xcodebuild -scheme fish.app -configuration Release DSTROOT=/tmp/fish_app/
|
||||
rm -f ~/fish_built/fish.app.zip
|
||||
cd DerivedData/fish/Build/Products/Release/
|
||||
zip -r ~/fish_built/fish.app.zip fish.app
|
||||
|
||||
@@ -19,35 +19,23 @@ wd="$PWD"
|
||||
# The name of the prefix, which is the directory that you get when you untar
|
||||
prefix="fish"
|
||||
|
||||
# Get the version from git-describe
|
||||
VERSION=`git describe --dirty 2>/dev/null`
|
||||
prefix="$prefix-$VERSION"
|
||||
|
||||
# The path where we will output the tar file
|
||||
path=~/fish_built/$prefix.tar
|
||||
path=~/fish_built/fish-2.0.tar
|
||||
|
||||
# Clean up stuff we've written before
|
||||
rm -f "$path" "$path".gz
|
||||
|
||||
# git starts the archive
|
||||
git archive --format=tar --prefix="$prefix"/ HEAD > "$path"
|
||||
git archive --format=tar --prefix="$prefix"/ master > "$path"
|
||||
|
||||
# tarball out the documentation, generate a configure script and version file
|
||||
# Don't use autoreconf since it invokes commands that may not be installed, like aclocal
|
||||
# Don't run autoheader since configure.ac runs it. autoconf is enough.
|
||||
autoconf
|
||||
./configure --with-doxygen
|
||||
make user_doc share/man
|
||||
echo $VERSION > version
|
||||
# tarball out the documentation
|
||||
make user_doc
|
||||
make share/man
|
||||
cd /tmp
|
||||
rm -f "$prefix"
|
||||
ln -s "$wd" "$prefix"
|
||||
TAR_APPEND="gnutar --append --file=$path --mtime=now --owner=0 --group=0 --mode=g+w,a+rX"
|
||||
$TAR_APPEND --no-recursion "$prefix"/user_doc
|
||||
$TAR_APPEND "$prefix"/user_doc/html "$prefix"/share/man
|
||||
$TAR_APPEND "$prefix"/version
|
||||
$TAR_APPEND "$prefix"/configure "$prefix"/config.h.in
|
||||
rm -f "$prefix"/version
|
||||
tar --append --file="$path" "$prefix"/user_doc/html
|
||||
tar --append --file="$path" "$prefix"/share/man
|
||||
rm -f "$prefix"
|
||||
|
||||
# gzip it
|
||||
|
||||
1423
builtin.cpp
1423
builtin.cpp
File diff suppressed because it is too large
Load Diff
28
builtin.h
28
builtin.h
@@ -164,35 +164,19 @@ void builtin_pop_io(parser_t &parser);
|
||||
wcstring builtin_get_desc(const wcstring &b);
|
||||
|
||||
|
||||
|
||||
/** Support for setting and removing transient command lines.
|
||||
This is used by 'complete -C' in order to make
|
||||
the commandline builtin operate on the string to complete instead
|
||||
of operating on whatever is to be completed. It's also used by
|
||||
completion wrappers, to allow a command to appear as the command
|
||||
being wrapped for the purposes of completion.
|
||||
|
||||
Instantiating an instance of builtin_commandline_scoped_transient_t
|
||||
pushes the command as the new transient commandline. The destructor removes it.
|
||||
It will assert if construction/destruction does not happen in a stack-like (LIFO) order.
|
||||
/**
|
||||
Slightly kludgy function used with 'complete -C' in order to make
|
||||
the commandline builtin operate on the string to complete instead
|
||||
of operating on whatever is to be completed.
|
||||
*/
|
||||
class builtin_commandline_scoped_transient_t
|
||||
{
|
||||
size_t token;
|
||||
public:
|
||||
builtin_commandline_scoped_transient_t(const wcstring &cmd);
|
||||
~builtin_commandline_scoped_transient_t();
|
||||
};
|
||||
const wchar_t *builtin_complete_get_temporary_buffer();
|
||||
|
||||
|
||||
/**
|
||||
Run the __fish_print_help function to obtain the help information
|
||||
for the specified command.
|
||||
*/
|
||||
|
||||
wcstring builtin_help_get(parser_t &parser, const wchar_t *cmd);
|
||||
|
||||
/** Defines a function, like builtin_function. Returns 0 on success. args should NOT contain 'function' as the first argument. */
|
||||
int define_function(parser_t &parser, const wcstring_list_t &args, const wcstring &contents, int definition_line_offset, wcstring *out_err);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -79,51 +79,6 @@ static size_t get_cursor_pos()
|
||||
return current_cursor_pos;
|
||||
}
|
||||
|
||||
static pthread_mutex_t transient_commandline_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static wcstring_list_t *get_transient_stack()
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
ASSERT_IS_LOCKED(transient_commandline_lock);
|
||||
// A pointer is a little more efficient than an object as a static because we can elide the thread-safe initialization
|
||||
static wcstring_list_t *result = NULL;
|
||||
if (! result)
|
||||
{
|
||||
result = new wcstring_list_t();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool get_top_transient(wcstring *out_result)
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
bool result = false;
|
||||
scoped_lock locker(transient_commandline_lock);
|
||||
const wcstring_list_t *stack = get_transient_stack();
|
||||
if (! stack->empty())
|
||||
{
|
||||
out_result->assign(stack->back());
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
builtin_commandline_scoped_transient_t::builtin_commandline_scoped_transient_t(const wcstring &cmd)
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
scoped_lock locker(transient_commandline_lock);
|
||||
wcstring_list_t *stack = get_transient_stack();
|
||||
stack->push_back(cmd);
|
||||
this->token = stack->size();
|
||||
}
|
||||
|
||||
builtin_commandline_scoped_transient_t::~builtin_commandline_scoped_transient_t()
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
scoped_lock locker(transient_commandline_lock);
|
||||
wcstring_list_t *stack = get_transient_stack();
|
||||
assert(this->token == stack->size());
|
||||
stack->pop_back();
|
||||
}
|
||||
|
||||
/**
|
||||
Replace/append/insert the selection with/at/after the specified string.
|
||||
@@ -188,13 +143,17 @@ static void write_part(const wchar_t *begin,
|
||||
int cut_at_cursor,
|
||||
int tokenize)
|
||||
{
|
||||
size_t pos = get_cursor_pos()-(begin-get_buffer());
|
||||
wcstring out;
|
||||
wchar_t *buff;
|
||||
size_t pos;
|
||||
|
||||
pos = get_cursor_pos()-(begin-get_buffer());
|
||||
|
||||
if (tokenize)
|
||||
{
|
||||
wchar_t *buff = wcsndup(begin, end-begin);
|
||||
buff = wcsndup(begin, end-begin);
|
||||
// fwprintf( stderr, L"Subshell: %ls, end char %lc\n", buff, *end );
|
||||
wcstring out;
|
||||
out.clear();
|
||||
tokenizer_t tok(buff, TOK_ACCEPT_UNFINISHED);
|
||||
for (; tok_has_next(&tok); tok_next(&tok))
|
||||
{
|
||||
@@ -206,17 +165,11 @@ static void write_part(const wchar_t *begin,
|
||||
{
|
||||
case TOK_STRING:
|
||||
{
|
||||
wcstring tmp = tok_last(&tok);
|
||||
unescape_string_in_place(&tmp, UNESCAPE_INCOMPLETE);
|
||||
out.append(tmp);
|
||||
out.append(escape_string(tok_last(&tok), UNESCAPE_INCOMPLETE));
|
||||
out.push_back(L'\n');
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,9 +185,8 @@ static void write_part(const wchar_t *begin,
|
||||
}
|
||||
|
||||
// debug( 0, L"woot2 %ls -> %ls", buff, esc );
|
||||
wcstring tmp = wcstring(begin, end - begin);
|
||||
unescape_string_in_place(&tmp, UNESCAPE_INCOMPLETE);
|
||||
stdout_buffer.append(tmp);
|
||||
|
||||
stdout_buffer.append(begin, end - begin);
|
||||
stdout_buffer.append(L"\n");
|
||||
|
||||
}
|
||||
@@ -255,24 +207,18 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||
int append_mode=0;
|
||||
|
||||
int function_mode = 0;
|
||||
int selection_mode = 0;
|
||||
|
||||
int tokenize = 0;
|
||||
|
||||
int cursor_mode = 0;
|
||||
int line_mode = 0;
|
||||
int search_mode = 0;
|
||||
int paging_mode = 0;
|
||||
const wchar_t *begin = NULL, *end = NULL;
|
||||
|
||||
scoped_push<const wchar_t *> saved_current_buffer(¤t_buffer);
|
||||
scoped_push<size_t> saved_current_cursor_pos(¤t_cursor_pos);
|
||||
|
||||
wcstring transient_commandline;
|
||||
if (get_top_transient(&transient_commandline))
|
||||
const wchar_t *begin, *end;
|
||||
|
||||
current_buffer = (wchar_t *)builtin_complete_get_temporary_buffer();
|
||||
if (current_buffer)
|
||||
{
|
||||
current_buffer = transient_commandline.c_str();
|
||||
current_cursor_pos = transient_commandline.size();
|
||||
current_cursor_pos = wcslen(current_buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -305,31 +251,77 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||
static const struct woption
|
||||
long_options[] =
|
||||
{
|
||||
{ L"append", no_argument, 0, 'a' },
|
||||
{ L"insert", no_argument, 0, 'i' },
|
||||
{ L"replace", no_argument, 0, 'r' },
|
||||
{ L"current-job", no_argument, 0, 'j' },
|
||||
{ L"current-process", no_argument, 0, 'p' },
|
||||
{ L"current-token", no_argument, 0, 't' },
|
||||
{ L"current-buffer", no_argument, 0, 'b' },
|
||||
{ L"cut-at-cursor", no_argument, 0, 'c' },
|
||||
{ L"function", no_argument, 0, 'f' },
|
||||
{ L"tokenize", no_argument, 0, 'o' },
|
||||
{ L"help", no_argument, 0, 'h' },
|
||||
{ L"input", required_argument, 0, 'I' },
|
||||
{ L"cursor", no_argument, 0, 'C' },
|
||||
{ L"line", no_argument, 0, 'L' },
|
||||
{ L"search-mode", no_argument, 0, 'S' },
|
||||
{ L"selection", no_argument, 0, 's' },
|
||||
{ L"paging-mode", no_argument, 0, 'P' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
{
|
||||
L"append", no_argument, 0, 'a'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"insert", no_argument, 0, 'i'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"replace", no_argument, 0, 'r'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"current-job", no_argument, 0, 'j'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"current-process", no_argument, 0, 'p'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"current-token", no_argument, 0, 't'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"current-buffer", no_argument, 0, 'b'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"cut-at-cursor", no_argument, 0, 'c'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"function", no_argument, 0, 'f'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"tokenize", no_argument, 0, 'o'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"help", no_argument, 0, 'h'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"input", required_argument, 0, 'I'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"cursor", no_argument, 0, 'C'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"line", no_argument, 0, 'L'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"search-mode", no_argument, 0, 'S'
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
int opt_index = 0;
|
||||
|
||||
int opt = wgetopt_long(argc,
|
||||
argv,
|
||||
L"abijpctwforhI:CLSsP",
|
||||
L"abijpctwforhI:CLS",
|
||||
long_options,
|
||||
&opt_index);
|
||||
if (opt == -1)
|
||||
@@ -406,14 +398,6 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||
search_mode = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
selection_mode = 1;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
paging_mode = 1;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
builtin_print_help(parser, argv[0], stdout_buffer);
|
||||
return 0;
|
||||
@@ -431,7 +415,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||
/*
|
||||
Check for invalid switch combinations
|
||||
*/
|
||||
if (buffer_part || cut_at_cursor || append_mode || tokenize || cursor_mode || line_mode || search_mode || paging_mode)
|
||||
if (buffer_part || cut_at_cursor || append_mode || tokenize || cursor_mode || line_mode || search_mode)
|
||||
{
|
||||
append_format(stderr_buffer,
|
||||
BUILTIN_ERR_COMBO,
|
||||
@@ -458,10 +442,10 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||
{
|
||||
/*
|
||||
input_unreadch inserts the specified keypress or
|
||||
readline function at the back of the queue of unused
|
||||
readline function at the top of the stack of unused
|
||||
keypresses
|
||||
*/
|
||||
input_queue_ch(c);
|
||||
input_unreadch(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -477,21 +461,10 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (selection_mode)
|
||||
{
|
||||
size_t start, len;
|
||||
const wchar_t *buffer = reader_get_buffer();
|
||||
if (reader_get_selection(&start, &len))
|
||||
{
|
||||
stdout_buffer.append(buffer + start, len);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Check for invalid switch combinations
|
||||
*/
|
||||
if ((search_mode || line_mode || cursor_mode || paging_mode) && (argc-woptind > 1))
|
||||
if ((search_mode || line_mode || cursor_mode) && (argc-woptind > 1))
|
||||
{
|
||||
|
||||
append_format(stderr_buffer,
|
||||
@@ -502,7 +475,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((buffer_part || tokenize || cut_at_cursor) && (cursor_mode || line_mode || search_mode || paging_mode))
|
||||
if ((buffer_part || tokenize || cut_at_cursor) && (cursor_mode || line_mode || search_mode))
|
||||
{
|
||||
append_format(stderr_buffer,
|
||||
BUILTIN_ERR_COMBO,
|
||||
@@ -591,12 +564,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||
|
||||
if (search_mode)
|
||||
{
|
||||
return ! reader_search_mode();
|
||||
}
|
||||
|
||||
if (paging_mode)
|
||||
{
|
||||
return ! reader_has_pager_contents();
|
||||
return !reader_search_mode();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,12 @@ Functions used for implementing the complete builtin.
|
||||
#include "parser.h"
|
||||
#include "reader.h"
|
||||
|
||||
|
||||
/**
|
||||
Internal storage for the builtin_complete_get_temporary_buffer() function.
|
||||
*/
|
||||
static const wchar_t *temporary_buffer;
|
||||
|
||||
/*
|
||||
builtin_complete_* are a set of rather silly looping functions that
|
||||
make sure that all the proper combinations of complete_add or
|
||||
@@ -173,16 +179,14 @@ static void builtin_complete_add(const wcstring_list_t &cmd,
|
||||
static void builtin_complete_remove3(const wchar_t *cmd,
|
||||
int cmd_type,
|
||||
wchar_t short_opt,
|
||||
const wcstring_list_t &long_opt,
|
||||
int long_mode)
|
||||
const wcstring_list_t &long_opt)
|
||||
{
|
||||
for (size_t i=0; i<long_opt.size(); i++)
|
||||
{
|
||||
complete_remove(cmd,
|
||||
cmd_type,
|
||||
short_opt,
|
||||
long_opt.at(i).c_str(),
|
||||
long_mode);
|
||||
long_opt.at(i).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +209,6 @@ static void builtin_complete_remove2(const wchar_t *cmd,
|
||||
complete_remove(cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
0,
|
||||
0);
|
||||
|
||||
}
|
||||
@@ -214,36 +217,24 @@ static void builtin_complete_remove2(const wchar_t *cmd,
|
||||
builtin_complete_remove3(cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
gnu_opt,
|
||||
0);
|
||||
gnu_opt);
|
||||
builtin_complete_remove3(cmd,
|
||||
cmd_type,
|
||||
*s,
|
||||
old_opt,
|
||||
1);
|
||||
old_opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gnu_opt.empty() && old_opt.empty())
|
||||
{
|
||||
complete_remove(cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
builtin_complete_remove3(cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
gnu_opt,
|
||||
0);
|
||||
gnu_opt);
|
||||
builtin_complete_remove3(cmd,
|
||||
cmd_type,
|
||||
0,
|
||||
old_opt,
|
||||
1);
|
||||
old_opt);
|
||||
|
||||
}
|
||||
|
||||
@@ -279,6 +270,13 @@ static void builtin_complete_remove(const wcstring_list_t &cmd,
|
||||
|
||||
}
|
||||
|
||||
|
||||
const wchar_t *builtin_complete_get_temporary_buffer()
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
return temporary_buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
The complete builtin. Used for specifying programmable
|
||||
tab-completions. Calls the functions in complete.c for any heavy
|
||||
@@ -292,6 +290,7 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
int result_mode=SHARED;
|
||||
int remove = 0;
|
||||
int authoritative = -1;
|
||||
int flags = COMPLETE_AUTO_SPACE;
|
||||
|
||||
wcstring short_opt;
|
||||
wcstring_list_t gnu_opt, old_opt;
|
||||
@@ -302,7 +301,6 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
|
||||
wcstring_list_t cmd;
|
||||
wcstring_list_t path;
|
||||
wcstring_list_t wrap_targets;
|
||||
|
||||
static int recursion_level=0;
|
||||
|
||||
@@ -315,31 +313,81 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
static const struct woption
|
||||
long_options[] =
|
||||
{
|
||||
{ L"exclusive", no_argument, 0, 'x' },
|
||||
{ L"no-files", no_argument, 0, 'f' },
|
||||
{ L"require-parameter", no_argument, 0, 'r' },
|
||||
{ L"path", required_argument, 0, 'p' },
|
||||
{ L"command", required_argument, 0, 'c' },
|
||||
{ L"short-option", required_argument, 0, 's' },
|
||||
{ L"long-option", required_argument, 0, 'l' },
|
||||
{ L"old-option", required_argument, 0, 'o' },
|
||||
{ L"description", required_argument, 0, 'd' },
|
||||
{ L"arguments", required_argument, 0, 'a' },
|
||||
{ L"erase", no_argument, 0, 'e' },
|
||||
{ L"unauthoritative", no_argument, 0, 'u' },
|
||||
{ L"authoritative", no_argument, 0, 'A' },
|
||||
{ L"condition", required_argument, 0, 'n' },
|
||||
{ L"wraps", required_argument, 0, 'w' },
|
||||
{ L"do-complete", optional_argument, 0, 'C' },
|
||||
{ L"help", no_argument, 0, 'h' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
{
|
||||
L"exclusive", no_argument, 0, 'x'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"no-files", no_argument, 0, 'f'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"require-parameter", no_argument, 0, 'r'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"path", required_argument, 0, 'p'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"command", required_argument, 0, 'c'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"short-option", required_argument, 0, 's'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"long-option", required_argument, 0, 'l'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"old-option", required_argument, 0, 'o'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"description", required_argument, 0, 'd'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"arguments", required_argument, 0, 'a'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"erase", no_argument, 0, 'e'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"unauthoritative", no_argument, 0, 'u'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"authoritative", no_argument, 0, 'A'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"condition", required_argument, 0, 'n'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"do-complete", optional_argument, 0, 'C'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"help", no_argument, 0, 'h'
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 0, 0, 0
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
int opt_index = 0;
|
||||
|
||||
int opt = wgetopt_long(argc,
|
||||
argv,
|
||||
L"a:c:p:s:l:o:d:frxeuAn:C::w:h",
|
||||
L"a:c:p:s:l:o:d:frxeuAn:C::h",
|
||||
long_options,
|
||||
&opt_index);
|
||||
if (opt == -1)
|
||||
@@ -375,8 +423,8 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
case 'p':
|
||||
case 'c':
|
||||
{
|
||||
wcstring tmp;
|
||||
if (unescape_string(woptarg, &tmp, UNESCAPE_SPECIAL))
|
||||
wcstring tmp = woptarg;
|
||||
if (unescape_string(tmp, 1))
|
||||
{
|
||||
if (opt=='p')
|
||||
path.push_back(tmp);
|
||||
@@ -426,10 +474,6 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
case 'n':
|
||||
condition = woptarg;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
wrap_targets.push_back(woptarg);
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
do_complete = true;
|
||||
@@ -453,19 +497,15 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
{
|
||||
if (condition && wcslen(condition))
|
||||
{
|
||||
const wcstring condition_string = condition;
|
||||
parse_error_list_t errors;
|
||||
if (parse_util_detect_errors(condition_string, &errors, false /* do not accept incomplete */))
|
||||
if (parser.test(condition))
|
||||
{
|
||||
append_format(stderr_buffer,
|
||||
L"%ls: Condition '%ls' contained a syntax error",
|
||||
L"%ls: Condition '%ls' contained a syntax error\n",
|
||||
argv[0],
|
||||
condition);
|
||||
for (size_t i=0; i < errors.size(); i++)
|
||||
{
|
||||
append_format(stderr_buffer, L"\n%s: ", argv[0]);
|
||||
stderr_buffer.append(errors.at(i).describe(condition_string));
|
||||
}
|
||||
|
||||
parser.test(condition, NULL, &stderr_buffer, argv[0]);
|
||||
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
@@ -475,22 +515,15 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
{
|
||||
if (comp && wcslen(comp))
|
||||
{
|
||||
wcstring prefix;
|
||||
if (argv[0])
|
||||
{
|
||||
prefix.append(argv[0]);
|
||||
prefix.append(L": ");
|
||||
}
|
||||
|
||||
wcstring err_text;
|
||||
if (parser.detect_errors_in_argument_list(comp, &err_text, prefix.c_str()))
|
||||
if (parser.test_args(comp, 0, 0))
|
||||
{
|
||||
append_format(stderr_buffer,
|
||||
L"%ls: Completion '%ls' contained a syntax error\n",
|
||||
argv[0],
|
||||
comp);
|
||||
stderr_buffer.append(err_text);
|
||||
stderr_buffer.push_back(L'\n');
|
||||
|
||||
parser.test_args(comp, &stderr_buffer, argv[0]);
|
||||
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
@@ -503,9 +536,9 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
const wchar_t *token;
|
||||
|
||||
parse_util_token_extent(do_complete_param.c_str(), do_complete_param.size(), &token, 0, 0, 0);
|
||||
|
||||
/* Create a scoped transient command line, so that bulitin_commandline will see our argument, not the reader buffer */
|
||||
builtin_commandline_scoped_transient_t temp_buffer(do_complete_param);
|
||||
|
||||
const wchar_t *prev_temporary_buffer = temporary_buffer;
|
||||
temporary_buffer = do_complete_param.c_str();
|
||||
|
||||
if (recursion_level < 1)
|
||||
{
|
||||
@@ -518,32 +551,33 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
{
|
||||
const completion_t &next = comp.at(i);
|
||||
|
||||
/* Make a fake commandline, and then apply the completion to it. */
|
||||
const wcstring faux_cmdline = token;
|
||||
size_t tmp_cursor = faux_cmdline.size();
|
||||
wcstring faux_cmdline_with_completion = completion_apply_to_command_line(next.completion, next.flags, faux_cmdline, &tmp_cursor, false);
|
||||
const wchar_t *prepend;
|
||||
|
||||
/* completion_apply_to_command_line will append a space unless COMPLETE_NO_SPACE is set. We don't want to set COMPLETE_NO_SPACE because that won't close quotes. What we want is to close the quote, but not append the space. So we just look for the space and clear it. */
|
||||
if (!(next.flags & COMPLETE_NO_SPACE) && string_suffixes_string(L" ", faux_cmdline_with_completion))
|
||||
if (next.flags & COMPLETE_REPLACES_TOKEN)
|
||||
{
|
||||
faux_cmdline_with_completion.resize(faux_cmdline_with_completion.size() - 1);
|
||||
prepend = L"";
|
||||
}
|
||||
else
|
||||
{
|
||||
prepend = token;
|
||||
}
|
||||
|
||||
/* The input data is meant to be something like you would have on the command line, e.g. includes backslashes. The output should be raw, i.e. unescaped. So we need to unescape the command line. See #1127 */
|
||||
unescape_string_in_place(&faux_cmdline_with_completion, UNESCAPE_DEFAULT);
|
||||
stdout_buffer.append(faux_cmdline_with_completion);
|
||||
|
||||
/* Append any description */
|
||||
if (! next.description.empty())
|
||||
if (!(next.description).empty())
|
||||
{
|
||||
stdout_buffer.push_back(L'\t');
|
||||
stdout_buffer.append(next.description);
|
||||
append_format(stdout_buffer, L"%ls%ls\t%ls\n", prepend, next.completion.c_str(), next.description.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
append_format(stdout_buffer, L"%ls%ls\n", prepend, next.completion.c_str());
|
||||
}
|
||||
stdout_buffer.push_back(L'\n');
|
||||
}
|
||||
|
||||
recursion_level--;
|
||||
}
|
||||
|
||||
temporary_buffer = prev_temporary_buffer;
|
||||
|
||||
}
|
||||
else if (woptind != argc)
|
||||
{
|
||||
@@ -562,8 +596,6 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
int flags = COMPLETE_AUTO_SPACE;
|
||||
|
||||
if (remove)
|
||||
{
|
||||
builtin_complete_remove(cmd,
|
||||
@@ -571,7 +603,6 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
short_opt.c_str(),
|
||||
gnu_opt,
|
||||
old_opt);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -587,18 +618,7 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||
desc,
|
||||
flags);
|
||||
}
|
||||
|
||||
// Handle wrap targets (probably empty)
|
||||
// We only wrap commands, not paths
|
||||
for (size_t w=0; w < wrap_targets.size(); w++)
|
||||
{
|
||||
const wcstring &wrap_target = wrap_targets.at(w);
|
||||
for (size_t i=0; i < cmd.size(); i++)
|
||||
{
|
||||
|
||||
(remove ? complete_remove_wrapper : complete_add_wrapper)(cmd.at(i), wrap_target);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ static void builtin_jobs_print(const job_t *j, int mode, int header)
|
||||
/*
|
||||
Print table header before first job
|
||||
*/
|
||||
stdout_buffer.append(_(L"Process\n"));
|
||||
stdout_buffer.append(_(L"Procces\n"));
|
||||
}
|
||||
|
||||
for (p=j->first_process; p; p=p->next)
|
||||
@@ -164,6 +164,7 @@ static int builtin_jobs(parser_t &parser, wchar_t **argv)
|
||||
int found=0;
|
||||
int mode=JOBS_DEFAULT;
|
||||
int print_last = 0;
|
||||
const job_t *j;
|
||||
|
||||
argc = builtin_count_args(argv);
|
||||
woptind=0;
|
||||
@@ -304,7 +305,7 @@ static int builtin_jobs(parser_t &parser, wchar_t **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
const job_t *j = job_get_from_pid(pid);
|
||||
j = job_get_from_pid(pid);
|
||||
|
||||
if (j && !job_is_completed(j))
|
||||
{
|
||||
@@ -343,7 +344,6 @@ static int builtin_jobs(parser_t &parser, wchar_t **argv)
|
||||
append_format(stdout_buffer,
|
||||
_(L"%ls: There are no jobs\n"),
|
||||
argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
\a = alert (bell)
|
||||
\b = backspace
|
||||
\c = produce no further output
|
||||
\e = escape
|
||||
\f = form feed
|
||||
\n = new line
|
||||
\r = carriage return
|
||||
@@ -195,6 +194,11 @@ double C_STRTOD(wchar_t const *nptr, wchar_t **endptr)
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline unsigned wchar_t to_uwchar_t(wchar_t ch)
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
|
||||
void builtin_printf_state_t::fatal_error(const wchar_t *fmt, ...)
|
||||
{
|
||||
// Don't error twice
|
||||
@@ -287,7 +291,7 @@ static T string_to_scalar_type(const wchar_t *s, builtin_printf_state_t *state)
|
||||
T val;
|
||||
if (*s == L'\"' || *s == L'\'')
|
||||
{
|
||||
wchar_t ch = *++s;
|
||||
unsigned wchar_t ch = *++s;
|
||||
val = ch;
|
||||
}
|
||||
else
|
||||
@@ -315,9 +319,6 @@ void builtin_printf_state_t::print_esc_char(wchar_t c)
|
||||
case L'c': /* Cancel the rest of the output. */
|
||||
this->early_exit = true;
|
||||
break;
|
||||
case L'e': /* Escape */
|
||||
this->append_output(L'\x1B');
|
||||
break;
|
||||
case L'f': /* Form feed. */
|
||||
this->append_output(L'\f');
|
||||
break;
|
||||
@@ -357,22 +358,19 @@ long builtin_printf_state_t::print_esc(const wchar_t *escstart, bool octal_0)
|
||||
esc_value = esc_value * 16 + hex_to_bin(*p);
|
||||
if (esc_length == 0)
|
||||
this->fatal_error(_(L"missing hexadecimal number in escape"));
|
||||
this->append_output(ENCODE_DIRECT_BASE + esc_value % 256);
|
||||
this->append_format_output(L"%lc", esc_value);
|
||||
}
|
||||
else if (is_octal_digit(*p))
|
||||
{
|
||||
/* Parse \0ooo (if octal_0 && *p == L'0') or \ooo (otherwise).
|
||||
Allow \ooo if octal_0 && *p != L'0'; this is an undocumented
|
||||
extension to POSIX that is compatible with Bash 2.05b. */
|
||||
/* Wrap mod 256, which matches historic behavior */
|
||||
for (esc_length = 0, p += octal_0 && *p == L'0'; esc_length < 3 && is_octal_digit(*p); ++esc_length, ++p)
|
||||
esc_value = esc_value * 8 + octal_to_bin(*p);
|
||||
this->append_output(ENCODE_DIRECT_BASE + esc_value % 256);
|
||||
this->append_format_output(L"%c", esc_value);
|
||||
}
|
||||
else if (*p && wcschr(L"\"\\abcefnrtv", *p))
|
||||
{
|
||||
else if (*p && wcschr(L"\"\\abcfnrtv", *p))
|
||||
print_esc_char(*p++);
|
||||
}
|
||||
else if (*p == L'u' || *p == L'U')
|
||||
{
|
||||
wchar_t esc_char = *p;
|
||||
@@ -468,7 +466,6 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
|
||||
fmt.append(L"L");
|
||||
break;
|
||||
case L's':
|
||||
case L'c':
|
||||
fmt.append(L"l");
|
||||
break;
|
||||
default:
|
||||
@@ -578,16 +575,6 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
|
||||
}
|
||||
}
|
||||
|
||||
/* For each character in str, set the corresponding boolean in the array to the given flag */
|
||||
static inline void modify_allowed_format_specifiers(bool ok[UCHAR_MAX + 1], const char *str, bool flag)
|
||||
{
|
||||
for (const char *c = str; *c != '\0'; c++)
|
||||
{
|
||||
unsigned char idx = static_cast<unsigned char>(*c);
|
||||
ok[idx] = flag;
|
||||
}
|
||||
}
|
||||
|
||||
/* Print the text in FORMAT, using ARGV (with ARGC elements) for
|
||||
arguments to any `%' directives.
|
||||
Return the number of elements of ARGV used. */
|
||||
@@ -630,7 +617,9 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
|
||||
break;
|
||||
}
|
||||
|
||||
modify_allowed_format_specifiers(ok, "aAcdeEfFgGiosuxX", true);
|
||||
ok['a'] = ok['A'] = ok['c'] = ok['d'] = ok['e'] = ok['E'] =
|
||||
ok['f'] = ok['F'] = ok['g'] = ok['G'] = ok['i'] = ok['o'] =
|
||||
ok['s'] = ok['u'] = ok['x'] = ok['X'] = true;
|
||||
|
||||
for (;; f++, direc_length++)
|
||||
{
|
||||
@@ -638,17 +627,18 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch
|
||||
{
|
||||
case L'I':
|
||||
case L'\'':
|
||||
modify_allowed_format_specifiers(ok, "aAceEosxX", false);
|
||||
ok['a'] = ok['A'] = ok['c'] = ok['e'] = ok['E'] =
|
||||
ok['o'] = ok['s'] = ok['x'] = ok['X'] = false;
|
||||
break;
|
||||
case '-':
|
||||
case '+':
|
||||
case ' ':
|
||||
break;
|
||||
case L'#':
|
||||
modify_allowed_format_specifiers(ok, "cdisu", false);
|
||||
ok['c'] = ok['d'] = ok['i'] = ok['s'] = ok['u'] = false;
|
||||
break;
|
||||
case '0':
|
||||
modify_allowed_format_specifiers(ok, "cs", false);
|
||||
ok['c'] = ok['s'] = false;
|
||||
break;
|
||||
default:
|
||||
goto no_more_flag_characters;
|
||||
@@ -689,7 +679,7 @@ no_more_flag_characters:
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
modify_allowed_format_specifiers(ok, "c", false);
|
||||
ok['c'] = false;
|
||||
if (*f == L'*')
|
||||
{
|
||||
++f;
|
||||
@@ -733,8 +723,8 @@ no_more_flag_characters:
|
||||
++f;
|
||||
|
||||
{
|
||||
wchar_t conversion = *f;
|
||||
if (conversion > 0xFF || ! ok[conversion])
|
||||
unsigned wchar_t conversion = *f;
|
||||
if (! ok[conversion])
|
||||
{
|
||||
this->fatal_error(_(L"%.*ls: invalid conversion specification"), (int)(f + 1 - direc_start), direc_start);
|
||||
return 0;
|
||||
|
||||
@@ -69,7 +69,7 @@ static int my_env_set(const wchar_t *key, const wcstring_list_t &val, int scope)
|
||||
|
||||
/* Don't bother validating (or complaining about) values that are already present */
|
||||
wcstring_list_t existing_values;
|
||||
const env_var_t existing_variable = env_get_string(key, scope);
|
||||
const env_var_t existing_variable = env_get_string(key);
|
||||
if (! existing_variable.missing_or_empty())
|
||||
tokenize_variable_array(existing_variable, existing_values);
|
||||
|
||||
@@ -157,16 +157,9 @@ static int my_env_set(const wchar_t *key, const wcstring_list_t &val, int scope)
|
||||
break;
|
||||
}
|
||||
|
||||
case ENV_SCOPE:
|
||||
{
|
||||
append_format(stderr_buffer, _(L"%ls: Tried to set the special variable '%ls' with the wrong scope\n"), L"set", key);
|
||||
retcode=1;
|
||||
break;
|
||||
}
|
||||
|
||||
case ENV_INVALID:
|
||||
{
|
||||
append_format(stderr_buffer, _(L"%ls: Tried to set the special variable '%ls' to an invalid value\n"), L"set", key);
|
||||
append_format(stderr_buffer, _(L"%ls: Unknown error"), L"set");
|
||||
retcode=1;
|
||||
break;
|
||||
}
|
||||
@@ -360,7 +353,7 @@ static void print_variables(int include_values, int esc, bool shorten_ok, int sc
|
||||
|
||||
if (include_values)
|
||||
{
|
||||
env_var_t value = env_get_string(key, scope);
|
||||
env_var_t value = env_get_string(key);
|
||||
if (!value.missing())
|
||||
{
|
||||
int shorten = 0;
|
||||
@@ -435,7 +428,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
|
||||
int slice=0;
|
||||
int i;
|
||||
|
||||
const wchar_t *bad_char = NULL;
|
||||
wchar_t *bad_char;
|
||||
|
||||
|
||||
/* Parse options to obtain the requested operation and the modifiers */
|
||||
@@ -526,7 +519,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
|
||||
}
|
||||
|
||||
|
||||
/* We can't both list and erase variables */
|
||||
/* We can't both list and erase varaibles */
|
||||
if (erase && list)
|
||||
{
|
||||
append_format(stderr_buffer,
|
||||
@@ -595,7 +588,7 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
|
||||
wcstring_list_t result;
|
||||
size_t j;
|
||||
|
||||
env_var_t dest_str = env_get_string(dest, scope);
|
||||
env_var_t dest_str = env_get_string(dest);
|
||||
if (! dest_str.missing())
|
||||
tokenize_variable_array(dest_str, result);
|
||||
|
||||
@@ -685,6 +678,14 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (slice && erase && (scope != ENV_USER))
|
||||
{
|
||||
free(dest);
|
||||
append_format(stderr_buffer, _(L"%ls: Can not specify scope when erasing array slice\n"), argv[0]);
|
||||
builtin_print_help(parser, argv[0], stderr_buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
set assignment can work in two modes, either using slices or
|
||||
using the whole array. We detect which mode is used here.
|
||||
@@ -696,47 +697,40 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
|
||||
/*
|
||||
Slice mode
|
||||
*/
|
||||
size_t idx_count, val_count;
|
||||
wcstring_list_t values;
|
||||
std::vector<long> indexes;
|
||||
wcstring_list_t result;
|
||||
|
||||
const env_var_t dest_str = env_get_string(dest, scope);
|
||||
const env_var_t dest_str = env_get_string(dest);
|
||||
if (! dest_str.missing())
|
||||
{
|
||||
tokenize_variable_array(dest_str, result);
|
||||
}
|
||||
else if (erase)
|
||||
{
|
||||
retcode = 1;
|
||||
}
|
||||
|
||||
if (!retcode)
|
||||
for (; woptind<argc; woptind++)
|
||||
{
|
||||
for (; woptind<argc; woptind++)
|
||||
if (!parse_index(indexes, argv[woptind], dest, result.size()))
|
||||
{
|
||||
if (!parse_index(indexes, argv[woptind], dest, result.size()))
|
||||
builtin_print_help(parser, argv[0], stderr_buffer);
|
||||
retcode = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
val_count = argc-woptind-1;
|
||||
idx_count = indexes.size();
|
||||
|
||||
if (!erase)
|
||||
{
|
||||
if (val_count < idx_count)
|
||||
{
|
||||
append_format(stderr_buffer, _(BUILTIN_SET_ARG_COUNT), argv[0]);
|
||||
builtin_print_help(parser, argv[0], stderr_buffer);
|
||||
retcode = 1;
|
||||
retcode=1;
|
||||
break;
|
||||
}
|
||||
|
||||
size_t idx_count = indexes.size();
|
||||
size_t val_count = argc-woptind-1;
|
||||
|
||||
if (!erase)
|
||||
if (val_count == idx_count)
|
||||
{
|
||||
if (val_count < idx_count)
|
||||
{
|
||||
append_format(stderr_buffer, _(BUILTIN_SET_ARG_COUNT), argv[0]);
|
||||
builtin_print_help(parser, argv[0], stderr_buffer);
|
||||
retcode=1;
|
||||
break;
|
||||
}
|
||||
if (val_count == idx_count)
|
||||
{
|
||||
woptind++;
|
||||
break;
|
||||
}
|
||||
woptind++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -807,16 +801,6 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we are setting variables above the effective scope.
|
||||
See https://github.com/fish-shell/fish-shell/issues/806
|
||||
*/
|
||||
|
||||
env_var_t global_dest = env_get_string(dest, ENV_GLOBAL);
|
||||
if (universal && ! global_dest.missing())
|
||||
{
|
||||
append_format(stderr_buffer, _(L"%ls: Warning: universal scope selected, but a global variable '%ls' exists.\n"), L"set", dest);
|
||||
}
|
||||
|
||||
free(dest);
|
||||
|
||||
if (retcode == STATUS_BUILTIN_OK && preserve_incoming_failure_exit_status)
|
||||
|
||||
@@ -11,8 +11,6 @@ Functions used for implementing the set_color builtin.
|
||||
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#elif HAVE_NCURSES_CURSES_H
|
||||
#include <ncurses/curses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
@@ -83,12 +81,6 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
|
||||
|
||||
int argc = builtin_count_args(argv);
|
||||
|
||||
/* Some code passes variables to set_color that don't exist, like $fish_user_whatever. As a hack, quietly return failure. */
|
||||
if (argc <= 1)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const wchar_t *bgcolor = NULL;
|
||||
bool bold = false, underline=false;
|
||||
int errret;
|
||||
@@ -134,34 +126,40 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Remaining arguments are foreground color */
|
||||
std::vector<rgb_color_t> fgcolors;
|
||||
for (; woptind < argc; woptind++)
|
||||
/* Remaining argument is foreground color */
|
||||
const wchar_t *fgcolor = NULL;
|
||||
if (woptind < argc)
|
||||
{
|
||||
rgb_color_t fg = rgb_color_t(argv[woptind]);
|
||||
if (fg.is_none() || fg.is_ignore())
|
||||
if (woptind + 1 == argc)
|
||||
{
|
||||
append_format(stderr_buffer, _(L"%ls: Unknown color '%ls'\n"), argv[0], argv[woptind]);
|
||||
fgcolor = argv[woptind];
|
||||
}
|
||||
else
|
||||
{
|
||||
append_format(stderr_buffer,
|
||||
_(L"%ls: Too many arguments\n"),
|
||||
argv[0]);
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
}
|
||||
fgcolors.push_back(fg);
|
||||
}
|
||||
|
||||
if (fgcolors.empty() && bgcolor == NULL && !bold && !underline)
|
||||
if (fgcolor == NULL && bgcolor == NULL && !bold && !underline)
|
||||
{
|
||||
append_format(stderr_buffer,
|
||||
_(L"%ls: Expected an argument\n"),
|
||||
argv[0]);
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
}
|
||||
|
||||
// #1323: We may have multiple foreground colors. Choose the best one.
|
||||
// If we had no foreground coor, we'll get none(); if we have at least one we expect not-none
|
||||
const rgb_color_t fg = best_color(fgcolors, output_get_color_support());
|
||||
assert(fgcolors.empty() || !(fg.is_none() || fg.is_ignore()));
|
||||
|
||||
const rgb_color_t fg = rgb_color_t(fgcolor ? fgcolor : L"");
|
||||
if (fgcolor && fg.is_none())
|
||||
{
|
||||
append_format(stderr_buffer, _(L"%ls: Unknown color '%ls'\n"), argv[0], fgcolor);
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
}
|
||||
|
||||
const rgb_color_t bg = rgb_color_t(bgcolor ? bgcolor : L"");
|
||||
if (bgcolor && (bg.is_none() || bg.is_ignore()))
|
||||
if (bgcolor && bg.is_none())
|
||||
{
|
||||
append_format(stderr_buffer, _(L"%ls: Unknown color '%ls'\n"), argv[0], bgcolor);
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
@@ -183,6 +181,7 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* Save old output function so we can restore it */
|
||||
int (* const saved_writer_func)(char) = output_get_writer();
|
||||
|
||||
@@ -206,29 +205,29 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
|
||||
{
|
||||
if (bg.is_normal())
|
||||
{
|
||||
write_color(rgb_color_t::black(), false /* not is_fg */);
|
||||
write_background_color(0);
|
||||
writembs(tparm(exit_attribute_mode));
|
||||
}
|
||||
}
|
||||
|
||||
if (! fg.is_none())
|
||||
if (fgcolor != NULL)
|
||||
{
|
||||
if (fg.is_normal() || fg.is_reset())
|
||||
if (fg.is_normal())
|
||||
{
|
||||
write_color(rgb_color_t::black(), true /* is_fg */);
|
||||
write_foreground_color(0);
|
||||
writembs(tparm(exit_attribute_mode));
|
||||
}
|
||||
else
|
||||
{
|
||||
write_color(fg, true /* is_fg */);
|
||||
write_foreground_color(index_for_color(fg));
|
||||
}
|
||||
}
|
||||
|
||||
if (bgcolor != NULL)
|
||||
{
|
||||
if (! bg.is_normal() && ! bg.is_reset())
|
||||
if (! bg.is_normal())
|
||||
{
|
||||
write_color(bg, false /* not is_fg */);
|
||||
write_background_color(index_for_color(bg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,8 +235,9 @@ static int builtin_set_color(parser_t &parser, wchar_t **argv)
|
||||
output_set_writer(saved_writer_func);
|
||||
|
||||
/* Output the collected string */
|
||||
stdout_buffer.append(str2wcstring(builtin_set_color_output));
|
||||
builtin_set_color_output.clear();
|
||||
std::string local_output;
|
||||
std::swap(builtin_set_color_output, local_output);
|
||||
stdout_buffer.append(str2wcstring(local_output));
|
||||
|
||||
return STATUS_BUILTIN_OK;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@ enum
|
||||
|
||||
int builtin_test(parser_t &parser, wchar_t **argv);
|
||||
|
||||
static const wchar_t * const condstr[] =
|
||||
{
|
||||
L"!", L"&&", L"||", L"==", L"!=", L"<", L">", L"-nt", L"-ot", L"-ef", L"-eq",
|
||||
L"-ne", L"-lt", L"-gt", L"-le", L"-ge", L"=~"
|
||||
};
|
||||
|
||||
namespace test_expressions
|
||||
{
|
||||
|
||||
@@ -33,15 +39,13 @@ enum token_t
|
||||
test_bang, // "!", inverts sense
|
||||
|
||||
test_filetype_b, // "-b", for block special files
|
||||
test_filetype_c, // "-c", for character special files
|
||||
test_filetype_d, // "-d", for directories
|
||||
test_filetype_e, // "-e", for files that exist
|
||||
test_filetype_f, // "-f", for for regular files
|
||||
test_filetype_G, // "-G", for check effective group id
|
||||
test_filetype_g, // "-g", for set-group-id
|
||||
test_filetype_h, // "-h", for symbolic links
|
||||
test_filetype_c, // "-c" for character special files
|
||||
test_filetype_d, // "-d" for directories
|
||||
test_filetype_e, // "-e" for files that exist
|
||||
test_filetype_f, // "-f" for for regular files
|
||||
test_filetype_g, // "-g" for set-group-id
|
||||
test_filetype_h, // "-h" for symbolic links
|
||||
test_filetype_L, // "-L", same as -h
|
||||
test_filetype_O, // "-O", for check effective user id
|
||||
test_filetype_p, // "-p", for FIFO
|
||||
test_filetype_S, // "-S", socket
|
||||
|
||||
@@ -97,11 +101,9 @@ static const struct token_info_t
|
||||
{test_filetype_d, L"-d", UNARY_PRIMARY},
|
||||
{test_filetype_e, L"-e", UNARY_PRIMARY},
|
||||
{test_filetype_f, L"-f", UNARY_PRIMARY},
|
||||
{test_filetype_G, L"-G", UNARY_PRIMARY},
|
||||
{test_filetype_g, L"-g", UNARY_PRIMARY},
|
||||
{test_filetype_h, L"-h", UNARY_PRIMARY},
|
||||
{test_filetype_L, L"-L", UNARY_PRIMARY},
|
||||
{test_filetype_O, L"-O", UNARY_PRIMARY},
|
||||
{test_filetype_p, L"-p", UNARY_PRIMARY},
|
||||
{test_filetype_S, L"-S", UNARY_PRIMARY},
|
||||
{test_filesize_s, L"-s", UNARY_PRIMARY},
|
||||
@@ -646,11 +648,13 @@ expression *test_parser::parse_args(const wcstring_list_t &args, wcstring &err)
|
||||
expression *result = parser.parse_expression(0, (unsigned int)args.size());
|
||||
|
||||
/* Handle errors */
|
||||
bool errored = false;
|
||||
for (size_t i = 0; i < parser.errors.size(); i++)
|
||||
{
|
||||
err.append(L"test: ");
|
||||
err.append(parser.errors.at(i));
|
||||
err.push_back(L'\n');
|
||||
errored = true;
|
||||
// For now we only show the first error
|
||||
break;
|
||||
}
|
||||
@@ -665,12 +669,14 @@ expression *test_parser::parse_args(const wcstring_list_t &args, wcstring &err)
|
||||
{
|
||||
append_format(err, L"test: unexpected argument at index %lu: '%ls'\n", (unsigned long)result->range.end, args.at(result->range.end).c_str());
|
||||
}
|
||||
errored = true;
|
||||
|
||||
delete result;
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -812,31 +818,25 @@ static bool unary_primary_evaluate(test_expressions::token_t token, const wcstri
|
||||
case test_filetype_b: // "-b", for block special files
|
||||
return !wstat(arg, &buf) && S_ISBLK(buf.st_mode);
|
||||
|
||||
case test_filetype_c: // "-c", for character special files
|
||||
case test_filetype_c: // "-c" for character special files
|
||||
return !wstat(arg, &buf) && S_ISCHR(buf.st_mode);
|
||||
|
||||
case test_filetype_d: // "-d", for directories
|
||||
case test_filetype_d: // "-d" for directories
|
||||
return !wstat(arg, &buf) && S_ISDIR(buf.st_mode);
|
||||
|
||||
case test_filetype_e: // "-e", for files that exist
|
||||
case test_filetype_e: // "-e" for files that exist
|
||||
return !wstat(arg, &buf);
|
||||
|
||||
case test_filetype_f: // "-f", for for regular files
|
||||
case test_filetype_f: // "-f" for for regular files
|
||||
return !wstat(arg, &buf) && S_ISREG(buf.st_mode);
|
||||
|
||||
case test_filetype_G: // "-G", for check effective group id
|
||||
return !wstat(arg, &buf) && getegid() == buf.st_gid;
|
||||
|
||||
case test_filetype_g: // "-g", for set-group-id
|
||||
case test_filetype_g: // "-g" for set-group-id
|
||||
return !wstat(arg, &buf) && (S_ISGID & buf.st_mode);
|
||||
|
||||
case test_filetype_h: // "-h", for symbolic links
|
||||
case test_filetype_h: // "-h" for symbolic links
|
||||
case test_filetype_L: // "-L", same as -h
|
||||
return !lwstat(arg, &buf) && S_ISLNK(buf.st_mode);
|
||||
|
||||
case test_filetype_O: // "-O", for check effective user id
|
||||
return !wstat(arg, &buf) && geteuid() == buf.st_uid;
|
||||
|
||||
case test_filetype_p: // "-p", for FIFO
|
||||
return !wstat(arg, &buf) && S_ISFIFO(buf.st_mode);
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ static void print_all(int hard)
|
||||
|
||||
for (i=0; resource_arr[i].desc; i++)
|
||||
{
|
||||
w=maxi(w, fish_wcswidth(resource_arr[i].desc));
|
||||
w=maxi(w, my_wcswidth(resource_arr[i].desc));
|
||||
}
|
||||
|
||||
for (i=0; resource_arr[i].desc; i++)
|
||||
|
||||
24
color.cpp
24
color.cpp
@@ -6,7 +6,7 @@
|
||||
|
||||
bool rgb_color_t::try_parse_special(const wcstring &special)
|
||||
{
|
||||
memset(&data, 0, sizeof data);
|
||||
bzero(&data, sizeof data);
|
||||
const wchar_t *name = special.c_str();
|
||||
if (! wcscasecmp(name, L"normal"))
|
||||
{
|
||||
@@ -102,7 +102,7 @@ static unsigned char convert_color(const unsigned char rgb[3], const uint32_t *c
|
||||
|
||||
bool rgb_color_t::try_parse_rgb(const wcstring &name)
|
||||
{
|
||||
memset(&data, 0, sizeof data);
|
||||
bzero(&data, sizeof data);
|
||||
/* We support the following style of rgb formats (case insensitive):
|
||||
#FA3
|
||||
#F3A035
|
||||
@@ -125,7 +125,7 @@ bool rgb_color_t::try_parse_rgb(const wcstring &name)
|
||||
{
|
||||
int val = parse_hex_digit(name.at(digit_idx++));
|
||||
if (val < 0) break;
|
||||
data.color.rgb[i] = val*16+val;
|
||||
data.rgb[i] = val*16+val;
|
||||
}
|
||||
success = (i == 3);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ bool rgb_color_t::try_parse_rgb(const wcstring &name)
|
||||
int hi = parse_hex_digit(name.at(digit_idx++));
|
||||
int lo = parse_hex_digit(name.at(digit_idx++));
|
||||
if (lo < 0 || hi < 0) break;
|
||||
data.color.rgb[i] = hi*16+lo;
|
||||
data.rgb[i] = hi*16+lo;
|
||||
}
|
||||
success = (i == 3);
|
||||
}
|
||||
@@ -184,7 +184,7 @@ wcstring_list_t rgb_color_t::named_color_names(void)
|
||||
|
||||
bool rgb_color_t::try_parse_named(const wcstring &str)
|
||||
{
|
||||
memset(&data, 0, sizeof data);
|
||||
bzero(&data, sizeof data);
|
||||
size_t max = sizeof named_colors / sizeof *named_colors;
|
||||
for (size_t idx=0; idx < max; idx++)
|
||||
{
|
||||
@@ -298,13 +298,7 @@ static unsigned char term256_color_for_rgb(const unsigned char rgb[3])
|
||||
unsigned char rgb_color_t::to_term256_index() const
|
||||
{
|
||||
assert(type == type_rgb);
|
||||
return term256_color_for_rgb(data.color.rgb);
|
||||
}
|
||||
|
||||
color24_t rgb_color_t::to_color24() const
|
||||
{
|
||||
assert(type == type_rgb);
|
||||
return data.color;
|
||||
return term256_color_for_rgb(data.rgb);
|
||||
}
|
||||
|
||||
unsigned char rgb_color_t::to_name_index() const
|
||||
@@ -316,7 +310,7 @@ unsigned char rgb_color_t::to_name_index() const
|
||||
}
|
||||
else if (type == type_rgb)
|
||||
{
|
||||
return term8_color_for_rgb(data.color.rgb);
|
||||
return term8_color_for_rgb(data.rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -333,7 +327,7 @@ void rgb_color_t::parse(const wcstring &str)
|
||||
if (! success) success = try_parse_rgb(str);
|
||||
if (! success)
|
||||
{
|
||||
memset(&this->data, 0, sizeof this->data);
|
||||
bzero(this->data.rgb, sizeof this->data.rgb);
|
||||
this->type = type_none;
|
||||
}
|
||||
}
|
||||
@@ -357,7 +351,7 @@ wcstring rgb_color_t::description() const
|
||||
case type_named:
|
||||
return format_string(L"named(%d: %ls)", (int)data.name_idx, name_for_color_idx(data.name_idx));
|
||||
case type_rgb:
|
||||
return format_string(L"rgb(0x%02x%02x%02x)", data.color.rgb[0], data.color.rgb[1], data.color.rgb[2]);
|
||||
return format_string(L"rgb(0x%02x%02x%02x)", data.rgb[0], data.rgb[1], data.rgb[2]);
|
||||
case type_reset:
|
||||
return L"reset";
|
||||
case type_normal:
|
||||
|
||||
12
color.h
12
color.h
@@ -8,11 +8,6 @@
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
|
||||
/* 24 bit color */
|
||||
struct color24_t
|
||||
{
|
||||
unsigned char rgb[3];
|
||||
};
|
||||
|
||||
/* A type that represents a color. We work hard to keep it at a size of 4 bytes. */
|
||||
class rgb_color_t
|
||||
@@ -41,7 +36,7 @@ class rgb_color_t
|
||||
union
|
||||
{
|
||||
unsigned char name_idx; //0-10
|
||||
color24_t color;
|
||||
unsigned char rgb[3];
|
||||
} data;
|
||||
|
||||
/** Try parsing a special color name like "normal" */
|
||||
@@ -134,12 +129,9 @@ class rgb_color_t
|
||||
/** Returns the name index for the given color. Requires that the color be named or RGB. */
|
||||
unsigned char to_name_index() const;
|
||||
|
||||
/** Returns the term256 index for the given color. Requires that the color be RGB. */
|
||||
/** Returns the term256 index for the given color. Requires that the color be named or RGB. */
|
||||
unsigned char to_term256_index() const;
|
||||
|
||||
/** Returns the 24 bit color for the given color. Requires that the color be RGB. */
|
||||
color24_t to_color24() const;
|
||||
|
||||
/** Returns whether the color is bold */
|
||||
bool is_bold() const
|
||||
{
|
||||
|
||||
1602
common.cpp
1602
common.cpp
File diff suppressed because it is too large
Load Diff
266
common.h
266
common.h
@@ -59,22 +59,15 @@ typedef std::vector<wcstring> wcstring_list_t;
|
||||
*/
|
||||
#define BYTE_MAX 0xffu
|
||||
|
||||
/** BOM value */
|
||||
#define UTF8_BOM_WCHAR 0xFEFFu
|
||||
/**
|
||||
Escape special fish syntax characters like the semicolon
|
||||
*/
|
||||
#define UNESCAPE_SPECIAL 1
|
||||
|
||||
/* Flags for unescape_string functions */
|
||||
enum
|
||||
{
|
||||
/* Default behavior */
|
||||
UNESCAPE_DEFAULT = 0,
|
||||
|
||||
/* Escape special fish syntax characters like the semicolon */
|
||||
UNESCAPE_SPECIAL = 1 << 0,
|
||||
|
||||
/* Allow incomplete escape sequences */
|
||||
UNESCAPE_INCOMPLETE = 1 << 1
|
||||
};
|
||||
typedef unsigned int unescape_flags_t;
|
||||
/**
|
||||
Allow incomplete escape sequences
|
||||
*/
|
||||
#define UNESCAPE_INCOMPLETE 2
|
||||
|
||||
/* Flags for the escape() and escape_string() functions */
|
||||
enum
|
||||
@@ -90,47 +83,10 @@ enum
|
||||
};
|
||||
typedef unsigned int escape_flags_t;
|
||||
|
||||
/* Directions */
|
||||
enum selection_direction_t
|
||||
{
|
||||
/* visual directions */
|
||||
direction_north,
|
||||
direction_east,
|
||||
direction_south,
|
||||
direction_west,
|
||||
direction_page_north,
|
||||
direction_page_south,
|
||||
|
||||
/* logical directions */
|
||||
direction_next,
|
||||
direction_prev,
|
||||
|
||||
/* special value that means deselect */
|
||||
direction_deselect
|
||||
};
|
||||
|
||||
inline bool selection_direction_is_cardinal(selection_direction_t dir)
|
||||
{
|
||||
switch (dir)
|
||||
{
|
||||
case direction_north:
|
||||
case direction_page_north:
|
||||
case direction_east:
|
||||
case direction_page_south:
|
||||
case direction_south:
|
||||
case direction_west:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Helper macro for errors
|
||||
*/
|
||||
#define VOMIT_ON_FAILURE(a) do { if (0 != (a)) { VOMIT_ABORT(errno, #a); } } while (0)
|
||||
#define VOMIT_ON_FAILURE_NO_ERRNO(a) do { int err = (a); if (0 != err) { VOMIT_ABORT(err, #a); } } while (0)
|
||||
#define VOMIT_ABORT(err, str) do { int code = (err); fprintf(stderr, "%s failed on line %d in file %s: %d (%s)\n", str, __LINE__, __FILE__, code, strerror(code)); abort(); } while(0)
|
||||
#define VOMIT_ON_FAILURE(a) do { if (0 != (a)) { int err = errno; fprintf(stderr, "%s failed on line %d in file %s: %d (%s)\n", #a, __LINE__, __FILE__, err, strerror(err)); abort(); }} while (0)
|
||||
|
||||
/** Exits without invoking destructors (via _exit), useful for code after fork. */
|
||||
void exit_without_destructors(int code) __attribute__((noreturn));
|
||||
@@ -158,7 +114,7 @@ extern int debug_level;
|
||||
/**
|
||||
Profiling flag. True if commands should be profiled.
|
||||
*/
|
||||
extern bool g_profiling_active;
|
||||
extern char *profile;
|
||||
|
||||
/**
|
||||
Name of the current program. Should be set at startup. Used by the
|
||||
@@ -166,10 +122,6 @@ extern bool g_profiling_active;
|
||||
*/
|
||||
extern const wchar_t *program_name;
|
||||
|
||||
/* Variants of read() and write() that ignores return values, defeating a warning */
|
||||
void read_ignore(int fd, void *buff, size_t count);
|
||||
void write_ignore(int fd, const void *buff, size_t count);
|
||||
|
||||
/**
|
||||
This macro is used to check that an input argument is not null. It
|
||||
is a bit lika a non-fatal form of assert. Instead of exit-ing on
|
||||
@@ -193,10 +145,10 @@ void write_ignore(int fd, const void *buff, size_t count);
|
||||
*/
|
||||
#define FATAL_EXIT() \
|
||||
{ \
|
||||
char exit_read_buff; \
|
||||
show_stackframe(); \
|
||||
read_ignore( 0, &exit_read_buff, 1 ); \
|
||||
exit_without_destructors( 1 ); \
|
||||
char exit_read_buff; \
|
||||
show_stackframe(); \
|
||||
read( 0, &exit_read_buff, 1 ); \
|
||||
exit_without_destructors( 1 ); \
|
||||
} \
|
||||
|
||||
|
||||
@@ -241,7 +193,7 @@ void write_ignore(int fd, const void *buff, size_t count);
|
||||
/**
|
||||
Check if the specified string element is a part of the specified string list
|
||||
*/
|
||||
#define contains( str, ... ) contains_internal( str, 0, __VA_ARGS__, NULL )
|
||||
#define contains( str,... ) contains_internal( str, __VA_ARGS__, NULL )
|
||||
|
||||
/**
|
||||
Print a stack trace to stderr
|
||||
@@ -291,81 +243,10 @@ bool string_prefixes_string(const wchar_t *proposed_prefix, const wcstring &valu
|
||||
bool string_suffixes_string(const wcstring &proposed_suffix, const wcstring &value);
|
||||
bool string_suffixes_string(const wchar_t *proposed_suffix, const wcstring &value);
|
||||
|
||||
|
||||
/** Test if a string prefixes another without regard to case. Returns true if a is a prefix of b */
|
||||
bool string_prefixes_string_case_insensitive(const wcstring &proposed_prefix, const wcstring &value);
|
||||
|
||||
enum fuzzy_match_type_t
|
||||
{
|
||||
/* We match the string exactly: FOOBAR matches FOOBAR */
|
||||
fuzzy_match_exact = 0,
|
||||
|
||||
/* We match a prefix of the string: FO matches FOOBAR */
|
||||
fuzzy_match_prefix,
|
||||
|
||||
/* We match the string exactly, but in a case insensitive way: foobar matches FOOBAR */
|
||||
fuzzy_match_case_insensitive,
|
||||
|
||||
/* We match a prefix of the string, in a case insensitive way: foo matches FOOBAR */
|
||||
fuzzy_match_prefix_case_insensitive,
|
||||
|
||||
/* We match a substring of the string: OOBA matches FOOBAR */
|
||||
fuzzy_match_substring,
|
||||
|
||||
/* A subsequence match with insertions only: FBR matches FOOBAR */
|
||||
fuzzy_match_subsequence_insertions_only,
|
||||
|
||||
/* We don't match the string */
|
||||
fuzzy_match_none
|
||||
};
|
||||
|
||||
/* Indicates where a match type requires replacing the entire token */
|
||||
static inline bool match_type_requires_full_replacement(fuzzy_match_type_t t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case fuzzy_match_exact:
|
||||
case fuzzy_match_prefix:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Indicates where a match shares a prefix with the string it matches */
|
||||
static inline bool match_type_shares_prefix(fuzzy_match_type_t t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case fuzzy_match_exact:
|
||||
case fuzzy_match_prefix:
|
||||
case fuzzy_match_case_insensitive:
|
||||
case fuzzy_match_prefix_case_insensitive:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Test if string is a fuzzy match to another */
|
||||
struct string_fuzzy_match_t
|
||||
{
|
||||
enum fuzzy_match_type_t type;
|
||||
|
||||
/* Strength of the match. The value depends on the type. Lower is stronger. */
|
||||
size_t match_distance_first;
|
||||
size_t match_distance_second;
|
||||
|
||||
/* Constructor */
|
||||
string_fuzzy_match_t(enum fuzzy_match_type_t t, size_t distance_first = 0, size_t distance_second = 0);
|
||||
|
||||
/* Return -1, 0, 1 if this match is (respectively) better than, equal to, or worse than rhs */
|
||||
int compare(const string_fuzzy_match_t &rhs) const;
|
||||
};
|
||||
|
||||
/* Compute a fuzzy match for a string. If maximum_match is not fuzzy_match_none, limit the type to matches at or below that type. */
|
||||
string_fuzzy_match_t string_fuzzy_match_string(const wcstring &string, const wcstring &match_against, fuzzy_match_type_t limit_type = fuzzy_match_none);
|
||||
|
||||
|
||||
/** Test if a list contains a string using a linear search. */
|
||||
bool list_contains_string(const wcstring_list_t &list, const wcstring &str);
|
||||
|
||||
@@ -392,8 +273,8 @@ void format_size_safe(char buff[128], unsigned long long sz);
|
||||
void debug_safe(int level, const char *msg, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL, const char *param5 = NULL, const char *param6 = NULL, const char *param7 = NULL, const char *param8 = NULL, const char *param9 = NULL, const char *param10 = NULL, const char *param11 = NULL, const char *param12 = NULL);
|
||||
|
||||
/** Writes out a long safely */
|
||||
void format_long_safe(char buff[64], long val);
|
||||
void format_long_safe(wchar_t buff[64], long val);
|
||||
void format_long_safe(char buff[128], long val);
|
||||
void format_long_safe(wchar_t buff[128], long val);
|
||||
|
||||
|
||||
template<typename T>
|
||||
@@ -546,22 +427,6 @@ class narrow_string_rep_t
|
||||
|
||||
bool is_forked_child();
|
||||
|
||||
|
||||
class mutex_lock_t
|
||||
{
|
||||
public:
|
||||
pthread_mutex_t mutex;
|
||||
mutex_lock_t()
|
||||
{
|
||||
VOMIT_ON_FAILURE_NO_ERRNO(pthread_mutex_init(&mutex, NULL));
|
||||
}
|
||||
|
||||
~mutex_lock_t()
|
||||
{
|
||||
VOMIT_ON_FAILURE_NO_ERRNO(pthread_mutex_destroy(&mutex));
|
||||
}
|
||||
};
|
||||
|
||||
/* Basic scoped lock class */
|
||||
class scoped_lock
|
||||
{
|
||||
@@ -576,52 +441,9 @@ class scoped_lock
|
||||
void lock(void);
|
||||
void unlock(void);
|
||||
scoped_lock(pthread_mutex_t &mutex);
|
||||
scoped_lock(mutex_lock_t &lock);
|
||||
~scoped_lock();
|
||||
};
|
||||
|
||||
class rwlock_t
|
||||
{
|
||||
public:
|
||||
pthread_rwlock_t rwlock;
|
||||
rwlock_t()
|
||||
{
|
||||
VOMIT_ON_FAILURE_NO_ERRNO(pthread_rwlock_init(&rwlock, NULL));
|
||||
}
|
||||
|
||||
~rwlock_t()
|
||||
{
|
||||
VOMIT_ON_FAILURE_NO_ERRNO(pthread_rwlock_destroy(&rwlock));
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Scoped lock class for rwlocks
|
||||
*/
|
||||
class scoped_rwlock
|
||||
{
|
||||
pthread_rwlock_t *rwlock_obj;
|
||||
bool locked;
|
||||
bool locked_shared;
|
||||
|
||||
/* No copying */
|
||||
scoped_rwlock &operator=(const scoped_lock &);
|
||||
scoped_rwlock(const scoped_lock &);
|
||||
|
||||
public:
|
||||
void lock(void);
|
||||
void unlock(void);
|
||||
void lock_shared(void);
|
||||
void unlock_shared(void);
|
||||
/*
|
||||
upgrade shared lock to exclusive.
|
||||
equivalent to `lock.unlock_shared(); lock.lock();`
|
||||
*/
|
||||
void upgrade(void);
|
||||
scoped_rwlock(pthread_rwlock_t &rwlock, bool shared = false);
|
||||
scoped_rwlock(rwlock_t &rwlock, bool shared = false);
|
||||
~scoped_rwlock();
|
||||
};
|
||||
|
||||
/**
|
||||
A scoped manager to save the current value of some variable, and optionally
|
||||
@@ -689,13 +511,19 @@ wcstring vformat_string(const wchar_t *format, va_list va_orig);
|
||||
void append_format(wcstring &str, const wchar_t *format, ...);
|
||||
void append_formatv(wcstring &str, const wchar_t *format, va_list ap);
|
||||
|
||||
/**
|
||||
Returns a newly allocated wide character string array equivalent of
|
||||
the specified multibyte character string array
|
||||
*/
|
||||
char **wcsv2strv(const wchar_t * const *in);
|
||||
|
||||
/**
|
||||
Test if the given string is a valid variable name.
|
||||
|
||||
\return null if this is a valid name, and a pointer to the first invalid character otherwise
|
||||
*/
|
||||
|
||||
const wchar_t *wcsvarname(const wchar_t *str);
|
||||
wchar_t *wcsvarname(const wchar_t *str);
|
||||
|
||||
|
||||
/**
|
||||
@@ -709,18 +537,16 @@ const wchar_t *wcsfuncname(const wchar_t *str);
|
||||
/**
|
||||
Test if the given string is valid in a variable name
|
||||
|
||||
\return true if this is a valid name, false otherwise
|
||||
\return 1 if this is a valid name, 0 otherwise
|
||||
*/
|
||||
|
||||
bool wcsvarchr(wchar_t chr);
|
||||
int wcsvarchr(wchar_t chr);
|
||||
|
||||
|
||||
/**
|
||||
Convenience variants on fish_wcwswidth().
|
||||
|
||||
See fallback.h for the normal definitions.
|
||||
A wcswidth workalike. Fish uses this since the regular wcswidth seems flaky.
|
||||
*/
|
||||
int fish_wcswidth(const wchar_t *str);
|
||||
int fish_wcswidth(const wcstring& str);
|
||||
int my_wcswidth(const wchar_t *c);
|
||||
|
||||
/**
|
||||
This functions returns the end of the quoted substring beginning at
|
||||
@@ -756,8 +582,8 @@ wcstring wsetlocale(int category, const wchar_t *locale);
|
||||
|
||||
\return zero if needle is not found, of if needle is null, non-zero otherwise
|
||||
*/
|
||||
__sentinel bool contains_internal(const wchar_t *needle, int vararg_handle, ...);
|
||||
__sentinel bool contains_internal(const wcstring &needle, int vararg_handle, ...);
|
||||
__sentinel bool contains_internal(const wchar_t *needle, ...);
|
||||
__sentinel bool contains_internal(const wcstring &needle, ...);
|
||||
|
||||
/**
|
||||
Call read while blocking the SIGCHLD signal. Should only be called
|
||||
@@ -800,19 +626,16 @@ ssize_t read_loop(int fd, void *buff, size_t count);
|
||||
void debug(int level, const char *msg, ...);
|
||||
void debug(int level, const wchar_t *msg, ...);
|
||||
|
||||
/** Writes a string to stderr, followed by a newline */
|
||||
void print_stderr(const wcstring &str);
|
||||
|
||||
/**
|
||||
Replace special characters with backslash escape sequences. Newline is
|
||||
replaced with \n, etc.
|
||||
|
||||
\param in The string to be escaped
|
||||
\param flags Flags to control the escaping
|
||||
\return The escaped string
|
||||
\param escape_all Whether all characters wich hold special meaning in fish (Pipe, semicolon, etc,) should be escaped, or only unprintable characters
|
||||
\return The escaped string, or 0 if there is not enough memory
|
||||
*/
|
||||
|
||||
wcstring escape(const wchar_t *in, escape_flags_t flags);
|
||||
wchar_t *escape(const wchar_t *in, escape_flags_t flags);
|
||||
wcstring escape_string(const wcstring &in, escape_flags_t flags);
|
||||
|
||||
/**
|
||||
@@ -821,14 +644,16 @@ wcstring escape_string(const wcstring &in, escape_flags_t flags);
|
||||
character and a few more into constants which are defined in a
|
||||
private use area of Unicode. This assumes wchar_t is a unicode
|
||||
character set.
|
||||
|
||||
The result must be free()d. The original string is not modified. If
|
||||
an invalid sequence is specified, 0 is returned.
|
||||
|
||||
*/
|
||||
wchar_t *unescape(const wchar_t * in,
|
||||
int escape_special);
|
||||
|
||||
/** Unescapes a string in-place. A true result indicates the string was unescaped, a false result indicates the string was unmodified. */
|
||||
bool unescape_string_in_place(wcstring *str, unescape_flags_t escape_special);
|
||||
|
||||
/** Unescapes a string, returning the unescaped value by reference. On failure, the output is set to an empty string. */
|
||||
bool unescape_string(const wchar_t *input, wcstring *output, unescape_flags_t escape_special);
|
||||
bool unescape_string(const wcstring &input, wcstring *output, unescape_flags_t escape_special);
|
||||
bool unescape_string(wcstring &str,
|
||||
int escape_special);
|
||||
|
||||
|
||||
/**
|
||||
@@ -913,12 +738,11 @@ void assert_is_not_forked_child(const char *who);
|
||||
#define ASSERT_IS_NOT_FORKED_CHILD_TRAMPOLINE(x) assert_is_not_forked_child(x)
|
||||
#define ASSERT_IS_NOT_FORKED_CHILD() ASSERT_IS_NOT_FORKED_CHILD_TRAMPOLINE(__FUNCTION__)
|
||||
|
||||
/** Macro to help suppress potentially unused variable warnings */
|
||||
#define USE(var) (void)(var)
|
||||
|
||||
extern "C" {
|
||||
__attribute__((noinline)) void debug_thread_error(void);
|
||||
}
|
||||
|
||||
/** Return the path of an appropriate runtime data directory */
|
||||
std::string common_get_runtime_path();
|
||||
|
||||
#endif
|
||||
|
||||
879
complete.cpp
879
complete.cpp
File diff suppressed because it is too large
Load Diff
74
complete.h
74
complete.h
@@ -14,7 +14,6 @@
|
||||
|
||||
|
||||
#include <wchar.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
@@ -32,7 +31,7 @@
|
||||
#define NO_COMMON 2
|
||||
/**
|
||||
* Only use the argument list specifies with completion after
|
||||
* option. This is the same as (NO_FILES | NO_COMMON)
|
||||
* option. This is the same as (NO_FILES & NO_COMMON)
|
||||
*/
|
||||
#define EXCLUSIVE 3
|
||||
|
||||
@@ -55,6 +54,13 @@
|
||||
*/
|
||||
#define COMPLETE_SEP_STR L"\004"
|
||||
|
||||
/**
|
||||
* Separator between completion items in fish_pager. This is used for
|
||||
* completion grouping, e.g. when putting completions with the same
|
||||
* descriptions on the same line.
|
||||
*/
|
||||
#define COMPLETE_ITEM_SEP L'\uf500'
|
||||
|
||||
/**
|
||||
* Character that separates the completion and description on
|
||||
* programmable completions
|
||||
@@ -69,11 +75,16 @@ enum
|
||||
*/
|
||||
COMPLETE_NO_SPACE = 1 << 0,
|
||||
|
||||
/** This completion is case insensitive. */
|
||||
COMPLETE_CASE_INSENSITIVE = 1 << 1,
|
||||
|
||||
/** This is not the suffix of a token, but replaces it entirely */
|
||||
COMPLETE_REPLACES_TOKEN = 1 << 2,
|
||||
|
||||
/** This completion may or may not want a space at the end - guess by
|
||||
checking the last character of the completion. */
|
||||
/**
|
||||
This completion may or may not want a space at the end - guess by
|
||||
checking the last character of the completion.
|
||||
*/
|
||||
COMPLETE_AUTO_SPACE = 1 << 3,
|
||||
|
||||
/** This completion should be inserted as-is, without escaping. */
|
||||
@@ -96,15 +107,16 @@ class completion_t
|
||||
/* Destructor. Not inlining it saves code size. */
|
||||
~completion_t();
|
||||
|
||||
/** The completion string */
|
||||
/**
|
||||
The completion string
|
||||
*/
|
||||
wcstring completion;
|
||||
|
||||
/** The description for this completion */
|
||||
/**
|
||||
The description for this completion
|
||||
*/
|
||||
wcstring description;
|
||||
|
||||
/** The type of fuzzy match */
|
||||
string_fuzzy_match_t match;
|
||||
|
||||
/**
|
||||
Flags determining the completion behaviour.
|
||||
|
||||
@@ -115,18 +127,22 @@ class completion_t
|
||||
The COMPLETE_NO_CASE can be used to signal that this completion
|
||||
is case insensitive.
|
||||
*/
|
||||
complete_flags_t flags;
|
||||
int flags;
|
||||
|
||||
bool is_case_insensitive() const
|
||||
{
|
||||
return !!(flags & COMPLETE_CASE_INSENSITIVE);
|
||||
}
|
||||
|
||||
/* Construction. Note: defining these so that they are not inlined reduces the executable size. */
|
||||
completion_t(const wcstring &comp, const wcstring &desc = wcstring(), string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), complete_flags_t flags_val = 0);
|
||||
completion_t(const wcstring &comp, const wcstring &desc = L"", int flags_val = 0);
|
||||
completion_t(const completion_t &);
|
||||
completion_t &operator=(const completion_t &);
|
||||
|
||||
/* Compare two completions. No operating overlaoding to make this always explicit (there's potentially multiple ways to compare completions). */
|
||||
|
||||
/* "Naturally less than" means in a natural ordering, where digits are treated as numbers. For example, foo10 is naturally greater than foo2 (but alphabetically less than it) */
|
||||
static bool is_naturally_less_than(const completion_t &a, const completion_t &b);
|
||||
static bool is_alphabetically_equal_to(const completion_t &a, const completion_t &b);
|
||||
/* The following are needed for sorting and uniquing completions */
|
||||
bool operator < (const completion_t& rhs) const;
|
||||
bool operator == (const completion_t& rhs) const;
|
||||
bool operator != (const completion_t& rhs) const;
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -138,6 +154,12 @@ enum
|
||||
};
|
||||
typedef uint32_t completion_request_flags_t;
|
||||
|
||||
/** Given a list of completions, returns a list of their completion fields */
|
||||
wcstring_list_t completions_to_wcstring_list(const std::vector<completion_t> &completions);
|
||||
|
||||
/** Sorts a list of completions */
|
||||
void sort_completions(std::vector<completion_t> &completions);
|
||||
|
||||
/**
|
||||
|
||||
Add a completion.
|
||||
@@ -206,15 +228,17 @@ void complete_set_authoritative(const wchar_t *cmd, bool cmd_type, bool authorit
|
||||
void complete_remove(const wchar_t *cmd,
|
||||
bool cmd_is_path,
|
||||
wchar_t short_opt,
|
||||
const wchar_t *long_opt,
|
||||
int long_mode);
|
||||
const wchar_t *long_opt);
|
||||
|
||||
|
||||
/** Find all completions of the command cmd, insert them into out.
|
||||
/** Find all completions of the command cmd, insert them into out. If to_load is
|
||||
* not NULL, append all commands that we would autoload, but did not (presumably
|
||||
* because this is not the main thread)
|
||||
*/
|
||||
void complete(const wcstring &cmd,
|
||||
std::vector<completion_t> &comp,
|
||||
completion_request_flags_t flags);
|
||||
completion_request_flags_t flags,
|
||||
wcstring_list_t *to_load = NULL);
|
||||
|
||||
/**
|
||||
Print a list of all current completions into the string.
|
||||
@@ -262,17 +286,9 @@ void complete_load(const wcstring &cmd, bool reload);
|
||||
\param flags completion flags
|
||||
|
||||
*/
|
||||
void append_completion(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc = wcstring(), int flags = 0, string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact));
|
||||
void append_completion(std::vector<completion_t> &completions, const wcstring &comp, const wcstring &desc = L"", int flags = 0);
|
||||
|
||||
/* Function used for testing */
|
||||
void complete_set_variable_names(const wcstring_list_t *names);
|
||||
|
||||
/* Support for "wrap targets." A wrap target is a command that completes liek another command. The target chain is the sequence of wraps (A wraps B wraps C...). Any loops in the chain are silently ignored. */
|
||||
bool complete_add_wrapper(const wcstring &command, const wcstring &wrap_target);
|
||||
bool complete_remove_wrapper(const wcstring &command, const wcstring &wrap_target);
|
||||
wcstring_list_t complete_get_wrap_chain(const wcstring &command);
|
||||
|
||||
/* Wonky interface: returns all wraps. Even-values are the commands, odd values are the targets. */
|
||||
wcstring_list_t complete_get_wrap_pairs();
|
||||
|
||||
#endif
|
||||
|
||||
532
config.guess
vendored
532
config.guess
vendored
@@ -1,10 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012 Free Software Foundation, Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
timestamp='2012-02-10'
|
||||
timestamp='2006-02-27'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@@ -17,7 +17,9 @@ timestamp='2012-02-10'
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -25,16 +27,16 @@ timestamp='2012-02-10'
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
|
||||
# Originally written by Per Bothner. Please send patches (context
|
||||
# diff format) to <config-patches@gnu.org> and include a ChangeLog
|
||||
# entry.
|
||||
# Originally written by Per Bothner <per@bothner.com>.
|
||||
# Please send patches to <config-patches@gnu.org>. Submit a context
|
||||
# diff and a properly formatted ChangeLog entry.
|
||||
#
|
||||
# This script attempts to guess a canonical system name similar to
|
||||
# config.sub. If it succeeds, it prints the system name on stdout, and
|
||||
# exits with 0. Otherwise, it exits with 1.
|
||||
#
|
||||
# You can get the latest version of this script from:
|
||||
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
|
||||
# The plan is that this can be called by configure scripts if you
|
||||
# don't specify an explicit build system type.
|
||||
|
||||
me=`echo "$0" | sed -e 's,.*/,,'`
|
||||
|
||||
@@ -54,8 +56,7 @@ version="\
|
||||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
@@ -143,7 +144,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
*:NetBSD:*:*)
|
||||
# NetBSD (nbsd) targets should (where applicable) match one or
|
||||
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
|
||||
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
|
||||
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
|
||||
# switched to ELF, *-*-netbsd* would select the old
|
||||
# object file format. This provides both forward
|
||||
@@ -160,7 +161,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
arm*) machine=arm-unknown ;;
|
||||
sh3el) machine=shl-unknown ;;
|
||||
sh3eb) machine=sh-unknown ;;
|
||||
sh5el) machine=sh5le-unknown ;;
|
||||
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
|
||||
esac
|
||||
# The Operating System including object format, if it has switched
|
||||
@@ -169,7 +169,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
|
||||
eval $set_cc_for_build
|
||||
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ELF__
|
||||
| grep __ELF__ >/dev/null
|
||||
then
|
||||
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
|
||||
# Return netbsd for either. FIX?
|
||||
@@ -179,7 +179,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
os=netbsd
|
||||
os=netbsd
|
||||
;;
|
||||
esac
|
||||
# The OS release
|
||||
@@ -211,7 +211,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
|
||||
exit ;;
|
||||
macppc:MirBSD:*:*)
|
||||
echo powerpc-unknown-mirbsd${UNAME_RELEASE}
|
||||
echo powerppc-unknown-mirbsd${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:MirBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
|
||||
@@ -222,7 +222,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
|
||||
;;
|
||||
*5.*)
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
|
||||
;;
|
||||
esac
|
||||
# According to Compaq, /usr/sbin/psrinfo has been available on
|
||||
@@ -268,10 +268,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
|
||||
exitcode=$?
|
||||
trap '' 0
|
||||
exit $exitcode ;;
|
||||
exit ;;
|
||||
Alpha\ *:Windows_NT*:*)
|
||||
# How do we know it's Interix rather than the generic POSIX subsystem?
|
||||
# Should we change UNAME_MACHINE based on the output of uname instead
|
||||
@@ -297,7 +294,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
echo s390-ibm-zvmoe
|
||||
exit ;;
|
||||
*:OS400:*:*)
|
||||
echo powerpc-ibm-os400
|
||||
echo powerpc-ibm-os400
|
||||
exit ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
@@ -326,33 +323,14 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
case `/usr/bin/uname -p` in
|
||||
sparc) echo sparc-icl-nx7; exit ;;
|
||||
esac ;;
|
||||
s390x:SunOS:*:*)
|
||||
echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
sun4H:SunOS:5.*:*)
|
||||
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
|
||||
echo i386-pc-auroraux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
|
||||
eval $set_cc_for_build
|
||||
SUN_ARCH="i386"
|
||||
# If there is a compiler, see if it is configured for 64-bit objects.
|
||||
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
|
||||
# This test works for both compilers.
|
||||
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
|
||||
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
|
||||
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_64BIT_ARCH >/dev/null
|
||||
then
|
||||
SUN_ARCH="x86_64"
|
||||
fi
|
||||
fi
|
||||
echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
i86pc:SunOS:5.*:*)
|
||||
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
# According to config.sub, this is the proper way to canonicalize
|
||||
@@ -396,23 +374,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# MiNT. But MiNT is downward compatible to TOS, so this should
|
||||
# be no problem.
|
||||
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
exit ;;
|
||||
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
echo m68k-atari-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
|
||||
echo m68k-milan-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
echo m68k-milan-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
|
||||
echo m68k-hades-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
echo m68k-hades-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
|
||||
echo m68k-unknown-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
echo m68k-unknown-mint${UNAME_RELEASE}
|
||||
exit ;;
|
||||
m68k:machten:*:*)
|
||||
echo m68k-apple-machten${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -482,8 +460,8 @@ EOF
|
||||
echo m88k-motorola-sysv3
|
||||
exit ;;
|
||||
AViiON:dgux:*:*)
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
|
||||
then
|
||||
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
|
||||
@@ -496,7 +474,7 @@ EOF
|
||||
else
|
||||
echo i586-dg-dgux${UNAME_RELEASE}
|
||||
fi
|
||||
exit ;;
|
||||
exit ;;
|
||||
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
|
||||
echo m88k-dolphin-sysv3
|
||||
exit ;;
|
||||
@@ -553,7 +531,7 @@ EOF
|
||||
echo rs6000-ibm-aix3.2
|
||||
fi
|
||||
exit ;;
|
||||
*:AIX:*:[4567])
|
||||
*:AIX:*:[45])
|
||||
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
|
||||
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
@@ -596,52 +574,52 @@ EOF
|
||||
9000/[678][0-9][0-9])
|
||||
if [ -x /usr/bin/getconf ]; then
|
||||
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
|
||||
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
|
||||
case "${sc_cpu_version}" in
|
||||
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
|
||||
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
|
||||
532) # CPU_PA_RISC2_0
|
||||
case "${sc_kernel_bits}" in
|
||||
32) HP_ARCH="hppa2.0n" ;;
|
||||
64) HP_ARCH="hppa2.0w" ;;
|
||||
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
|
||||
case "${sc_cpu_version}" in
|
||||
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
|
||||
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
|
||||
532) # CPU_PA_RISC2_0
|
||||
case "${sc_kernel_bits}" in
|
||||
32) HP_ARCH="hppa2.0n" ;;
|
||||
64) HP_ARCH="hppa2.0w" ;;
|
||||
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
|
||||
esac ;;
|
||||
esac
|
||||
esac ;;
|
||||
esac
|
||||
fi
|
||||
if [ "${HP_ARCH}" = "" ]; then
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
|
||||
#define _HPUX_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#define _HPUX_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
long bits = sysconf(_SC_KERNEL_BITS);
|
||||
#endif
|
||||
long cpu = sysconf (_SC_CPU_VERSION);
|
||||
int main ()
|
||||
{
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
long bits = sysconf(_SC_KERNEL_BITS);
|
||||
#endif
|
||||
long cpu = sysconf (_SC_CPU_VERSION);
|
||||
|
||||
switch (cpu)
|
||||
{
|
||||
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
|
||||
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
|
||||
case CPU_PA_RISC2_0:
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
switch (bits)
|
||||
{
|
||||
case 64: puts ("hppa2.0w"); break;
|
||||
case 32: puts ("hppa2.0n"); break;
|
||||
default: puts ("hppa2.0"); break;
|
||||
} break;
|
||||
#else /* !defined(_SC_KERNEL_BITS) */
|
||||
puts ("hppa2.0"); break;
|
||||
#endif
|
||||
default: puts ("hppa1.0"); break;
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
switch (cpu)
|
||||
{
|
||||
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
|
||||
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
|
||||
case CPU_PA_RISC2_0:
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
switch (bits)
|
||||
{
|
||||
case 64: puts ("hppa2.0w"); break;
|
||||
case 32: puts ("hppa2.0n"); break;
|
||||
default: puts ("hppa2.0"); break;
|
||||
} break;
|
||||
#else /* !defined(_SC_KERNEL_BITS) */
|
||||
puts ("hppa2.0"); break;
|
||||
#endif
|
||||
default: puts ("hppa1.0"); break;
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
|
||||
test -z "$HP_ARCH" && HP_ARCH=hppa
|
||||
@@ -661,7 +639,7 @@ EOF
|
||||
# => hppa64-hp-hpux11.23
|
||||
|
||||
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
|
||||
grep -q __LP64__
|
||||
grep __LP64__ >/dev/null
|
||||
then
|
||||
HP_ARCH="hppa2.0w"
|
||||
else
|
||||
@@ -732,22 +710,22 @@ EOF
|
||||
exit ;;
|
||||
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
|
||||
echo c1-convex-bsd
|
||||
exit ;;
|
||||
exit ;;
|
||||
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit ;;
|
||||
exit ;;
|
||||
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
|
||||
echo c34-convex-bsd
|
||||
exit ;;
|
||||
exit ;;
|
||||
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
|
||||
echo c38-convex-bsd
|
||||
exit ;;
|
||||
exit ;;
|
||||
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
|
||||
echo c4-convex-bsd
|
||||
exit ;;
|
||||
exit ;;
|
||||
CRAY*Y-MP:*:*:*)
|
||||
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
|
||||
exit ;;
|
||||
@@ -771,14 +749,14 @@ EOF
|
||||
exit ;;
|
||||
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
|
||||
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit ;;
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit ;;
|
||||
5000:UNIX_System_V:4.*:*)
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
|
||||
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
|
||||
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit ;;
|
||||
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
@@ -790,48 +768,38 @@ EOF
|
||||
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:FreeBSD:*:*)
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
case ${UNAME_PROCESSOR} in
|
||||
amd64)
|
||||
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
case ${UNAME_MACHINE} in
|
||||
pc98)
|
||||
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
*)
|
||||
echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
|
||||
esac
|
||||
exit ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-cygwin
|
||||
exit ;;
|
||||
*:MINGW*:*)
|
||||
i*:MINGW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-mingw32
|
||||
exit ;;
|
||||
i*:MSYS*:*)
|
||||
echo ${UNAME_MACHINE}-pc-msys
|
||||
i*:MSYS_NT-*:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-mingw32
|
||||
exit ;;
|
||||
i*:windows32*:*)
|
||||
# uname -m includes "-pc" on this system.
|
||||
echo ${UNAME_MACHINE}-mingw32
|
||||
# uname -m includes "-pc" on this system.
|
||||
echo ${UNAME_MACHINE}-mingw32
|
||||
exit ;;
|
||||
i*:PW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-pw32
|
||||
exit ;;
|
||||
*:Interix*:*)
|
||||
case ${UNAME_MACHINE} in
|
||||
x86)
|
||||
echo i586-pc-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
authenticamd | genuineintel | EM64T)
|
||||
echo x86_64-unknown-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
IA64)
|
||||
echo ia64-unknown-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
esac ;;
|
||||
x86:Interix*:[345]*)
|
||||
echo i586-pc-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
EM64T:Interix*:[345]*)
|
||||
echo x86_64-unknown-interix${UNAME_RELEASE}
|
||||
exit ;;
|
||||
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
|
||||
echo i${UNAME_MACHINE}-pc-mks
|
||||
exit ;;
|
||||
8664:Windows_NT:*)
|
||||
echo x86_64-pc-mks
|
||||
exit ;;
|
||||
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
|
||||
# How do we know it's Interix rather than the generic POSIX subsystem?
|
||||
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
|
||||
@@ -861,68 +829,17 @@ EOF
|
||||
i*86:Minix:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-minix
|
||||
exit ;;
|
||||
aarch64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
aarch64_be:Linux:*:*)
|
||||
UNAME_MACHINE=aarch64_be
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
alpha:Linux:*:*)
|
||||
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
|
||||
EV5) UNAME_MACHINE=alphaev5 ;;
|
||||
EV56) UNAME_MACHINE=alphaev56 ;;
|
||||
PCA56) UNAME_MACHINE=alphapca56 ;;
|
||||
PCA57) UNAME_MACHINE=alphapca56 ;;
|
||||
EV6) UNAME_MACHINE=alphaev6 ;;
|
||||
EV67) UNAME_MACHINE=alphaev67 ;;
|
||||
EV68*) UNAME_MACHINE=alphaev68 ;;
|
||||
esac
|
||||
objdump --private-headers /bin/sh | grep -q ld.so.1
|
||||
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
|
||||
exit ;;
|
||||
arm*:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ARM_EABI__
|
||||
then
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
else
|
||||
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
|
||||
| grep -q __ARM_PCS_VFP
|
||||
then
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
|
||||
fi
|
||||
fi
|
||||
exit ;;
|
||||
avr32*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
cris:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-axis-linux-gnu
|
||||
echo cris-axis-linux-gnu
|
||||
exit ;;
|
||||
crisv32:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-axis-linux-gnu
|
||||
echo crisv32-axis-linux-gnu
|
||||
exit ;;
|
||||
frv:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
hexagon:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
i*86:Linux:*:*)
|
||||
LIBC=gnu
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#ifdef __dietlibc__
|
||||
LIBC=dietlibc
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
|
||||
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
|
||||
echo frv-unknown-linux-gnu
|
||||
exit ;;
|
||||
ia64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
@@ -933,33 +850,74 @@ EOF
|
||||
m68*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
mips:Linux:*:* | mips64:Linux:*:*)
|
||||
mips:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#undef CPU
|
||||
#undef ${UNAME_MACHINE}
|
||||
#undef ${UNAME_MACHINE}el
|
||||
#undef mips
|
||||
#undef mipsel
|
||||
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
|
||||
CPU=${UNAME_MACHINE}el
|
||||
CPU=mipsel
|
||||
#else
|
||||
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
|
||||
CPU=${UNAME_MACHINE}
|
||||
CPU=mips
|
||||
#else
|
||||
CPU=
|
||||
#endif
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
|
||||
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
|
||||
/^CPU/{
|
||||
s: ::g
|
||||
p
|
||||
}'`"
|
||||
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
|
||||
;;
|
||||
mips64:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#undef CPU
|
||||
#undef mips64
|
||||
#undef mips64el
|
||||
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
|
||||
CPU=mips64el
|
||||
#else
|
||||
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
|
||||
CPU=mips64
|
||||
#else
|
||||
CPU=
|
||||
#endif
|
||||
#endif
|
||||
EOF
|
||||
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
|
||||
/^CPU/{
|
||||
s: ::g
|
||||
p
|
||||
}'`"
|
||||
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
|
||||
;;
|
||||
or32:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
echo or32-unknown-linux-gnu
|
||||
exit ;;
|
||||
padre:Linux:*:*)
|
||||
echo sparc-unknown-linux-gnu
|
||||
ppc:Linux:*:*)
|
||||
echo powerpc-unknown-linux-gnu
|
||||
exit ;;
|
||||
parisc64:Linux:*:* | hppa64:Linux:*:*)
|
||||
echo hppa64-unknown-linux-gnu
|
||||
ppc64:Linux:*:*)
|
||||
echo powerpc64-unknown-linux-gnu
|
||||
exit ;;
|
||||
alpha:Linux:*:*)
|
||||
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
|
||||
EV5) UNAME_MACHINE=alphaev5 ;;
|
||||
EV56) UNAME_MACHINE=alphaev56 ;;
|
||||
PCA56) UNAME_MACHINE=alphapca56 ;;
|
||||
PCA57) UNAME_MACHINE=alphapca56 ;;
|
||||
EV6) UNAME_MACHINE=alphaev6 ;;
|
||||
EV67) UNAME_MACHINE=alphaev67 ;;
|
||||
EV68*) UNAME_MACHINE=alphaev68 ;;
|
||||
esac
|
||||
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
|
||||
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
|
||||
exit ;;
|
||||
parisc:Linux:*:* | hppa:Linux:*:*)
|
||||
# Look for CPU level
|
||||
@@ -969,17 +927,14 @@ EOF
|
||||
*) echo hppa-unknown-linux-gnu ;;
|
||||
esac
|
||||
exit ;;
|
||||
ppc64:Linux:*:*)
|
||||
echo powerpc64-unknown-linux-gnu
|
||||
exit ;;
|
||||
ppc:Linux:*:*)
|
||||
echo powerpc-unknown-linux-gnu
|
||||
parisc64:Linux:*:* | hppa64:Linux:*:*)
|
||||
echo hppa64-unknown-linux-gnu
|
||||
exit ;;
|
||||
s390:Linux:*:* | s390x:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-ibm-linux
|
||||
exit ;;
|
||||
sh64*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
sh*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
@@ -987,18 +942,75 @@ EOF
|
||||
sparc:Linux:*:* | sparc64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
tile*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
vax:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-dec-linux-gnu
|
||||
exit ;;
|
||||
x86_64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit ;;
|
||||
xtensa*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
echo x86_64-unknown-linux-gnu
|
||||
exit ;;
|
||||
i*86:Linux:*:*)
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us. cd to the root directory to prevent
|
||||
# problems with other programs or directories called `ld' in the path.
|
||||
# Set LC_ALL=C to ensure ld outputs messages in English.
|
||||
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
|
||||
| sed -ne '/supported targets:/!d
|
||||
s/[ ][ ]*/ /g
|
||||
s/.*supported targets: *//
|
||||
s/ .*//
|
||||
p'`
|
||||
case "$ld_supported_targets" in
|
||||
elf32-i386)
|
||||
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
|
||||
;;
|
||||
a.out-i386-linux)
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
|
||||
exit ;;
|
||||
coff-i386)
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
|
||||
exit ;;
|
||||
"")
|
||||
# Either a pre-BFD a.out linker (linux-gnuoldld) or
|
||||
# one that does not give us useful --help.
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
|
||||
exit ;;
|
||||
esac
|
||||
# Determine whether the default compiler is a.out or elf
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#include <features.h>
|
||||
#ifdef __ELF__
|
||||
# ifdef __GLIBC__
|
||||
# if __GLIBC__ >= 2
|
||||
LIBC=gnu
|
||||
# else
|
||||
LIBC=gnulibc1
|
||||
# endif
|
||||
# else
|
||||
LIBC=gnulibc1
|
||||
# endif
|
||||
#else
|
||||
#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun)
|
||||
LIBC=gnu
|
||||
#else
|
||||
LIBC=gnuaout
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __dietlibc__
|
||||
LIBC=dietlibc
|
||||
#endif
|
||||
EOF
|
||||
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
|
||||
/^LIBC/{
|
||||
s: ::g
|
||||
p
|
||||
}'`"
|
||||
test x"${LIBC}" != x && {
|
||||
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
|
||||
exit
|
||||
}
|
||||
test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
|
||||
;;
|
||||
i*86:DYNIX/ptx:4*:*)
|
||||
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
|
||||
# earlier versions are messed up and put the nodename in both
|
||||
@@ -1006,11 +1018,11 @@ EOF
|
||||
echo i386-sequent-sysv4
|
||||
exit ;;
|
||||
i*86:UNIX_SV:4.2MP:2.*)
|
||||
# Unixware is an offshoot of SVR4, but it has its own version
|
||||
# number series starting with 2...
|
||||
# I am not positive that other SVR4 systems won't match this,
|
||||
# Unixware is an offshoot of SVR4, but it has its own version
|
||||
# number series starting with 2...
|
||||
# I am not positive that other SVR4 systems won't match this,
|
||||
# I just have to hope. -- rms.
|
||||
# Use sysv4.2uw... so that sysv4* matches it.
|
||||
# Use sysv4.2uw... so that sysv4* matches it.
|
||||
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
|
||||
exit ;;
|
||||
i*86:OS/2:*:*)
|
||||
@@ -1027,7 +1039,7 @@ EOF
|
||||
i*86:syllable:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-syllable
|
||||
exit ;;
|
||||
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
|
||||
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit ;;
|
||||
i*86:*DOS:*:*)
|
||||
@@ -1042,7 +1054,7 @@ EOF
|
||||
fi
|
||||
exit ;;
|
||||
i*86:*:5:[678]*)
|
||||
# UnixWare 7.x, OpenUNIX and OpenServer 6.
|
||||
# UnixWare 7.x, OpenUNIX and OpenServer 6.
|
||||
case `/bin/uname -X | grep "^Machine"` in
|
||||
*486*) UNAME_MACHINE=i486 ;;
|
||||
*Pentium) UNAME_MACHINE=i586 ;;
|
||||
@@ -1070,13 +1082,10 @@ EOF
|
||||
exit ;;
|
||||
pc:*:*:*)
|
||||
# Left here for compatibility:
|
||||
# uname -m prints for DJGPP always 'pc', but it prints nothing about
|
||||
# the processor, so we play safe by assuming i586.
|
||||
# Note: whatever this is, it MUST be the same as what config.sub
|
||||
# prints for the "djgpp" host, or else GDB configury will decide that
|
||||
# this is a cross-build.
|
||||
echo i586-pc-msdosdjgpp
|
||||
exit ;;
|
||||
# uname -m prints for DJGPP always 'pc', but it prints nothing about
|
||||
# the processor, so we play safe by assuming i386.
|
||||
echo i386-pc-msdosdjgpp
|
||||
exit ;;
|
||||
Intel:Mach:3*:*)
|
||||
echo i386-pc-mach3
|
||||
exit ;;
|
||||
@@ -1111,18 +1120,8 @@ EOF
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
|
||||
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& { echo i486-ncr-sysv4; exit; } ;;
|
||||
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
|
||||
OS_REL='.3'
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; }
|
||||
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
|
||||
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& { echo i486-ncr-sysv4; exit; } ;;
|
||||
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
|
||||
echo m68k-unknown-lynxos${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -1135,7 +1134,7 @@ EOF
|
||||
rs6000:LynxOS:2.*:*)
|
||||
echo rs6000-unknown-lynxos${UNAME_RELEASE}
|
||||
exit ;;
|
||||
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
|
||||
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
|
||||
echo powerpc-unknown-lynxos${UNAME_RELEASE}
|
||||
exit ;;
|
||||
SM[BE]S:UNIX_SV:*:*)
|
||||
@@ -1155,10 +1154,10 @@ EOF
|
||||
echo ns32k-sni-sysv
|
||||
fi
|
||||
exit ;;
|
||||
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit ;;
|
||||
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit ;;
|
||||
*:UNIX_System_V:4*:FTX*)
|
||||
# From Gerald Hewes <hewes@openmarket.com>.
|
||||
# How about differentiating between stratus architectures? -djm
|
||||
@@ -1184,11 +1183,11 @@ EOF
|
||||
exit ;;
|
||||
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
|
||||
if [ -d /usr/nec ]; then
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit ;;
|
||||
exit ;;
|
||||
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
|
||||
echo powerpc-be-beos
|
||||
exit ;;
|
||||
@@ -1198,9 +1197,6 @@ EOF
|
||||
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
|
||||
echo i586-pc-beos
|
||||
exit ;;
|
||||
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
|
||||
echo i586-pc-haiku
|
||||
exit ;;
|
||||
SX-4:SUPER-UX:*:*)
|
||||
echo sx4-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -1210,15 +1206,6 @@ EOF
|
||||
SX-6:SUPER-UX:*:*)
|
||||
echo sx6-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
SX-7:SUPER-UX:*:*)
|
||||
echo sx7-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
SX-8:SUPER-UX:*:*)
|
||||
echo sx8-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
SX-8R:SUPER-UX:*:*)
|
||||
echo sx8r-nec-superux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
Power*:Rhapsody:*:*)
|
||||
echo powerpc-apple-rhapsody${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -1228,16 +1215,6 @@ EOF
|
||||
*:Darwin:*:*)
|
||||
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
|
||||
case $UNAME_PROCESSOR in
|
||||
i386)
|
||||
eval $set_cc_for_build
|
||||
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
|
||||
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
|
||||
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_64BIT_ARCH >/dev/null
|
||||
then
|
||||
UNAME_PROCESSOR="x86_64"
|
||||
fi
|
||||
fi ;;
|
||||
unknown) UNAME_PROCESSOR=powerpc ;;
|
||||
esac
|
||||
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
|
||||
@@ -1253,9 +1230,6 @@ EOF
|
||||
*:QNX:*:4*)
|
||||
echo i386-pc-qnx
|
||||
exit ;;
|
||||
NEO-?:NONSTOP_KERNEL:*:*)
|
||||
echo neo-tandem-nsk${UNAME_RELEASE}
|
||||
exit ;;
|
||||
NSE-?:NONSTOP_KERNEL:*:*)
|
||||
echo nse-tandem-nsk${UNAME_RELEASE}
|
||||
exit ;;
|
||||
@@ -1301,13 +1275,13 @@ EOF
|
||||
echo pdp10-unknown-its
|
||||
exit ;;
|
||||
SEI:*:*:SEIUX)
|
||||
echo mips-sei-seiux${UNAME_RELEASE}
|
||||
echo mips-sei-seiux${UNAME_RELEASE}
|
||||
exit ;;
|
||||
*:DragonFly:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit ;;
|
||||
*:*VMS:*:*)
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
case "${UNAME_MACHINE}" in
|
||||
A*) echo alpha-dec-vms ; exit ;;
|
||||
I*) echo ia64-dec-vms ; exit ;;
|
||||
@@ -1322,12 +1296,6 @@ EOF
|
||||
i*86:rdos:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-rdos
|
||||
exit ;;
|
||||
i*86:AROS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-aros
|
||||
exit ;;
|
||||
x86_64:VMkernel:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-esx
|
||||
exit ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
@@ -1350,11 +1318,11 @@ main ()
|
||||
#include <sys/param.h>
|
||||
printf ("m68k-sony-newsos%s\n",
|
||||
#ifdef NEWSOS4
|
||||
"4"
|
||||
"4"
|
||||
#else
|
||||
""
|
||||
""
|
||||
#endif
|
||||
); exit (0);
|
||||
); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1488,9 +1456,9 @@ This script, last modified $timestamp, has failed to recognize
|
||||
the operating system you are using. It is advised that you
|
||||
download the most up to date version of the config scripts from
|
||||
|
||||
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
|
||||
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
|
||||
and
|
||||
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
|
||||
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
|
||||
|
||||
If the version you run ($0) is already up to date, please
|
||||
send the following data and any information you think might be
|
||||
|
||||
337
config.sub
vendored
337
config.sub
vendored
@@ -1,10 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012 Free Software Foundation, Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
timestamp='2012-04-18'
|
||||
timestamp='2006-02-27'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
@@ -21,7 +21,9 @@ timestamp='2012-04-18'
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -30,16 +32,13 @@ timestamp='2012-04-18'
|
||||
|
||||
|
||||
# Please send patches to <config-patches@gnu.org>. Submit a context
|
||||
# diff and a properly formatted GNU ChangeLog entry.
|
||||
# diff and a properly formatted ChangeLog entry.
|
||||
#
|
||||
# Configuration subroutine to validate and canonicalize a configuration type.
|
||||
# Supply the specified configuration type as an argument.
|
||||
# If it is invalid, we print an error message on stderr and exit with code 1.
|
||||
# Otherwise, we print the canonical config type on stdout and succeed.
|
||||
|
||||
# You can get the latest version of this script from:
|
||||
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
|
||||
|
||||
# This file is supposed to be the same for all GNU packages
|
||||
# and recognize all the CPU types, system types and aliases
|
||||
# that are meaningful with *any* GNU software.
|
||||
@@ -73,8 +72,7 @@ Report bugs and patches to <config-patches@gnu.org>."
|
||||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
@@ -122,18 +120,12 @@ esac
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
|
||||
linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
|
||||
knetbsd*-gnu* | netbsd*-gnu* | \
|
||||
kopensolaris*-gnu* | \
|
||||
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
|
||||
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
|
||||
storm-chaos* | os2-emx* | rtmk-nova*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
android-linux)
|
||||
os=-linux-android
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
|
||||
;;
|
||||
*)
|
||||
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
|
||||
if [ $basic_machine != $1 ]
|
||||
@@ -156,13 +148,10 @@ case $os in
|
||||
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
|
||||
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
|
||||
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
|
||||
-apple | -axis | -knuth | -cray | -microblaze)
|
||||
-apple | -axis | -knuth | -cray)
|
||||
os=
|
||||
basic_machine=$1
|
||||
;;
|
||||
-bluegene*)
|
||||
os=-cnk
|
||||
;;
|
||||
-sim | -cisco | -oki | -wec | -winbond)
|
||||
os=
|
||||
basic_machine=$1
|
||||
@@ -177,10 +166,10 @@ case $os in
|
||||
os=-chorusos
|
||||
basic_machine=$1
|
||||
;;
|
||||
-chorusrdb)
|
||||
os=-chorusrdb
|
||||
-chorusrdb)
|
||||
os=-chorusrdb
|
||||
basic_machine=$1
|
||||
;;
|
||||
;;
|
||||
-hiux*)
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
@@ -225,12 +214,6 @@ case $os in
|
||||
-isc*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-lynx*178)
|
||||
os=-lynxos178
|
||||
;;
|
||||
-lynx*5)
|
||||
os=-lynxos5
|
||||
;;
|
||||
-lynx*)
|
||||
os=-lynxos
|
||||
;;
|
||||
@@ -255,32 +238,23 @@ case $basic_machine in
|
||||
# Some are omitted here because they have special meanings below.
|
||||
1750a | 580 \
|
||||
| a29k \
|
||||
| aarch64 | aarch64_be \
|
||||
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
|
||||
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
|
||||
| am33_2.0 \
|
||||
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
|
||||
| be32 | be64 \
|
||||
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
|
||||
| bfin \
|
||||
| c4x | clipper \
|
||||
| d10v | d30v | dlx | dsp16xx \
|
||||
| epiphany \
|
||||
| fido | fr30 | frv \
|
||||
| fr30 | frv \
|
||||
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||
| hexagon \
|
||||
| i370 | i860 | i960 | ia64 \
|
||||
| ip2k | iq2000 \
|
||||
| le32 | le64 \
|
||||
| lm32 \
|
||||
| m32c | m32r | m32rle | m68000 | m68k | m88k \
|
||||
| maxq | mb | microblaze | mcore | mep | metag \
|
||||
| m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \
|
||||
| mips | mipsbe | mipseb | mipsel | mipsle \
|
||||
| mips16 \
|
||||
| mips64 | mips64el \
|
||||
| mips64octeon | mips64octeonel \
|
||||
| mips64orion | mips64orionel \
|
||||
| mips64r5900 | mips64r5900el \
|
||||
| mips64vr | mips64vrel \
|
||||
| mips64orion | mips64orionel \
|
||||
| mips64vr4100 | mips64vr4100el \
|
||||
| mips64vr4300 | mips64vr4300el \
|
||||
| mips64vr5000 | mips64vr5000el \
|
||||
@@ -293,42 +267,31 @@ case $basic_machine in
|
||||
| mipsisa64sr71k | mipsisa64sr71kel \
|
||||
| mipstx39 | mipstx39el \
|
||||
| mn10200 | mn10300 \
|
||||
| moxie \
|
||||
| mt \
|
||||
| msp430 \
|
||||
| nds32 | nds32le | nds32be \
|
||||
| nios | nios2 \
|
||||
| ns16k | ns32k \
|
||||
| open8 \
|
||||
| or32 \
|
||||
| pdp10 | pdp11 | pj | pjl \
|
||||
| powerpc | powerpc64 | powerpc64le | powerpcle \
|
||||
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
|
||||
| pyramid \
|
||||
| rl78 | rx \
|
||||
| score \
|
||||
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh64 | sh64le \
|
||||
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
|
||||
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
|
||||
| spu \
|
||||
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
|
||||
| ubicom32 \
|
||||
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
|
||||
| strongarm \
|
||||
| tahoe | thumb | tic4x | tic80 | tron \
|
||||
| v850 | v850e \
|
||||
| we32k \
|
||||
| x86 | xc16x | xstormy16 | xtensa \
|
||||
| z8k | z80)
|
||||
| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
|
||||
| z8k)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
c54x)
|
||||
basic_machine=tic54x-unknown
|
||||
m32c)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
c55x)
|
||||
basic_machine=tic55x-unknown
|
||||
;;
|
||||
c6x)
|
||||
basic_machine=tic6x-unknown
|
||||
;;
|
||||
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
|
||||
m6811 | m68hc11 | m6812 | m68hc12)
|
||||
# Motorola 68HC11/12.
|
||||
basic_machine=$basic_machine-unknown
|
||||
os=-none
|
||||
;;
|
||||
@@ -338,21 +301,6 @@ case $basic_machine in
|
||||
basic_machine=mt-unknown
|
||||
;;
|
||||
|
||||
strongarm | thumb | xscale)
|
||||
basic_machine=arm-unknown
|
||||
;;
|
||||
xgate)
|
||||
basic_machine=$basic_machine-unknown
|
||||
os=-none
|
||||
;;
|
||||
xscaleeb)
|
||||
basic_machine=armeb-unknown
|
||||
;;
|
||||
|
||||
xscaleel)
|
||||
basic_machine=armel-unknown
|
||||
;;
|
||||
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
# (2) the word "unknown" tends to confuse beginning users.
|
||||
@@ -367,36 +315,29 @@ case $basic_machine in
|
||||
# Recognize the basic CPU types with company name.
|
||||
580-* \
|
||||
| a29k-* \
|
||||
| aarch64-* | aarch64_be-* \
|
||||
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
|
||||
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
|
||||
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
|
||||
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
|
||||
| avr-* | avr32-* \
|
||||
| be32-* | be64-* \
|
||||
| avr-* \
|
||||
| bfin-* | bs2000-* \
|
||||
| c[123]* | c30-* | [cjt]90-* | c4x-* \
|
||||
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
|
||||
| clipper-* | craynv-* | cydra-* \
|
||||
| d10v-* | d30v-* | dlx-* \
|
||||
| elxsi-* \
|
||||
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
|
||||
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
|
||||
| h8300-* | h8500-* \
|
||||
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
|
||||
| hexagon-* \
|
||||
| i*86-* | i860-* | i960-* | ia64-* \
|
||||
| ip2k-* | iq2000-* \
|
||||
| le32-* | le64-* \
|
||||
| lm32-* \
|
||||
| m32c-* | m32r-* | m32rle-* \
|
||||
| m32r-* | m32rle-* \
|
||||
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
|
||||
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
|
||||
| m88110-* | m88k-* | maxq-* | mcore-* \
|
||||
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
|
||||
| mips16-* \
|
||||
| mips64-* | mips64el-* \
|
||||
| mips64octeon-* | mips64octeonel-* \
|
||||
| mips64orion-* | mips64orionel-* \
|
||||
| mips64r5900-* | mips64r5900el-* \
|
||||
| mips64vr-* | mips64vrel-* \
|
||||
| mips64orion-* | mips64orionel-* \
|
||||
| mips64vr4100-* | mips64vr4100el-* \
|
||||
| mips64vr4300-* | mips64vr4300el-* \
|
||||
| mips64vr5000-* | mips64vr5000el-* \
|
||||
@@ -411,36 +352,29 @@ case $basic_machine in
|
||||
| mmix-* \
|
||||
| mt-* \
|
||||
| msp430-* \
|
||||
| nds32-* | nds32le-* | nds32be-* \
|
||||
| nios-* | nios2-* \
|
||||
| none-* | np1-* | ns16k-* | ns32k-* \
|
||||
| open8-* \
|
||||
| orion-* \
|
||||
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
|
||||
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
|
||||
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
|
||||
| pyramid-* \
|
||||
| rl78-* | romp-* | rs6000-* | rx-* \
|
||||
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
|
||||
| romp-* | rs6000-* \
|
||||
| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
|
||||
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
|
||||
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
|
||||
| sparclite-* \
|
||||
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
|
||||
| tahoe-* \
|
||||
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
|
||||
| tahoe-* | thumb-* \
|
||||
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
|
||||
| tile*-* \
|
||||
| tron-* \
|
||||
| ubicom32-* \
|
||||
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
|
||||
| vax-* \
|
||||
| v850-* | v850e-* | vax-* \
|
||||
| we32k-* \
|
||||
| x86-* | x86_64-* | xc16x-* | xps100-* \
|
||||
| xstormy16-* | xtensa*-* \
|
||||
| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
|
||||
| xstormy16-* | xtensa-* \
|
||||
| ymp-* \
|
||||
| z8k-* | z80-*)
|
||||
| z8k-*)
|
||||
;;
|
||||
# Recognize the basic CPU types without company name, with glob match.
|
||||
xtensa*)
|
||||
basic_machine=$basic_machine-unknown
|
||||
m32c-*)
|
||||
;;
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
@@ -458,7 +392,7 @@ case $basic_machine in
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
;;
|
||||
abacus)
|
||||
abacus)
|
||||
basic_machine=abacus-unknown
|
||||
;;
|
||||
adobe68k)
|
||||
@@ -504,10 +438,6 @@ case $basic_machine in
|
||||
basic_machine=m68k-apollo
|
||||
os=-bsd
|
||||
;;
|
||||
aros)
|
||||
basic_machine=i386-pc
|
||||
os=-aros
|
||||
;;
|
||||
aux)
|
||||
basic_machine=m68k-apple
|
||||
os=-aux
|
||||
@@ -516,35 +446,10 @@ case $basic_machine in
|
||||
basic_machine=ns32k-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
blackfin)
|
||||
basic_machine=bfin-unknown
|
||||
os=-linux
|
||||
;;
|
||||
blackfin-*)
|
||||
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
bluegene*)
|
||||
basic_machine=powerpc-ibm
|
||||
os=-cnk
|
||||
;;
|
||||
c54x-*)
|
||||
basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
c55x-*)
|
||||
basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
c6x-*)
|
||||
basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
c90)
|
||||
basic_machine=c90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
cegcc)
|
||||
basic_machine=arm-unknown
|
||||
os=-cegcc
|
||||
;;
|
||||
convex-c1)
|
||||
basic_machine=c1-convex
|
||||
os=-bsd
|
||||
@@ -573,8 +478,8 @@ case $basic_machine in
|
||||
basic_machine=craynv-cray
|
||||
os=-unicosmp
|
||||
;;
|
||||
cr16 | cr16-*)
|
||||
basic_machine=cr16-unknown
|
||||
cr16c)
|
||||
basic_machine=cr16c-unknown
|
||||
os=-elf
|
||||
;;
|
||||
crds | unos)
|
||||
@@ -612,10 +517,6 @@ case $basic_machine in
|
||||
basic_machine=m88k-motorola
|
||||
os=-sysv3
|
||||
;;
|
||||
dicos)
|
||||
basic_machine=i686-pc
|
||||
os=-dicos
|
||||
;;
|
||||
djgpp)
|
||||
basic_machine=i586-pc
|
||||
os=-msdosdjgpp
|
||||
@@ -731,6 +632,7 @@ case $basic_machine in
|
||||
i370-ibm* | ibm*)
|
||||
basic_machine=i370-ibm
|
||||
;;
|
||||
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
|
||||
i*86v32)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv32
|
||||
@@ -769,14 +671,6 @@ case $basic_machine in
|
||||
basic_machine=m68k-isi
|
||||
os=-sysv
|
||||
;;
|
||||
m68knommu)
|
||||
basic_machine=m68k-unknown
|
||||
os=-linux
|
||||
;;
|
||||
m68knommu-*)
|
||||
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
m88k-omron*)
|
||||
basic_machine=m88k-omron
|
||||
;;
|
||||
@@ -788,17 +682,10 @@ case $basic_machine in
|
||||
basic_machine=ns32k-utek
|
||||
os=-sysv
|
||||
;;
|
||||
microblaze)
|
||||
basic_machine=microblaze-xilinx
|
||||
;;
|
||||
mingw32)
|
||||
basic_machine=i386-pc
|
||||
os=-mingw32
|
||||
;;
|
||||
mingw32ce)
|
||||
basic_machine=arm-unknown
|
||||
os=-mingw32ce
|
||||
;;
|
||||
miniframe)
|
||||
basic_machine=m68000-convergent
|
||||
;;
|
||||
@@ -827,18 +714,10 @@ case $basic_machine in
|
||||
ms1-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
|
||||
;;
|
||||
msys)
|
||||
basic_machine=i386-pc
|
||||
os=-msys
|
||||
;;
|
||||
mvs)
|
||||
basic_machine=i370-ibm
|
||||
os=-mvs
|
||||
;;
|
||||
nacl)
|
||||
basic_machine=le32-unknown
|
||||
os=-nacl
|
||||
;;
|
||||
ncr3000)
|
||||
basic_machine=i486-ncr
|
||||
os=-sysv4
|
||||
@@ -903,12 +782,6 @@ case $basic_machine in
|
||||
np1)
|
||||
basic_machine=np1-gould
|
||||
;;
|
||||
neo-tandem)
|
||||
basic_machine=neo-tandem
|
||||
;;
|
||||
nse-tandem)
|
||||
basic_machine=nse-tandem
|
||||
;;
|
||||
nsr-tandem)
|
||||
basic_machine=nsr-tandem
|
||||
;;
|
||||
@@ -939,14 +812,6 @@ case $basic_machine in
|
||||
basic_machine=i860-intel
|
||||
os=-osf
|
||||
;;
|
||||
parisc)
|
||||
basic_machine=hppa-unknown
|
||||
os=-linux
|
||||
;;
|
||||
parisc-*)
|
||||
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
pbd)
|
||||
basic_machine=sparc-tti
|
||||
;;
|
||||
@@ -991,10 +856,9 @@ case $basic_machine in
|
||||
;;
|
||||
power) basic_machine=power-ibm
|
||||
;;
|
||||
ppc | ppcbe) basic_machine=powerpc-unknown
|
||||
ppc) basic_machine=powerpc-unknown
|
||||
;;
|
||||
ppc-* | ppcbe-*)
|
||||
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppcle | powerpclittle | ppc-le | powerpc-little)
|
||||
basic_machine=powerpcle-unknown
|
||||
@@ -1049,10 +913,6 @@ case $basic_machine in
|
||||
sb1el)
|
||||
basic_machine=mipsisa64sb1el-unknown
|
||||
;;
|
||||
sde)
|
||||
basic_machine=mipsisa32-sde
|
||||
os=-elf
|
||||
;;
|
||||
sei)
|
||||
basic_machine=mips-sei
|
||||
os=-seiux
|
||||
@@ -1064,9 +924,6 @@ case $basic_machine in
|
||||
basic_machine=sh-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
sh5el)
|
||||
basic_machine=sh5le-unknown
|
||||
;;
|
||||
sh64)
|
||||
basic_machine=sh64-unknown
|
||||
;;
|
||||
@@ -1088,9 +945,6 @@ case $basic_machine in
|
||||
basic_machine=i860-stratus
|
||||
os=-sysv4
|
||||
;;
|
||||
strongarm-* | thumb-*)
|
||||
basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
sun2)
|
||||
basic_machine=m68000-sun
|
||||
;;
|
||||
@@ -1147,9 +1001,17 @@ case $basic_machine in
|
||||
basic_machine=t90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
tile*)
|
||||
basic_machine=$basic_machine-unknown
|
||||
os=-linux-gnu
|
||||
tic54x | c54x*)
|
||||
basic_machine=tic54x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tic55x | c55x*)
|
||||
basic_machine=tic55x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tic6x | c6x*)
|
||||
basic_machine=tic6x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tx39)
|
||||
basic_machine=mipstx39-unknown
|
||||
@@ -1218,9 +1080,6 @@ case $basic_machine in
|
||||
xps | xps100)
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
xscale-* | xscalee[bl]-*)
|
||||
basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
|
||||
;;
|
||||
ymp)
|
||||
basic_machine=ymp-cray
|
||||
os=-unicos
|
||||
@@ -1229,10 +1088,6 @@ case $basic_machine in
|
||||
basic_machine=z8k-unknown
|
||||
os=-sim
|
||||
;;
|
||||
z80-*-coff)
|
||||
basic_machine=z80-unknown
|
||||
os=-sim
|
||||
;;
|
||||
none)
|
||||
basic_machine=none-none
|
||||
os=-none
|
||||
@@ -1271,7 +1126,7 @@ case $basic_machine in
|
||||
we32k)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
|
||||
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
|
||||
basic_machine=sh-unknown
|
||||
;;
|
||||
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
|
||||
@@ -1318,12 +1173,9 @@ esac
|
||||
if [ x"$os" != x"" ]
|
||||
then
|
||||
case $os in
|
||||
# First match some system type aliases
|
||||
# that might get confused with valid system types.
|
||||
# First match some system type aliases
|
||||
# that might get confused with valid system types.
|
||||
# -solaris* is a basic system type, with this one exception.
|
||||
-auroraux)
|
||||
os=-auroraux
|
||||
;;
|
||||
-solaris1 | -solaris1.*)
|
||||
os=`echo $os | sed -e 's|solaris1|sunos4|'`
|
||||
;;
|
||||
@@ -1344,11 +1196,10 @@ case $os in
|
||||
# Each alternative MUST END IN A *, to match a version number.
|
||||
# -sysv* is not here because it comes later, after sysvr4.
|
||||
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
|
||||
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
|
||||
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
|
||||
| -sym* | -kopensolaris* \
|
||||
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
|
||||
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
|
||||
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
|
||||
| -aos* | -aros* \
|
||||
| -aos* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
|
||||
@@ -1357,10 +1208,9 @@ case $os in
|
||||
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -chorusos* | -chorusrdb* | -cegcc* \
|
||||
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -linux-android* \
|
||||
| -linux-newlib* | -linux-uclibc* \
|
||||
| -chorusos* | -chorusrdb* \
|
||||
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
|
||||
| -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
|
||||
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
|
||||
@@ -1368,7 +1218,7 @@ case $os in
|
||||
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
|
||||
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
|
||||
| -skyos* | -haiku* | -rdos*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-qnx*)
|
||||
@@ -1407,7 +1257,7 @@ case $os in
|
||||
-opened*)
|
||||
os=-openedition
|
||||
;;
|
||||
-os400*)
|
||||
-os400*)
|
||||
os=-os400
|
||||
;;
|
||||
-wince*)
|
||||
@@ -1456,7 +1306,7 @@ case $os in
|
||||
-sinix*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-tpf*)
|
||||
-tpf*)
|
||||
os=-tpf
|
||||
;;
|
||||
-triton*)
|
||||
@@ -1498,11 +1348,6 @@ case $os in
|
||||
-zvmoe)
|
||||
os=-zvmoe
|
||||
;;
|
||||
-dicos*)
|
||||
os=-dicos
|
||||
;;
|
||||
-nacl*)
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
@@ -1525,12 +1370,6 @@ else
|
||||
# system, and we'll never get to this point.
|
||||
|
||||
case $basic_machine in
|
||||
score-*)
|
||||
os=-elf
|
||||
;;
|
||||
spu-*)
|
||||
os=-elf
|
||||
;;
|
||||
*-acorn)
|
||||
os=-riscix1.2
|
||||
;;
|
||||
@@ -1540,21 +1379,9 @@ case $basic_machine in
|
||||
arm*-semi)
|
||||
os=-aout
|
||||
;;
|
||||
c4x-* | tic4x-*)
|
||||
os=-coff
|
||||
;;
|
||||
hexagon-*)
|
||||
os=-elf
|
||||
;;
|
||||
tic54x-*)
|
||||
os=-coff
|
||||
;;
|
||||
tic55x-*)
|
||||
os=-coff
|
||||
;;
|
||||
tic6x-*)
|
||||
os=-coff
|
||||
;;
|
||||
c4x-* | tic4x-*)
|
||||
os=-coff
|
||||
;;
|
||||
# This must come before the *-dec entry.
|
||||
pdp10-*)
|
||||
os=-tops20
|
||||
@@ -1573,13 +1400,13 @@ case $basic_machine in
|
||||
;;
|
||||
m68000-sun)
|
||||
os=-sunos3
|
||||
# This also exists in the configure program, but was not the
|
||||
# default.
|
||||
# os=-sunos4
|
||||
;;
|
||||
m68*-cisco)
|
||||
os=-aout
|
||||
;;
|
||||
mep-*)
|
||||
os=-elf
|
||||
;;
|
||||
mips*-cisco)
|
||||
os=-elf
|
||||
;;
|
||||
@@ -1604,7 +1431,7 @@ case $basic_machine in
|
||||
*-ibm)
|
||||
os=-aix
|
||||
;;
|
||||
*-knuth)
|
||||
*-knuth)
|
||||
os=-mmixware
|
||||
;;
|
||||
*-wec)
|
||||
@@ -1709,7 +1536,7 @@ case $basic_machine in
|
||||
-sunos*)
|
||||
vendor=sun
|
||||
;;
|
||||
-cnk*|-aix*)
|
||||
-aix*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-beos*)
|
||||
|
||||
441
configure.ac
441
configure.ac
@@ -1,3 +1,4 @@
|
||||
|
||||
#
|
||||
# This file is the main build configuration file for fish. It is used
|
||||
# to determine your systems capabilities, and tries to adapt fish to
|
||||
@@ -8,12 +9,7 @@
|
||||
# configure the build process.
|
||||
#
|
||||
|
||||
m4_syscmd([build_tools/git_version_gen.sh 2>/dev/null])
|
||||
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT(fish,
|
||||
m4_esyscmd([cut -f 3 -d ' ' FISH-BUILD-VERSION-FILE | tr -d '\n']),
|
||||
fish-users@lists.sf.net)
|
||||
AC_INIT(fish,2.0.0,fish-users@lists.sf.net)
|
||||
|
||||
conf_arg=$@
|
||||
|
||||
@@ -21,9 +17,17 @@ conf_arg=$@
|
||||
# List of output variables produced by this configure script
|
||||
#
|
||||
|
||||
AC_SUBST(docdir)
|
||||
AC_SUBST(HAVE_GETTEXT)
|
||||
AC_SUBST(HAVE_DOXYGEN)
|
||||
AC_SUBST(LDFLAGS_FISH)
|
||||
AC_SUBST(LIBS_FISH)
|
||||
AC_SUBST(LIBS_FISH_INDENT)
|
||||
AC_SUBST(LIBS_FISH_PAGER)
|
||||
AC_SUBST(LIBS_FISHD)
|
||||
AC_SUBST(LIBS_MIMEDB)
|
||||
AC_SUBST(localedir)
|
||||
AC_SUBST(optbindirs)
|
||||
AC_SUBST(prefix)
|
||||
|
||||
|
||||
#
|
||||
@@ -89,12 +93,51 @@ fi
|
||||
#
|
||||
|
||||
AC_PROG_CXX([g++ c++])
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_SED
|
||||
AC_LANG(C++)
|
||||
|
||||
echo "CXXFLAGS: $CXXFLAGS"
|
||||
|
||||
#
|
||||
# Detect directories which may contain additional headers, libraries
|
||||
# and commands. This needs to be done early - before Autoconf starts
|
||||
# to mess with CFLAGS and all the other environemnt variables.
|
||||
#
|
||||
# This mostly helps OS X users, since fink usually installs out of
|
||||
# tree and doesn't update CFLAGS.
|
||||
#
|
||||
# It also helps FreeBSD which puts libiconv in /usr/local/lib
|
||||
|
||||
for i in /usr/pkg /sw /opt /opt/local /usr/local; do
|
||||
|
||||
AC_MSG_CHECKING([for $i/include include directory])
|
||||
if test -d $i/include; then
|
||||
AC_MSG_RESULT(yes)
|
||||
CXXFLAGS="$CXXFLAGS -I$i/include/"
|
||||
CFLAGS="$CFLAGS -I$i/include/"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for $i/lib library directory])
|
||||
if test -d $i/lib; then
|
||||
AC_MSG_RESULT(yes)
|
||||
LDFLAGS="$LDFLAGS -L$i/lib/ -Wl,-rpath,$i/lib/"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for $i/bin command directory])
|
||||
if test -d $i/bin; then
|
||||
AC_MSG_RESULT(yes)
|
||||
optbindirs="$optbindirs $i/bin"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
#
|
||||
# Tell autoconf to create config.h header
|
||||
#
|
||||
@@ -109,11 +152,9 @@ AC_CONFIG_HEADERS(config.h)
|
||||
AH_BOTTOM([#if __GNUC__ >= 3
|
||||
#define __warn_unused __attribute__ ((warn_unused_result))
|
||||
#define __sentinel __attribute__ ((sentinel))
|
||||
#define __packed __attribute__ ((packed))
|
||||
#else
|
||||
#define __warn_unused
|
||||
#define __sentinel
|
||||
#define __packed
|
||||
#endif])
|
||||
|
||||
|
||||
@@ -143,48 +184,6 @@ AS_IF([test x$local_gettext != xno],
|
||||
],
|
||||
)
|
||||
|
||||
#
|
||||
# Build/clean the documentation only if Doxygen is available
|
||||
#
|
||||
|
||||
doxygen_minimum=1.8.7
|
||||
|
||||
AC_ARG_WITH(
|
||||
doxygen,
|
||||
AS_HELP_STRING(
|
||||
[--with-doxygen],
|
||||
[use Doxygen to regenerate documentation]
|
||||
),
|
||||
[use_doxygen=$withval],
|
||||
[use_doxygen=auto]
|
||||
)
|
||||
|
||||
AS_IF([test "$use_doxygen" != "no"],
|
||||
[
|
||||
AC_CHECK_PROGS([found_doxygen], [doxygen], [no])
|
||||
if test "$found_doxygen" != no; then
|
||||
# test version
|
||||
AC_MSG_CHECKING([the doxygen version])
|
||||
doxygen_version=`doxygen --version 2>/dev/null`
|
||||
AC_MSG_RESULT([$doxygen_version])
|
||||
dnl This requires autoconf 2.60 or newer
|
||||
AS_VERSION_COMPARE([$doxygen_version], [$doxygen_minimum],
|
||||
[ if test "$use_doxygen" = auto; then
|
||||
AC_MSG_WARN([doxygen version $doxygen_version found, but $doxygen_minimum required])
|
||||
HAVE_DOXYGEN=0
|
||||
else
|
||||
AC_MSG_FAILURE([doxygen version $doxygen_version found, but $doxygen_minimum required])
|
||||
fi
|
||||
],
|
||||
[HAVE_DOXYGEN=1], [HAVE_DOXYGEN=1])
|
||||
elif test "$use_doxygen" != auto; then
|
||||
AC_MSG_FAILURE([--with-doxygen was given, but the doxygen program could not be found])
|
||||
else
|
||||
HAVE_DOXYGEN=0
|
||||
fi
|
||||
],
|
||||
)
|
||||
|
||||
#
|
||||
# Try to enable large file support. This will make sure that on systems
|
||||
# where off_t can be either 32 or 64 bit, the latter size is used. On
|
||||
@@ -193,37 +192,58 @@ AS_IF([test "$use_doxygen" != "no"],
|
||||
|
||||
CXXFLAGS="$CXXFLAGS -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64"
|
||||
|
||||
|
||||
# fish does not use exceptions
|
||||
# Disabling exceptions saves about 20% (!) of the compiled code size
|
||||
CXXFLAGS="$CXXFLAGS -fno-exceptions"
|
||||
|
||||
|
||||
#
|
||||
# -Wall is there to keep me on my toes
|
||||
# But signed comparison warnings are way too aggressive
|
||||
# If we are using gcc, set some flags that increase the odds of the
|
||||
# compiler producing a working binary...
|
||||
#
|
||||
|
||||
CXXFLAGS="$CXXFLAGS -Wall -Wno-sign-compare"
|
||||
if test "$GCC" = yes; then
|
||||
|
||||
#
|
||||
# This is needed in order to get the really cool backtraces on Linux
|
||||
#
|
||||
#
|
||||
# -fno-optimize-sibling-calls seems to work around a bug where
|
||||
# sending a SIGWINCH to fish on NetBSD 3.0 causes fish to exit when
|
||||
# compiled with GCC 3.3.3. This is probably either a compiler bug
|
||||
# or a libc bug, but adding this flag seems to fix things for
|
||||
# now. Long term, the real problem should be tracked down and
|
||||
# truly fixed, at which point we can remove this silly flag. This
|
||||
# bug has been verified to not exist on Linux using GCC 3.3.3.
|
||||
#
|
||||
|
||||
GCC_VERSION=$($CC -dumpversion)
|
||||
GCC_VERSION_MAJOR=$(echo $GCC_VERSION | cut -d'.' -f1)
|
||||
GCC_VERSION_MINOR=$(echo $GCC_VERSION | cut -d'.' -f2)
|
||||
GCC_VERSION_PATCH=$(echo $GCC_VERSION | cut -d'.' -f3)
|
||||
|
||||
if test "$GCC_VERSION_MAJOR" -le 3; then
|
||||
if test 0"$GCC_VERSION_MINOR" -le 3; then
|
||||
if test 0"$GCC_VERSION_PATCH" -le 3; then
|
||||
CXXFLAGS="$CXXFLAGS -fno-optimize-sibling-calls"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# fish does not use exceptions
|
||||
# Disabling exceptions saves about 20% (!) of the compiled code size
|
||||
CXXFLAGS="$CXXFLAGS -fno-exceptions"
|
||||
|
||||
|
||||
#
|
||||
# -Wall is there to keep me on my toes
|
||||
#
|
||||
|
||||
# Some day...
|
||||
CXXFLAGS="$CXXFLAGS -Wall"
|
||||
|
||||
#
|
||||
# This is needed in order to get the really cool backtraces on Linux
|
||||
#
|
||||
|
||||
if test `uname` != "Darwin"; then
|
||||
LDFLAGS_FISH="$LDFLAGS_FISH -rdynamic"
|
||||
fi
|
||||
|
||||
if test `uname` != "Darwin"; then
|
||||
LDFLAGS_FISH="$LDFLAGS_FISH -rdynamic"
|
||||
fi
|
||||
|
||||
#
|
||||
# On Cygwin, we need to add some flags for ncurses.
|
||||
#
|
||||
case `uname` in
|
||||
CYGWIN*)
|
||||
echo "adding flags for ncurses on Cygwin"
|
||||
CXXFLAGS="$CXXFLAGS -I/usr/include -I/usr/include/ncursesw"
|
||||
LDFLAGS_FISH="$LDFLAGS_FISH -L/usr/lib/ncursesw"
|
||||
;;
|
||||
esac
|
||||
|
||||
#
|
||||
# If we are compiling against glibc, set some flags to work around
|
||||
@@ -262,7 +282,7 @@ if test "$glibc" = yes; then
|
||||
# fallback.h, in order to keep fish working on non-gnu platforms.
|
||||
#
|
||||
|
||||
CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE=1 -D_ISO99_SOURCE=1"
|
||||
CFLAGS="$CFLAGS -D_GNU_SOURCE=1 -D_ISO99_SOURCE=1"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
@@ -301,6 +321,35 @@ case $target_os in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check for Solaris curses tputs having fixed length parameter list.
|
||||
AC_MSG_CHECKING([if we are using non varargs tparm.])
|
||||
AC_COMPILE_IFELSE(
|
||||
[
|
||||
AC_LANG_PROGRAM(
|
||||
[
|
||||
#include <curses.h>
|
||||
#include <term.h>
|
||||
],
|
||||
[
|
||||
tparm( "" );
|
||||
]
|
||||
)
|
||||
],
|
||||
[tparm_solaris_kludge=no],
|
||||
[tparm_solaris_kludge=yes]
|
||||
)
|
||||
if test "x$tparm_solaris_kludge" = "xyes"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[TPARM_SOLARIS_KLUDGE],
|
||||
[1],
|
||||
[Define to 1 if tparm accepts a fixed amount of paramters.]
|
||||
)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# BSD-specific flags go here
|
||||
#
|
||||
@@ -318,6 +367,40 @@ case $target_os in
|
||||
esac
|
||||
|
||||
|
||||
#
|
||||
# Set up PREFIX and related preprocessor symbols. Fish needs to know
|
||||
# where it will be installed. One of the reasons for this is so that
|
||||
# it can make sure the fish installation directory is in the path
|
||||
# during startup.
|
||||
#
|
||||
|
||||
if [[ "$prefix" = NONE ]]; then
|
||||
prefix=/usr/local
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Set up the directory where the documentation files should be
|
||||
# installed
|
||||
#
|
||||
|
||||
AC_ARG_VAR( [docdir], [Documentation direcotry] )
|
||||
|
||||
if test -z $docdir; then
|
||||
docdir=$datadir/doc/fish
|
||||
else
|
||||
docdir=$docdir
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Set up locale directory. This is where the .po files will be
|
||||
# installed.
|
||||
#
|
||||
|
||||
localedir=$datadir/locale
|
||||
|
||||
|
||||
#
|
||||
# See if Linux procfs is present. This is used to get extra
|
||||
# information about running processes.
|
||||
@@ -337,9 +420,6 @@ AC_DEFINE(
|
||||
[Define to 1 if the wgettext function should be used for translating strings.]
|
||||
)
|
||||
|
||||
# Disable curses macros that conflict with the STL
|
||||
AC_DEFINE([NCURSES_NOMACROS], [1], [Define to 1 to disable ncurses macros that conflict with the STL])
|
||||
AC_DEFINE([NOMACROS], [1], [Define to 1 to disable curses macros that conflict with the STL])
|
||||
|
||||
#
|
||||
# Check presense of various libraries. This is done on a per-binary
|
||||
@@ -349,22 +429,89 @@ AC_DEFINE([NOMACROS], [1], [Define to 1 to disable curses macros that conflict w
|
||||
#
|
||||
|
||||
# Check for os dependant libraries for all binaries.
|
||||
LIBS_COMMON=$LIBS
|
||||
LIBS=""
|
||||
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( shm_open, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( pthread_create, pthread, , [AC_MSG_ERROR([Cannot find the pthread library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( setupterm, [ncurses tinfo curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish. If this is Linux, try running 'sudo apt-get install libncurses5-dev' or 'sudo yum install ncurses-devel'])] )
|
||||
AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] )
|
||||
AC_SEARCH_LIBS( [nan], [m], [AC_DEFINE( [HAVE_NAN], [1], [Define to 1 if you have the nan function])] )
|
||||
LIBS_SHARED=$LIBS
|
||||
LIBS=$LIBS_COMMON
|
||||
|
||||
#
|
||||
# Check for libraries needed by fish.
|
||||
#
|
||||
|
||||
LIBS_COMMON=$LIBS
|
||||
LIBS="$LIBS_SHARED"
|
||||
if test x$local_gettext != xno; then
|
||||
AC_SEARCH_LIBS( gettext, intl,,)
|
||||
fi
|
||||
|
||||
# Check for libiconv_open if we can't find iconv_open. Silly OS X does
|
||||
# weird macro magic for the sole purpose of amusing me.
|
||||
AC_SEARCH_LIBS( iconv_open, iconv, , [AC_SEARCH_LIBS( libiconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] )] )
|
||||
|
||||
LIBS_FISH=$LIBS
|
||||
LIBS=$LIBS_COMMON
|
||||
|
||||
#
|
||||
# Check for libraries needed by fish_indent.
|
||||
#
|
||||
|
||||
LIBS_COMMON=$LIBS
|
||||
LIBS="$LIBS_SHARED"
|
||||
if test x$local_gettext != xno; then
|
||||
AC_SEARCH_LIBS( gettext, intl,,)
|
||||
fi
|
||||
LIBS_FISH_INDENT=$LIBS
|
||||
LIBS=$LIBS_COMMON
|
||||
|
||||
#
|
||||
# Check for libraries needed by fish_pager.
|
||||
#
|
||||
|
||||
LIBS_COMMON=$LIBS
|
||||
LIBS="$LIBS_SHARED"
|
||||
if test x$local_gettext != xno; then
|
||||
AC_SEARCH_LIBS( gettext, intl,,)
|
||||
fi
|
||||
AC_SEARCH_LIBS( iconv_open, iconv, , [AC_SEARCH_LIBS( libiconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] )] )
|
||||
LIBS_FISH_PAGER=$LIBS
|
||||
LIBS=$LIBS_COMMON
|
||||
|
||||
#
|
||||
# Check for libraries needed by fishd.
|
||||
#
|
||||
|
||||
LIBS_COMMON=$LIBS
|
||||
LIBS="$LIBS_SHARED"
|
||||
if test x$local_gettext != xno; then
|
||||
AC_SEARCH_LIBS( gettext, intl,,)
|
||||
fi
|
||||
AC_SEARCH_LIBS( iconv_open, iconv, , [AC_SEARCH_LIBS( libiconv_open, iconv, , [AC_MSG_ERROR([Could not find an iconv implementation, needed to build fish])] )] )
|
||||
LIBS_FISHD=$LIBS
|
||||
LIBS=$LIBS_COMMON
|
||||
|
||||
#
|
||||
# Check for libraries needed by mimedb.
|
||||
#
|
||||
|
||||
LIBS_COMMON=$LIBS
|
||||
LIBS="$LIBS_SHARED"
|
||||
if test x$local_gettext != xno; then
|
||||
AC_SEARCH_LIBS( gettext, intl,,)
|
||||
fi
|
||||
LIBS_MIMEDB=$LIBS
|
||||
LIBS=$LIBS_COMMON
|
||||
|
||||
|
||||
#
|
||||
# Check presense of various header files
|
||||
#
|
||||
|
||||
AC_CHECK_HEADERS([getopt.h termios.h sys/resource.h term.h ncurses/term.h ncurses.h ncurses/curses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h execinfo.h spawn.h sys/sysctl.h])
|
||||
AC_CHECK_HEADERS([getopt.h termios.h sys/resource.h term.h ncurses/term.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h execinfo.h spawn.h])
|
||||
|
||||
if test x$local_gettext != xno; then
|
||||
AC_CHECK_HEADERS([libintl.h])
|
||||
@@ -382,6 +529,7 @@ AC_CHECK_HEADER(
|
||||
[AC_MSG_ERROR([Could not find the header regex.h, needed to build fish])]
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# On some platforms (Solaris 10) adding -std=c99 in turn requires that
|
||||
# _POSIX_C_SOURCE be defined to 200112L otherwise several
|
||||
@@ -411,7 +559,7 @@ AC_CHECK_HEADER(
|
||||
# conditional definition of __EXTENSIONS__, to avoid redundant tests.
|
||||
#
|
||||
|
||||
XCXXFLAGS="$CXXFLAGS"
|
||||
XCFLAGS="$CXXFLAGS"
|
||||
|
||||
echo checking how to use -D_XOPEN_SOURCE=600 and -D_POSIX_C_SOURCE=200112L...
|
||||
local_found_posix_switch=no
|
||||
@@ -419,7 +567,7 @@ local_found_posix_switch=no
|
||||
for i in "" "-D_POSIX_C_SOURCE=200112L" "-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L"; do
|
||||
|
||||
AC_MSG_CHECKING( if switches \"$i\" works)
|
||||
CXXFLAGS="$XCXXFLAGS $i"
|
||||
CFLAGS="$XCFLAGS $i"
|
||||
|
||||
#
|
||||
# Try to run this program, which should test various extensions
|
||||
@@ -450,10 +598,6 @@ for i in "" "-D_POSIX_C_SOURCE=200112L" "-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=2
|
||||
/* As above (under at least Linux and FreeBSD). */
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
#include <termios.h>
|
||||
#endif
|
||||
],
|
||||
[
|
||||
/* Avert high-level optimisation, by making the program's
|
||||
@@ -497,19 +641,9 @@ done
|
||||
#
|
||||
|
||||
if test ! x$local_found_posix_switch = xyes; then
|
||||
CXXFLAGS="$XCXXFLAGS"
|
||||
CFLAGS="$XCFLAGS"
|
||||
fi
|
||||
|
||||
#
|
||||
# Detect nanoseconds fields in struct stat
|
||||
#
|
||||
AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
|
||||
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
|
||||
|
||||
#
|
||||
# Check for D_TYPE in dirent, only on BSD and Linux
|
||||
#
|
||||
AC_STRUCT_DIRENT_D_TYPE
|
||||
|
||||
#
|
||||
# Check for presense of various functions used by fish
|
||||
@@ -517,7 +651,7 @@ AC_STRUCT_DIRENT_D_TYPE
|
||||
|
||||
AC_CHECK_FUNCS( wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
|
||||
AC_CHECK_FUNCS( futimes wcwidth wcswidth wcstok fputwc fgetwc )
|
||||
AC_CHECK_FUNCS( wcstol wcslcat wcslcpy lrand48_r killpg mkostemp )
|
||||
AC_CHECK_FUNCS( wcstol wcslcat wcslcpy lrand48_r killpg )
|
||||
AC_CHECK_FUNCS( backtrace backtrace_symbols sysconf getifaddrs )
|
||||
|
||||
if test x$local_gettext != xno; then
|
||||
@@ -609,7 +743,7 @@ AC_LINK_IFELSE(
|
||||
|
||||
#
|
||||
# If we have a fwprintf in libc, test that it actually works. As of
|
||||
# March 2006, it is broken under DragonFly BSD.
|
||||
# March 2006, it is broken under Dragonfly BSD.
|
||||
#
|
||||
|
||||
if test "$ac_cv_func_fwprintf" = yes; then
|
||||
@@ -694,56 +828,6 @@ else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for sys_errlist
|
||||
AC_MSG_CHECKING([for sys_errlist array])
|
||||
AC_TRY_LINK(
|
||||
[
|
||||
#include <stdio.h>
|
||||
],
|
||||
[
|
||||
const char *p;
|
||||
p = sys_errlist[sys_nerr];
|
||||
],
|
||||
have_sys_errlist=yes,
|
||||
have_sys_errlist=no
|
||||
)
|
||||
if test "$have_sys_errlist" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[HAVE_SYS_ERRLIST],
|
||||
[1],
|
||||
[Define to 1 if the sys_errlist array is available.]
|
||||
)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for _sys_errs
|
||||
AC_MSG_CHECKING([for _sys_errs array])
|
||||
AC_TRY_LINK(
|
||||
[
|
||||
#include <string>
|
||||
],
|
||||
[
|
||||
std::string p;
|
||||
extern const char _sys_errs[];
|
||||
extern const int _sys_index[];
|
||||
p = _sys_errs[_sys_index[0]];
|
||||
],
|
||||
have__sys__errs=yes,
|
||||
have__sys__errs=no
|
||||
)
|
||||
if test "$have__sys__errs" = yes; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[HAVE__SYS__ERRS],
|
||||
[1],
|
||||
[Define to 1 if the _sys_errs array is available.]
|
||||
)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check if getopt_long exists and works
|
||||
AC_MSG_CHECKING([if getopt_long exists and works])
|
||||
AC_TRY_LINK(
|
||||
@@ -780,45 +864,26 @@ else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
# Check for Solaris curses tputs having fixed length parameter list.
|
||||
AC_MSG_CHECKING([if we are using non varargs tparm.])
|
||||
AC_COMPILE_IFELSE(
|
||||
[
|
||||
AC_LANG_PROGRAM(
|
||||
[
|
||||
#if HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
# Check if del_curterm is broken - in that case we redefine
|
||||
# del_curterm as a no-op, to avoid a double-free
|
||||
|
||||
#if HAVE_TERM_H
|
||||
#include <term.h>
|
||||
#elif HAVE_NCURSES_TERM_H
|
||||
#include <ncurses/term.h>
|
||||
#endif
|
||||
],
|
||||
[
|
||||
tparm( "" );
|
||||
]
|
||||
AC_MSG_CHECKING([If del_curterm is broken])
|
||||
case $target_os in
|
||||
*bsd*)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[HAVE_BROKEN_DEL_CURTERM],
|
||||
[1],
|
||||
[del_curterm is broken, redefine it to a no-op to avoid a double-free bug]
|
||||
)
|
||||
],
|
||||
[tparm_solaris_kludge=no],
|
||||
[tparm_solaris_kludge=yes]
|
||||
)
|
||||
if test "x$tparm_solaris_kludge" = "xyes"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(
|
||||
[TPARM_SOLARIS_KLUDGE],
|
||||
[1],
|
||||
[Define to 1 if tparm accepts a fixed amount of paramters.]
|
||||
)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Tell the world what we know
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_FILES([Makefile fish.spec])
|
||||
AC_OUTPUT
|
||||
|
||||
if test ! x$local_found_posix_switch = xyes; then
|
||||
|
||||
@@ -1,262 +0,0 @@
|
||||
# Formatting guide for fish docs
|
||||
|
||||
The fish documentation has been updated to support Doxygen 1.8.7+, and while the main benefit of this change is extensive Markdown support, the addition of a fish lexicon and syntax filter, combined with semantic markup rules allows for automatic formatting enhancements across the HTML user_docs, the developer docs and the man pages.
|
||||
|
||||
Initially my motivation was to fix a problem with long options ([Issue #1557](https://github.com/fish-shell/fish-shell/issues/1557) on GitHub), but as I worked on fixing the issue I realised there was an opportunity to simplify, reinforce and clarify the current documentation, hopefully making further contribution easier and cleaner, while allowing the documentation examples to presented more clearly with less author effort.
|
||||
|
||||
While the documentation is pretty robust to variations in the documentation source, adherence to the following style guide will help keep the already excellent documention in good shape moving forward.
|
||||
|
||||
## Line breaks and wrapping
|
||||
|
||||
Contrary to the rest of the fish source code, the documentation greatly benefits from the use of long lines and soft wrapping. It allows paragraphs to be treated as complete blocks by Doxygen, means that the semantic filter can see complete lines when deciding on how to apply syntax highlighting, and means that man pages will consistently wrap to the width of the users console in advanced pagers, such as 'most'.
|
||||
|
||||
## Doxygen special commands and aliases
|
||||
|
||||
While Markdown syntax forms the basis of the documentation content, there are some exceptions that require the use of Doxygen special commands. On the whole, Doxygen commands should be avoided, especially inline word formatting such as \\c as this would allow Doxygen to make unhelpful assumptions, such as converting double dashes (\--) to n-dashes (–).
|
||||
|
||||
### Structure: \\page, \\section and \\subsection
|
||||
|
||||
Use of Doxygen sections markers are important, as these determine what will be eventually output as a web page, man page or included in the developer docs.
|
||||
|
||||
Currently the make process for the documentation is quite convoluted, but basically the HTML docs are produced from a single, compiled file, doc.h. This contains a number of \\page markers that produce the various pages used in the documentation. The format of a \\page mark is:
|
||||
|
||||
\page universally_unique_page_id Page title
|
||||
|
||||
The source files that contain the page markers are currently:
|
||||
|
||||
- __index.hdr.in__: Core documentation
|
||||
- __commands.hdr.in__: Individual commands
|
||||
- __tutorial.hdr__: Tutorial
|
||||
- __design.hdr__: Design document
|
||||
- __faq.hdr__: Frequently Asked Questions
|
||||
- __license.hdr__: Fish and 3rd party licences
|
||||
|
||||
Unless there is a _VERY_ good reason and developer consensus, new pages should never be added.
|
||||
|
||||
The rest of the documentation is structured using \\section and \\subsection markers. Most of the source files (listed above) contain their full content, the exception being commands, which are separated out into source text files in the doc_src directory. These files are concatenated into one file, so each one starts with a \\section declaration. The synopsis, description and examples (if present) are declared as \\subsections. The format of these marks is practically identical to the page mark.
|
||||
|
||||
\section universally_unique_section_id Section title
|
||||
\subsection universally_unique_subsection_id Subsection title
|
||||
|
||||
Each page, section and subsection id _must_ be unique across the whole of the documentation, otherwise Doxygen will issue a warning.
|
||||
|
||||
### Semantic markup: the \\fish .. \\endfish block
|
||||
|
||||
While Doxygen has support for \\code..\\endcode blocks with enhanced markup and syntax colouring, it only understands the core Doxygen languages: C, C++, Objective C, Java, PHP, Python, Tcl and Fortran. To enhance Fish's syntax presentation, use the special \\fish..\\endfish blocks instead.
|
||||
|
||||
Text placed in this block will be parsed by Doxygen using the included lexicon filter (see lexicon_filter.in) as a Doxygen input filter. The filter is built during make so that it can pick up information on builtins, functions and shell commands mentioned in completions and apply markup to keywords found inside the \\fish block.
|
||||
|
||||
Basically, preformatted plain text inside the \\fish block is fed through the filter and is returned marked up so that Doxygen aliases can convert it back to a presentable form, according to the output document type.
|
||||
|
||||
For instance:
|
||||
|
||||
`echo hello world`
|
||||
|
||||
is transformed into:
|
||||
|
||||
`@cmnd{echo} @args{hello} @args{world}`
|
||||
|
||||
which is then transformed by Doxygen into an HTML version (`make user_doc`):
|
||||
|
||||
`<span class="command">echo</span> <span class="argument">hello</span> <span class="argument">world</span>`
|
||||
|
||||
A man page version (`make share/man`):
|
||||
|
||||
__echo__ hello world
|
||||
|
||||
And a simple HTML version for the developer docs (`make doc`) and the LATEX/PDF manual (`make doc/refman.pdf`):
|
||||
|
||||
`echo hello world`
|
||||
|
||||
### Fonts
|
||||
|
||||
In older browsers, it was easy to set the fonts used for the three basic type styles (serif, sans-serif and monospace). Modern browsers have removed these options in their respective quests for simplification, assuming the content author will provide suitable styles for the content in the site's CSS, or the end user will provide overriding styles manually. Doxygen's default styling is very simple and most users will just accept this default.
|
||||
|
||||
I've tried to use a sensible set of fonts in the documentation's CSS based on 'good' terminal fonts and as a result the firt preference font used throughout the documentation is '[DejaVu](http://dejavu-fonts.org)'. The rationale behaind this is that while DejaVu is getting a little long in the tooth, it still provides the most complete support across serif, sans-serif and monospace styles (giving a well balanced feel and consistent [x-height](http://en.wikipedia.org/wiki/X-height)), has the widest support for extended Unicode characters and has a free, permissive licenses (though it's still incompatible with GPLv2, though arguably less so than the SIL Open Font license, though this is a moot point when using it solely in the docs).
|
||||
|
||||
#### Fonts inside \\fish blocks and \`backticks\`
|
||||
|
||||
As the point of these contructs is to make fish's syntax clearer to the user, it makes sense to mimic what the user will see in the console, therefore any content is formatted using the monospaced style, specifically monospaced fonts are chosen in the following order:
|
||||
|
||||
1. __DejaVu Sans Mono__: Explained above. [[↓](http://dejavu-fonts.org)]
|
||||
2. __Source Code Pro__: Monospaced code font, part of Adobe's free Edge Web Fonts. [[↓](https://edgewebfonts.adobe.com)]
|
||||
3. __Menlo__: Apple supplied variant of DejaVu.
|
||||
4. __Ubuntu Mono__: Ubuntu Linux's default monospaced font. [[↓](http://font.ubuntu.com)]
|
||||
5. __Consolas__: Modern Microsoft supplied console font.
|
||||
6. __Monaco__: Apple supplied console font since 1984!
|
||||
7. __Lucida Console__: Generic mono terminal font, standard in many OS's and distros.
|
||||
8. __monospace__: Catchall style. Chooses default monospaced font, often Courier.
|
||||
9. __fixed__: As above, more often used on mobile devices.
|
||||
|
||||
#### General Fonts
|
||||
|
||||
1. __DejaVu Sans__: As above.[[↓](http://dejavu-fonts.org)]
|
||||
2. __Roboto__: Elegant Google free font and is Doxygen's default [[↓](http://www.google.com/fonts/specimen/Roboto)]
|
||||
3. __Lucida Grande__: Default Apple OS X content font.
|
||||
4. __Calibri__: Default Microsoft Office font (since 2007).
|
||||
5. __Verdana__: Good general font found in a lot of OSs.
|
||||
6. __Helvetica Neue__: Better spaced and balanced Helvetica/Arial variant.
|
||||
7. __Helvetica__: Standard humanist typeface found almost everywhere.
|
||||
8. __Arial__: Microsoft's Helvetica.
|
||||
9. __sans-serif__: Catchall style. Chooses default sans-serif typeface, often Helvetica.
|
||||
|
||||
The ordering of the fonts is important as it's designed to allow the documentation to settle into a number of different identities according to the fonts available. If you have the complete DejaVu family installed, then the docs are presented using that, and if your Console is set up to use the same fonts, presentation will be completely consistent.
|
||||
|
||||
On OS X, with nothing extra installed, the docs will default to Menlo and Lucida Grande giving a Mac feel. Under Windows, it will default to using Consolas and Calibri on recent versions, giving a modern Windows style.
|
||||
|
||||
#### Other sources:
|
||||
|
||||
- [Font Squirrel](http://www.fontsquirrel.com): Good source of open source font packages.
|
||||
|
||||
### Choosing a CLI style: using a \\fish{style} block
|
||||
|
||||
By default, when output as HTML, a \\fish block uses syntax colouring suited to the style of the documentation rather than trying to mimic the terminal. The block has a light, bordered background and a colour scheme that 'suggests' what the user would see in a console.
|
||||
|
||||
Additional stying can be applied adding a style declaration:
|
||||
|
||||
\fish{additional_style [another_style...]}
|
||||
...
|
||||
\endfish
|
||||
|
||||
This will translate to classes applied to the `<div>` tag, like so:
|
||||
|
||||
<div class="fish additional_style another_style">
|
||||
...
|
||||
</div>
|
||||
|
||||
The various classes are defined in `doc_src/user_doc.css` and new style can be simply added
|
||||
|
||||
The documentation currently defines a couple of additional styles:
|
||||
|
||||
- __cli-dark__: Used in the _tutorial_ and _FAQ_ to simulate a dark background terminal, with fish's default colours (slightly tweaked for legibility in the browser).
|
||||
|
||||
- __synopsis__: A simple colour theme helpful for displaying the logical 'summary' of a command's syntax, options and structure.
|
||||
|
||||
## Markdown
|
||||
|
||||
Apart from the exceptions discussed above, the rest of the documentation now supports the use of Markdown. As such the use of Doxygen special commands for HTML tags is unnecessary.
|
||||
|
||||
There are a few exceptions and extensions to the Markdown [standard](http://daringfireball.net/projects/markdown/) that are documented in the Doxygen [documentation](http://www.stack.nl/~dimitri/doxygen/manual/markdown.html).
|
||||
|
||||
### \`Backticks\`
|
||||
|
||||
As is standard in Markdown and 'Github Flavoured Markdown' (GFM), backticks can be used to denote inline technical terms in the documentation, `like so`. In the documentation this will set the font to the monospaced 'console' typeface and will cause the enclosed term to stand out.
|
||||
|
||||
However, fenced code blocks using 4 spaces or 3 backticks (\`\`\`) should be avoided as Doxygen will interpret these as \\code blocks and try to apply standard syntax colouring, which doesn't work so well for fish examples. Use `\fish..\endfish` blocks instead.
|
||||
|
||||
### Lists
|
||||
|
||||
Standard Markdown list rules apply, but as Doxygen will collapse white space on output, combined with the use of long lines, it's a good idea to include an extra new line between long list items to assist future editing.
|
||||
|
||||
## Special cases
|
||||
|
||||
The following can be used in \\fish blocks to render some fish scenarios. These are mostly used in the tutorial when an interactive situation needs to be displayed.
|
||||
|
||||
### Custom formatting tags
|
||||
|
||||
- `<s>`: auto\<s\>suggestion\</s\>.
|
||||
- `<m>`: \<m\>Matched\</m\> items, such as tab completions.
|
||||
- `<sm>`: Matched items \<sm\>searched\<sm\> for, like grep results.
|
||||
- `<error>`: \<error\>This would be shown as an error.\</error\>
|
||||
- `<asis>`: \<asis\>This test will not be parsed for fish markup.\</asis\>
|
||||
- `<outp>`: \<outp\>This would be rendered as command/script output.\</outp\>
|
||||
|
||||
### Prompts and cursors
|
||||
|
||||
- `>_`: Display a basic prompt.
|
||||
- `~>_`: Display a prompt with a the home directory as the current working directory.
|
||||
- `___` (3 underscores): Display a cursor.
|
||||
|
||||
|
||||
### Keyboard shortcuts: @key{} and @cursor_key{}
|
||||
|
||||
Graphical keyboard shortcuts can be defined using the following special commands. These allow for the different text requirements across the html and man pages. The HTML uses CSS to create a keyboard style, whereas the man page would display the key as text.
|
||||
|
||||
- `@key{lable}`
|
||||
Displays a key with a purely textual lable, such as: 'Tab', 'Page Up', 'Page Down', 'Home', 'End', 'F1', 'F19' and so on.
|
||||
|
||||
- `@key{modifier,lable}`
|
||||
Displays a keystroke requiring the use of a 'modifier' key, such as 'Control-A', 'Shift-X', 'Alt-Tab' etc.
|
||||
|
||||
- `@key{modifier,entity,lable}`
|
||||
Displays a keystroke using a graphical entity, such as an arrow symbol for cursor key based shortcuts.
|
||||
|
||||
- `@cursor_key{entity,lable}`
|
||||
A special case for cursor keys, when no modifier is needed. i.e. `@cursor_key{↑,up}` for the up arrow key.
|
||||
|
||||
Some useful Unicode/HTML5 entities:
|
||||
|
||||
- Up arrow: `↑`
|
||||
- Down arrow: `↓`
|
||||
- Left arrow: `←`
|
||||
- Right arrow `→`
|
||||
- Shift: `⇧`
|
||||
- Tab: `⇥`
|
||||
- Mac option: `⌥`
|
||||
- Mac command: `⌘`
|
||||
|
||||
## Notes
|
||||
|
||||
### Doxygen
|
||||
|
||||
Tested on:
|
||||
- Ubuntu 14.04 with Doxygen 1.8.8, built from [GitHub source](https://github.com/doxygen/doxygen.git).
|
||||
- CentOS 6.5 with Doxygen 1.8.8, built from [GitHub source](https://github.com/doxygen/doxygen.git).
|
||||
- Mac OS X 10.9 with Homebrew install Doxygen 1.8.7 and 1.8.8.
|
||||
|
||||
Graphviz was also installed in all the above testing.
|
||||
|
||||
Doxygen 1.8.6 and lower do not have the \\htmlonly[block] directive which fixes a multitude of problems in the rendering of the docs. In Doxygen 1.8.7 the list of understood HTML entities was greatly increased. I tested earlier versions and many little issues returned.
|
||||
|
||||
As fish ships with pre-built documentation, I don't see this as an issue.
|
||||
|
||||
### Updated Configure/Makefile
|
||||
|
||||
- Tested on Ubuntu 14.04, CentOS 6.5 and Mac OS X 10.9.
|
||||
- Makefile has GNU/BSD sed/grep detection.
|
||||
|
||||
### HTML output
|
||||
|
||||
- The output HTML is HTML5 compliant, but should quickly and elegantly degrade on older browsers without losing basic structure.
|
||||
- The CSS avoids the use or browser specific extenstions (i.e. -webkit, -moz etc), using the W3C HTML5 standard instead.
|
||||
- It's been tested in Chrome 37.0 and Firefox 32.0 on Mac OS X 10.9 (+Safari 7), Windows 8.1 (+Internet Explorer 11) and Ubuntu Desktop 14.04.
|
||||
- My assumption is basically that if someone cares enough to want to install fish, they'll be keeping a browser current.
|
||||
|
||||
### Man page output
|
||||
|
||||
- Tested on Ubuntu 14.04, CentOS 6.5 and Mac OS X 10.9.
|
||||
- Output is substantially cleaner.
|
||||
- Tested in cat, less, more and most pagers using the following fish script:
|
||||
|
||||
```
|
||||
function manTest --description 'Test manpage' --argument page
|
||||
set -l pager
|
||||
for i in $argv
|
||||
switch $i
|
||||
case "-l"
|
||||
set pager -P '/usr/bin/less -is'
|
||||
case "-m"
|
||||
set pager -P '/usr/bin/more -s'
|
||||
case "-c"
|
||||
set pager -P '/bin/cat'
|
||||
end
|
||||
end
|
||||
man $pager ~/Projects/OpenSource/fish-shell/share/man/man1/$page.1
|
||||
end
|
||||
|
||||
# Assumes 'most' is the default system pager.
|
||||
# NOT PORTABLE! Paths would be need to be updated on other systems.
|
||||
```
|
||||
|
||||
### Developer docs and LATEX/PDF output
|
||||
|
||||
- HTML developer docs tested on Ubuntu 14.04, CentOS 6.5 and Mac OS X 10.9.
|
||||
- LATEX/PDF reference manual tested on Mac OS X 10.9 using MacTEX. PDF production returns an error (due to Doxygen's use of an outdated 'float' package), but manual PDF output is ok.
|
||||
|
||||
### Future changes
|
||||
|
||||
1. The documentation creation process would be better if it could be modularised further and moved out of the makefile into a number of supporting scripts. This would allow both the automake and Xcode build processes to use the documentation scripts directly.
|
||||
2. Remove the Doxygen dependency entirely for the user documentation. This would be very acheivable now that the bulk of the documentation is in Markdown.
|
||||
3. It would be useful to gauge what parts of the documentation are actually used by users. Judging by the amount of 'missing comment' errors during the developer docs build phase, this aspect of the docs has been rather neglected. If it is not longer used or useful, then this could change the future direction of the documentation and significantly streamline the process.
|
||||
|
||||
#### Author: Mark Griffiths [@GitHub](https://github.com/MarkGriffiths)
|
||||
@@ -1,44 +0,0 @@
|
||||
\section abbr abbr - manage fish abbreviations
|
||||
|
||||
\subsection abbr-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
abbr -a word="phrase"
|
||||
abbr -s
|
||||
abbr -l
|
||||
abbr -e word
|
||||
\endfish
|
||||
|
||||
\subsection abbr-description Description
|
||||
|
||||
`abbr` manipulates the list of abbreviations that fish will expand.
|
||||
|
||||
Abbreviations are user-defined character sequences or words that are replaced with longer phrases after they are entered. For example, a frequently-run command such as `git checkout` can be abbreviated to `gco`. After entering `gco` and pressing @key{Space} or @key{Enter}, the full text `git checkout` will appear in the command line.
|
||||
|
||||
Abbreviations are stored, by default, in a universal variable.
|
||||
|
||||
The following parameters are available:
|
||||
|
||||
- `-a WORD PHRASE` or `--add WORD PHRASE` Adds a new abbreviation, where WORD will be expanded to PHRASE.
|
||||
|
||||
- `-s` or `--show` Show all abbreviated words and their expanded phrases in a manner suitable for export and import.
|
||||
|
||||
- `-l` or `--list` Lists all abbreviated words.
|
||||
|
||||
- `-e WORD` or `--erase WORD` Erase the abbreviation WORD.
|
||||
|
||||
\subsection abbr-example Examples
|
||||
|
||||
\fish
|
||||
abbr -a gco git checkout
|
||||
\endfish
|
||||
Add a new abbreviation where `gco` will be replaced with `git checkout`.
|
||||
|
||||
\fish
|
||||
abbr -e gco
|
||||
\endfish
|
||||
Erase the `gco` abbreviation.
|
||||
|
||||
\fish
|
||||
ssh another_host abbr -s | source
|
||||
\endfish
|
||||
Import the abbreviations defined on another_host over SSH.
|
||||
@@ -1,34 +1,34 @@
|
||||
\section alias alias - create a function
|
||||
|
||||
\subsection alias-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
alias NAME DEFINITION
|
||||
alias NAME=DEFINITION
|
||||
\endfish
|
||||
<pre>alias NAME DEFINITION
|
||||
alias NAME=DEFINITION</pre>
|
||||
|
||||
\subsection alias-description Description
|
||||
|
||||
`alias` is a simple wrapper for the `function` builtin. It exists for backwards compatibility with Posix shells. For other uses, it is recommended to define a <a href='#function'>function</a>.
|
||||
\c alias is a simple wrapper for the \c function builtin.
|
||||
It exists for backwards compatibility with Posix
|
||||
shells. For other uses, it is recommended to define a <a
|
||||
href='#function'>function</a>.
|
||||
|
||||
`fish` does not keep track of which functions have been defined using `alias`. They must be erased using `functions -e`.
|
||||
\c fish does not keep track of which functions have been defined using
|
||||
\c alias. They must be erased using <code>functions -e</code>.
|
||||
|
||||
- `NAME` is the name of the alias
|
||||
|
||||
- `DEFINITION` is the actual command to execute. The string `$argv` will be appended.
|
||||
- NAME is the name of the alias
|
||||
- DEFINITION is the actual command to execute. The string " $argv" will be appended.
|
||||
|
||||
You cannot create an alias to a function with the same name.
|
||||
|
||||
|
||||
\subsection alias-example Example
|
||||
|
||||
The following code will create `rmi`, which runs `rm` with additional arguments on every invocation.
|
||||
The following code will create \c rmi, which runs \c rm with additional
|
||||
arguments on every invocation.
|
||||
|
||||
\fish
|
||||
alias rmi "rm -i"
|
||||
<code>alias rmi "rm -i"</code>
|
||||
|
||||
# This is equivalent to entering the following function:
|
||||
This is equivalent to entering the following function:
|
||||
|
||||
function rmi
|
||||
<pre>function rmi
|
||||
rm -i $argv
|
||||
end
|
||||
\endfish
|
||||
end</pre>
|
||||
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
\section and and - conditionally execute a command
|
||||
|
||||
\subsection and-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
COMMAND1; and COMMAND2
|
||||
\endfish
|
||||
<tt>COMMAND1; and COMMAND2</tt>
|
||||
|
||||
\subsection and-description Description
|
||||
|
||||
`and` is used to execute a command if the current exit status (as set by the last previous command) is 0.
|
||||
\c and is used to execute a command if the current exit
|
||||
status (as set by the last previous command) is 0.
|
||||
|
||||
`and` does not change the current exit status.
|
||||
|
||||
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
|
||||
\c and does not change the current exit status.
|
||||
|
||||
The exit status of the last foreground command to exit can always be
|
||||
accessed using the <a href="index.html#variables-status">$status</a>
|
||||
variable.
|
||||
|
||||
\subsection and-example Example
|
||||
|
||||
The following code runs the `make` command to build a program. If the build succeeds, `make`'s exit status is 0, and the program is installed. If either step fails, the exit status is 1, and `make clean` is run, which removes the files created by the build process.
|
||||
The following code runs the \c make command to build a program. If the
|
||||
build succeeds, <code>make</code>'s exit status is 0, and the program is installed. If either step fails,
|
||||
the exit status is 1, and <tt>make clean</tt> is run, which removes the files created by the.
|
||||
build process.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
make; and make install; or make clean
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
@@ -1,45 +1,49 @@
|
||||
\section begin begin - start a new block of code
|
||||
|
||||
\subsection begin-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
begin; [COMMANDS...;] end
|
||||
\endfish
|
||||
<tt>begin; [COMMANDS...;] end</tt>
|
||||
|
||||
\subsection begin-description Description
|
||||
|
||||
`begin` is used to create a new block of code.
|
||||
\c begin is used to create a new block of code.
|
||||
|
||||
The block is unconditionally executed. `begin; ...; end` is equivalent to `if true; ...; end`.
|
||||
The block
|
||||
is unconditionally executed. <code>begin; ...; end</tt> is equivalent
|
||||
to <tt>if true; ...; end</tt>.
|
||||
|
||||
`begin` is used to group a number of commands into a block. This allows the introduction of a new variable scope, redirection of the input or output of a set of commands as a group, or to specify precedence when using the conditional commands like `and`.
|
||||
|
||||
`begin` does not change the current exit status.
|
||||
\c begin is used to group a number of commands into a block.
|
||||
This allows the introduction of a new variable scope, redirection of the input or
|
||||
output of a set of commands as a group, or to specify precedence when
|
||||
using the conditional commands like \c and.
|
||||
|
||||
\c begin does not change the current exit status.
|
||||
|
||||
\subsection begin-example Example
|
||||
|
||||
The following code sets a number of variables inside of a block scope. Since the variables are set inside the block and have local scope, they will be automatically deleted when the block ends.
|
||||
The following code sets a number of variables inside of a block
|
||||
scope. Since the variables are set inside the block and have local
|
||||
scope, they will be automatically deleted when the block ends.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
begin
|
||||
set -l PIRATE Yarrr
|
||||
...
|
||||
set -l PIRATE Yarrr
|
||||
...
|
||||
end
|
||||
|
||||
# This will not output anything, since the PIRATE variable went out
|
||||
# of scope at the end of the block
|
||||
echo $PIRATE
|
||||
# This will not output anything, since the PIRATE variable
|
||||
# went out of scope at the end of the block
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
In the following code, all output is redirected to the file out.html.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
begin
|
||||
echo $xml_header
|
||||
echo $html_header
|
||||
if test -e $file
|
||||
...
|
||||
end
|
||||
...
|
||||
end > out.html
|
||||
\endfish
|
||||
echo $xml_header
|
||||
echo $html_header
|
||||
if test -e $file
|
||||
...
|
||||
end
|
||||
...
|
||||
|
||||
end > out.html
|
||||
</pre>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
\section bg bg - send jobs to background
|
||||
|
||||
\subsection bg-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
bg [PID...]
|
||||
\endfish
|
||||
<tt>bg [PID...]</tt>
|
||||
|
||||
\subsection bg-description Description
|
||||
|
||||
`bg` sends <a href="index.html#syntax-job-control">jobs</a> 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 with the specified process group IDs are put in the background.
|
||||
\c bg sends <a href="index.html#syntax-job-control">jobs</a> 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 with the specified process group IDs are put in the background.
|
||||
|
||||
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.
|
||||
|
||||
|
||||
\subsection bg-example Example
|
||||
|
||||
`bg %1` will put the job with job ID 1 in the background.
|
||||
<tt>bg \%1</tt> will put the job with job ID 1 in the background.
|
||||
|
||||
|
||||
149
doc_src/bind.txt
149
doc_src/bind.txt
@@ -1,125 +1,64 @@
|
||||
\section bind bind - handle fish key bindings
|
||||
|
||||
\subsection bind-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
bind [(-M | --mode) MODE] [(-m | --sets-mode) NEW_MODE]
|
||||
[(-k | --key)] SEQUENCE COMMAND [COMMAND...]
|
||||
bind [(-M | --mode) MODE] [(-k | --key)] SEQUENCE
|
||||
bind (-K | --key-names) [(-a | --all)]
|
||||
bind (-f | --function-names)
|
||||
bind (-e | --erase) [(-M | --mode) MODE]
|
||||
(-a | --all | [(-k | --key)] SEQUENCE [SEQUENCE...])
|
||||
\endfish
|
||||
<tt>bind [OPTIONS] SEQUENCE COMMAND</tt>
|
||||
|
||||
\subsection bind-description Description
|
||||
|
||||
`bind` adds a binding for the specified key sequence to the specified command.
|
||||
<tt>bind</tt> adds a binding for the specified key sequence to the
|
||||
specified command.
|
||||
|
||||
SEQUENCE is the character sequence to bind to. These should be written as <a href="index.html#escapes">fish escape sequences</a>. For example, because pressing the Alt key and another character sends that character prefixed with an escape character, Alt-based key bindings can be written using the `\e` escape. For example, @key{Alt,w} can be written as `\ew`. The control character can be written in much the same way using the `\c` escape, for example @key{Control,X} (^X) can be written as `\cx`. Note that Alt-based key bindings are case sensitive and Control-based key bindings are not. This is a constraint of text-based terminals, not `fish`.
|
||||
SEQUENCE is the character sequence to bind to. These should be written as
|
||||
<a href="index.html#escapes">fish escape sequences</a>. For example, because pressing
|
||||
the Alt key and another character sends that character prefixed with
|
||||
an escape character, Alt-based key bindings can be written using the
|
||||
\c \\e escape. For example, Alt-w can be written as
|
||||
<tt>\\ew</tt>. The control character can be written in much the same way
|
||||
using the \c \\c escape, for example Control-x (^X) can be written as
|
||||
<tt>\\cx</tt>. Note that Alt-based key bindings are case sensitive and
|
||||
Control-based key bindings are not. This is a constraint of text-based
|
||||
termainls, not \c fish.
|
||||
|
||||
The default key binding can be set by specifying a `SEQUENCE` of the empty string (that is, ```''``` ). It will be used whenever no other binding matches. For most key bindings, it makes sense to use the `self-insert` function (i.e. ```bind '' self-insert```) as the default keybinding. This will insert any keystrokes not specifically bound to into the editor. Non- printable characters are ignored by the editor, so this will not result in control sequences being printable.
|
||||
The default key binding can be set by specifying a SEQUENCE of the empty
|
||||
string (that is, <code>''</code>). It will be used whenever no
|
||||
other binding matches. For most key bindings, it makes sense to use
|
||||
the \c self-insert function (i.e. <tt>bind '' self-insert</tt> as the
|
||||
default keybinding. This will insert any keystrokes not specifically
|
||||
bound to into the editor. Non-printable characters are ignored by the
|
||||
editor, so this will not result in control sequences being
|
||||
printable.
|
||||
|
||||
If the `-k` switch is used, the name of the 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.)
|
||||
If the -k switch is used, the name of the 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 \c terminfo(5) for more information, or use <tt>bind
|
||||
--key-names</tt> for a list of all available named keys.)
|
||||
|
||||
`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.
|
||||
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 <a href="#function">function</a> 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 <a href="#function">function</a> 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 such a script produces output, the script needs to finish by calling `commandline -f repaint` in order to tell fish that a repaint is in order.
|
||||
|
||||
When multiple `COMMAND`s are provided, they are all run in the specified order when the key is pressed.
|
||||
|
||||
If no `SEQUENCE` is provided, all bindings (or just the bindings in the specified `MODE`) are printed. If `SEQUENCE` is provided without `COMMAND`, just the binding matching that sequence is printed.
|
||||
|
||||
Key bindings are not saved between sessions by default. To save custom keybindings, edit the `fish_user_key_bindings` function and insert the appropriate `bind` statements.
|
||||
|
||||
Key bindings may use "modes", which mimics Vi's modal input behavior. The default mode is "default", and every bind applies to a single mode. The mode can be viewed/changed with the `$fish_bind_mode` variable.
|
||||
Key bindings are not saved between sessions by default. To save custom
|
||||
keybindings, edit the \c fish_user_key_bindings function and insert the
|
||||
appropirate \c bind statements.
|
||||
|
||||
The following parameters are available:
|
||||
|
||||
- `-k` or `--key` Specify a key name, such as 'left' or 'backspace' instead of a character sequence
|
||||
|
||||
- `-K` or `--key-names` Display a list of available key names. Specifying `-a` or `--all` includes keys that don't have a known mapping
|
||||
|
||||
- `-f` or `--function-names` Display a list of available input functions
|
||||
|
||||
- `-M MODE` or `--mode MODE` Specify a bind mode that the bind is used in. Defaults to "default"
|
||||
|
||||
- `-m NEW_MODE` or `--sets-mode NEW_MODE` Change the current mode to `NEW_MODE` after this binding is executed
|
||||
|
||||
- `-e` or `--erase` Erase the binding with the given sequence and mode instead of defining a new one. Multiple sequences can be specified with this flag. Specifying `-a` or `--all` with `-M` or `--mode` erases all binds in the given mode regardless of sequence. Specifying `-a` or `--all` without `-M` or `--mode` erases all binds in all modes regardless of sequence.
|
||||
|
||||
- `-a` or `--all` See `--erase` and `--key-names`
|
||||
|
||||
The following special input functions are available:
|
||||
|
||||
- `backward-char`, moves one character to the left
|
||||
|
||||
- `backward-delete-char`, deletes one character of input to the left of the cursor
|
||||
|
||||
- `backward-kill-line`, move everything from the beginning of the line to the cursor to the killring
|
||||
|
||||
- `backward-kill-word`, move the word to the left of the cursor to the killring
|
||||
|
||||
- `backward-word`, move one word to the left
|
||||
|
||||
- `beginning-of-history`, move to the beginning of the history
|
||||
|
||||
- `beginning-of-line`, move to the beginning of the line
|
||||
|
||||
- `capitalize-word`, make the current word begin with a capital letter
|
||||
|
||||
- `complete`, guess the remainder of the current token
|
||||
|
||||
- `delete-char`, delete one character to the right of the cursor
|
||||
|
||||
- `delete-line`, delete the entire line
|
||||
|
||||
- `downcase-word`, make the current word lowercase
|
||||
|
||||
- `dump-functions`, print a list of all key-bindings
|
||||
|
||||
- `end-of-history`, move to the end of the history
|
||||
|
||||
- `end-of-line`, move to the end of the line
|
||||
|
||||
- `explain`, print a description of possible problems with the current command
|
||||
|
||||
- `forward-char`, move one character to the right
|
||||
|
||||
- `forward-word`, move one word to the right
|
||||
|
||||
- `history-search-backward`, search the history for the previous match
|
||||
|
||||
- `history-search-forward`, search the history for the next match
|
||||
|
||||
- `kill-line`, move everything from the cursor to the end of the line to the killring
|
||||
|
||||
- `kill-whole-line`, move the line to the killring
|
||||
|
||||
- `kill-word`, move the next word to the killring
|
||||
|
||||
- `upcase-word`, make the current word uppercase
|
||||
|
||||
- `yank`, insert the latest entry of the killring into the buffer
|
||||
|
||||
- `yank-pop`, rotate to the previous entry of the killring
|
||||
|
||||
- <tt>-k</tt> or <tt>--key</tt> Specify a key name, such as 'left' or 'backspace' instead of a character sequence
|
||||
- <tt>-K</tt> or <tt>--key-names</tt> Display a list of available key names
|
||||
- <tt>-f</tt> or <tt>--function-names</tt> Display a list of available input functions
|
||||
|
||||
\subsection bind-example Examples
|
||||
|
||||
\fish
|
||||
bind \cd 'exit'
|
||||
\endfish
|
||||
Causes `fish` to exit when @key{Control,D} is pressed.
|
||||
<tt>bind \\cd 'exit'</tt> causes \c fish to exit when Control-d is pressed.
|
||||
|
||||
\fish
|
||||
bind -k ppage history-search-backward
|
||||
\endfish
|
||||
Performs a history search when the @key{Page Up} key is pressed.
|
||||
<tt>bind -k ppage history-search-backward</tt> performs a history search when the Page Up key is pressed.
|
||||
|
||||
\fish
|
||||
set -g fish_key_bindings fish_vi_key_bindings
|
||||
bind -M insert \cc kill-whole-line force-repaint
|
||||
\endfish
|
||||
Turns on Vi key bindings and rebinds @key{Control,C} to clear the input line.
|
||||
|
||||
@@ -1,41 +1,40 @@
|
||||
\section block block - temporarily block delivery of events
|
||||
|
||||
\subsection block-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
block [OPTIONS...]
|
||||
\endfish
|
||||
<tt>block [OPTIONS...]</tt>
|
||||
|
||||
\subsection block-description Description
|
||||
|
||||
`block` prevents events triggered by `fish` or the <a href="commands.html#emit">`emit`</a> command from being delivered and acted upon while the block is in place.
|
||||
\c block prevents events triggered by \c fish or the
|
||||
<a href="commands.html#emit"><code>emit</code></a> command from
|
||||
being delivered and acted upon while the block is in place.
|
||||
|
||||
In functions, `block` can be useful while performing work that should not be interrupted by the shell.
|
||||
In functions, \c block can be useful while performing work that
|
||||
should not be interrupted by the shell.
|
||||
|
||||
The block can be removed. Any events which triggered while the block was in place will then be delivered.
|
||||
The block can be removed. Any events which triggered while the
|
||||
block was in place will then be delivered.
|
||||
|
||||
Event blocks should not be confused with code blocks, which are created with `begin`, `if`, `while` or `for`
|
||||
Event blocks should not be confused with code blocks, which are created
|
||||
with <code>begin</code>, <code>if</code>, <code>while</code> or
|
||||
<code>for</code>
|
||||
|
||||
The following parameters are available:
|
||||
|
||||
- `-l` or `--local` Release the block automatically at the end of the current innermost code block scope
|
||||
|
||||
- `-g` or `--global` Never automatically release the lock
|
||||
|
||||
- `-e` or `--erase` Release global block
|
||||
|
||||
- <tt>-l</tt> or <tt>--local</tt> Release the block automatically at the end of the current innermost code block scope
|
||||
- <tt>-g</tt> or <tt>--global</tt> Never automatically release the lock
|
||||
- <tt>-e</tt> or <tt>--erase</tt> Release global block
|
||||
|
||||
\subsection block-example Example
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
# Create a function that listens for events
|
||||
function --on-event foo foo; echo 'foo fired'; end
|
||||
|
||||
# Block the delivery of events
|
||||
block -g
|
||||
|
||||
emit foo
|
||||
# No output will be produced
|
||||
|
||||
block -e
|
||||
# 'foo fired' will now be printed
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
\section break break - stop the current inner loop
|
||||
|
||||
\subsection break-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end
|
||||
\endfish
|
||||
<tt>LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end</tt>
|
||||
|
||||
\subsection break-description Description
|
||||
|
||||
`break` halts a currently running loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
|
||||
|
||||
There are no parameters for `break`.
|
||||
\c break halts a currently running loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
|
||||
|
||||
There are no parameters for <code>break</code>.
|
||||
|
||||
\subsection break-example Example
|
||||
The following code searches all .c files for "smurf", and halts at the first occurrence.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
for i in *.c
|
||||
if grep smurf $i
|
||||
echo Smurfs are present in $i
|
||||
break
|
||||
end
|
||||
end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
\section breakpoint breakpoint - Launch debug mode
|
||||
|
||||
\subsection breakpoint-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
breakpoint
|
||||
\endfish
|
||||
<tt>breakpoint</tt>
|
||||
|
||||
\subsection breakpoint-description Description
|
||||
|
||||
`breakpoint` is used to halt a running script and launch an interactive debugging prompt.
|
||||
\c breakpoint is used to halt a running script and launch
|
||||
an interactive debugging prompt.
|
||||
|
||||
For more details, see <a href="index.html#debugging">Debugging fish scripts</a> in the `fish` manual.
|
||||
For more details, see <a href="index.html#debugging">Debugging fish
|
||||
scripts</a> in the \c fish manual.
|
||||
|
||||
There are no parameters for `breakpoint`.
|
||||
There are no parameters for <code>breakpoint</code>.
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
\section builtin builtin - run a builtin command
|
||||
|
||||
\subsection builtin-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
builtin BUILTINNAME [OPTIONS...]
|
||||
\endfish
|
||||
<tt>builtin BUILTINNAME [OPTIONS...]</tt>
|
||||
|
||||
\subsection builtin-description Description
|
||||
|
||||
`builtin` forces the shell to use a builtin command, rather than a function or program.
|
||||
\c builtin forces the shell to use a builtin command, rather than a function or program.
|
||||
|
||||
The following parameters are available:
|
||||
|
||||
- `-n` or `--names` List the names of all defined builtins
|
||||
|
||||
- <tt>-n</tt> or <tt>--names</tt> List the names of all defined builtins
|
||||
|
||||
\subsection builtin-example Example
|
||||
|
||||
\fish
|
||||
builtin jobs
|
||||
# executes the jobs builtin, even if a function named jobs exists
|
||||
\endfish
|
||||
<tt>builtin jobs</tt> executes the jobs builtin, even if a function named jobs exists.
|
||||
|
||||
@@ -1,27 +1,35 @@
|
||||
\section case case - conditionally execute a block of commands
|
||||
|
||||
\subsection case-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
|
||||
\endfish
|
||||
<tt>switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end</tt>
|
||||
|
||||
\subsection case-description Description
|
||||
|
||||
`switch` performs one of several blocks of commands, depending on whether a specified value equals one of several wildcarded values. `case` is used together with the `switch` statement in order to determine which block should be executed.
|
||||
\c switch performs one of several blocks of commands, depending on whether
|
||||
a specified value equals one of several wildcarded values. \c case is used
|
||||
together with the \c switch statement in order to determine which block should
|
||||
be executed.
|
||||
|
||||
Each `case` command is given one or more parameters. The first `case` command with a parameter that matches the string specified in the switch command will be evaluated. `case` parameters may contain wildcards. These need to be escaped or quoted in order to avoid regular wildcard expansion using filenames.
|
||||
Each \c case command is given one or more parameters. The first \c case
|
||||
command with a parameter that matches the string specified in the
|
||||
switch command will be evaluated. \c case parameters may contain
|
||||
wildcards. These need to be escaped or quoted in order to avoid
|
||||
regular wildcard expansion using filenames.
|
||||
|
||||
Note that fish does not fall through on case statements. Only the first matching case is executed.
|
||||
|
||||
Note that command substitutions in a case statement will be evaluated even if its body is not taken. All substitutions, including command substitutions, must be performed before the value can be compared against the parameter.
|
||||
Note that fish does not fall through on case statements. Only the
|
||||
first matching case is executed.
|
||||
|
||||
Note that command substitutions in a case statement will be
|
||||
evaluated even if its body is not taken. All substitutions, including
|
||||
command substitutions, must be performed before the value can be compared
|
||||
against the parameter.
|
||||
|
||||
\subsection case-example Example
|
||||
|
||||
If the variable \$animal contains the name of an animal, the following
|
||||
code would attempt to classify it:
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
switch $animal
|
||||
case cat
|
||||
echo evil
|
||||
@@ -35,8 +43,8 @@ switch $animal
|
||||
case '*'
|
||||
echo I have no idea what a $animal is
|
||||
end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
If the above code was run with `$animal` set to `whale`, the output
|
||||
would be `mammal`.
|
||||
If the above code was run with \c \$animal set to \c whale, the output
|
||||
would be \c mammal.
|
||||
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
\section cd cd - change directory
|
||||
|
||||
\subsection cd-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
cd [DIRECTORY]
|
||||
\endfish
|
||||
<tt>cd [DIRECTORY]</tt>
|
||||
|
||||
\subsection cd-description Description
|
||||
`cd` changes the current working directory.
|
||||
\c cd changes the current working directory.
|
||||
|
||||
If `DIRECTORY` is supplied, it will become the new directory. If no parameter is given, the contents of the `HOME` environment variable will be used.
|
||||
If \c DIRECTORY is supplied, it will become the new directory. If no parameter
|
||||
is given, the contents of the \c HOME environment variable will be used.
|
||||
|
||||
If `DIRECTORY` is a relative path, the paths found in the `CDPATH` environment variable array will be tried as prefixes for the specified path.
|
||||
|
||||
Note that the shell will attempt to change directory without requiring `cd` if the name of a directory is provided (starting with `.`, `/` or `~`, or ending with `/`).
|
||||
If \c DIRECTORY is a relative path, the paths found in the
|
||||
\c CDPATH environment variable array will be tried as prefixes for the specified
|
||||
path.
|
||||
|
||||
Note that the shell will attempt to change directory without requiring \c cd
|
||||
if the name of a directory is provided (starting with '.', '/' or '~').
|
||||
|
||||
\subsection cd-example Examples
|
||||
|
||||
\fish
|
||||
cd
|
||||
# changes the working directory to your home directory.
|
||||
\c cd changes the working directory to your home directory.
|
||||
|
||||
cd /usr/src/fish-shell
|
||||
# changes the working directory to /usr/src/fish-shell
|
||||
\endfish
|
||||
<code>cd /usr/src/fish-shell</code> changes the working directory to
|
||||
<code>/usr/src/fish-shell</code>.
|
||||
|
||||
@@ -1,24 +1,12 @@
|
||||
\section command command - run a program
|
||||
|
||||
\subsection command-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
command [OPTIONS] COMMANDNAME [ARGS...]
|
||||
\endfish
|
||||
<tt>command COMMANDNAME [OPTIONS...]</tt>
|
||||
|
||||
\subsection command-description Description
|
||||
|
||||
`command` forces the shell to execute the program `COMMANDNAME` and ignore any functions or builtins with the same name.
|
||||
\c command forces the shell to execute the program \c COMMANDNAME and ignore any functions or builtins with the same name.
|
||||
|
||||
The following options are available:
|
||||
\subsection command-example Example
|
||||
|
||||
- `-s` or `--search` returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the `$PATH`.
|
||||
|
||||
With the `-s` option, `command` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found.
|
||||
|
||||
For basic compatibility with POSIX `command`, the `-v` flag is recognized as an alias for `-s`.
|
||||
|
||||
\subsection command-example Examples
|
||||
|
||||
`command ls` causes fish to execute the `ls` program, even if an `ls` function exists.
|
||||
|
||||
`command -s ls` returns the path to the `ls` program.
|
||||
<tt>command ls</tt> causes fish to execute the \c ls program, even if an 'ls' function exists.
|
||||
|
||||
@@ -1,59 +1,63 @@
|
||||
\section commandline commandline - set or get the current command line buffer
|
||||
|
||||
\subsection commandline-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
commandline [OPTIONS] [CMD]
|
||||
\endfish
|
||||
<tt>commandline [OPTIONS] [CMD]</tt>
|
||||
|
||||
\subsection commandline-description Description
|
||||
|
||||
`commandline` can be used to set or get the current contents of the command line buffer.
|
||||
\c commandline can be used to set or get the current contents of the command
|
||||
line buffer.
|
||||
|
||||
With no parameters, `commandline` returns the current value of the command line.
|
||||
With no parameters, \c commandline returns the current value of the command
|
||||
line.
|
||||
|
||||
With `CMD` specified, the command line buffer is erased and replaced with the contents of `CMD`.
|
||||
With \c CMD specified, the command line buffer is erased and replaced with
|
||||
the contents of \c CMD.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-C` or `--cursor` set or get the current cursor position, not the contents of the buffer. If no argument is given, the current cursor position is printed, otherwise the argument is interpreted as the new cursor position.
|
||||
- \c -C or \c --cursor set or get the current cursor position, not
|
||||
the contents of the buffer. If no argument is given, the current
|
||||
cursor position is printed, otherwise the argument is interpreted
|
||||
as the new cursor position.
|
||||
- \c -f or \c --function inject readline functions into the
|
||||
reader. This option cannot be combined with any other option. It
|
||||
will cause any additional arguments to be interpreted as readline
|
||||
functions, and these functions will be injected into the reader, so
|
||||
that they will be returned to the reader before any additional
|
||||
actual key presses are read.
|
||||
|
||||
- `-f` or `--function` inject readline functions into the reader. This option cannot be combined with any other option. It will cause any additional arguments to be interpreted as readline functions, and these functions will be injected into the reader, so that they will be returned to the reader before any additional actual key presses are read.
|
||||
The following options change the way \c commandline updates the
|
||||
command line buffer:
|
||||
|
||||
The following options change the way `commandline` updates the command line buffer:
|
||||
- \c -a or \c --append do not remove the current commandline, append
|
||||
the specified string at the end of it
|
||||
- \c -i or \c --insert do not remove the current commandline, insert
|
||||
the specified string at the current cursor position
|
||||
- \c -r or \c --replace remove the current commandline and replace it
|
||||
with the specified string (default)
|
||||
|
||||
- `-a` or `--append` do not remove the current commandline, append the specified string at the end of it
|
||||
The following options change what part of the commandline is printed
|
||||
or updated:
|
||||
|
||||
- `-i` or `--insert` do not remove the current commandline, insert the specified string at the current cursor position
|
||||
- \c -b or \c --current-buffer select the entire buffer (default)
|
||||
- \c -j or \c --current-job select the current job
|
||||
- \c -p or \c --current-process select the current process
|
||||
- \c -t or \c --current-token select the current token.
|
||||
|
||||
- `-r` or `--replace` remove the current commandline and replace it with the specified string (default)
|
||||
The following options change the way \c commandline prints the current
|
||||
commandline buffer:
|
||||
|
||||
The following options change what part of the commandline is printed or updated:
|
||||
- \c -c or \c --cut-at-cursor only print selection up until the
|
||||
current cursor position
|
||||
- \c -o or \c --tokenize tokenize the selection and print one string-type token per line
|
||||
|
||||
- `-b` or `--current-buffer` select the entire buffer (default)
|
||||
|
||||
- `-j` or `--current-job` select the current job
|
||||
|
||||
- `-p` or `--current-process` select the current process
|
||||
|
||||
- `-t` or `--current-token` select the current token.
|
||||
|
||||
The following options change the way `commandline` prints the current commandline buffer:
|
||||
|
||||
- `-c` or `--cut-at-cursor` only print selection up until the current cursor position
|
||||
|
||||
- `-o` or `--tokenize` tokenize the selection and print one string-type token per line
|
||||
|
||||
If `commandline` is called during a call to complete a given string using `complete -C STRING`, `commandline` will consider the specified string to be the current contents of the command line.
|
||||
|
||||
The following options output metadata about the commandline state:
|
||||
|
||||
- `-L` or `--line` print the line that the cursor is on, with the topmost line starting at 1
|
||||
|
||||
- `-S` or `--search-mode` evaluates to true if the commandline is performing a history search
|
||||
|
||||
- `-P` or `--paging-mode` evaluates to true if the commandline is showing pager contents, such as tab completions
|
||||
|
||||
If \c commandline is called during a call to complete a given string
|
||||
using <code>complete -C STRING</code>, \c commandline will consider the
|
||||
specified string to be the current contents of the command line.
|
||||
|
||||
\subsection commandline-example Example
|
||||
|
||||
`commandline -j $history[3]` replaces the job under the cursor with the third item from the command line history.
|
||||
<tt>commandline -j $history[3]</tt> replaces the job under the cursor with the
|
||||
third item from the command line history.
|
||||
|
||||
@@ -1,38 +1,6 @@
|
||||
/**
|
||||
\page commands Commands
|
||||
\htmlonly[block]
|
||||
<div class="fish_left_bar">
|
||||
<div class="logo"></div>
|
||||
<div class="menu commands_menu">
|
||||
\endhtmlonly
|
||||
@command_list_toc@
|
||||
|
||||
\htmlonly[block]
|
||||
</div>
|
||||
</div>
|
||||
<div class="commands fish_right_bar">
|
||||
<h1 class="interior_title">Command reference</h1>
|
||||
\endhtmlonly
|
||||
`fish` ships with a large number of builtin commands, shellscript functions and external commands. These are all described below.
|
||||
|
||||
Almost all fish commands respond to the `-h` or `--help` options to display their relevant help, also accessible using the `help` and `man` commands, like so:
|
||||
|
||||
\fish
|
||||
echo -h
|
||||
echo --help
|
||||
# Prints help to the terminal window
|
||||
|
||||
man echo
|
||||
# Displays the man page in the system pager
|
||||
# (normally 'less', 'more' or 'most').
|
||||
|
||||
help echo
|
||||
# Open a web browser to show the relevant documentation
|
||||
\endfish
|
||||
/** \page commands Commands, functions and builtins bundled with fish
|
||||
Fish ships with a large number of builtin commands, shellscript functions and external commands. These are all described below.
|
||||
|
||||
@command_list@
|
||||
|
||||
\htmlonly[block]
|
||||
</div>
|
||||
\endhtmlonly
|
||||
*/
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
\section complete complete - edit command specific tab-completions
|
||||
|
||||
\subsection complete-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
complete ( -c | --command | -p | --path ) COMMAND
|
||||
[( -s | --short-option ) SHORT_OPTION]
|
||||
[( -l | --long-option | -o | --old-option ) LONG_OPTION]
|
||||
[( -a | --arguments ) OPTION_ARGUMENTS]
|
||||
[( -w | --wraps ) WRAPPED_COMMAND]
|
||||
[( -d | --description ) DESCRIPTION]
|
||||
\endfish
|
||||
<tt>complete (-c|--command|-p|--path) COMMAND [(-s|--short-option) SHORT_OPTION] [(-l|--long-option|-o|--old-option) LONG_OPTION [(-a||--arguments) OPTION_ARGUMENTS] [(-d|--description) DESCRIPTION] </tt>
|
||||
|
||||
\subsection complete-description Description
|
||||
|
||||
@@ -16,88 +9,69 @@ For an introduction to specifying completions, see <a
|
||||
href='index.html#completion-own'>Writing your own completions</a> in
|
||||
the fish manual.
|
||||
|
||||
- `COMMAND` is the name of the command for which to add a completion.
|
||||
- <tt>COMMAND</tt> is the name of the command for which to add a completion
|
||||
- <tt>SHORT_OPTION</tt> is a one character option for the command
|
||||
- <tt>LONG_OPTION</tt> is a multi character option for the command
|
||||
- <tt>OPTION_ARGUMENTS</tt> is parameter containing a space-separated list of possible option-arguments, which may contain subshells
|
||||
- <tt>DESCRIPTION</tt> is a description of what the option and/or option arguments do
|
||||
- <tt>-C STRING</tt> or <tt>--do-complete=STRING</tt> makes complete try to find all possible completions for the specified string
|
||||
- <tt>-e</tt> or <tt>--erase</tt> implies that the specified completion should be deleted
|
||||
- <tt>-f</tt> or <tt>--no-files</tt> specifies that the option specified by this completion may not be followed by a filename
|
||||
- <tt>-n</tt> or <tt>--condition</tt> 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.
|
||||
- <tt>-o</tt> or <tt>--old-option</tt> implies that the command uses old long style options with only one dash
|
||||
- <tt>-p</tt> or <tt>--path</tt> implies that the string COMMAND is the full path of the command
|
||||
- <tt>-r</tt> or <tt>--require-parameter</tt> specifies that the option specified by this completion always must have an option argument, i.e. may not be followed by another option
|
||||
- <tt>-u</tt> or <tt>--unauthoritative</tt> implies that there may be more options than the ones specified, and that fish should not assume that options not listed are spelling errors
|
||||
- <tt>-A</tt> or <tt>--authoritative</tt> implies that there may be no more options than the ones specified, and that fish should assume that options not listed are spelling errors
|
||||
- <tt>-x</tt> or <tt>--exclusive</tt> implies both <tt>-r</tt> and <tt>-f</tt>
|
||||
|
||||
- `SHORT_OPTION` is a one character option for the command.
|
||||
Command specific tab-completions in \c 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:
|
||||
|
||||
- `LONG_OPTION` is a multi character option for the command.
|
||||
- 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').
|
||||
- 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').
|
||||
|
||||
- `OPTION_ARGUMENTS` is parameter containing a space-separated list of possible option-arguments, which may contain subshells.
|
||||
|
||||
- `DESCRIPTION` is a description of what the option and/or option arguments do.
|
||||
|
||||
- `-C STRING` or `--do-complete=STRING` makes complete try to find all possible completions for the specified string.
|
||||
|
||||
- `-w WRAPPED_COMMAND` or `--wraps=WRAPPED_COMMAND` causes the specified command to inherit completions from the wrapped command.
|
||||
|
||||
- `-e` or `--erase` implies that the specified completion should be deleted.
|
||||
|
||||
- `-f` or `--no-files` specifies that the option specified by this completion may not be followed by a filename.
|
||||
|
||||
- `-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.
|
||||
|
||||
- `-o` or `--old-option` implies that the command uses old long style options with only one dash.
|
||||
|
||||
- `-p` or `--path` implies that the string `COMMAND` is the full path of the command.
|
||||
|
||||
- `-r` or `--require-parameter` specifies that the option specified by this completion always must have an option argument, i.e. may not be followed by another option.
|
||||
|
||||
- `-u` or `--unauthoritative` implies that there may be more options than the ones specified, and that fish should not assume that options not listed are spelling errors.
|
||||
|
||||
- `-A` or `--authoritative` implies that there may be no more options than the ones specified, and that fish should assume that options not listed are spelling errors.
|
||||
|
||||
- `-x` or `--exclusive` implies both `-r` and `-f`.
|
||||
|
||||
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:
|
||||
|
||||
- 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`').
|
||||
|
||||
- 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`') 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, command path, or command switches may all be used multiple times to specify multiple commands which have the same completion or multiple switches accepted by a command.
|
||||
|
||||
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.
|
||||
|
||||
When erasing completions, it is possible to either erase all completions for a specific command by specifying `complete -e -c COMMAND`, or by specifying a specific completion option to delete by specifying either a long, short or old style option.
|
||||
The options for specifying command name, command path, or command
|
||||
switches may all be used multiple times to specify multiple commands
|
||||
which have the same completion or multiple switches accepted by a
|
||||
command.
|
||||
|
||||
When erasing completions, it is possible to either erase all
|
||||
completions for a specific command by specifying <tt>complete -e -c
|
||||
COMMAND</tt>, or by specifying a specific completion option to delete
|
||||
by specifying either a long, short or old style option.
|
||||
|
||||
\subsection complete-example 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 <tt>-o</tt> for the \c gcc command requires
|
||||
that a file follows it. This can be done using writing <tt>complete
|
||||
-c gcc -s o -r</tt>.
|
||||
|
||||
\fish
|
||||
complete -c gcc -s o -r
|
||||
\endfish
|
||||
The short style option <tt>-d</tt> for the \c grep command requires
|
||||
that one of the strings 'read', 'skip' or 'recurse' is used. This can
|
||||
be specified writing <tt>complete -c grep -s d -x -a "read skip
|
||||
recurse"</tt>.
|
||||
|
||||
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:
|
||||
The \c 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: <tt>complete -x -c su -d "Username" -a "(cat
|
||||
/etc/passwd|cut -d : -f 1)" </tt>.
|
||||
|
||||
\fish
|
||||
complete -c grep -s d -x -a "read skip recurse"
|
||||
\endfish
|
||||
|
||||
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:
|
||||
|
||||
\fish
|
||||
complete -x -c su -d "Username" -a "(cat /etc/passwd | cut -d : -f 1)"
|
||||
\endfish
|
||||
|
||||
The `rpm` command has several different modes. If the `-e` or `--erase` flag has been specified, `rpm` should delete one or more packages, in which case several switches related to deleting packages are valid, like the `nodeps` switch.
|
||||
The \c rpm command has several different modes. If the \c -e or \c
|
||||
--erase flag has been specified, \c rpm should delete one or more
|
||||
packages, in which case several switches related to deleting packages
|
||||
are valid, like the \c nodeps switch.
|
||||
|
||||
This can be written as:
|
||||
|
||||
\fish
|
||||
complete -c rpm -n "__fish_contains_opt -s e erase" -l nodeps -d "Don't check dependencies"
|
||||
\endfish
|
||||
<tt>complete -c rpm -n "__fish_contains_opt -s e erase" -l nodeps -d
|
||||
"Don't check dependencies"</tt>
|
||||
|
||||
where `__fish_contains_opt` is a function that checks the commandline buffer for the presence of a specified set of options.
|
||||
|
||||
To implement an alias, use the `-w` or `--wraps` option:
|
||||
|
||||
\fish
|
||||
complete -c hub -w git
|
||||
\endfish
|
||||
|
||||
Now hub inherits all of the completions from git. Note this can also be specified in a function declaration.
|
||||
where \c __fish_contains_opt is a function that checks the commandline
|
||||
buffer for the presence of a specified set of options.
|
||||
|
||||
|
||||
@@ -1,38 +1,26 @@
|
||||
\section contains contains - test if a word is present in a list
|
||||
|
||||
\subsection contains-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
contains [OPTIONS] KEY [VALUES...]
|
||||
\endfish
|
||||
<code>contains [OPTIONS] KEY [VALUES...]</code>
|
||||
|
||||
\subsection contains-description Description
|
||||
|
||||
`contains` tests whether the set `VALUES` contains the string `KEY`. If so, `contains` exits with status 0; if not, it exits with status 1.
|
||||
\c contains tests whether the set \c VALUES contains the string
|
||||
<code>KEY</code>. If so, \c contains exits with status 0; if not, it exits
|
||||
with status 1.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-i` or `--index` print the word index
|
||||
|
||||
Note that, like GNU tools, `contains` interprets all arguments starting with a `-` as options to contains, until it reaches an argument that is `--` (two dashes). See the examples below.
|
||||
- \c -i or \c --index print the word index
|
||||
- \c -h or \c --help display this message
|
||||
|
||||
\subsection contains-example Example
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
for i in ~/bin /usr/local/bin
|
||||
if not contains $i $PATH
|
||||
set PATH $PATH $i
|
||||
end
|
||||
if not contains \$i \$PATH
|
||||
set PATH \$PATH \$i
|
||||
end
|
||||
end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
The above code tests if `~/bin` and `/usr/local/bin` are in the path and adds them if not.
|
||||
|
||||
\fish
|
||||
function hasargs
|
||||
if contains -- -q $argv
|
||||
echo '$argv contains a -q option'
|
||||
end
|
||||
end
|
||||
\endfish
|
||||
|
||||
The above code checks for `-q` in the argument list, using the `--` argument to demarcate options to `contains` from the key to search for.
|
||||
The above code tests if \c ~/bin and \c /usr/local/bin are in the path and adds them if not.
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
\section continue continue - skip the remainder of the current iteration of the current inner loop
|
||||
|
||||
\subsection continue-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end
|
||||
\endfish
|
||||
<tt>LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end</tt>
|
||||
|
||||
\subsection continue-description Description
|
||||
|
||||
`continue` skips the remainder of the current iteration of the current inner loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
|
||||
\c continue skips the remainder of the current iteration of the current inner loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
|
||||
|
||||
\subsection continue-example Example
|
||||
|
||||
The following code removes all tmp files that do not contain the word smurf.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
for i in *.tmp
|
||||
if grep smurf $i
|
||||
continue
|
||||
end
|
||||
rm $i
|
||||
end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
\section count count - count the number of elements of an array
|
||||
|
||||
\subsection count-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
count $VARIABLE
|
||||
\endfish
|
||||
<tt>count $VARIABLE</tt>
|
||||
|
||||
\subsection count-description Description
|
||||
|
||||
`count` prints the number of arguments that were passed to it. This is usually used to find out how many elements an environment variable array contains.
|
||||
<tt>count</tt> prints the number of arguments that were
|
||||
passed to it. This is usually used to find out how many elements an
|
||||
environment variable array contains.
|
||||
|
||||
`count` does not accept any options, including `-h` or `--help`.
|
||||
|
||||
`count` exits with a non-zero exit status if no arguments were passed to it, and with zero if at least one argument was passed.
|
||||
\c count does not accept any options, including '-h'.
|
||||
|
||||
\c count exits with a non-zero exit status if no arguments were passed
|
||||
to it, and with zero if at least one argument was passed.
|
||||
|
||||
\subsection count-example Example
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
count $PATH
|
||||
# Returns the number of directories in the users PATH variable.
|
||||
</pre>
|
||||
|
||||
returns the number of directories in the users PATH variable.
|
||||
|
||||
<pre>
|
||||
count *.txt
|
||||
# Returns the number of files in the current working directory ending with the suffix '.txt'.
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
returns the number of files in the current working directory ending with the suffix '.txt'.
|
||||
|
||||
@@ -1,110 +1,134 @@
|
||||
/**
|
||||
\page design Design document
|
||||
\htmlonly[block]
|
||||
<div class="fish_only_bar">
|
||||
<div class="design">
|
||||
<h1 class="interior_title">Design documentation</h1>
|
||||
\endhtmlonly
|
||||
/** \page design Design document
|
||||
|
||||
\section design-overview Overview
|
||||
|
||||
This is a description of the design principles that have been used to design fish. The fish design has three high level goals. These are:
|
||||
This is a description of the design principles that have been used to
|
||||
design fish. The fish design has three high level goals. These are:
|
||||
|
||||
-# Everything that can be done in other shell languages should be possible to do in fish, though fish may rely on external commands in doing so.
|
||||
|
||||
-# Fish should be user friendly, but not at the expense of expressiveness. Most tradeoffs between power and ease of use can be avoided with careful design.
|
||||
|
||||
-# Whenever possible without breaking the above goals, fish should follow the Posix syntax.
|
||||
|
||||
To achieve these high-level goals, the fish design relies on a number of more specific design principles. These are presented below, together with a rationale and a few examples for each.
|
||||
-# Everything that can be done in other shell languages should be
|
||||
possible to do in fish, though fish may rely on external commands in
|
||||
doing so.
|
||||
-# Fish should be user friendly, but not at the expense of expressiveness.
|
||||
Most tradeoffs between power and ease of use can be avoided with careful design.
|
||||
-# Whenever possible without breaking the above goals, fish should
|
||||
follow the Posix syntax.
|
||||
|
||||
To achieve these high-level goals, the fish design relies on a number
|
||||
of more specific design principles. These are presented below,
|
||||
together with a rationale and a few examples for each.
|
||||
|
||||
\section ortho 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.
|
||||
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.
|
||||
Related features make the language larger, which makes it harder to
|
||||
learn. It also increases the size of the sourcecode, making the
|
||||
program harder to maintain and update.
|
||||
|
||||
Examples:
|
||||
|
||||
- Here documents are too similar to using echo inside of a pipeline.
|
||||
- Subshells, command substitution and process substitution are strongly related. \c fish only supports command substitution, the others can be achieved either using a block or the psub shellscript function.
|
||||
- Having both aliases and functions is confusing, especially since both of them have limitations and problems. \c fish functions have none of the drawbacks of either syntax.
|
||||
- The many Posix quoting styles are silly, especially \$''.
|
||||
|
||||
- Subshells, command substitution and process substitution are strongly related. `fish` only supports command substitution, the others can be achieved either using a block or the psub shellscript function.
|
||||
|
||||
- Having both aliases and functions is confusing, especially since both of them have limitations and problems. `fish` functions have none of the drawbacks of either syntax.
|
||||
|
||||
- The many Posix quoting styles are silly, especially $''.
|
||||
|
||||
|
||||
\section design-response The law of responsiveness
|
||||
\section sep The law of responsiveness
|
||||
|
||||
The shell should attempt to remain responsive to the user at all times, even in the face of contended or unresponsive filesystems. It is only acceptable to block in response to a user initiated action, such as running a command.
|
||||
|
||||
Rationale:
|
||||
|
||||
Bad performance increases user-facing complexity, because it trains users to recognize and route around slow use cases. It is also incredibly frustrating.
|
||||
|
||||
Examples:
|
||||
|
||||
- Features like syntax highlighting and autosuggestions must perform all of their disk I/O asynchronously.
|
||||
|
||||
- Startup should minimize forks and disk I/O, so that fish can be started even if the system is under load.
|
||||
|
||||
\section design-configurability Configurability is the root of all evil
|
||||
\section conf Configurability is the root of all evil
|
||||
|
||||
Every configuration option in a program is a place where the program is too stupid to figure out for itself what the user really wants, and should be considered a failure of both the program and the programmer who implemented it.
|
||||
Every configuration option in a program is a place where the program
|
||||
is too stupid to figure out for itself what the user really wants, and
|
||||
should be considered a failiure of both the program and the programmer
|
||||
who implemented it.
|
||||
|
||||
Rationale:
|
||||
Different configuration options are a nightmare to maintain, since the number of potential bugs caused by specific configuration combinations quickly becomes an issue. Configuration options often imply assumptions about the code which change when reimplementing the code, causing issues with backwards compatibility. But mostly, configuration options should be avoided since they simply should not exist, as the program should be smart enough to do what is best, or at least a good enough approximation of it.
|
||||
|
||||
Different configuration options are a nightmare to maintain, since the
|
||||
number of potential bugs caused by specific configuration combinations
|
||||
quickly becomes an issue. Configuration options often imply
|
||||
assumptions about the code which change when reimplementing the code,
|
||||
causing issues with backwards compatibility. But mostly, configuration
|
||||
options should be avoided since they simply should not exist, as the
|
||||
program should be smart enough to do what is best, or at least a good
|
||||
enough approximation of it.
|
||||
|
||||
Examples:
|
||||
|
||||
- Fish allows the user to set various syntax highlighting colors. This is needed because fish does not know what colors the terminal uses by default, which might make some things unreadable. The proper solution would be for text color preferences to be defined centrally by the user for all programs, and for the terminal emulator to send these color properties to fish.
|
||||
|
||||
- Fish does not allow you to set the history filename, the number of history entries, different language substyles or any number of other common shell configuration options.
|
||||
|
||||
A special note on the evils of configurability is the long list of very useful features found in some shells, that are not turned on by default. Both zsh and bash support command-specific completions, but no such completions are shipped with bash by default, and they are turned off by default in zsh. Other features that zsh supports that are disabled by default include tab-completion of strings containing wildcards, a sane completion pager and a history file.
|
||||
A special note on the evils of configurability is the long list of
|
||||
very useful features found in some shells, that are not turned on by
|
||||
default. Both zsh and bash support command specific completions, but
|
||||
no such completions are shipped with bash by default, and they are
|
||||
turned off by default in zsh. Other features that zsh support that are
|
||||
disabled by default include tab-completion of strings containing
|
||||
wildcards, a sane completion pager and a history file.
|
||||
|
||||
\section user The law of user focus
|
||||
|
||||
When designing a program, one should first think about how to make a intuitive and powerful program. Implementation issues should only be considered once a user interface has been designed.
|
||||
When designing a program, one should first think about how to make a
|
||||
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.
|
||||
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 to 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.
|
||||
|
||||
- The differences between builtin commands, shellscript functions and builtin commands should be made as small as possible. Builtins 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 io redirection.
|
||||
- Instead of forking when performing command substitution to provide a fake variable scope, all fish commands are performed from the same process, and fish instead supports true scoping.
|
||||
|
||||
- All blocks end with the `end` built-in.
|
||||
- All blocks end with the \c end builtin.
|
||||
|
||||
\section disc The law of discoverability
|
||||
|
||||
A program should be designed to make its features as easy as possible to discover for the user.
|
||||
A program should be designed to make its features as
|
||||
easy as possible to discover for the user.
|
||||
|
||||
Rationale:
|
||||
A program whose features are discoverable turns a new user into an expert in a shorter span of time, since the user will become an expert on the program simply by using it.
|
||||
|
||||
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 she/he remembers the new information until the next time she/he uses the same program.
|
||||
A program whose features are discoverable turns a new user into an
|
||||
expert in a shorter span of time, since the user will become an expert
|
||||
on the program simply by using it.
|
||||
|
||||
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 commandline programs is
|
||||
through manual pages. This requires both that the user starts to use a
|
||||
different program, and the she/he then remembers the new information
|
||||
until the next time she/he uses 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.
|
||||
|
||||
- Every syntax error and error in a builtin 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.
|
||||
- The help manual should be easy to read, easily available from the shell, complete and contain many examples
|
||||
|
||||
- The language should be uniform, so that once the user understands the command/argument syntax, she/he will know the whole language, and be able to use tab-completion to discover new features.
|
||||
|
||||
|
||||
\htmlonly[block]
|
||||
</div>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
- The language should be uniform, so that once the user understands the command/argument syntax, he will know the whole language, and be able to use tab-completion to discover new featues.
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
\section dirh dirh - print directory history
|
||||
|
||||
\subsection dirh-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
dirh
|
||||
\endfish
|
||||
<tt>dirh</tt>
|
||||
|
||||
\subsection dirh-description Description
|
||||
|
||||
`dirh` prints the current directory history. The current position in the history is highlighted using the color defined in the `fish_color_history_current` environment variable.
|
||||
<tt>dirh</tt> prints the current directory history. The current position in the
|
||||
history is highlighted using the color defined in the
|
||||
<tt>fish_color_history_current</tt> environment variable.
|
||||
|
||||
`dirh` does not accept any parameters.
|
||||
\c dirh does not accept any parameters.
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
\section dirs dirs - print directory stack
|
||||
|
||||
\subsection dirs-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
dirs
|
||||
\endfish
|
||||
<tt>dirs</tt>
|
||||
|
||||
\subsection dirs-description Description
|
||||
<tt>dirs</tt> prints the current directory stack, as created by the
|
||||
<code><a href="#pushd">pushd</a></code> command.
|
||||
|
||||
`dirs` prints the current directory stack, as created by the <a href="#pushd">`pushd`</a> command.
|
||||
|
||||
`dirs` does not accept any parameters.
|
||||
\c dirs does not accept any parameters.
|
||||
|
||||
@@ -1,60 +1,39 @@
|
||||
\section echo echo - display a line of text
|
||||
|
||||
\subsection echo-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
echo [OPTIONS] [STRING]
|
||||
\endfish
|
||||
<tt>echo [STRING]</tt>
|
||||
|
||||
\subsection echo-description Description
|
||||
|
||||
`echo` displays a string of text.
|
||||
\c echo displays a string of text.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-n`, Do not output a newline
|
||||
|
||||
- `-s`, Do not separate arguments with spaces
|
||||
|
||||
- `-E`, Disable interpretation of backslash escapes (default)
|
||||
|
||||
- `-e`, Enable interpretation of backslash escapes
|
||||
- \c -n, \c Do not output a newline
|
||||
- \c -s, \c Do not separate arguments with spaces
|
||||
- \c -E, \c Disable interpretation of backslash escapes (default)
|
||||
- \c -e, \c Enable interpretation of backslash escapes
|
||||
- \c -h, \c --help Display this help
|
||||
|
||||
\subsection echo-escapes Escape Sequences
|
||||
|
||||
If `-e` is used, the following sequences are recognized:
|
||||
If \c -e is used, the following sequences are recognized:
|
||||
|
||||
- `\` backslash
|
||||
|
||||
- `\a` alert (BEL)
|
||||
|
||||
- `\b` backspace
|
||||
|
||||
- `\c` produce no further output
|
||||
|
||||
- `\e` escape
|
||||
|
||||
- `\f` form feed
|
||||
|
||||
- `\n` new line
|
||||
|
||||
- `\r` carriage return
|
||||
|
||||
- `\t` horizontal tab
|
||||
|
||||
- `\v` vertical tab
|
||||
|
||||
- `\0NNN` byte with octal value NNN (1 to 3 digits)
|
||||
|
||||
- `\xHH` byte with hexadecimal value HH (1 to 2 digits)
|
||||
- \c \\\\ \c backslash
|
||||
- \\a alert (BEL)
|
||||
- \\b backspace
|
||||
- \\c produce no further output
|
||||
- \\e escape
|
||||
- \\f form feed
|
||||
- \\n new line
|
||||
- \\r carriage return
|
||||
- \\t horizontal tab
|
||||
- \\v vertical tab
|
||||
- \\0NNN byte with octal value NNN (1 to 3 digits)
|
||||
- \\xHH byte with hexadecimal value HH (1 to 2 digits)
|
||||
|
||||
\subsection echo-example Example
|
||||
|
||||
\fish
|
||||
echo 'Hello World'
|
||||
\endfish
|
||||
Print hello world to stdout
|
||||
<tt>echo 'Hello World'</tt> Print hello world to stdout
|
||||
|
||||
\fish
|
||||
echo -e 'Top\nBottom'
|
||||
\endfish
|
||||
Print Top and Bottom on separate lines, using an escape sequence
|
||||
<tt>echo -e 'Top\\nBottom'</tt> Print Top and Bottom on separate lines, using an escape sequence
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
\section else else - execute command if a condition is not met
|
||||
|
||||
\subsection else-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end
|
||||
\endfish
|
||||
<tt>if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end</tt>
|
||||
|
||||
\subsection else-description Description
|
||||
|
||||
`if` will execute the command `CONDITION`. If the condition's exit status is 0, the commands `COMMANDS_TRUE` will execute. If it is not 0 and `else` is given, `COMMANDS_FALSE` will be executed.
|
||||
|
||||
<tt>if</tt> will execute the command \c CONDITION. If the condition's exit
|
||||
status is 0, the commands \c COMMANDS_TRUE will execute. If it is not 0 and
|
||||
<tt>else</tt> is given, \c COMMANDS_FALSE will be executed.
|
||||
|
||||
\subsection else-example Example
|
||||
|
||||
The following code tests whether a file `foo.txt` exists as a regular file.
|
||||
The following code tests whether a file \c foo.txt exists as a regular file.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
if test -f foo.txt
|
||||
echo foo.txt exists
|
||||
else
|
||||
echo foo.txt does not exist
|
||||
end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
\section emit emit - Emit a generic event
|
||||
|
||||
\subsection emit-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
emit EVENT_NAME [ARGUMENTS...]
|
||||
\endfish
|
||||
\subsection block-synopsis Synopsis
|
||||
<tt>emit EVENT_NAME [ARGUMENTS...]</tt>
|
||||
|
||||
\subsection emit-description Description
|
||||
|
||||
`emit` emits, or fires, an event. Events are delivered to, or caught by, special functions called event handlers. The arguments are passed to the event handlers as function arguments.
|
||||
|
||||
\c emit emits, or fires, an event. Events are delivered to, or caught by, special functions called event handlers. The arguments are passed to the event handlers as function arguments.
|
||||
|
||||
\subsection emit-example Example
|
||||
|
||||
The following code first defines an event handler for the generic event named 'test_event', and then emits an event of that type.
|
||||
The following code first defines an event handler for the generic
|
||||
event named 'test_event', and then emits an event of that type.
|
||||
|
||||
\fish
|
||||
function event_test --on-event test_event
|
||||
<pre>function event_test --on-event test_event
|
||||
echo event test: $argv
|
||||
end
|
||||
|
||||
emit test_event something
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
\section end end - end a block of commands.
|
||||
|
||||
\subsection end-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
<pre>
|
||||
begin; [COMMANDS...] end
|
||||
if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end
|
||||
while CONDITION; COMMANDS...; end
|
||||
for VARNAME in [VALUES...]; COMMANDS...; end
|
||||
switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
\subsection end-description Description
|
||||
|
||||
`end` ends a block of commands.
|
||||
<tt>end</tt> ends a block of commands.
|
||||
|
||||
For more information, read the
|
||||
documentation for the block constructs, such as `if`, `for` and `while`.
|
||||
documentation for the block constructs, such as \c if, \c for and \c
|
||||
while.
|
||||
|
||||
The `end` command does not change the current exit status.
|
||||
The \c end command does not change the current exit status.
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
\section eval eval - evaluate the specified commands
|
||||
|
||||
\subsection eval-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
eval [COMMANDS...]
|
||||
\endfish
|
||||
<tt>eval [COMMANDS...]</tt>
|
||||
|
||||
\subsection eval-description Description
|
||||
`eval` evaluates the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator.
|
||||
|
||||
<tt>eval</tt> evaluates the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator.
|
||||
|
||||
\subsection eval-example Example
|
||||
|
||||
The following code will call the ls command. Note that `fish` does not support the use of shell variables as direct commands; `eval` can be used to work around this.
|
||||
The folloing code will call the ls command. Note that \c fish does not
|
||||
support the use of environment variables as direct commands; \c eval can
|
||||
be used to work around this.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
set cmd ls
|
||||
eval $cmd
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
\section exec exec - execute command in current process
|
||||
|
||||
\subsection exec-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
exec COMMAND [OPTIONS...]
|
||||
\endfish
|
||||
<tt>exec COMMAND [OPTIONS...]</tt>
|
||||
|
||||
\subsection exec-description Description
|
||||
|
||||
`exec` replaces the currently running shell with a new command. On successful completion, `exec` never returns. `exec` cannot be used inside a pipeline.
|
||||
|
||||
\c exec replaces the currently running shell with a new command.
|
||||
On successful completion, \c exec never returns. \c exec cannot be used
|
||||
inside a pipeline.
|
||||
|
||||
\subsection exec-example Example
|
||||
|
||||
`exec emacs` starts up the emacs text editor, and exits `fish`. When emacs exits, the session will terminate.
|
||||
<tt>exec emacs</tt> starts up the emacs text editor, and exits \c fish.
|
||||
When emacs exits, the session will terminate.
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
\section exit exit - exit the shell
|
||||
|
||||
\subsection exit-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
exit [STATUS]
|
||||
\endfish
|
||||
<tt>exit [STATUS]</tt>
|
||||
|
||||
\subsection exit-description Description
|
||||
|
||||
`exit` causes fish to exit. If `STATUS` is supplied, it will be converted to an integer and used as the exit code. Otherwise, the exit code will be that of the last command executed.
|
||||
\c exit causes fish to exit. If <tt>STATUS</tt> is
|
||||
supplied, it will be converted to an integer and used as the exit
|
||||
code. Otherwise, the exit code will be that of the last command executed.
|
||||
|
||||
If exit is called while sourcing a file (using the <a href="#source">source</a> builtin) the rest of the file will be skipped, but the shell itself will not exit.
|
||||
If exit is called while sourcing a file (using the <a
|
||||
href="#source">.</a> builtin) the rest of the file will be skipped,
|
||||
but the shell itself will not exit.
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
\section false false - return an unsuccessful result
|
||||
|
||||
\subsection false-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
false
|
||||
\endfish
|
||||
|
||||
\subsection false-description Description
|
||||
|
||||
`false` sets the exit status to 1.
|
||||
233
doc_src/faq.hdr
233
doc_src/faq.hdr
@@ -1,21 +1,5 @@
|
||||
/**
|
||||
\page faq Frequently asked questions
|
||||
\htmlonly[block]
|
||||
<div class="fish_left_bar">
|
||||
<div class="logo"></div>
|
||||
<div class="menu faq_menu">
|
||||
/** \page faq Frequently asked questions
|
||||
|
||||
\endhtmlonly
|
||||
|
||||
- <a href='#faq-envvar'>How do I set or clear an environment variable?</a>
|
||||
- <a href='#faq-login-cmd'>How do I run a command every login? What's fish's equivalent to `.bashrc`?</a>
|
||||
- <a href='#faq-prompt'>How do I set my prompt?</a>
|
||||
- <a href='#faq-cmd-history'>How do I run a command from history?</a>
|
||||
- <a href='#faq-subcommand'>How do I run a subcommand? The backtick doesn't work!</a>
|
||||
- <a href='#faq-exit-status'>How do I get the exit status of a command?</a>
|
||||
- <a href='#faq-single-env'>How do I set an environment variable for just one command?</a>
|
||||
- <a href='#faq-customize-colors'>How do I customize my syntax highlighting colors?</a>
|
||||
- <a href='#faq-update-manpage-completions'>How do I update man page completions?</a>
|
||||
- <a href='#faq-cwd-symlink'>Why does cd, pwd and other fish commands always resolve symlinked directories to their canonical path?</a>
|
||||
- <a href='#faq-cd-implicit'>I accidentally entered a directory path and fish changed directory. What happened?</a>
|
||||
- <a href='#faq-open'>The open command doesn't work.</a>
|
||||
@@ -25,198 +9,157 @@
|
||||
- <a href='#faq-history'>Why doesn't history substitution ("!$" etc.) work?</a>
|
||||
- <a href='#faq-uninstalling'>How do I uninstall fish?</a>
|
||||
|
||||
\htmlonly[block]
|
||||
</div>
|
||||
</div>
|
||||
<div class="faq fish_right_bar">
|
||||
<h1 class="interior_title">Frequently Asked Questions</h1>
|
||||
\endhtmlonly
|
||||
|
||||
|
||||
\section faq-envvar How do I set or clear an environment variable?
|
||||
|
||||
Use the <a href="commands.html#set">`set`</a> command:
|
||||
|
||||
\fish{cli-dark}
|
||||
set -x key value
|
||||
set -e key
|
||||
\endfish
|
||||
|
||||
|
||||
\section faq-login-cmd How do I run a command every login? What's fish's equivalent to .bashrc?
|
||||
|
||||
Edit the file `~/.config/fish/config.fish`, creating it if it does not exist (Note the leading period).
|
||||
|
||||
<hr>
|
||||
\section faq-prompt 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:
|
||||
|
||||
\fish{cli-dark}
|
||||
function fish_prompt
|
||||
set_color $fish_color_cwd
|
||||
echo -n (prompt_pwd)
|
||||
set_color normal
|
||||
echo -n ' > '
|
||||
end
|
||||
\endfish
|
||||
|
||||
You can also use the Web configuration tool, <a href="commands.html#fish_config">`fish_config`</a>, to preview and choose from a gallery of sample prompts.
|
||||
|
||||
|
||||
\section faq-cmd-history How do I run a command from history?
|
||||
|
||||
Type some part of the command, and then hit the @cursor_key{↑,up} or @cursor_key{↓,down} arrow keys to navigate through history matches.
|
||||
|
||||
<hr>
|
||||
\section faq-subcommand How do I run a subcommand? The backtick doesn't work!
|
||||
|
||||
`fish` uses parentheses for subcommands. For example:
|
||||
|
||||
\fish{cli-dark}
|
||||
for i in (ls)
|
||||
echo $i
|
||||
end
|
||||
\endfish
|
||||
|
||||
|
||||
\section faq-exit-status How do I get the exit status of a command?
|
||||
|
||||
Use the `$status` variable. This replaces the `$?` variable used in some other shells.
|
||||
|
||||
<hr>
|
||||
\section faq-single-env How do I set an environment variable for just one command?
|
||||
|
||||
<i>`SOME_VAR=1 command` produces an error: `Unknown command "SOME_VAR=1"`.</i>
|
||||
|
||||
Use the `env` command.
|
||||
|
||||
`env SOME_VAR=1 command`
|
||||
|
||||
You can also declare a local variable in a block:
|
||||
|
||||
\fish{cli-dark}
|
||||
begin
|
||||
set -lx SOME_VAR 1
|
||||
command
|
||||
end
|
||||
\endfish
|
||||
|
||||
|
||||
\section faq-customize-colors How do I customize my syntax highlighting colors?
|
||||
|
||||
Use the web configuration tool, <a href="commands.html#fish_config">`fish_config`</a>, or alter the <a href="index.html#variables-color">`fish_color` family of environment variables</a>.
|
||||
|
||||
<hr>
|
||||
\section faq-update-manpage-completions How do I update man page completions?
|
||||
|
||||
Use the <a href="commands.html#fish_update_completions">`fish_update_completions`</a> command.
|
||||
|
||||
<hr>
|
||||
\section faq-cwd-symlink Why does cd, $PWD and and various fish commands always resolve symlinked directories to their canonical path?
|
||||
|
||||
<i>For example if `~/images` is a symlink to `~/Documents/Images`, if I write '`cd images`', my prompt will say `~/Documents/Images`, not `~/images`.</i>
|
||||
<i>
|
||||
For example if ~/images is a symlink to ~/Documents/Images, if I write
|
||||
'cd images', my prompt will say ~/D/Images, not ~/images.
|
||||
</i>
|
||||
|
||||
Because it is impossible to consistently keep symlinked directories unresolved. It is indeed possible to do this partially, and many other shells do so. But it was felt there are enough serious corner cases that this is a bad idea. Most such issues have to do with how '..' is handled, and are varitations of the following example:
|
||||
Because it is impossible to consistently keep symlinked directories
|
||||
unresolved. It is indeed possible to do this partially, and many other
|
||||
shells do so. But it was felt there are enough serious corner cases
|
||||
that this is a bad idea. Most such issues have to do with how '..' is
|
||||
handled, and are varitations of the following example:
|
||||
|
||||
Writing `cd images; ls ..` given the above directory structure would list the contents of `~/Documents`, not of `~`, even though using `cd ..` changes the current directory to `~`, and the prompt, the `pwd` builtin and many other directory information sources suggest that the current directory is `~/images` and its parent is `~`. This issue is not possible to fix without either making every single command into a builtin, breaking Unix semantics or implementing kludges in every single command. This issue can also be seen when doing IO redirection.
|
||||
Writing <code>cd images; ls ..</code> given the above directory
|
||||
structure would list the contents of ~/Documents, not of ~, even
|
||||
though using <code>cd ..</code> changes the current directory to ~,
|
||||
and the prompt, the pwd builtin and many other directory information
|
||||
sources suggest that the current directory is ~/images and its
|
||||
parent is ~. This issue is not possible to fix without either making
|
||||
every single command into a builtin, breaking Unix semantics or
|
||||
implementing kludges in every single command.
|
||||
|
||||
Another related issue is that many programs that operate on recursive directory trees, like the find command, silently ignore symlinked directories. For example, ```find $PWD -name '*.txt'``` silently fails in shells that don't resolve symlinked paths.
|
||||
This issue can also be seen when doing IO redirection.
|
||||
|
||||
Another related issue is that many programs that operate on recursive
|
||||
directory trees, like the find command, silently ignore symlinked
|
||||
directories. For example, <code>find $PWD -name '*.txt'</code>
|
||||
silently fails in shells that don't resolve symlinked paths.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-cd-implicit 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.
|
||||
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
|
||||
<code>~</code> and enter.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-open 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 <a href="index.html#more-help">asking for more help</a>.
|
||||
The \c open command uses the MIME type database and the <code>.desktop</code> 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 <a href="index.html#more-help">asking for
|
||||
more help</a>.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-default 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) as root:
|
||||
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) as root:
|
||||
|
||||
\fish{cli-dark}
|
||||
echo /usr/local/bin/fish >>/etc/shells
|
||||
\endfish
|
||||
|
||||
If you installed a prepackaged version of fish, the package manager should have already done this for you.
|
||||
<code>echo /usr/local/bin/fish >>/etc/shells</code>
|
||||
|
||||
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:
|
||||
|
||||
\fish{cli-dark}
|
||||
chsh -s /usr/local/bin/fish
|
||||
\endfish
|
||||
<code>chsh -s /usr/local/bin/fish</code>
|
||||
|
||||
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.
|
||||
You may need to adjust the above path to e.g. \c /usr/bin/fish. Use the command <code>which fish</code> 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.
|
||||
Unfortunately, there is no way to make the changes take effect at once.
|
||||
You will need to log out and back in again.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-titlebar I'm seeing weird output before each prompt when using screen. What's wrong?
|
||||
|
||||
Quick answer:
|
||||
|
||||
Run the following command in fish:
|
||||
|
||||
\fish{cli-dark}
|
||||
function fish_title; end; funcsave fish_title
|
||||
\endfish
|
||||
<pre>
|
||||
echo 'function fish_title;end' > ~/.config/fish/config.fish
|
||||
</pre>
|
||||
|
||||
Problem solved!
|
||||
|
||||
The long answer:
|
||||
|
||||
Fish is trying to set the titlebar message of your terminal. While screen itself supports this feature, your terminal does not. Unfortunately, when the underlying terminal doesn't support setting the titlebar, screen simply passes through the escape codes and text to the underlying terminal instead of ignoring them. It is impossible to detect and resolve this problem from inside fish since fish has no way of knowing what the underlying terminal type is. For now, the only way to fix this is to unset the titlebar message, as suggested above.
|
||||
Fish is trying to set the titlebar message of your terminal. While
|
||||
screen itself supports this feature, your terminal does
|
||||
not. Unfortunately, when the underlying terminal doesn't support
|
||||
setting the titlebar, screen simply passes through the escape codes
|
||||
and text to the underlying terminal instead of ignoring them. It is
|
||||
impossible detect and resolve this problem from inside fish since fish
|
||||
has no way of knowing what the underlying terminal type is. For now,
|
||||
the only way to fix this is to unset the titlebar message, as
|
||||
suggested above.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-greeting 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:
|
||||
Change the value of the variable fish_greeting. For example, to remove
|
||||
the greeting use:
|
||||
|
||||
\fish{cli-dark}
|
||||
<pre>
|
||||
set fish_greeting
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-history Why doesn't history substitution ("!$" etc.) work?
|
||||
|
||||
Because history substitution is an awkward interface that was invented before interactive line editing was even possible. Fish drops it in favor of perfecting the interactive history recall interface. Switching requires a small change of habits: if you want to modify an old line/word, first recall it, then edit. E.g. don't type "sudo !!" - first press Up, then Home, then type "sudo ".
|
||||
Because history substitution is an awkward interface that was invented before
|
||||
interactive line editing was even possible. Fish drops it in favor of
|
||||
perfecting the interactive history recall interface. Switching requires a
|
||||
small change of habits: if you want to modify an old line/word, first recall
|
||||
it, then edit. E.g. don't type "sudo !!" - first press Up, then Home, then
|
||||
type "sudo ".
|
||||
|
||||
Fish history recall is very simple yet effective:
|
||||
|
||||
- As in any modern shell, the Up arrow, @cursor_key{↑,Up} recalls whole lines, starting from the last line executed. A single press replaces "!!", later presses replace "!-3" and the like.
|
||||
|
||||
- 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 constrain the recall to lines that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like.
|
||||
|
||||
- @key{Alt,↑,Up} recalls individual arguments, starting from the last argument in the last line executed. A single press replaces "!$", later presses replace "!!:4" and the like.
|
||||
|
||||
- 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 @key{Alt,↑,Up}. This will show only arguments containing that part and you will get what you want much faster. Try it out, this is very convenient!
|
||||
|
||||
- If you want to reuse several arguments from the same line ("!!:3*" and the like), consider recalling the whole line and removing what you don't need (@key{Alt,D} and @key{Alt,Backspace} are your friends).
|
||||
- As in any modern shell, the Up arrow recalls whole lines, starting from the last line executed. A single press replaces "!!", later presses replace "!-3" and the like.
|
||||
- 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 constrain the recall to lines that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like.
|
||||
- Alt+Up recalls individual arguments, starting from the last argument in the last line executed. A single press replaces "!$", later presses replace "!!:4" and the like.
|
||||
- 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 Alt+Up. This will show only arguments containing that part and you will get what you want much faster. Try it out, this is very convenient!
|
||||
- If you want to reuse several arguments from the same line ("!!:3*" and the like), consider recalling the whole line and removing what you don't need (Alt+D and Alt+Backspace are your friends).
|
||||
|
||||
See <a href='index.html#editor'>documentation</a> for more details about line editing in fish.
|
||||
|
||||
<hr>
|
||||
|
||||
\section faq-uninstalling Uninstalling fish
|
||||
|
||||
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.
|
||||
Should you wish to uninstall fish, first ensure fish is not set as your shell. Run <code>chsh -s /bin/bash</code> if you are not sure.
|
||||
|
||||
Next, do the following (assuming fish was installed to /usr/local):
|
||||
|
||||
\fish{cli-dark}
|
||||
<pre>
|
||||
rm -Rf /usr/local/etc/fish /usr/local/share/fish ~/.config/fish
|
||||
rm /usr/local/share/man/man1/fish*.1
|
||||
cd /usr/local/bin
|
||||
rm -f fish mimedb fishd fish_indent
|
||||
\endfish
|
||||
|
||||
\htmlonly[block]
|
||||
</div>
|
||||
\endhtmlonly
|
||||
rm -f fish mimedb fish_pager fishd fish_indent
|
||||
</pre>
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
\section fg fg - bring job to foreground
|
||||
|
||||
\subsection fg-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
fg [PID]
|
||||
\endfish
|
||||
<tt>fg [PID]</tt>
|
||||
|
||||
\subsection fg-description Description
|
||||
|
||||
`fg` brings the specified <a href="index.html#syntax-job-control">job</a> 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.
|
||||
\c fg brings the specified <a href="index.html#syntax-job-control">job</a> 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.
|
||||
|
||||
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.
|
||||
|
||||
|
||||
\subsection fg-example Example
|
||||
|
||||
`fg %1` will put the job with job ID 1 in the foreground.
|
||||
<tt>fg \%1</tt> will put the job with job ID 1 in the foreground.
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
\section fish fish - the friendly interactive shell
|
||||
|
||||
\subsection fish-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
fish [OPTIONS] [-c command] [FILE [ARGUMENTS...]]
|
||||
\endfish
|
||||
fish [-h] [-v] [-c command] [FILE [ARGUMENTS...]]
|
||||
|
||||
\subsection fish-description Description
|
||||
|
||||
`fish` is a command-line shell written mainly with interactive use in mind. The full manual is available <a href='index.html'>in HTML</a> by using the <a href='#help'>help</a> command from inside fish.
|
||||
\c fish is a command-line shell written mainly with interactive use in mind. The
|
||||
full manual is available <a href='index.html'>in HTML</a> by using the
|
||||
<a href='#help'>help</a> command from inside fish.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-c` or `--command=COMMANDS` evaluate the specified commands instead of reading from the commandline
|
||||
- <code>-c</code> or <code>--command=COMMANDS</code> evaluate the specified commands instead of reading from the commandline
|
||||
- <code>-d</code> or <code>--debug-level=DEBUG_LEVEL</code> specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1.
|
||||
- <code>-h</code> or <code>--help</code> display help and exit
|
||||
- <code>-i</code> or <code>--interactive</code> specify that fish is to run in interactive mode
|
||||
- <code>-l</code> or <code>--login</code> specify that fish is to run as a login shell
|
||||
- <code>-n</code> or <code>--no-execute</code> do not execute any commands, only perform syntax checking
|
||||
- <code>-p</code> or <code>--profile=PROFILE_FILE</code> when fish exits, output timing information on all executed commands to the specified file
|
||||
- <code>-v</code> or <code>--version</code> display version and exit
|
||||
|
||||
- `-d` or `--debug-level=DEBUG_LEVEL` specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1.
|
||||
|
||||
- `-i` or `--interactive` specify that fish is to run in interactive mode
|
||||
|
||||
- `-l` or `--login` specify that fish is to run as a login shell
|
||||
|
||||
- `-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
|
||||
|
||||
- `-v` or `--version` display version and exit
|
||||
|
||||
The fish exit status is generally the exit status of the last foreground command. If fish is exiting because of a parse error, the exit status is 127.
|
||||
The fish exit status is generally the exit status of the last
|
||||
foreground command. If fish is exiting because of a parse error, the
|
||||
exit status is 127.
|
||||
|
||||
@@ -2,17 +2,21 @@
|
||||
|
||||
\subsection fish_config-description Description
|
||||
|
||||
`fish_config` starts the web-based configuration interface.
|
||||
\c fish_config starts the web-based configuration interface.
|
||||
|
||||
The web interface allows you to view your functions, variables and history, and to make changes to your prompt and color configuration.
|
||||
The web interface allows you to view your functions, variables and history, and
|
||||
to make changes to your prompt and color configuration.
|
||||
|
||||
`fish_config` starts a local web server and then opens a web browser window; when you have finished, close the browser window and then press the Enter key to terminate the configuration session.
|
||||
\c fish_config starts a local web server and then opens a web browser window; when
|
||||
you have finished, close the browser window and then press the Enter key to
|
||||
terminate the configuration session.
|
||||
|
||||
`fish_config` optionally accepts name of the initial configuration tab. For e.g. `fish_config history` will start configuration interface with history tab.
|
||||
|
||||
If the `BROWSER` environment variable is set, it will be used as the name of the web browser to open instead of the system default.
|
||||
There are no parameters for <code>fish_config</code>.
|
||||
|
||||
If the \c BROWSER environment variable is set, it will be used as the name
|
||||
of the web browser to open instead of the system default.
|
||||
|
||||
\subsection fish_config-example Example
|
||||
|
||||
`fish_config` opens a new web browser window and allows you to configure certain fish settings.
|
||||
\c fish_config opens a new web browser window and allows you to configure certain
|
||||
fish settings.
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
\section fish_indent fish_indent - indenter and prettifier
|
||||
|
||||
\subsection fish_indent-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
fish_indent [OPTIONS]
|
||||
\endfish
|
||||
<tt>fish_indent [options]</tt>
|
||||
|
||||
\subsection fish_indent-description Description
|
||||
|
||||
`fish_indent` is used to indent a piece of fish code. `fish_indent` reads commands from standard input and outputs them to standard output.
|
||||
\c fish_indent is used to indent a piece of fish
|
||||
code. \c fish_indent reads commands from standard input and outputs
|
||||
them to standard output.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-i` or `--no-indent` do not indent commands; only reformat to one job per line
|
||||
- <tt>-h</tt> or <tt>--help</tt> displays this help message and then exits
|
||||
- <tt>-i</tt> or <tt>--no-indent</tt> do not indent commands
|
||||
- <tt>-v</tt> or <tt>--version</tt> displays the current fish version and then exits
|
||||
|
||||
- `-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`
|
||||
|
||||
7
doc_src/fish_pager.txt
Normal file
7
doc_src/fish_pager.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
\section fish_pager fish_pager - internal command used by fish
|
||||
|
||||
\subsection fish_pager-description Description
|
||||
|
||||
\c fish_pager is used internally by fish. It should not be used by other
|
||||
commands, as its interface is liable to change in the future.
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
\section fish_prompt fish_prompt - define the appearance of the command line prompt
|
||||
|
||||
\subsection fish_prompt-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
function fish_prompt
|
||||
<pre>function fish_prompt
|
||||
...
|
||||
end
|
||||
\endfish
|
||||
end</pre>
|
||||
|
||||
\subsection fish_prompt-description Description
|
||||
|
||||
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.
|
||||
By defining the \c fish_prompt function, the user can choose a custom
|
||||
prompt. The \c 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 <a href="index.html#variables-status">$status</a> outside of the `fish_prompt` function.
|
||||
|
||||
`fish` ships with a number of example prompts that can be chosen with the `fish_config` command.
|
||||
The exit status of commands within \c fish_prompt will not modify the value of <a href="index.html#variables-status">$status</a> outside of the \c fish_prompt function.
|
||||
|
||||
\c fish ships with a number of example prompts that can be chosen with the
|
||||
\c fish_config command.
|
||||
|
||||
\subsection fish_prompt-example Example
|
||||
|
||||
A simple prompt:
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
function fish_prompt -d "Write out the prompt"
|
||||
printf '%s@%s%s%s%s> ' (whoami) (hostname | cut -d . -f 1) \
|
||||
(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
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
\section fish_right_prompt fish_right_prompt - define the appearance of the right-side command line prompt
|
||||
|
||||
\subsection fish_right_prompt-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
function fish_right_prompt
|
||||
<pre>function fish_right_prompt
|
||||
...
|
||||
end
|
||||
\endfish
|
||||
end</pre>
|
||||
|
||||
\subsection fish_right_prompt-description Description
|
||||
|
||||
`fish_right_prompt` is similar to `fish_prompt`, except that it appears on the right side of the terminal window.
|
||||
\c fish_right_prompt is similar to \c fish_prompt, except that it appears on the right side of the terminal window.
|
||||
|
||||
Multiple lines are not supported in `fish_right_prompt`.
|
||||
Multiple lines are not supported in \c fish_right_prompt.
|
||||
|
||||
|
||||
\subsection fish_right_prompt-example Example
|
||||
\subsection fish_prompt-example Example
|
||||
|
||||
A simple right prompt:
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
function fish_right_prompt -d "Write out the right prompt"
|
||||
date "+%m/%d/%y"
|
||||
end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
\subsection fish_update_completions-description Description
|
||||
|
||||
`fish_update_completions` parses manual pages installed on the system, and attempts to create completion files in the `fish` configuration directory.
|
||||
\c fish_update_completions parses manual pages installed on the system, and attempts to create completion files in the \c fish configuration directory.
|
||||
|
||||
This does not overwrite custom completions.
|
||||
|
||||
There are no parameters for `fish_update_completions`.
|
||||
There are no parameters for <code>fish_update_completions</code>.
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
408-600-6421\section fish_vi_mode fish_vi_mode - Enable vi mode
|
||||
|
||||
\subsection fish_vi_mode-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
fish_vi_mode
|
||||
\endfish
|
||||
|
||||
\subsection fish_vi_mode-description Description
|
||||
|
||||
`fish_vi_mode` enters a vi-like command editing mode. To always start in vi mode, add `fish_vi_mode` to your `config.fish` file.
|
||||
33
doc_src/fishd.txt
Normal file
33
doc_src/fishd.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
\section fishd fishd - universal variable daemon
|
||||
|
||||
\subsection fishd-synopsis Synopsis
|
||||
<tt>fishd [(-h|--help|-v|--version)]</tt>
|
||||
|
||||
\subsection fishd-description Description
|
||||
|
||||
The \c fishd daemon is used to load, save and distribute universal
|
||||
variable information. \c fish automatically connects to \c fishd via a socket
|
||||
on startup.
|
||||
|
||||
\c fishd is started and stopped automatically.
|
||||
|
||||
The following options are available if starting \c fishd manually:
|
||||
|
||||
- <tt>-h</tt> or <tt>--help</tt> displays this help message and then exits
|
||||
- <tt>-v</tt> or <tt>--version</tt> displays the current fish version and then exits
|
||||
|
||||
\subsection fishd-files Files
|
||||
|
||||
- \c ~/.config/fish/fishd.MACHINE_ID - permanent storage location for universal
|
||||
variable data. \c MACHINE_ID is generally based on the machine's MAC address.
|
||||
|
||||
The data is stored as a set of \c set and \c set_export commands such as
|
||||
would be parsed by fishd. The file must always be stored in YAML format.
|
||||
If an instance of fishd is running (which is generally the case), manual
|
||||
modifications to \c ~/.fishd.MACHINE_ID will be lost. Do NOT edit this file manually!
|
||||
|
||||
- \c /tmp/fishd.socket.USERNAME - the socket which fishd uses to communicate
|
||||
with all clients.
|
||||
|
||||
- /tmp/fishd.log.USERNAME - the fishd log file
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
\section for for - perform a set of commands multiple times.
|
||||
|
||||
\subsection for-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
for VARNAME in [VALUES...]; COMMANDS...; end
|
||||
\endfish
|
||||
<tt>for VARNAME in [VALUES...]; COMMANDS...; end</tt>
|
||||
|
||||
\subsection for-description Description
|
||||
|
||||
`for` is a loop construct. It will perform the commands specified by `COMMANDS` multiple times. On each iteration, the local variable specified by `VARNAME` is assigned a new value from `VALUES`. If `VALUES` is empty, `COMMANDS` will not be executed at all.
|
||||
<tt>for</tt> is a loop construct. It will perform the commands specified by
|
||||
\c COMMANDS multiple times. On each iteration, the environment variable specified by
|
||||
\c VARNAME is assigned a new value from \c VALUES. If \c VALUES is empty, \c COMMANDS will
|
||||
not be executed at all.
|
||||
|
||||
\subsection for-example Example
|
||||
|
||||
\fish
|
||||
for i in foo bar baz; echo $i; end
|
||||
The command
|
||||
|
||||
# would output:
|
||||
<tt>for i in foo bar baz; echo $i; end</tt>
|
||||
|
||||
would output:
|
||||
|
||||
<pre>
|
||||
foo
|
||||
bar
|
||||
baz
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
\section funced funced - edit a function interactively
|
||||
|
||||
\subsection funced-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
funced [OPTIONS] NAME
|
||||
\endfish
|
||||
<code>funced [OPTIONS] NAME</code>
|
||||
|
||||
\subsection funced-description Description
|
||||
|
||||
`funced` provides an interface to edit the definition of the function `NAME`.
|
||||
\c funced provides an interface to edit the definition of the function
|
||||
<code>NAME</code>.
|
||||
|
||||
If the `$EDITOR` environment variable is set, it will be used as the program to edit the function. Otherwise, a built-in editor will be used.
|
||||
If the \c $EDITOR environment variable is set, it will be used as the program
|
||||
to edit the function. Otherwise, a built-in editor will be used.
|
||||
|
||||
If there is no function called `NAME` a new function will be created with the specified name
|
||||
If there is no function called \c NAME a new function will be created with
|
||||
the specified name
|
||||
|
||||
- `-e command` or `--editor command` Open the function body inside the text editor given by the command (for example, "vi"). The command 'fish' will use the built-in editor.
|
||||
|
||||
- `-i` or `--interactive` Open function body in the built-in editor.
|
||||
- <code>-e command</code> or <code>--editor command</code> Open the function
|
||||
body inside the text editor given by the command (for example, "vi"). The
|
||||
command 'fish' will use the built-in editor.
|
||||
- <code>-i</code> or <code>--interactive</code> Open function body in the
|
||||
built-in editor.
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
\section funcsave funcsave - save the definition of a function to the user's autoload directory
|
||||
|
||||
\subsection funcsave-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
funcsave FUNCTION_NAME
|
||||
\endfish
|
||||
<tt>funcsave FUNCTION_NAME</tt>
|
||||
|
||||
\subsection funcsave-description Description
|
||||
|
||||
`funcsave` saves the current definition of a function to a file in the fish configuration directory. This function will be automatically loaded by current and future fish sessions. This can be useful if you have interactively created a new function and wish to save it for later use.
|
||||
\c funcsave saves the current definition of a function to
|
||||
a file in the fish configuration directory. This function will be automatically
|
||||
loaded by current and future fish
|
||||
sessions. This can be useful if you have interactively created a new
|
||||
function and wish to save it for later use.
|
||||
|
||||
|
||||
@@ -1,93 +1,58 @@
|
||||
\section function function - create a function
|
||||
|
||||
\subsection function-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
function [OPTIONS] NAME; BODY; end
|
||||
\endfish
|
||||
<code>function [OPTIONS] NAME; BODY; end </code>
|
||||
|
||||
\subsection function-description Description
|
||||
|
||||
`function` creates a new function `NAME` with the body `BODY`.
|
||||
\c function creates a new function \c NAME with the body <code>BODY</code>.
|
||||
|
||||
A function is a list of commands that will be executed when the name of the function is given as a command.
|
||||
A function is a list of commands that will be executed when the name of the
|
||||
function is given as a command.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-a NAMES` or `--argument-names NAMES` assigns the value of successive command-line arguments to the names given in NAMES.
|
||||
- <code>-d DESCRIPTION</code> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description.
|
||||
- <code>-e</code> or <code>--on-event EVENT_NAME</code> tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt.
|
||||
- <code>-j PID</code> or <code> --on-job-exit PID</code> tells fish to run this function when the job with group ID PID exits. Instead of PID, 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.
|
||||
- <code>-p PID</code> or <code> --on-process-exit PID</code> tells fish to run this function when the fish child process with process ID PID exits.
|
||||
- <code>-s</code> or <code>--on-signal SIGSPEC</code> tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP).
|
||||
- <code>-v</code> or <code>--on-variable VARIABLE_NAME</code> tells fish to run this function when the variable VARIABLE_NAME changes value.
|
||||
|
||||
- `-d DESCRIPTION` or `--description=DESCRIPTION` is a description of what the function does, suitable as a completion description.
|
||||
|
||||
- `-w WRAPPED_COMMAND` or `--wraps=WRAPPED_COMMAND` causes the function to inherit completions from the given wrapped command. See the documentation for <a href="#complete">`complete`</a> for more information.
|
||||
|
||||
- `-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.
|
||||
|
||||
- `-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.
|
||||
|
||||
- `-p PID` or `--on-process-exit PID` tells fish to run this function when the fish child process with process ID PID exits.
|
||||
|
||||
- `-s` or `--on-signal SIGSPEC` tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP).
|
||||
|
||||
- `-S` or `--no-scope-shadowing` allows the function to access the variables of calling functions. Normally, any variables inside the function that have the same name as variables from the calling function are "shadowed", and their contents is independent of the calling function.
|
||||
|
||||
- `-V` or `--inherit-variable NAME` snapshots the value of the variable `NAME` and defines a local variable with that same name and value when the function is executed.
|
||||
|
||||
If the user enters any additional arguments after the function, they are inserted into the environment <a href="index.html#variables-arrays">variable array</a> `$argv`. If the `--argument-names` option is provided, the arguments are also assigned to names specified in that option.
|
||||
If the user enters any additional arguments after the function, they
|
||||
are inserted into the environment <a href="index.html#variables-arrays">variable array</a>
|
||||
<code>$argv</code>.
|
||||
|
||||
By using one of the event handler switches, a function can be made to run automatically at specific events. The user may generate new events using the <a href="#emit">emit</a> builtin. Fish generates the following named events:
|
||||
|
||||
- `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.
|
||||
|
||||
Note: This event will be emitted even if the command is invalid. The commandline parameter includes the entire commandline verbatim, and may potentially include newlines.
|
||||
|
||||
- `fish_postexec`, which is emitted right after executing an interactive command. The commandline is passed as the first parameter.
|
||||
|
||||
Note: This event will be emitted even if the command is invalid. The commandline parameter includes the entire commandline verbatim, and may potentially include newlines.
|
||||
|
||||
- \c fish_prompt, which is emitted whenever a new fish prompt is about to be displayed.
|
||||
- \c fish_command_not_found, which is emitted whenever a command lookup failed.
|
||||
|
||||
\subsection function-example Example
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
function ll
|
||||
ls -l $argv
|
||||
ls -l $argv
|
||||
end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
will run the `ls` command, using the `-l` option, while passing on any additional files and switches to `ls`.
|
||||
will run the \c ls command, using the \c -l option, while passing on any additional files and switches to \c ls.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
function mkdir -d "Create a directory and set CWD"
|
||||
command mkdir $argv
|
||||
if test $status = 0
|
||||
switch $argv[(count $argv)]
|
||||
case '-*'
|
||||
command mkdir $argv
|
||||
if test $status = 0
|
||||
switch $argv[(count $argv)]
|
||||
case '-*'
|
||||
|
||||
case '*'
|
||||
cd $argv[(count $argv)]
|
||||
return
|
||||
end
|
||||
end
|
||||
case '*'
|
||||
cd $argv[(count $argv)]
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
This will run the `mkdir` command, and if it is successful, change the current working directory to the one just created.
|
||||
|
||||
\fish
|
||||
function notify
|
||||
set -l job (jobs -l -g)
|
||||
or begin; echo "There are no jobs" >&2; return 1; end
|
||||
|
||||
function _notify_job_$job --on-job-exit $job --inherit-variable job
|
||||
echo -n \a # beep
|
||||
functions -e _notify_job_$job
|
||||
end
|
||||
end
|
||||
\endfish
|
||||
|
||||
This will beep when the most recent job completes.
|
||||
will run the mkdir command, and if it is successful, change the
|
||||
current working directory to the one just created.
|
||||
|
||||
|
||||
@@ -1,52 +1,51 @@
|
||||
\section functions functions - print or erase functions
|
||||
|
||||
\subsection functions-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
functions [ -a | --all ] [ -n | --names ]
|
||||
\subsection function-synopsis Synopsis
|
||||
<pre>functions [-n]
|
||||
functions -c OLDNAME NEWNAME
|
||||
functions -d DESCRIPTION FUNCTION
|
||||
functions [ -e | -q ] FUNCTIONS...
|
||||
\endfish
|
||||
functions [-eq] FUNCTIONS...</pre>
|
||||
|
||||
\subsection functions-description Description
|
||||
|
||||
`functions` prints or erases functions.
|
||||
\c functions prints or erases functions.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-a` or `--all` lists all functions, even those whose name start with an underscore.
|
||||
- <code>-a</code> or <code>--all</code> lists all functions, even those whose name start with an underscore.
|
||||
- <code>-c OLDNAME NEWNAME</code> or <code>--copy OLDNAME NEWNAME</code> creates a new function named NEWNAME, using the definition of the OLDNAME function.
|
||||
- <code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> changes the description of this function.
|
||||
- <code>-e</code> or <code>--erase</code> causes the specified functions to be erased.
|
||||
- <code>-h</code> or <code>--help</code> displays a help message and exits.
|
||||
- <code>-n</code> or <code>--names</code> lists the names of all defined functions.
|
||||
- <code>-q</code> or <code>--query</code> tests if the specified functions exist.
|
||||
|
||||
- `-c OLDNAME NEWNAME` or `--copy OLDNAME NEWNAME` creates a new function named NEWNAME, using the definition of the OLDNAME function.
|
||||
The default behavior of <code>functions</code>, when called with no arguments,
|
||||
is to print the names of all defined functions. Unless the \c -a option is
|
||||
given, no functions starting with underscores are not included in the output.
|
||||
|
||||
- `-d DESCRIPTION` or `--description=DESCRIPTION` changes the description of this function.
|
||||
If any non-option parameters are given, the definition of the specified
|
||||
functions are printed.
|
||||
|
||||
- `-e` or `--erase` causes the specified functions to be erased.
|
||||
Automatically loaded functions cannot be removed using <code>functions
|
||||
-e</code>. Either remove the definition file or change the
|
||||
$fish_function_path variable to remove autoloaded functions.
|
||||
|
||||
- `-n` or `--names` lists the names of all defined functions.
|
||||
Copying a function using \c -c copies only the body of the function, and
|
||||
does not attach any event notifications from the original function.
|
||||
|
||||
- `-q` or `--query` tests if the specified functions exist.
|
||||
|
||||
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.
|
||||
|
||||
Automatically loaded functions cannot be removed using `functions -e`. Either remove the definition file or change the $fish_function_path variable to remove autoloaded functions.
|
||||
|
||||
Copying a function using `-c` copies only the body of the function, and does not attach any event notifications from the original function.
|
||||
|
||||
Only one function's description can be changed in a single invocation of `functions -d`.
|
||||
|
||||
The exit status of `functions` is the number of functions specified in the argument list that do not exist, which can be used in concert with the `-q` option.
|
||||
Only one function's description can be changed in a single invocation
|
||||
of <code>functions -d</code>.
|
||||
|
||||
The exit status of \c functions is the number of functions
|
||||
specified in the argument list that do not exist, which can be used in
|
||||
concert with the \c -q option.
|
||||
|
||||
\subsection functions-example Examples
|
||||
\fish
|
||||
functions -n
|
||||
# Displays a list of currently-defined functions
|
||||
|
||||
functions -c foo bar
|
||||
# Copies the 'foo' function to a new function called 'bar'
|
||||
<code>functions -n</code> displays a list of currently-defined functions.
|
||||
|
||||
functions -e bar
|
||||
# Erases the function `bar`
|
||||
\endfish
|
||||
<code>functions -c foo bar</code> copies the \c foo function to a new function called
|
||||
<code>bar</code>.
|
||||
|
||||
<code>functions -e bar</code> erases the function <code>bar</code>.
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
\section help help - display fish documentation
|
||||
|
||||
\subsection help-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
help [SECTION]
|
||||
\endfish
|
||||
<tt>help [SECTION]</tt>
|
||||
|
||||
\subsection help-description Description
|
||||
|
||||
`help` displays the fish help documentation.
|
||||
\c help displays the fish help documentation.
|
||||
|
||||
If a `SECTION` is specified, the help for that command is shown.
|
||||
If a \c SECTION is specified, the help for that command is shown.
|
||||
|
||||
If the BROWSER environment variable is set, it will be used to display the documentation. Otherwise, fish will search for a suitable browser.
|
||||
|
||||
Note that most builtin commands display their help in the terminal when given the `--help` option.
|
||||
If the BROWSER environment variable is set, it will be used to display the
|
||||
documentation. Otherwise, fish will search for a suitable browser.
|
||||
|
||||
Note that most builtin commands display their help in the terminal when
|
||||
given the <tt>--help</tt> option.
|
||||
|
||||
\subsection help-example Example
|
||||
|
||||
`help fg` shows the documentation for the `fg` builtin.
|
||||
<tt>help fg</tt> shows the documentation for the \c fg builtin.
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
\section history history - Show and manipulate command history
|
||||
|
||||
\subsection history-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
history ( --merge | --save | --clear )
|
||||
history ( --search | --delete ) [ --prefix "prefix string" | --contains "search string" ]
|
||||
\endfish
|
||||
<pre>
|
||||
history (--save | --clear)
|
||||
history (--search | --delete ) (--prefix "prefix string" | --contains "search string")
|
||||
</pre>
|
||||
|
||||
\subsection history-description Description
|
||||
|
||||
`history` is used to list, search and delete the history of commands used.
|
||||
\c history is used to list, search and delete the history of commands used.
|
||||
|
||||
The following options are available:
|
||||
- `--merge` immediately incorporates history changes from other sessions. Ordinarily `fish` ignores history changes from sessions started after the current one. This command applies those changes immediately.
|
||||
|
||||
- `--save` saves all changes in the history file. The shell automatically saves the history file; this option is provided for internal use.
|
||||
- \c --save saves all changes in the history file. The shell automatically
|
||||
saves the history file; this option is provided for internal use.
|
||||
- \c --clear clears the history file. A prompt is displayed before the history
|
||||
is erased.
|
||||
- \c --search returns history items in keeping with the \c --prefix or
|
||||
\c --contains options.
|
||||
- \c --delete deletes history items.
|
||||
- \c --prefix searches or deletes items in the history that begin with the
|
||||
specified text string.
|
||||
- \c --contains searches or deletes items in the history that contain the
|
||||
specified text string.
|
||||
|
||||
- `--clear` clears the history file. A prompt is displayed before the history is erased.
|
||||
|
||||
- `--search` returns history items in keeping with the `--prefix` or `--contains` options.
|
||||
|
||||
- `--delete` deletes history items.
|
||||
|
||||
- `--prefix` searches or deletes items in the history that begin with the specified text string.
|
||||
|
||||
- `--contains` searches or deletes items in the history that contain the specified text string.
|
||||
|
||||
If `--search` is specified without `--contains` or `--prefix`, `--contains` will be assumed.
|
||||
|
||||
If `--delete` is specified without `--contains` or `--prefix`, only a history item which exactly matches the parameter will be erased. No prompt will be given. If `--delete` is specified with either of these parameters, an interactive prompt will be displayed before any items are deleted.
|
||||
If \c --search is specified without \c --contains or <code>--prefix</code>,
|
||||
\c --contains will be assumed.
|
||||
|
||||
If \c --delete is specified without \c --contains or <code>--prefix</code>,
|
||||
only a history item which exactly matches the parameter will be erased. No
|
||||
prompt will be given. If \c --delete is specified with either of these
|
||||
parameters, an interactive prompt will be displayed before any items are
|
||||
deleted.
|
||||
|
||||
\subsection history-examples Example
|
||||
|
||||
\fish
|
||||
history --clear
|
||||
# Deletes all history items
|
||||
<code>history --clear</code> deletes all history items
|
||||
|
||||
history --search --contains "foo"
|
||||
# Outputs a list of all previous commands containing the string "foo".
|
||||
<code>history --search --contains "foo"</code> outputs a list of all previous
|
||||
commands containing the string "foo".
|
||||
|
||||
history --delete --prefix "foo"
|
||||
# Interactively deletes the record of previous commands which start with "foo".
|
||||
\endfish
|
||||
<code>history --delete --prefix "foo"</code> interactively deletes the record
|
||||
of previous commands which start with "foo".
|
||||
|
||||
@@ -1,32 +1,36 @@
|
||||
\section if if - conditionally execute a command
|
||||
|
||||
\subsection if-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
if CONDITION; COMMANDS_TRUE...;
|
||||
[else if CONDITION2; COMMANDS_TRUE2...;]
|
||||
[else; COMMANDS_FALSE...;]
|
||||
end
|
||||
\endfish
|
||||
<tt>if CONDITION; COMMANDS_TRUE...; [else if CONDITION2; COMMANDS_TRUE2...;] [else; COMMANDS_FALSE...;] end</tt>
|
||||
|
||||
\subsection if-description Description
|
||||
|
||||
`if` will execute the command `CONDITION`. If the condition's exit status is 0, the commands `COMMANDS_TRUE` will execute. If the exit status is not 0 and `else` is given, `COMMANDS_FALSE` will be executed.
|
||||
<tt>if</tt> will execute the command \c CONDITION. If the condition's
|
||||
exit status is 0, the commands \c COMMANDS_TRUE will execute. If the
|
||||
exit status is not 0 and <tt>else</tt> is given, \c COMMANDS_FALSE will
|
||||
be executed.
|
||||
|
||||
In order to use the exit status of multiple commands as the condition of an if block, use <a href="#begin">`begin; ...; end`</a> and the short circuit commands <a href="commands.html#and">`and`</a> and <a href="commands.html#or">`or`</a>.
|
||||
|
||||
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
|
||||
In order to use the exit status of multiple commands as the condition
|
||||
of an if block, use <a href="#begin"><tt>begin; ...; end</tt></a> and
|
||||
the short circuit commands <a href="commands.html#and"><tt>and</tt></a>
|
||||
and <a href="commands.html#or"><tt>or</tt></a>.
|
||||
|
||||
The exit status of the last foreground command to exit can always be
|
||||
accessed using the <a href="index.html#variables-status">$status</a>
|
||||
variable.
|
||||
|
||||
\subsection if-example Example
|
||||
|
||||
The following code will print `foo.txt exists` if the file foo.txt exists and is a regular file, otherwise it will print `bar.txt exists` if the file bar.txt exists and is a regular file, otherwise it will print `foo.txt and bar.txt do not exist`.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
if test -f foo.txt
|
||||
echo foo.txt exists
|
||||
echo foo.txt exists
|
||||
else if test -f bar.txt
|
||||
echo bar.txt exists
|
||||
echo bar.txt exists
|
||||
else
|
||||
echo foo.txt and bar.txt do not exist
|
||||
echo foo.txt and bar.txt do not exist
|
||||
end
|
||||
\endfish
|
||||
</pre>will print <tt>foo.txt exists</tt> if the file foo.txt
|
||||
exists and is a regular file, otherwise it will print
|
||||
<tt>bar.txt exists</tt> if the file bar.txt exists
|
||||
and is a regular file, otherwise it will print
|
||||
<tt>foo.txt and bar.txt do not exist</tt>.
|
||||
|
||||
1666
doc_src/index.hdr.in
1666
doc_src/index.hdr.in
File diff suppressed because it is too large
Load Diff
@@ -1,35 +1,14 @@
|
||||
\section isatty isatty - test if a file descriptor is a tty.
|
||||
\section isatty isatty - test if the specified file descriptor is a tty
|
||||
|
||||
\subsection isatty-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
isatty [FILE DESCRIPTOR]
|
||||
\endfish
|
||||
<tt>isatty [FILE DESCRIPTOR]</tt>
|
||||
|
||||
\subsection isatty-description Description
|
||||
<tt>isatty</tt> tests if a file descriptor is a tty.
|
||||
|
||||
`isatty` tests if a file descriptor is a tty.
|
||||
<tt>FILE DESCRIPTOR</tt> may be either the number of a file descriptor, or one of the
|
||||
strings <tt>stdin</tt>, \c stdout and <tt>stderr</tt>.
|
||||
|
||||
`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 tty, the exit status of the command is
|
||||
zero. Otherwise, it is non-zero.
|
||||
|
||||
If the specified file descriptor is a tty, the exit status of the command is zero. Otherwise, the exit status is non-zero. No messages are printed to standard error.
|
||||
|
||||
|
||||
\subsection isatty-examples Examples
|
||||
|
||||
From an interactive shell, the commands below exit with a return value of zero:
|
||||
|
||||
\fish
|
||||
isatty
|
||||
isatty stdout
|
||||
isatty 2
|
||||
echo | isatty 1
|
||||
\endfish
|
||||
|
||||
And these will exit non-zero:
|
||||
|
||||
\fish
|
||||
echo | isatty
|
||||
isatty 9
|
||||
isatty stdout > file
|
||||
isatty 2 2> file
|
||||
\endfish
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
\section jobs jobs - print currently running jobs
|
||||
|
||||
\subsection jobs-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
jobs [OPTIONS] [PID]
|
||||
\endfish
|
||||
<code>jobs [OPTIONS] [PID]</code>
|
||||
|
||||
\subsection jobs-description Description
|
||||
|
||||
`jobs` prints a list of the currently running <a href="index.html#syntax-job-control">jobs</a> and their status.
|
||||
<code>jobs</code> prints a list of the currently
|
||||
running <a href="index.html#syntax-job-control">jobs</a> and their status.
|
||||
|
||||
jobs accepts the following switches:
|
||||
|
||||
- `-c` or `--command` prints the command name for each process in jobs.
|
||||
|
||||
- `-g` or `--group` only prints the group ID of each job.
|
||||
|
||||
- `-l` or `--last` prints only the last job to be started.
|
||||
|
||||
- `-p` or `--pid` prints the process ID for each process in all jobs.
|
||||
|
||||
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\%.
|
||||
- <code>-c</code> or <code>--command</code> prints the command name for each process in jobs.
|
||||
- <code>-g</code> or <code>--group</code> only prints the group ID of each job.
|
||||
- <code>-h</code> or <code>--help</code> displays a help message and exits.
|
||||
- <code>-l</code> or <code>--last</code> prints only the last job to be started.
|
||||
- <code>-p</code> or <code>--pid</code> prints the process ID for each process in all jobs.
|
||||
|
||||
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\%.
|
||||
|
||||
\subsection jobs-example Example
|
||||
|
||||
`jobs` outputs a summary of the current jobs.
|
||||
<code>jobs</code> outputs a summary of the current jobs.
|
||||
|
||||
1659
doc_src/license.hdr
1659
doc_src/license.hdr
File diff suppressed because it is too large
Load Diff
@@ -2,19 +2,25 @@
|
||||
\section math math - Perform mathematics calculations
|
||||
|
||||
\subsection math-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
math EXPRESSION
|
||||
\endfish
|
||||
<tt>math EXPRESSION</tt>
|
||||
|
||||
\subsection math-description Description
|
||||
|
||||
`math` is used to perform mathematical calculations. It is a very thin wrapper for the bc program, which makes it possible to specify an expression from the command line without using non-standard extensions or a pipeline.
|
||||
|
||||
For a description of the syntax supported by math, see the manual for the bc program. Keep in mind that parameter expansion takes place on any expressions before they 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 have to be escaped.
|
||||
\c math is used to perform mathematical calculations. It is a very
|
||||
thin wrapper for the bc program, which makes it possible to specify an
|
||||
expression from the command line without using non-standard extensions
|
||||
or a pipeline.
|
||||
|
||||
For a description of the syntax supported by math, see the manual for
|
||||
the bc program. Keep in mind that parameter expansion takes place on
|
||||
any expressions before they are evaluated. This can be very useful in
|
||||
order to perform calculations involving environment variables or the
|
||||
output of command substitutions, but it also means that parenthesis
|
||||
have to be escaped.
|
||||
|
||||
\subsection math-example Examples
|
||||
|
||||
`math 1+1` outputs 2.
|
||||
<code>math 1+1</code> outputs 2.
|
||||
|
||||
`math $status-128` outputs the numerical exit status of the last command minus 128.
|
||||
<code>math $status-128</code> outputs the numerical exit status of the
|
||||
last command minus 128.
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
\section mimedb mimedb - lookup file information via the mime database
|
||||
|
||||
\subsection mimedb-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
mimedb [OPTIONS] FILES...
|
||||
\endfish
|
||||
<tt>mimedb [OPTIONS] FILES...</tt>
|
||||
|
||||
\subsection mimedb-description Description
|
||||
|
||||
`mimedb` queries the MIME type database and the `.desktop` files installed on the system in order to find information on the files listed in `FILES`. The information that `mimedb` can retrieve includes the MIME type for a file, a description of the type, and the default action that can be performed on the file. `mimedb` can also be used to launch the default action for this file.
|
||||
\c mimedb queries the MIME type database and the \c .desktop files
|
||||
installed on the system in order to find information on
|
||||
the files listed in <code>FILES</code>. The information that \c mimedb
|
||||
can retrieve includes the MIME type for a file, a description of the type,
|
||||
and the default action that can be performed on the file. \c mimedb can also
|
||||
be used to launch the default action for this file.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-t`, `--input-file-data` determines the files' type both by their filename and by their contents (default behaviour).
|
||||
- \c -t, \c --input-file-data determines the files' type both by their filename and by their contents (default behaviour).
|
||||
- \c -f, \c --input-filename determines the files' type by their filename.
|
||||
- \c -i, \c --input-mime specifies that the arguments are not files, but MIME types.
|
||||
- \c -m, \c --output-mime outputs the MIME type of each file (default behaviour).
|
||||
- \c -f, \c --output-description outputs the description of each MIME type.
|
||||
- \c -a, \c --output-action outputs the default action of each MIME type.
|
||||
- \c -l, \c --launch launches the default action for the specified files.
|
||||
- \c -h, \c --help displays a help message and exit.
|
||||
- \c -v, \c --version displays the version number and exits.
|
||||
|
||||
- `-f`, `--input-filename` determines the files' type by their filename.
|
||||
|
||||
- `-i`, `--input-mime` specifies that the arguments are not files, but MIME types.
|
||||
|
||||
- `-m`, `--output-mime` outputs the MIME type of each file (default behaviour).
|
||||
|
||||
- `-f`, `--output-description` outputs the description of each MIME type.
|
||||
|
||||
- `-a`, `--output-action` outputs the default action of each MIME type.
|
||||
|
||||
- `-l`, `--launch` launches the default action for the specified files.
|
||||
|
||||
- `-v`, `--version` displays the version number and exits.
|
||||
|
||||
@@ -1,29 +1,22 @@
|
||||
\section nextd nextd - move forward through directory history
|
||||
|
||||
\subsection nextd-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
nextd [ -l | --list ] [POS]
|
||||
\endfish
|
||||
<tt>nextd [-l | --list] [POS]</tt>
|
||||
|
||||
\subsection nextd-description Description
|
||||
<tt>nextd</tt> moves forwards <tt>POS</tt> positions in the history of visited
|
||||
directories; if the end of the history has been hit, a warning is printed.
|
||||
|
||||
`nextd` moves forwards `POS` positions in the history of visited directories; if the end of the history has been hit, a warning is printed.
|
||||
|
||||
If the `-l` or `--list` flag is specified, the current directory history is also displayed.
|
||||
|
||||
If the <code>-l></code> or <code>--list</code> flag is specified, the current
|
||||
directory history is also displayed.
|
||||
|
||||
\subsection nextd-example Example
|
||||
|
||||
\fish
|
||||
cd /usr/src
|
||||
<pre>cd /usr/src
|
||||
# Working directory is now /usr/src
|
||||
|
||||
cd /usr/src/fish-shell
|
||||
# Working directory is now /usr/src/fish-shell
|
||||
|
||||
prevd
|
||||
# Working directory is now /usr/src
|
||||
|
||||
nextd
|
||||
# Working directory is now /usr/src/fish-shell
|
||||
\endfish
|
||||
# Working directory is now /usr/src/fish-shell</pre>
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
\section not not - negate the exit status of a job
|
||||
|
||||
\subsection not-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
not COMMAND [OPTIONS...]
|
||||
\endfish
|
||||
<tt>not COMMAND [OPTIONS...]</tt>
|
||||
|
||||
\subsection not-description Description
|
||||
|
||||
`not` negates the exit status of another command. If the exit status is zero, `not` returns 1. Otherwise, `not` returns 0.
|
||||
|
||||
\c not negates the exit status of another command. If the exit status
|
||||
is zero, \c not returns 1. Otherwise, \c not returns 0.
|
||||
|
||||
\subsection not-example Example
|
||||
|
||||
The following code reports an error and exits if no file named spoon can be found.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
if not test -f spoon
|
||||
echo There is no spoon
|
||||
exit 1
|
||||
echo There is no spoon
|
||||
exit 1
|
||||
end
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
\section open open - open file in its default application
|
||||
|
||||
\subsection open-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
open FILES...
|
||||
\endfish
|
||||
<tt>open FILES...</tt>
|
||||
|
||||
\subsection open-description Description
|
||||
|
||||
`open` opens a file in its default application, using the `xdg-open` command if it exists, or else the <a href="commands.html#mimedb">mimedb</a> command.
|
||||
|
||||
\c open opens a file in its default application, using the \c xdg-open command if it exists, or else the <a href="commands.html#mimedb">mimedb</a> command.
|
||||
|
||||
\subsection open-example Example
|
||||
|
||||
`open *.txt` opens all the text files in the current directory using your system's default text editor.
|
||||
<tt>open *.txt</tt> opens all the text files in the current directory using your system's default text editor.
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
\section or or - conditionally execute a command
|
||||
|
||||
\subsection or-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
COMMAND1; or COMMAND2
|
||||
\endfish
|
||||
<tt>COMMAND1; or COMMAND2</tt>
|
||||
|
||||
\subsection or-description Description
|
||||
|
||||
`or` is used to execute a command if the current exit status (as set by the last previous command) is not 0.
|
||||
\c or is used to execute a command if the current exit
|
||||
status (as set by the last previous command) is not 0.
|
||||
|
||||
`or` does not change the current exit status.
|
||||
|
||||
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
|
||||
\c or does not change the current exit status.
|
||||
|
||||
The exit status of the last foreground command to exit can always be
|
||||
accessed using the <a href="index.html#variables-status">$status</a>
|
||||
variable.
|
||||
|
||||
\subsection or-example Example
|
||||
|
||||
The following code runs the `make` command to build a program. If the build succeeds, the program is installed. If either step fails, `make clean` is run, which removes the files created by the build process.
|
||||
The following code runs the \c make command to build a program. If the
|
||||
build succeeds, the program is installed. If either step fails,
|
||||
<tt>make clean</tt> is run, which removes the files created by the
|
||||
build process.
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
make; and make install; or make clean
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
\section popd popd - move through directory stack
|
||||
|
||||
\subsection popd-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
popd
|
||||
\endfish
|
||||
<tt>popd</tt>
|
||||
|
||||
\subsection popd-description Description
|
||||
|
||||
`popd` removes the top directory from the directory stack and changes the working directory to the new top directory. Use <a href="#pushd">`pushd`</a> to add directories to the stack.
|
||||
|
||||
<tt>popd</tt> removes the top directory from the directory stack and
|
||||
changes the working directory to the new top directory. Use <a
|
||||
href="#pushd"><tt>pushd</tt></a> to add directories to the stack.
|
||||
|
||||
\subsection popd-example Example
|
||||
|
||||
\fish
|
||||
<pre>
|
||||
pushd /usr/src
|
||||
# Working directory is now /usr/src
|
||||
# Directory stack contains /usr/src
|
||||
|
||||
pushd /usr/src/fish-shell
|
||||
# Working directory is now /usr/src/fish-shell
|
||||
# Directory stack contains /usr/src /usr/src/fish-shell
|
||||
|
||||
popd
|
||||
# Working directory is now /usr/src
|
||||
# Directory stack contains /usr/src
|
||||
\endfish
|
||||
</pre>
|
||||
|
||||
@@ -1,29 +1,24 @@
|
||||
\section prevd prevd - move backward through directory history
|
||||
|
||||
\subsection prevd-synopsis Synopsis
|
||||
\fish{synopsis}
|
||||
prevd [ -l | --list ] [POS]
|
||||
\endfish
|
||||
<tt>prevd [-l | --list] [POS]</tt>
|
||||
|
||||
\subsection prevd-description Description
|
||||
|
||||
`prevd` moves backwards `POS` positions in the history of visited directories; if the beginning of the history has been hit, a warning is printed.
|
||||
|
||||
If the `-l` or `--list` flag is specified, the current history is also displayed.
|
||||
<tt>prevd</tt> moves backwards <tt>POS</tt> positions in the history
|
||||
of visited directories; if the beginning of the history has been hit,
|
||||
a warning is printed.
|
||||
|
||||
If the <code>-l</code> or <code>--list</code> flag is specified, the current
|
||||
history is also displayed.
|
||||
|
||||
\subsection prevd-example Example
|
||||
|
||||
\fish
|
||||
cd /usr/src
|
||||
<pre>cd /usr/src
|
||||
# Working directory is now /usr/src
|
||||
|
||||
cd /usr/src/fish-shell
|
||||
# Working directory is now /usr/src/fish-shell
|
||||
|
||||
prevd
|
||||
# Working directory is now /usr/src
|
||||
|
||||
nextd
|
||||
# Working directory is now /usr/src/fish-shell
|
||||
\endfish
|
||||
# Working directory is now /usr/src/fish-shell</pre>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user