recently, as the incorrect arguments were being passed to execve. The
function went through the trouble of creating the proper arguments, and
then failed to use them.
darcs-hash:20080104015631-2d839-1d79a7810fcc3e2a3788dabdbc22d13a4bd4f404.gz
Add a function which checks that an option has not been used (useful to avoid
incompatible combinations of options and necessary for the completions for
the pacman package manager.
darcs-hash:20071217230315-782a0-be39b1258832f0d2427765200d051e5d688b041b.gz
There are various terminfo entries for screen that should be recognized aside from simply 'screen' such as 'screen-256color' and 'screen-bce'.
darcs-hash:20071013184358-35ec8-5e85add3cc1667781590e12118a98ec6641bc714.gz
Shells such as bash, sh, tcsh, and ksh each support a "colon command" that causes the script to be
evaluated as a bourne script. In the case of bash and sh, this command is a no-op. For others,
it means the script has sh syntax.
To suppor this in fish, I've added code to launch_process that checks for a ':' as the first
character of p->actual_cmd. If it is a colon, the process descriptor is modified to call
/bin/sh, which should exist on any POSIX system.
darcs-hash:20061208220428-5830d-6bde4f1a3e8100296a60c21f9e47988e20688a77.gz
Completions for all tools which come with eix.
(http://dev.croup.de/proj/eix)
darcs-hash:20061110155925-a923b-fd06120f7ea5f65cb752fe437bfccb6f16c87b45.gz
- You don't need to supply the package right after -C or -u etc.
- Better descriptions
darcs-hash:20061109145341-a923b-a1a54d3a5a040396ccba350c125f3b1ba645c601.gz
The current method of gettext detection is broken on (at least) OS X and Solaris, where which always returns successfully. This method seems to work on Linux, OS X, and Solaris.
darcs-hash:20060313014458-c90d9-8b169581a8632b6a47c61310ef3c976abd67d8e0.gz
Tweak to fallback.h to make it compile under OS X. As shipped with fish 1.21.2, this causes a lot of warnings and then dies.
darcs-hash:20060313014333-c90d9-de59932f81dd6debbfb48225893983df485df12b.gz
Command-line completions for svn. This includes some tweaks to the cvs completions file, to move a common function out into fish_complete.fish.
darcs-hash:20060210004314-494f2-c12a77084499cbc4216e8c5603ae4fadfb6b384c.gz
Better completions for cvs. Covers most flags in the manual, except for some for history that I couldn't write good descriptions for. Descriptions could probably use some tweaking, but the basic structure should be much better than what we had before.
darcs-hash:20060208023146-494f2-bea009421c161257f09c0f53c52ab1ee116fc3dc.gz
Tweak the open function to use /usr/bin/open on Darwin, and mimedb on everything else.
darcs-hash:20060206012623-494f2-e4626c03895065837f0c8981482d5b16313dfc08.gz
Changed __fish_describe_command to use awk instead of sed, and handle 'alternative' names, as used by OS X. (And possibly some BSDs?)
darcs-hash:20060205221805-494f2-85a48edd8e6fbcfc1dcd28079e4adfa52a0466d0.gz
Tweaked prompt_pwd and pwd to omit the leading /private from some system directories on OS X.
darcs-hash:20060205194908-494f2-936d1346a4cd118f763bea24495edf9829b59748.gz
Without this check, it would be possible to attempt to source a directory and get stuck in an infinite loop.
darcs-hash:20051215172122-35ec8-b3ce05d8d7ee9534edf92b74ca842d034b894e8a.gz
Adds checks for RLIMIT_NPROC, RLIMIT_RSS and RLIMIT_MEMLOCK not available
on all platforms.
darcs-hash:20051124111321-cac88-606a61ca0f3baa69115be658a056f42a5a9318ad.gz
Error message for invalid character in variable name
*/
#define BUILTIN_ERR_VARCHAR _( L"%ls: Invalid character '%lc' in variable name. Only alphanumerical characters and underscores are valid in a variable name.\n" )
/**
Error message for invalid (empty) variable name
*/
#define BUILTIN_ERR_VARNAME_ZERO _( L"%ls: Variable name can not be the empty string\n" )
/**
Error message when second argument to for isn't 'in'
*/
#define BUILTIN_FOR_ERR_IN _( L"%ls: Second argument must be 'in'\n" )
/**
Error message for insufficient number of arguments
*/
#define BUILTIN_FOR_ERR_COUNT _( L"%ls: Expected at least two arguments, got %d\n")
#define BUILTIN_FOR_ERR_NAME _( L"%ls: '%ls' is not a valid variable name\n" )
/**
Error message when too many arguments are supplied to a builtin
*/
#define BUILTIN_ERR_TOO_MANY_ARGUMENTS _( L"%ls: Too many arguments\n" )
/**
Error message when block types mismatch in the end builtin, e.g. 'begin; end for'
*/
#define BUILTIN_END_BLOCK_MISMATCH _( L"%ls: Block mismatch: '%ls' vs. '%ls'\n" )
/**
Error message for unknown block type in the end builtin, e.g. 'begin; end beggin'
*/
#define BUILTIN_END_BLOCK_UNKNOWN _( L"%ls: Unknown block type '%ls'\n" )
#define BUILTIN_ERR_NOT_NUMBER _( L"%ls: Argument '%ls' is not a number\n" )
/**
/**
Stringbuffer used to represent standard output
Stringbuffer used to represent standard output
*/
*/
@@ -66,10 +129,11 @@ int builtin_exists( wchar_t *cmd );
of the builtin. The list is terminated by a
of the builtin. The list is terminated by a
null pointer. This syntax resembles the syntax
null pointer. This syntax resembles the syntax
for exec.
for exec.
\param io the io redirections to perform on this builtin.
\return the exit status of the builtin command
\return the exit status of the builtin command
*/
*/
intbuiltin_run(wchar_t**argv);
intbuiltin_run(wchar_t**argv,io_data_t*io);
/**
/**
Insert all builtin names into l. These are not copies of the strings and should not be freed after use.
Insert all builtin names into l. These are not copies of the strings and should not be freed after use.
@@ -92,26 +156,21 @@ void builtin_pop_io();
*/
*/
constwchar_t*builtin_get_desc(constwchar_t*b);
constwchar_t*builtin_get_desc(constwchar_t*b);
/**
Counts the number of non null pointers in the specified array
*/
intbuiltin_count_args(wchar_t**argv);
/**
/**
Print help for the specified builtin. If \c b is sb_err, also print the line information
Slightly kludgy function used with 'complete -C' inorder to make
the commandline builtin operate on the string to complete instead
Under curses, tputs expects an int (*func)(char) as its last parameter, but in ncurses, tputs expects a int (*func)(int) as its last parameter. tputs_arg_t is defined to always be what tputs expects. Hopefully.
Maximum number of bytes used by a single utf-8 character
*/
#ifdef NCURSES_VERSION
typedefinttputs_arg_t;
#else
typedefchartputs_arg_t;
#endif
/**
Maximum number of bytes in a utf-8 character
*/
*/
#define MAX_UTF8_BYTES 6
#define MAX_UTF8_BYTES 6
/**
/**
Color code for set_color. Does not update the color.
This is in the unicode private use area.
*/
*/
#define ENCODE_DIRECT_BASE 0xf100
#define FISH_COLOR_IGNORE -1
/**
/**
Color code for set_color. Sets the default color.
Highest legal ascii value
*/
*/
#define FISH_COLOR_RESET -2
#define ASCII_MAX 127u
/** Save the shell mode on startup so we can restore them on exit */
/**
Highest legal 16-bit unicode value
*/
#define UCS2_MAX 0xffffu
/**
Highest legal byte value
*/
#define BYTE_MAX 0xffu
/**
Escape special fish syntax characters like the semicolon
*/
#define UNESCAPE_SPECIAL 1
/**
Allow incomplete escape sequences
*/
#define UNESCAPE_INCOMPLETE 2
/**
Escape all characters, including magic characters like the semicolon
*/
#define ESCAPE_ALL 1
/**
Do not try to use 'simplified' quoted escapes, and do not use empty quotes as the empty string
*/
#define ESCAPE_NO_QUOTED 2
/**
Save the shell mode on startup so we can restore them on exit
*/
externstructtermiosshell_modes;
externstructtermiosshell_modes;
/**
/**
The character to use where the text has been truncated. Is an ellipsis on unicode system and a $ on other systems.
The character to use where the text has been truncated. Is an
ellipsis on unicode system and a $ on other systems.
*/
*/
externwchar_tellipsis_char;
externwchar_tellipsis_char;
/**
/**
The maximum number of charset convertion errors to report
The verbosity level of fish. If a call to debug has a severity
*/
level higher than \c debug_level, it will not be printed.
externinterror_max;
/**
The verbosity of fish
*/
*/
externintdebug_level;
externintdebug_level;
@@ -64,8 +87,93 @@ extern char *profile;
debug function.
debug function.
*/
*/
externwchar_t*program_name;
externwchar_t*program_name;
/**
/**
Take an array_list_t containing wide strings and converts them to a wchar_t **.
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
failiure, the current function is ended at once. The second
parameter is the return value of the current function on failiure.
*/
#define CHECK( arg, retval ) \
if( !(arg) ) \
{ \
debug( 0, \
_( L"function %s called with null value for argument %s. " ), \
__func__, \
#arg ); \
bugreport(); \
show_stackframe(); \
return retval; \
}
/**
Pause for input, then exit the program. If supported, print a backtrace first.
*/
#define FATAL_EXIT() \
{ \
int exit_read_count;char exit_read_buff; \
show_stackframe(); \
exit_read_count=read( 0, &exit_read_buff, 1 ); \
exit( 1 ); \
} \
/**
Exit program at once, leaving an error message about running out of memory.
*/
#define DIE_MEM() \
{ \
fwprintf( stderr, \
L"fish: Out of memory on line %d of file %s, shutting down fish\n", \
__LINE__, \
__FILE__ ); \
FATAL_EXIT(); \
}
/**
Check if signals are blocked. If so, print an error message and
return from the function performing this check.
*/
#define CHECK_BLOCK( retval ) \
if( signal_is_blocked() ) \
{ \
debug( 0, \
_( L"function %s called while blocking signals. " ), \
__func__); \
bugreport(); \
show_stackframe(); \
return retval; \
}
/**
Shorthand for wgettext call
*/
#define _(wstr) wgettext(wstr)
/**
Noop, used to tell xgettext that a string should be translated,
even though it is not directly sent to wgettext.
*/
#define N_(wstr) wstr
/**
Check if the specified stringelement is a part of the specified string list
Returns a newly allocated wide character string wich is a copy of the string in, but of length c or shorter. The returned string is always null terminated, and the null is not included in the string length.
*/
wchar_t*wcsndup(constwchar_t*in,intc);
/**
Converts from wide char to digit in the specified base. If d is not
a valid digit in the specified base, return -1.
*/
longconvert_digit(wchar_td,intbase);
/**
Convert a wide character string to a number in the specified
base. This functions is the wide character string equivalent of
strtol. For bases of 10 or lower, 0..9 are used to represent
numbers. For bases below 36, a-z and A-Z are used to represent
numbers higher than 9. Higher bases than 36 are not supported.
*/
longwcstol(constwchar_t*nptr,
wchar_t**endptr,
intbase);
size_t
wcslcat(wchar_t*dst,constwchar_t*src,size_tsiz);
size_t
wcslcpy(wchar_t*dst,constwchar_t*src,size_tsiz);
/**
Create a dublicate string. Wide string version of strdup.
*/
wchar_t*wcsdup(constwchar_t*in);
/**
Case insensitive string compare function. Wide string version of
strcasecmp.
This implementation of wcscasecmp does not take into account
esoteric locales where uppercase and lowercase do not cleanly
transform between each other. Hopefully this should be fine since
fish only uses this function with one of the strings supplied by
Call read while blocking the SIGCHLD signal. Should only be called
Call read while blocking the SIGCHLD signal. Should only be called
if you _know_ there is data available for reading.
if you _know_ there is data available for reading, or the program
will hang until there is data.
*/
*/
intread_blocked(intfd,void*buf,size_tcount);
intread_blocked(intfd,void*buf,size_tcount);
/**
/**
This is for writing process notification messages. Has to write to
Loop a write request while failiure is non-critical. Return -1 and set errno
stdout, so clr_eol and such functions will work correctly. Not an
in case of critical error.
issue since this function is only used in interactive mode anyway.
*/
*/
ssize_twrite_loop(intfd,char*buff,size_tcount);
intwriteb(tputs_arg_tb);
voiddie_mem();
/**
Clean up
*/
voidcommon_destroy();
/**
/**
Issue a debug message with printf-style string formating and
Issue a debug message with printf-style string formating and
automatic line breaking. The string will begin with the string \c
automatic line breaking. The string will begin with the string \c
program_name, followed by a colon and a whitespace.
program_name, followed by a colon and a whitespace.
Because debug is often called to tell the user about an error,
before using wperror to give a specific error message, debug will
never ever modify the value of errno.
\param level the priority of the message. Lower number means higher priority. Messages with a priority_number higher than \c debug_level will be ignored..
\param level the priority of the message. Lower number means higher priority. Messages with a priority_number higher than \c debug_level will be ignored..
\param the message format string.
\param msg the message format string.
Example:
Example:
@@ -244,7 +356,7 @@ void common_destroy();
will print the string 'fish: Pi = 3.141', given that debug_level is 1 or higher, and that program_name is 'fish'.
will print the string 'fish: Pi = 3.141', given that debug_level is 1 or higher, and that program_name is 'fish'.
*/
*/
voiddebug(intlevel,wchar_t*msg,...);
voiddebug(intlevel,constwchar_t*msg,...);
/**
/**
Replace special characters with backslash escape sequences. Newline is
Replace special characters with backslash escape sequences. Newline is
Prototypes for functions related to tab-completion.
Prototypes for functions related to tab-completion.
These functions are used for storing and retrieving tab-completion data, as well as for performing tab-completion.
These functions are used for storing and retrieving tab-completion
data, as well as for performing tab-completion.
*/
*/
#ifndef FISH_COMPLETE_H
#ifndef FISH_COMPLETE_H
/**
Header guard
*/
#define FISH_COMPLETE_H
#define FISH_COMPLETE_H
#include<wchar.h>
#include<wchar.h>
#include"util.h"
#include"util.h"
/** Use all completions */
/**
Use all completions
*/
#define SHARED 0
#define SHARED 0
/** Do not use file completion */
/**
Do not use file completion
*/
#define NO_FILES 1
#define NO_FILES 1
/** Require a parameter after completion */
/**
Require a parameter after completion
*/
#define NO_COMMON 2
#define NO_COMMON 2
/** Only use the argument list specifies with completion after option. This is the same as (NO_FILES & NO_COMMON) */
/**
Only use the argument list specifies with completion after
option. This is the same as (NO_FILES & NO_COMMON)
*/
#define EXCLUSIVE 3
#define EXCLUSIVE 3
/** Command is a path */
/**
Command is a path
*/
#define PATH 1
#define PATH 1
/** Command is not a path */
/**
Command is not a path
*/
#define COMMAND 0
#define COMMAND 0
/** Separateor between completion and description*/
/**
Separator between completion and description
*/
#define COMPLETE_SEP L'\004'
#define COMPLETE_SEP L'\004'
/** Separateor between completion and description*/
/**
Separator between completion and description
*/
#define COMPLETE_SEP_STR L"\004"
#define COMPLETE_SEP_STR L"\004"
/**
/**
Character that separates the completion and description on programmable completions
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
*/
*/
#define PROG_COMPLETE_SEP L'\t'
#define PROG_COMPLETE_SEP L'\t'
/**
/**
Initializes various structures used for tab-completion.
Do not insert space afterwards if this is the only completion. (The
default is to try insert a space)
*/
*/
voidcomplete_init();
#define COMPLETE_NO_SPACE 1
/**
/**
Destroys various structures used for tab-completion and free()s the memory used by them.
This compeltion is case insensitive.
Warning: The contents of the completion_t structure is actually
different if this flag is set! Specifically, the completion string
contains the _entire_ completion token, not only the current
*/
*/
voidcomplete_destroy();
#define COMPLETE_NO_CASE 2
/**
This compeltion is the whole argument, not just the remainder. This
flag must never be set on completions returned from the complete()
function. It is strictly for internal use in the completion code.
*/
#define COMPLETE_WHOLE_ARGUMENT 4
/**
This completion may or may not want a space at the end - guess by
checking the last character of the completion.
*/
#define COMPLETE_AUTO_SPACE 8
/**
This completion should be inserted as-is, without escaping.
*/
#define COMPLETE_DONT_ESCAPE 16
typedefstruct
{
/**
The completion string
*/
constwchar_t*completion;
/**
The description for this completion
*/
constwchar_t*description;
/**
Flags determining the completion behaviour.
Determines whether a space should be inserted after this
compeltion if it is the only possible completion using the
COMPLETE_NO_SPACE flag.
The COMPLETE_NO_CASE can be used to signal that this completion
is case insensitive.
*/
intflags;
}
completion_t;
/**
/**
Add a completion.
Add a completion.
Values are copied and should be freed by the caller.
All supplied values are copied, they should be freed by or otherwise
disposed by the caller.
Examples:
Examples:
@@ -83,28 +169,35 @@ void complete_destroy();
file completion is not performed.
file completion is not performed.
\param comp A space separated list of completions which may contain subshells.
\param comp A space separated list of completions which may contain subshells.
\param desc A description of the completion.
\param desc A description of the completion.
\param authorative Whether there list of completions for this command is complete. If true, any options not matching one of the provided options will be flagged as an error by syntax highlighting.
\param condition a command to be run to check it this completion should be used. If \c condition is empty, the completion is always used.
\param condition a command to be run to check it this completion should be used. If \c condition is empty, the completion is always used.
\param flags A set of completion flags
*/
*/
voidcomplete_add(constwchar_t*cmd,
voidcomplete_add(constwchar_t*cmd,
intcmd_type,
intcmd_type,
wchar_tshort_opt,
wchar_tshort_opt,
constwchar_t*long_opt,
constwchar_t*long_opt,
intlong_mode,
intlong_mode,
intresult_mode,
intresult_mode,
intauthorative,
constwchar_t*condition,
constwchar_t*condition,
constwchar_t*comp,
constwchar_t*comp,
constwchar_t*desc,
constwchar_t*desc);
intflags);
/**
Sets whether the completion list for this command is complete. If
true, any options not matching one of the provided options will be
flagged as an error by syntax highlighting.
*/
voidcomplete_set_authoritative(constwchar_t*cmd,
intcmd_type,
intauthoritative);
/**
/**
Remove a previously defined completion
Remove a previously defined completion
*/
*/
voidcomplete_remove(constwchar_t*cmd,
voidcomplete_remove(constwchar_t*cmd,
intcmd_type,
intcmd_type,
wchar_tshort_opt,
wchar_tshort_opt,
constwchar_t*long_opt);
constwchar_t*long_opt);
/**
/**
Find all completions of the command cmd, insert them into out. The
Find all completions of the command cmd, insert them into out. The
Tests if the specified option is defined for the specified command
Tests if the specified option is defined for the specified command
*/
*/
@@ -159,6 +243,20 @@ int complete_is_valid_argument( const wchar_t *str,
\param cmd the command for which to load command-specific completions
\param cmd the command for which to load command-specific completions
\param reload should the commands completions be reloaded, even if they where previously loaded. (This is set to true on actual completions, so that changed completion are updated in running shells)
\param reload should the commands completions be reloaded, even if they where previously loaded. (This is set to true on actual completions, so that changed completion are updated in running shells)
*/
*/
voidcomplete_load(wchar_t*cmd,intreload);
voidcomplete_load(constwchar_t*cmd,intreload);
/**
Create a new completion entry
\param context The halloc context to use for allocating new memory
\section and and - conditionally execute a command
\section and and - Conditionally execute a command
\subsection and-synopsis Synopsis
\subsection and-synopsis Synopsis
<tt>and COMMAND1; COMMAND2</tt>
<tt>COMMAND1; and COMMAND2</tt>
\subsection and-description Description
\subsection and-description Description
The \c and builtin is used to execute one command, and if it returns
The \c and builtin is used to execute a command if the current exit
zero status, also execute a second command.
status (as set by the last previous command) is 0.
The and command 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
\subsection and-example Example
The following code runs the \c make command to build a program, and if it suceeds, it runs <tt>make install</tt>, which installs the program.
The following code runs the \c make command to build a program, if the
<pre>
build succeeds, the program is installed. If either step fails,
and make; make install
<tt>make clean</tt> is run, which removes the files created by the
</pre>
build process
\c or and \c and can be nested, as in this example, that attempts to build and install a program, and removed the files created by the build process on failiure
@@ -8,7 +8,7 @@ Sends the specified jobs to the background. A background job is
executed simultaneously with fish, and does not have access to the
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 group ids are put in the background.
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 group ids are put in the background.
The PID of the desired process is usually found by using process globbing.
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.
The <tt>bind</tt> builtin causes fish to add the readline style bindings specified by <tt>BINDINGS</tt> to the list of key bindings. For more information on specifying keyboard bindings, use <tt>man readline</tt> to access the readline documentation.
\subsection bind-description Description
\subsection bind-description Description
- <tt>-M MODE</tt> or <tt>--set-mode=MODE</tt> sets the current input mode to MODE.
The <tt>bind</tt> builtin causes fish to add a key binding from the specified sequence.
SEQUENCE is the character sequence to bind to. Usually, one would use
fish escape sequences to express them. 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>. Control character can be written in much the same way
using the \c \\c escape, for example Control-x can be written as
<tt>\\cx</tt>. Note that Alt-based key bindings are case sensitive and
Control base key bindings are not. This is not a design choice in
fish, it is simply how terminals work.
If SEQUENCE is the empty string, i.e. an empty set of quotes, this is
interpreted as the default keybinding. 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 keybining. 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 e.g. 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 man 5 terminfo 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.
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.
- <tt>-a</tt> or <tt>--all</tt> If --key-names is specified, show all key names, not only the ones that actually are defined for the current terminal. If erase mode is specified, this switch will cause all current bindings to be erased.
- <tt>-e</tt> or <tt>--erase</tt> Erase mode. All non-switch arguments are interpreted as character sequences and any commands associated with those sequences are erased.
- <tt>-h</tt> or <tt>--help</tt> Display help and exit
- <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 Example
\subsection bind-example Example
<tt>bind -M vi</tt> changes to the vi input mode
<tt>bind \\cd 'exit'</tt> causes fish to exit on Control-d
<tt>bind -k ppage history-search-backward</tt> Causes fish to perform a history search when the page up key is pressed
<tt>bind '"\\M-j": jobs'</tt> Binds the jobs command to the Alt-j keyboard shortcut
\section break break - stop the innermost currently evaluated loop
\section break break - stop the innermost currently evaluated loop
\subsection break-synopsis Synopsis
\subsection break-synopsis Synopsis
@@ -8,14 +7,13 @@
The \c break builtin is used to halt 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.
The \c break builtin is used to halt 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.
\subsection break-example Example
\subsection break-example Example
The following code searches all .c files for smurfs, and halts at the first occurance.
The following code searches all .c files for smurfs, and halts at the first occurrence.
<p>
<tt>for i in *.c;
<br> if grep smurf $i;
<br> echo Smurfs are present in $i;
For an introduction to how to specify completions, see the section <a
href='index.html#completions-own'>Writing your own completions</a> of
the fish manual.
- <tt>COMMAND</tt> 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>SHORT_OPTION</tt> is a one character option for the command
- <tt>LONG_OPTION</tt> is a multi 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>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>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>-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>-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> specides 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>-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>-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>-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>-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>--unauthorative</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>-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>
- <tt>-x</tt> or <tt>--exclusive</tt> implies both <tt>-r</tt> and <tt>-f</tt>
Command specific tab-completions in \c fish are based on the notion
Command specific tab-completions in \c fish are based on the notion
@@ -25,13 +32,14 @@ that do not begin with a hyphen. Fish recognizes three styles of
options, the same styles as the GNU version of the getopt
options, the same styles as the GNU version of the getopt
library. These styles are:
library. These styles are:
- Short options, like '-a'. Short options are a single character long, are preceeded by a single hyphen and may ge 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').
- 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 are more than one character long, are preceeded by a single hyphen and may not be grouped together. Option arguments are specified in the following parameter ('-ao null').
- 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 are more than one character long, are preceeded 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 abbrevated so long as the abbrevation is unique ('--h' is equivalent to '--help' if help is the only long option beginning with an 'h').
- 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').
\c complete only allows one of old style long options and GNU style
The options for specifying command name, command path, or command
long options to be used on a specific command, but short options can
switches may all be used multiple times to specify multiple commands
always be specified.
which have the same completion or multiple switches accepted by a
command.
When erasing completions, it is possible to either erase all
When erasing completions, it is possible to either erase all
completions for a specific command by specifying <tt>complete -e -c
completions for a specific command by specifying <tt>complete -e -c
@@ -61,7 +69,9 @@ are valid, like the \c nodeps switch.
The \c continue builtin is used to skip the current lap of the innermost 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.
The \c continue builtin is used to skip the current lap of the innermost 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.
\subsection continue-example Example
\subsection continue-example Example
The following code removes all tmp files without smurfs.
The following code removes all tmp files without smurfs.
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 achive 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.
Rationale:
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 achived 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 \$''.
\section sep The law of minimalism
The shell should only contain features that cannot be implemented in
a reasonable way outside of the shell. A large performance decrease,
as well as some program complexity increase is acceptable in order to
improve separation.
Rationale:
A modular project is easier to maintain since smaller programs are far
easier to understand than larger ones. A modular project is also more
future proof since the modules can be individually
replaced. Modularity also decreases the severity of bugs, since there
is good hope that a bug, even a serious one, in one module, does not
take the whole system down.
Examples:
- Builtin commands should only be created when it cannot be
avoided. \c echo, \c kill, \c printf and \c time are among the commands
that fish does not implement internally since they can be provided as
external commands. Several other commands that are commonly implemented
as builtins and can not be implemented as external commands,
including \c type, \c vared, \c pushd and \c popd are implemented as shellscript
functions in fish.
- Mathematical calculations, regex matching, generating lists of numbers
and many other funtions can easily be done in external programs. They
should not be supported internally by the shell.
The law of minimalism does not imply that a large feature set is
bad. So long as a feature is not part of the shell itself, but a
separate command or at least a shellscript function, bloat is fine.
\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 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.
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 of 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.
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 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 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 \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.
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 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 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, he will know the whole language, and be able to use tab-completion to discover new featues.
\section eval eval - evaluate the specified commands
\subsection eval-synopsis Synopsis
\subsection eval-synopsis Synopsis
<tt>eval [COMMANDS...]</tt>
<tt>eval [COMMANDS...]</tt>
\subsection eval-description Description
\subsection eval-description Description
The <tt>eval</tt> builtin causes fish to evaluate 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.
The <tt>eval</tt> function causes fish to evaluate 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.
Fish is trying to set the titlebar message of your terminal. While
screen itself supports this feature, your terminal does
not. Unfortuntaly, 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.
<hr>
\section faq-greeting How do I change the greeting message?
Change the value of the variable fish_greeting. For example, to remove
the greeting use:
<pre>
set fish_greeting
</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 ".
Fish history recall is very simple yet effective:
- 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.
Sends the specified job to the foreground. While a foreground job is
Sends the specified job to the foreground. 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.
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 process globbing.
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.
\section fish fish - the friendly interactive shell
\subsection fish-synopsis Synopsis
fish [-h] [-v] [-c command] [FILE [ARGUMENTS...]]
\subsection fish-description Description
A commandline 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.
- <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
The fish exit status is generally the exit status of the last
foreground command. If fish is exiting because of a parse error, the
\section funced funced - edit a function interactively
\subsection funced-synopsis Synopsis
<code>funced NAME</code>
\subsection funced-description Description
Use the funced command to interactively edit the definition of a
function. If there is no function with the name specified, a skeleton function is inserted, if a function exist, the definion will be shown on the command line.
- \c -b or \c --key-binding specifies that the function is a key biding. Key binding functions work exactly like regular functions except that they can not be tab-completed, and may contain the '-' character.
- <code>-d DESCRIPTION</code> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description
- <tt>-d DESCRIPTION</tt> 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.
- <tt>-j PID</tt> or <tt> --on-job-exit PID</tt> tells fish to run this function when the job with group id PID exits
- <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.
- <tt>-p PID</tt> or <tt> --on-process-exit PID</tt> tells fish to run this function when the fish child process with process id PID exits
- <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
- <tt>-s</tt> or <tt>--on-signal SIGSPEC</tt> tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a singal number, or the signal name, such as SIGHUP (or just HUP)
- <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)
- <tt>-v</tt> or <tt>--on-variable VARIABLE_NAME</tt> tells fish to run this function when the variable VARIABLE_NAME changes value
- <code>-v</code> or <code>--on-variable VARIABLE_NAME</code> tells fish to run this function when the variable VARIABLE_NAME changes value
This builtin command is used to create a new function. A Function is a
This builtin command is used to create a new function. A function is a
list of commands that will be executed when the name of the function
list of commands that will be executed when the name of the function
is entered. The function
is entered. The function
<pre>
<pre>
function hi
function hi
echo hello
echo hello
end
end
</pre>
</pre>
will write <tt>hello</tt> whenever the user enters \c hi.
will write <code>hello</code> whenever the user enters \c hi.
If the user enters any additional arguments after the function, they
If the user enters any additional arguments after the function, they
are inserted into the environment variable <a href="index.html#variables-arrays">array</a> argv.
are inserted into the environment <a href="index.html#variables-arrays">variable array</a> argv.
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:
- \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
\subsection function-example Example
<pre>function ll
<pre>
function ll
ls -l $argv
ls -l $argv
end
end
</pre>
</pre>
@@ -39,18 +45,18 @@ will run the \c ls command, using the \c -l option, while passing on any additio
<pre>
<pre>
function mkdir -d "Create a directory and set CWD"
function mkdir -d "Create a directory and set CWD"
mkdir $argv
mkdir $argv
if test $status = 0
if test $status = 0
switch $argv[(count $argv)]
switch $argv[(count $argv)]
case '-*'
case '-*'
case '*'
case '*'
cd $argv[(count $argv)]
cd $argv[(count $argv)]
return
return
end
end
end
end
end
end
</pre>
</pre>
will run the mkdir command, and if it is succesfull, change the
will run the mkdir command, and if it is successful, change the
current working directory to the one just created.
current working directory to the one just created.
\section functions functions - print or erase functions
\section functions functions - print or erase functions
\subsection function-synopsis Synopsis
\subsection function-synopsis Synopsis
<tt>functions [-e] FUNCTIONS...</tt>
<code>functions [-e] FUNCTIONS...</code>
\subsection functions-description Description
\subsection functions-description Description
This builtin command is used to print or erase functions.
This builtin command is used to print or erase functions.
- <tt>-e</tt> or <tt>--erase</tt> causes the specified functions to be erased.
- <code>-a</code> or <code>--all</code> list all functions, even those whose name start with an underscore.
- <tt>-n</tt> or <tt>--names</tt> List only the names of all defined functions
- <code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> change 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> display a help message and exit
- <code>-n</code> or <code>--names</code> list only the names of all defined functions, not their definition
- <code>-q</code> or <code>--query</code> test if the specified functions exist. Does not output anything, but the builtins exit status is the number of functions specified that were not defined.
If \c functions is called with no arguments, the names and definition
The default behavior of \c functions when called with no arguments,
of all functions are printed, otherwise, the specified function
is to print the names and definitions of all defined functions. If any
definitions will be printed.
non-switch parameters are given, only the definition of the specified
functions are printed.
Automatically loaded functions can not be removed using functions
-e. Either remove the definition file or change the
$fish_function_path variable to remove autoloaded functions.
The exit status of the functions builtin is the number functions
\section open open - open file in its default application
\section open open - Open file in it's default application
\subsection open-synopsis Synopsis
\subsection open-synopsis Synopsis
<tt>open FILES...</tt>
<tt>open FILES...</tt>
\subsection open-description Description
\subsection open-description Description
The \c open command is used to open a file in it's default application. \c open is implemented using the <a href="commands.html#mimedb">mimedb</a> command.
The \c open command is used to open a file in its default application. \c open is implemented using the \c xdg-open command if it exists, or else the <a href="commands.html#mimedb">mimedb</a> command.
\subsection open-example Example
\subsection open-example Example
<tt>open *.txt</tt> opens all the text files in the current directory using your systems default text editor.
<tt>open *.txt</tt> opens all the text files in the current directory using your system's default text editor.
The \c or builtin is used to execute one command, and if it returns
The \c or builtin is used to execute a command if the current exit
non-zero status, also execute a second command.
status (as set by the last previous command) is not 0.
The or command 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
\subsection or-example Example
The following code runs the \c make command to build a program, or if it fails, it runs <tt>make clean</tt>, which removes the files created by the build process
The following code runs the \c make command to build a program, if the
<pre>
build succeeds, the program is installed. If either step fails,
or make; make clean
<tt>make clean</tt> is run, which removes the files created by the
</pre>
build process
\c or and \c and can be nested, as in this example, that attempts to build and install a program, and removed the files created by the build process on failiure
The <tt>read</tt> builtin causes fish to read one line from standard
The <tt>read</tt> builtin causes fish to read one line from standard
input and store the result in one or more environment variables.
input and store the result in one or more environment variables.
- <tt>-c CMD</tt> or <tt>--command=CMD</tt> specifies that the initial string in the interactive mode command buffer should be CMD.
- <tt>-e</tt> or <tt>--export</tt> specifies that the variables will be exported to subshells.
- <tt>-e</tt> or <tt>--export</tt> specifies that the variables will be exported to subshells.
- <tt>-g</tt> or <tt>--global</tt> specifies that the variables will be made global.
- <tt>-g</tt> or <tt>--global</tt> specifies that the variables will be made global.
- <tt>-pPROMPT_CMD</tt> or <tt>--prompt=PROMPT_CMD</tt> specifies that the output of the shell command PROMPT_CMD should be used as the prompt for the interactive mode prompt. The default prompt command is <tt>set_color green; echo read; set_color normal; echo "> "</tt>.
- <tt>-m NAME</tt> or <tt>--mode-name=NAME</tt> specifies that the name NAME should be used to save/load the history file. If NAME is fish, the regular fish history will be available.
- <tt>-cCMD</tt> or <tt>--command=CMD</tt> specifies that the initial string in the interactive mode command buffer should be CMD.
- <tt>-p PROMPT_CMD</tt> or <tt>--prompt=PROMPT_CMD</tt> specifies that the output of the shell command PROMPT_CMD should be used as the prompt for the interactive mode prompt. The default prompt command is <tt>set_color green; echo read; set_color normal; echo "> "</tt>.
- <code>-s</code> or <code>--shell</code> Use syntax highlighting, tab completions and command termination suitable for entering shellscript code
- <code>-u</code> or <code>--unexport</code> causes the specified environment not to be exported to child processes
- <code>-U</code> or <code>--universal</code> causes the specified environment variable to be made universal. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.
- <code>-x</code> or <code>--export</code> causes the specified environment variable to be exported to child processes
Read starts by reading a single line of input from stdin, the line is
Read starts by reading a single line of input from stdin, the line is
then tokenized using the <tt>IFS</tt> environment variable. Each variable
then tokenized using the <tt>IFS</tt> environment variable. Each variable
set (-q | --query) [SCOPE_OPTIONS] VARIABLE_NAMES...
set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME
set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]...
</pre>
The <tt>set</tt> builtin causes fish to assign the variable <tt>VARIABLE_NAME</tt> the values <tt>VALUES...</tt>.
The <code>set</code> builtin causes fish to assign the variable <code>VARIABLE_NAME</code> the values <code>VALUES...</code>.
\subsection set-description Description
\subsection set-description Description
- <tt>-e</tt> or <tt>--erase</tt> causes the specified environment variable to be erased
- <code>-e</code> or <code>--erase</code> causes the specified environment variable to be erased
- <tt>-g</tt> or <tt>--global</tt> causes the specified environment variable to be made global. If this option is not supplied, the specified variable will dissapear when the current block ends
- <code>-l</code> or <code>--local</code> forces the specified environment variable to be given a scope that is local to the current block, even if a variable with the given name exists and is non-local
- <tt>-l</tt> or <tt>--local</tt> forces the specified environment variable to be made local to the current block, even if the variable already exists and is non-local
- <code>-g</code> or <code>--global</code> causes the specified environment variable to be given a global scope. Non-global variables disappear when the block they belong to ends
- <tt>-n</tt> or <tt>--names</tt> List only the names of all defined variables
- <code>-U</code> or <code>--universal</code> causes the specified environment variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.
- <tt>-q</tt> or <tt>--query</tt> test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
- <code>-n</code> or <code>--names</code> List only the names of all defined variables, not their value
- <tt>-u</tt> or <tt>--unexport</tt> causes the specified environment not to be exported to child processes
- <code>-q</code> or <code>--query</code> test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
- <tt>-U</tt> or <tt>--universal</tt> causes the specified environment variable to be made universal. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.
- <code>-u</code> or <code>--unexport</code> causes the specified environment not to be exported to child processes
- <tt>-x</tt> or <tt>--export</tt> causes the specified environment variable to be exported to child processes
- <code>-x</code> or <code>--export</code> causes the specified environment variable to be exported to child processes
If set is called with no arguments, the names and values of all
If set is called with no arguments, the names and values of all
environment variables are printed.
environment variables are printed. If some of the scope or export
flags have been given, only the variables matching the specified scope
If set is called with only one argument, the scope of the variable
are printed.
with the given name will be changed as specified, but it's value will
remain the same. If the variable did not previously exist, it's value
will be an empty string.
If the \c -e or \c --erase option is specified, the variable
specified by the following arguments will be erased
If a variable is set to more than one value, the variable will be an
If a variable is set to more than one value, the variable will be an
array with the specified elements.
array with the specified elements. If a variable is set to zero
elements, it will become an array with zero elements.
If the variable name is one or more array elements, such as <tt>PATH[1
If the variable name is one or more array elements, such as
3 7]</tt>, only those array elements specified will be changed.
<code>PATH[1 3 7]</code>, only those array elements specified will be
changed. When array indices are specified to set, multiple arguments
may be used to specify additional indexes, e.g. <code>set PATH[1]
PATH[4] /bin /sbin</code>. If you specify a negative index when
expanding or assigning to an array variable, the index will be
calculated from the end of the array. For example, the index -1 means
the last index of an array.
The scoping rules when creating or updating a variable are:
-# If a variable is explicitly set to either universal, global or local, that setting will be honored. If a variable of the same name exists in a different scope, that variable will not be changed.
-# If a variable is not explicitly set to be either universal, global or local, but has been previously defined, the previous variable scope is used.
-# If a variable is not explicitly set to be either universal, global or local and has never before been defined, the variable will be local to the currently executing functions. If no function is executing, the variable will be global.
The exporting rules when creating or updating a variable are identical
to the scoping rules for variables:
-# If a variable is explicitly set to either be exported or not exported, that setting will be honored.
-# If a variable is not explicitly set to be exported or not exported, but has been previously defined, the previous exporting rule for the variable is kept.
-# If a variable is not explicitly set to be either exported or unexported and has never before been defined, the variable will not be exported.
In query mode, the scope to be examined can be specified.
In erase mode, if variable indices are specified, only the specified
slices of the array variable will be erased. When erasing an entire
variable (i.e. no slicing), the scope of the variable to be erased can
be specified. That way, a global variable can be erased even if a
local variable with the same name exists. Scope can not be specified
when erasing a slice of an array. The innermost scope is always used.
The set command requires all switch arguments to come before any
non-switch arguments. For example, <code>set flags -l</code> will have
the effect of setting the value of the variable <code>flags</code> to
'-l', not making the variable local.
In assignment mode, set exits with an exit status of zero it the
variable assignments where sucessfully performed, with a non-zero exit
status otherwise. In query mode, the exit status is the number of
variables that where not found. In erase mode, set exits with a zero
exit status in case of success, with a non-zero exit status if the
commandline was invalid, if the variable was write-protected or if the
variable did not exist.
\subsection set-example Example
\subsection set-example Example
<tt>set foo hi</tt> sets the value of the variable foo to be hi.
<code>set -xg</code> will print all global, exported variables.
<tt>set -e smurf</tt> removes the variable \c smurf.
<code>set foo hi</code> sets the value of the variable foo to be hi.
<tt>set PATH[4] ~/bin</tt> changes the fourth element of the \c PATH array to \c ~/bin
<code>set -e smurf</code> removes the variable \c smurf.
<code>set PATH[4] ~/bin</code> changes the fourth element of the \c PATH array to \c ~/bin
- <tt>-d DELIMITER</tt>, <tt>--delimiter=DELIMITER</tt> is the list of characters that will be used as delimiters. If unspecified, the IFS environment variable will be used as the delimiter string,
\section type type - indicate how a name would be interpreted if used as a command name
\section type type - Indicate how a name would be interpreted if used as a command name
\subsection type-synopsis Synopsis
\subsection type-synopsis Synopsis
<tt>type [OPTIONS] name [name ...]</tt>
<tt>type [OPTIONS] name [name ...]</tt>
\subsection type-description Description
\subsection type-description Description
With no options, indicate how each name would be interpreted if used as a command name.
With no options, indicate how each name would be interpreted if used as a command name.
- \c -h or \c --help print this message
- \c -h or \c --help print this message
- \c -a or \c --all print all of possible definitions of the specified names
- \c -a or \c --all print all of possible definitions of the specified names
- \c -f or \c --no-functions supresses function and builtin lookup
- \c -f or \c --no-functions suppresses function and builtin lookup
- \c -t or \c --type print a string which is one of alias, keyword, function, builtin, or file if name is an alias, shell reserved word, function, builtin, or disk file, respectively
- \c -t or \c --type print a string which is one of alias, keyword, function, builtin, or file if name is an alias, shell reserved word, function, builtin, or disk file, respectively
- \c -p or \c --path either return the name of the disk file that would be executed if name were specified as a command name, or nothing if 'type -t name' would not return 'file'
- \c -p or \c --path either return the name of the disk file that would be executed if name were specified as a command name, or nothing if 'type -t name' would not return 'file'
- \c -P or \c --force-path either return the name of the disk file that would be executed if name were specified as a command name, or nothing no file with the specified name could be found in the PATH
- \c -P or \c --force-path either return the name of the disk file that would be executed if name were specified as a command name, or nothing no file with the specified name could be found in the PATH
\c type returns a zero exit status if the specified command was found,
otherwise the exit status is one.
\subsection type-example Example
\subsection type-example Example
<tt>type fg</tt> outputs the string 'fg is a shell builtin'.
<tt>type fg</tt> outputs the string 'fg is a shell builtin'.
\section ulimit ulimit - set or get the shells resource usage limits
\section ulimit ulimit - Set or get the shells resurce usage limits
\subsection ulimit-synopsis Synopsis
\subsection ulimit-synopsis Synopsis
<tt>ulimit [OPTIONS] [LIMIT]</tt>
<tt>ulimit [OPTIONS] [LIMIT]</tt>
\subsection ulimit-description Description
\subsection ulimit-description Description
The ulimit builtin provides control over the resources available to
The ulimit builtin is used to set the resource usage limits of the
the shell and to processes started by it. The -H and -S options
shell and any processes spawned by it. If a new limit value is
specify that the hard or soft limit is set for the given resource. A
omitted, the current value of the limit of the resource is printed.
hard limit cannot be increased once it is set; a soft limit may be
increased up to the value of the hard limit. If neither -H nor -S is
specified, both the soft and hard limits are set. The value of limit
can be a number in the unit specified for the resource or one of the
special values hard, soft, or unlimited, which stand for the current
hard limit, the current soft limit, and no limit, respectively. If
limit is omitted, the current value of the soft limit of the resource
is printed, unless the -H option is given. When more than one
resource is specified, the limit name and unit are printed before the
value. Other options are interpreted as follows:
- <code>-a</code> or <code>--all</code> Set or get all current limits
Use one of the following switches to specify which resource limit to set or report:
- <code>-c</code> or <code>--core-size</code> The maximum size of core files created
- <code>-d</code> or <code>--data-size</code> The maximum size of a process’s data segment
- <code>-c</code> or <code>--core-size</code> The maximum size of core files created. By setting this limit to zero, core dumps can be disabled.
- <code>-d</code> or <code>--data-size</code> The maximum size of a process's data segment
- <code>-f</code> or <code>--file-size</code> The maximum size of files created by the shell
- <code>-f</code> or <code>--file-size</code> The maximum size of files created by the shell
- <code>-l</code> or <code>--lock-size</code> The maximum size that may be locked into memory
- <code>-l</code> or <code>--lock-size</code> The maximum size that may be locked into memory
- <code>-m</code> or <code>--resident-set-size</code> The maximum resident set size
- <code>-m</code> or <code>--resident-set-size</code> The maximum resident set size
@@ -32,17 +22,42 @@ value. Other options are interpreted as follows:
- <code>-u</code> or <code>--process-count</code> The maximum number of processes available to a single user
- <code>-u</code> or <code>--process-count</code> The maximum number of processes available to a single user
- <code>-v</code> or <code>--virtual-memory-size</code> The maximum amount of virtual memory available to the shell. If supported by OS.
- <code>-v</code> or <code>--virtual-memory-size</code> The maximum amount of virtual memory available to the shell. If supported by OS.
Note that not all these limits are available in all operating systems.
The value of limit can be a number in the unit specified for
the resource or one of the special values hard, soft, or unlimited,
which stand for the current hard limit, the current soft limit, and no
limit, respectively.
If limit is given, it is the new value of the specified resource. If
If limit is given, it is the new value of the specified resource. If
no option is given, then -f is assumed. Values are in kilobytes,
no option is given, then -f is assumed. Values are in kilobytes,
except for -t, which is in seconds and -n and -u, which are unscaled
except for -t, which is in seconds and -n and -u, which are unscaled
values. The return status is 0 unless an invalid option or argument is
values. The return status is 0 unless an invalid option or argument is
supplied, or an error occurs while setting a new limit.
supplied, or an error occurs while setting a new limit.
The fish implementation of ulimit should behave identically to the implementation in bash, except for these differences:
ulimit also accepts the following switches that determine what type of
limit to set:
- <code>-H</code> or <code>--hard</code> Set hard resource limit
- <code>-S</code> or <code>--soft</code> Set soft resource limit
A hard limit can only be decreased, once it is set it can not be
increased; a soft limit may be increased up to the value of the hard
limit. If neither -H nor -S is specified, both the soft and hard
limits are updated when assigning a new limit value, and the soft
limit is used when reporting the current value.
The following additional options are also understood by ulimit:
- <code>-a</code> or <code>--all</code> Print all current limits
- <code>-h</code> or <code>--help</code> Display help and exit
The fish implementation of ulimit should behave identically to the
implementation in bash, except for these differences:
- Fish ulimit supports GNU-style long options for all switches
- Fish ulimit supports GNU-style long options for all switches
- Fish ulimit does not support the -p option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE.
- Fish ulimit does not support the -p option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE. Fish does not do this because it this method of determining pipe size is unreliable. Depending on bash version, there may also be further additional limits to set in bash that do not exist in fish.
- Fish ulimit does not support getting the values of multiple limits in one command, except by using the -a switch
- Fish ulimit does not support getting or setting multiple limits in one command, except reporting all values using the -a switch
\section umask umask - set or get the file-creation mask
\section umask umask - Set or get the shells resurce usage limits
\subsection umask-synopsis Synopsis
\subsection umask-synopsis Synopsis
<code>umask [OPTIONS] [MASK]</code>
<code>umask [OPTIONS] [MASK]</code>
@@ -10,9 +9,30 @@ With no argument, the current file-creation mask is printed, if an
argument is specified, it is the new file creation mask. The mask may
argument is specified, it is the new file creation mask. The mask may
be specified as an octal number, in which case it is interpreted as
be specified as an octal number, in which case it is interpreted as
the rights that should be masked away, i.e. it is the inverse of the
the rights that should be masked away, i.e. it is the inverse of the
file permissions any new files will have. If a synbolic mask is
file permissions any new files will have.
specified, the actual file permission bits, and not the inverse, are
specified.
If a symbolic mask is specified, the actual file permission bits, and
not the inverse, should be specified. A symbolic mask is a comma
separated list of rights. Each right consists of three parts:
- The first part specifies to whom this set of right applies, and can
be one of \c u, \c g, \c o or \c a, where \c u specifies the user who
owns the file, \c g specifies the group owner of the file, \c o
specific other users rights and \c a specifies all three should be
changed.
- The second part of a right specifies the mode, and can be one of \c
=, \c + or \c -, where \c = specifies that the rights should be set to
the new value, \c + specifies that the specified right should be added
to those previously specified and \c - specifies that the specified
rights should be removed from those previously specified.
- The third part of a right specifies what rights should be changed
and can be any combination of \c r, \c w and \c x, representing
read, write and execute rights.
If the first and second parts are skipped, they are assumed to be \c a
and \c =, respectively. As an example, <code>r,u+w</code> means all
users should have read access and the file owner should also have
write access.
- <code>-h</code> or <code>--help</code> print this message
- <code>-h</code> or <code>--help</code> print this message
- <code>-S</code> or <code>--symbolic</code> prints the file-creation mask in symbolic form instead of octal form. Use <code>man chmod</code> for more information.
- <code>-S</code> or <code>--symbolic</code> prints the file-creation mask in symbolic form instead of octal form. Use <code>man chmod</code> for more information.
@@ -23,7 +43,7 @@ in bash.
\subsection umask-example Example
\subsection umask-example Example
<code>umask 177</code> or <code>umask u=rw</code>sets the file
<code>umask 177</code> or <code>umask u=rw</code>sets the file
creation mask to read and write for the owner and no permissions at
creation mask to read and write for the owner and no permissions at
\param mode The type of the variable. Can be any combination of ENV_GLOBAL, ENV_LOCAL, ENV_EXPORT and ENV_USER. If mode is zero, the current variable space is searched and the current mode is used. If no current variable with the same name is found, ENV_LOCAL is assumed.
\param mode The type of the variable. Can be any combination of ENV_GLOBAL, ENV_LOCAL, ENV_EXPORT and ENV_USER. If mode is zero, the current variable space is searched and the current mode is used. If no current variable with the same name is found, ENV_LOCAL is assumed.
\returns 0 on suicess or an error code on failiure.
The current error codes are:
* ENV_PERM, can only be returned when setting as a user, e.g. ENV_USER is set. This means that the user tried to change a read-only variable.
* ENV_INVALID, the variable name or mode was invalid
Returns 1 if the specified key exists. This can't be reliable done
Returns 1 if the specified key exists. This can't be reliably done
using env_get, since env_get returns null for 0-element arrays
using env_get, since env_get returns null for 0-element arrays
\param key The name of the variable to remove
\param mode the scope to search in. All scopes are searched if unset
*/
*/
intenv_exist(constwchar_t*key);
intenv_exist(constwchar_t*key,intmode);
/**
/**
Remove environemnt variable
Remove environemnt variable
\param key The name of the variable to remove
\param key The name of the variable to remove
\param mode should be ENV_USER if this is a remove request from the user, 0 otherwise. If this is a user request, read-only variables can not be removed.
\param mode should be ENV_USER if this is a remove request from the user, 0 otherwise. If this is a user request, read-only variables can not be removed. The mode may also specify the scope of the variable that should be erased.
\return zero if the variable existed, and non-zero if the variable did not exist
*/
*/
voidenv_remove(constwchar_t*key,intmode);
intenv_remove(constwchar_t*key,intmode);
/**
/**
Push the variable stack. Used for implementing local variables for functions and for-loops.
Push the variable stack. Used for implementing local variables for functions and for-loops.
@@ -108,8 +129,14 @@ char **env_export_arr( int recalc );
/**
/**
Insert all variable names into l. These are not copies of the strings and should not be freed after use.
Insert all variable names into l. These are not copies of the strings and should not be freed after use.
debug(2,L"Could not connect to socket %d, starting fishd",s);
debug(2,L"Could not connect to socket %d, starting fishd",s);
if( start_fishd)
start_fishd();
{
start_fishd();
}
returnget_socket(0);
returnget_socket(0);
}
}
debug(3,L"Could not connect to socket %d, already tried forking, giving up",s);
debug(1,L"Could not connect to universal variable server, already tried manual restart (or no command supplied). You will not be able to share variable values between fish sessions. Is fish properly installed?");
debug(1,L"Could not create universal variable message");
env_universal_common_set(name,value,export);
return;
}
else
{
msg=create_message(export?SET_EXPORT:SET,
name,
value);
if(!msg)
{
debug(1,L"Could not create universal variable message");
return;
}
msg->count=1;
q_put(&env_universal_server.unsent,msg);
env_universal_barrier();
}
}
msg->count=1;
q_put(&env_universal_server.unsent,msg);
env_universal_barrier();
}
}
voidenv_universal_remove(constwchar_t*name)
intenv_universal_remove(constwchar_t*name)
{
{
intres;
message_t*msg;
message_t*msg;
if(!init)
if(!init)
return;
return1;
debug(2,
CHECK(name,1);
L"env_universal_remove( %ls )",
name);
msg=create_message(ERASE,name,0);
res=!env_universal_common_get(name);
msg->count=1;
debug(3,
q_put(&env_universal_server.unsent,msg);
L"env_universal_remove( \"%ls\" )",
env_universal_barrier();
name);
if(is_dead())
{
env_universal_common_remove(name);
}
else
{
msg=create_message(ERASE,name,0);
msg->count=1;
q_put(&env_universal_server.unsent,msg);
env_universal_barrier();
}
returnres;
}
}
voidenv_universal_get_names(array_list_t*l,
voidenv_universal_get_names(array_list_t*l,
intshow_exported,
intshow_exported,
intshow_unexported)
intshow_unexported)
{
{
if(!init)
return;
CHECK(l,);
env_universal_common_get_names(l,
env_universal_common_get_names(l,
show_exported,
show_exported,
show_unexported);
show_unexported);
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.