Compare commits

..

662 Commits

Author SHA1 Message Date
ridiculousfish
71bff26607 Merge remote-tracking branch 'upstream/master' 2012-04-18 13:21:03 -07:00
Jan Kanis
23bc10dfe6 Add stddef.h to util.c, so ptrdiff_t is defined in all environments 2012-01-31 01:38:20 +01:00
Jan Kanis
8ae00697c9 Merge branch 'merge-requests/14' 2012-01-25 01:21:14 +01:00
Jan Kanis
b0c6d891e9 reviewed merge reqest 14:
* fixed some whitespace inconsistencies
* changed variable handling in __fish_complete_subcommand_root
2012-01-25 01:14:47 +01:00
Jan Kanis
548164cd5e do not escape 'commandline' output without the -o flag 2012-01-25 00:11:00 +01:00
ridiculousfish
f12fd3707e Added a missing header for ptrdiff_t 2012-01-15 15:23:05 -08:00
ridiculousfish
8b407a32ff Fix to use proper type to compute difference between two pointers, which fixes a crash when fish is compiled LP64 2011-12-26 21:08:45 -08:00
Jan Kanis
344b9bdba3 Merge branch 'master' into merge-requests/14 2011-12-17 14:19:29 +01:00
Jan Kanis
834ea94eb9 update aptitude completions, patch by Dániel Ugra, closes Launchpad bug 238282 2011-09-25 01:24:34 +02:00
Jan Kanis
a060cc5893 uniq doesn't filter duplicates that aren't consecutive, use sort -u 2011-09-23 21:59:50 +02:00
gonchar
7ef0b3b821 *wvdial completion fixed 2011-09-23 18:40:14 +04:00
gonchar
39a2fd1717 * git rm and git status options are added
* ssh subcomand completion
* __fish_complete_subcommand now can skip variable number of tokens
2011-09-23 14:51:14 +04:00
gonchar
c66ec4df3d * __fish_complete_subcommand_root now passes arguments to
__fish_complete_subcommand

* sudo:
  - now can be completed bu group and user (-u and -g keys).
  - subcommand completion is fixed

* __fish_complete_proc.fish is added to complete killall command with
  list of running processes

* __fish_complete_tex.fish is updated with common options

* __fish_make_completion_signals.fish is added to make a list of kill
  signals for kill and killall

* completions:
 - minor filetype completions are added for djview, xpdf, mupdf, gv,
   xdvi
 - adduser is copmleted by user and group
 - dlocate and dpkg are completed by packages
 - find: -executable options is added
 - htop: options
 - funced and funcsave are completed by function names
 - ifdown and ifup are copmleted by interfaces
 - kill and killall: options, signals and processes
 - latexmk, ln, nm: options
 - lualatex and xelatex copmletions
 - sudo: -u and -g options
 - wvdial: presets
2011-09-23 12:24:21 +04:00
Jan Kanis
c25c48f763 Merge commit 'refs/merge-requests/13' of git://gitorious.org/fish-shell/fish-shell into merge-requests/13 2011-09-21 16:31:40 +02:00
Jan Kanis
5105d8d87e fixed bug where case-insensitive completion of /path\ with\ spaces/ doesn't reposition the cursor correctly 2011-09-21 15:40:45 +02:00
Mark A. Miller
35af336ff6 Fix an old, old reference to a long-gone fish function for gem.fish 2011-08-13 23:50:54 -05:00
Grissiom
157ca12d4b Merge commit 'refs/merge-requests/12' of git://gitorious.org/fish-shell/fish-shell into merge-requests/12 2011-07-28 10:06:19 +08:00
Adam Cozzette
e9d1a54983 fix: Fish may hang in Linux virtual console
I find that if I have a config.fish consisting of the following two
lines

status --job-control full
. empty.fish

where empty.fish is just an empty file in ~/.config/fish,  Fish will
hang when I attempt to log in on a virtual console (e.g. tty1). If I run
Fish within X11 or with either of those lines commented out,
everything's fine. I think the second line can be any command that cause
Fish to perform a fork().

The fix is pretty simple and just involves replacing getpid() with
getpgrp() in terminal_return_from_job in proc.c. See below for the
detailed explanation. I'm certainly no expert so I would appreciate it
if anyone else can confirm that my fix looks ok.

Here's what causes the bug as far as I can tell:

1. When I login on a virtual console,  /bin/login calls Fish. When Fish
begins executing its process group and the process group controlling the
terminal are both the pid of the /bin/login process.

2. The ". empty.fish" line causes Fish to fork a new process. The new
process creates a new process group and takes control of the terminal
under the name of that process group.

3. When the child process finishes,  the parent prcoess attempts to take
back control of the terminal by setting its controlling process group id
to be its pid.

4. Now there is a mismatch between the process group id of the Fish
shell (= the pid of the /bin/login process) and the process group id
controlling the terminal (= the pid of the Fish shell).
reader_interactive_init detects the mismatch and it thinks that it
doesn't have control of the terminal,  so it hangs as it waits for
control.

My fix just solves the problem in step 3 by having the parent process
correctly reassign control of the terminal to its process group.

Signed-off-by: Grissiom <chaos.proton@gmail.com>
2011-07-28 09:50:39 +08:00
Chris Nilsson
c8981c048f Merge commit 'refs/merge-requests/10' of git://gitorious.org/fish-shell/fish-shell into merge-requests/10 2011-07-10 16:32:44 +10:00
Andreas Raster
1ae44c6b3c still didn't work correctly, there were delimiters missing in the conditional as well 2011-06-24 02:45:05 +02:00
Andreas Raster
b2887477e3 last commits fix now also applied in the 'else' clause 2011-06-21 23:17:03 +02:00
Andreas Raster
8e2db29c9a fixed an issue when trying to complete something like 'cd /mnt/windows7/Program\ Files\ \('
fish would always spew a huge error message all over my terminal complaining about
some kind of tokenizer error, this patch fixed that
2011-06-21 17:02:49 +02:00
Shaun Reich
d38de7365a Change git-symbolic-ref to git symbolic-ref.
On my system at least (fedora 15), git-symbolic-ref is an invalid
command. Not sure if it's a BIC change from git itself, a distribution
thing, or a mistake on my end. Either way, no harm in using the
extended version. Now I get git branch status (yay).
2011-06-19 14:14:40 -04:00
Jakukyo Friel
cde6067cae minor changes on user doc 2011-02-20 02:58:11 +08:00
Christopher Nilsson
2583638f4b Merge commit 'refs/merge-requests/8' of git://gitorious.org/fish-shell/fish-shell into merge_request_8 2011-01-11 23:22:27 +11:00
Dylan Smith
11360b018f mimedb: Search all the defaults.list files rather than just the first.
The first defaults.list file found should not override all the other ones,
it just needs to be searched first.

E.g. For me (cat ~/.local/share/applications/defaults.list) returns
[Default Applications]
text/html=chromium-browser.desktop

So this should be used for text/html mimetypes, but the other defaults.list
files should be searched for other mimetypes.

I had to refactor get_filename so that it can return all the filenames, so
I changed it to append_filenames that appends all the filenames to a list
and provided a wrapper function called get_filename.
2010-12-02 23:55:45 +08:00
Grissiom
bdfc62184d fish_indent: indent "case" with the same level as "swith" 2010-12-02 23:42:48 +08:00
Grissiom
74f06d550a fish_indent: don't indent commands after a pipe
commands after a pipe tend to be at the same line of previous command.
So don't indent them.
2010-12-02 23:42:24 +08:00
James Bowlin
46986ad4c2 Use eix instead of emerge when possible
On Gentoo the eix program is MUCH faster than emerge for listing package
names.  I've left the emerge code in as a 2nd choice because not every
Gentoo system has eix installed (although they should).  Also,  the
emerge code didn't seem to produce any output on my system.

Signed-off-by: Grissiom <chaos.proton@gmail.com>
2010-12-02 01:33:56 +08:00
Dylan Smith
6a5d6471c5 mimedb: Search for exact mime type match in search_ini. 2010-12-02 01:19:56 +08:00
Dylan Smith
cf0850edfd mimedb: Add seperator between directory and filename in file_exists.
get_filename tried to work around this with hardcoded strings that end with
a '/', but would fail to work properly for environment variables
XDG_DATA_HOME or XDG_DATA_DIRS that don't do the same.
2010-12-02 01:16:29 +08:00
Dylan Smith
fd4ac87382 funcsave: Fixed error and help handling.
Renamed references to the previous command name of save_function to
funcsave, and returned an error after printing the help text when no
arguments are specified.
2010-12-02 01:13:51 +08:00
Dylan Smith
164144f126 default_key_bindings: Added mappings for ctrl-arrow keys.
On debian and ubuntu these control sequences are output while using
gnome-terminal and xterm.
2010-12-02 01:13:04 +08:00
Dylan Smith
f2ad4a2e8e Makefile: test for xsel directory before trying to clean it.
This avoids the users seeing ignored errors for make -C  clean.
2010-12-02 01:12:34 +08:00
Grissiom
df23913bb8 fish_indent: only output fd number when have to
The original patch is own by Dylan. I just did some cleaning and
reformating.
2010-12-01 13:05:10 +08:00
Dylan Smith
4ccf26fbcc builtin: count should not accept options, not even help
It is documented this way, but the common builtin_run function was
checking for -h or --help before even calling the builtin_count. Without
this functions like funced can't use count to check the number of
arguments before checking for -h or --help.

Signed-off-by: Grissiom <chaos.proton@gmail.com>
2010-11-26 19:00:18 +08:00
Dylan Smith
081e277fe4 builtin: read's --shell long option should require an argument
The short option -s doesn't need it and it won't be used.

Signed-off-by: Grissiom <chaos.proton@gmail.com>
2010-11-25 19:09:31 +08:00
Christopher Nilsson
dcecab384a Merge commit 'refs/merge-requests/6' of git://gitorious.org/fish-shell/fish-shell into merge_req_6 2010-11-24 22:34:29 +11:00
James Vega
4f9b07e979 Allow fish_greeting to be NULL or an array
Treat fish_greeting as a whole when show up the greeting messages. And
the user may want to set fish_greeting to an null value or an array.
This requires that the variable be quoted when used as an argument for
switch in __fish_config_interactive.

Signed-off-by: James Vega <jamessan@debian.org>
[modified the commit message]
Signed-off-by: Grissiom <chaos.proton@gmail.com>
2010-11-24 00:49:15 +08:00
Grissiom
9b97c55546 add test case for 364d3dbbf8 2010-11-24 00:35:56 +08:00
Dylan Smith
364d3dbbf8 exec: Don't format status returned directly from builtin function
The builtin function returns the raw status, which is not the same as
the integer return by waitpid. Therefore, the WIF macros shouldn't be
used for checking or obtaining the status.

This bug can be seen by executing (eval false). The builtin eval
function returns 1, but proc_format_status misinterprets it as a signal
by checking WIFSIGNALED, so adds 128 to the status to return 129.

Signed-off-by: Grissiom <chaos.proton@gmail.com>
2010-11-24 00:27:16 +08:00
James Vega
9f3a4d1640 Fix some spelling mistakes
Fix spelling mistakes in various bits of the documentation.

Signed-off-by: James Vega <jamessan@debian.org>
Signed-off-by: Grissiom <chaos.proton@gmail.com>
2010-11-23 23:50:49 +08:00
Dylan Smith
5fca92994f help.fish: Fix the sed expression to find anchors with id or name
Previously the expression only searched for anchors with a name
attribute, but doxygen 1.7.1 is producing anchors with the id attribute
instead. The sed expression allows both cases for compatibility.

I also used single quotes for the sed expression to avoid escaping
double quotes.

Signed-off-by: Grissiom <chaos.proton@gmail.com>
2010-11-23 23:37:09 +08:00
Grissiom
fefd17fe5e add test case for 6b243fbc 2010-11-23 23:05:21 +08:00
Dylan Smith
6b243fbcd3 eval: (eval false) should return an error status
This also caused (isatty < /dev/null) to return 0 since it uses eval,
and (ls | cat) to output using the classify indicator style since it
uses isatty. This is how I found the bug.

Reviewed-by: Grissiom <chaos.proton@gmail.com>
2010-11-22 19:36:42 +08:00
Dylan Smith
82f8c3834e Makefile: Provide PACKAGE_TARNAME for autoconf default docdir
docdir was previously being set to "${prefix}/share/doc/${PACKAGE_NAME}"
when it wasn't explicitely set on configuration using --docdir. Without
this appearing in the Makefile, some files silently get silently
installed directly into ${prefix}/share/doc instead within a fish
subdirectory.

I also added datarootdir to fix an autoconf warning,  since autoconf
normally would use it for the directory paths (e.g. docdir =
${datarootdir}/doc/${PACKAGE_TARNAME}). The autoconf generated configure
script has a hack to fix this, but states: "FIXME: This hack should be
removed a few years after 2.60."
2010-11-22 19:05:06 +08:00
Grissiom
e0ba91db31 Revert "use is_interactive instead of isatty to test whether we are in interactive mode"
This reverts commit ceba377ab8.
2010-11-22 08:43:21 +08:00
Grissiom
fa148bf59f break long lines 2010-11-22 08:42:57 +08:00
Christopher Nilsson
1b0ce33669 Merged changes from codemonkey and grissiom branches
Conflicts:
	kill.c
	seq.in
2010-11-12 02:07:14 +11:00
David Frascone
0cf2a1eb33 Fixed negative indices in the seq command 2010-11-05 09:34:42 -06:00
David Frascone
8a46a8ecb2 This change allows for customizing of the clipboard buffer, by supplying
a command to accept the "copy".  So, you add your clipboard buffer command
to an environment variable, and custom commands will be used for the copy
program.  Very useful when your OS is not naitively supported by fish.
2010-11-05 09:32:05 -06:00
David Frascone
4f0221bc4f Modify getopt string to force posix compliance. I forgot why I
needed this -- but -- some options were not working right.
2010-11-05 09:29:10 -06:00
David Frascone
ce08bb2ad2 The grep on the commands would sometimes output errors, causing noise and
breaking scripts.
2010-11-05 09:26:26 -06:00
David Frascone
93f797326e Optimized the result of the xsel check, so that it is cached.
It is called very often, and causes a significant performace hit.  The
availability of xsel is not likely to change during the invocation of
the shell.
2010-11-05 09:22:28 -06:00
Grissiom
ceba377ab8 use is_interactive instead of isatty to test whether we are in interactive mode 2010-10-13 04:30:23 +08:00
Grissiom
b9b6e867df check allocated memory when setting SHLVL 2010-10-08 09:38:06 +08:00
Grissiom
f47caefdb9 fix a memory allocation bug in commit 1e27024d75 2010-10-08 09:01:25 +08:00
James Buren
41ae7bccc2 silences some warnings outputted by gcc with -Wall and -Wextra 2010-10-08 08:43:57 +08:00
Grissiom
1e27024d75 accumulate SHLVL env variable at startup 2010-10-08 08:35:22 +08:00
Grissiom
6654fff377 fix null reference when erase TERM env
Way to reproduce:

> set -e TERM
fish: function contains_internal called with null value for argument a.
fish: This is a bug. If you can reproduce it,  please send a bug report
to fish-users@lists.sf.net.
fish: Backtrace:
/home/grissiom/sysroot/bin/fish(show_stackframe+0x1a) [0x43519a]
/home/grissiom/sysroot/bin/fish(contains_internal+0xce) [0x4373ee]
/home/grissiom/sysroot/bin/fish(reader_write_title+0x59) [0x424179]
/home/grissiom/sysroot/bin/fish() [0x4242d5]
/home/grissiom/sysroot/bin/fish(reader_readline+0x54) [0x425974]
/home/grissiom/sysroot/bin/fish(reader_read+0xba) [0x42742a]
/home/grissiom/sysroot/bin/fish(main+0x4be) [0x43b19e]
/lib64/libc.so.6(__libc_start_main+0xfd) [0x7fcbe0dcbb6d]
/home/grissiom/sysroot/bin/fish() [0x408c29]
2010-10-06 20:58:13 +08:00
Grissiom
89d999df72 some optimization on filling prompt_buff 2010-10-06 20:37:30 +08:00
Grissiom
a941d82be3 don't expand variables in no_exec mode
We couldn't know variables values unless execute commands, so disable
variable expansion in no_exec mode.
2010-10-06 11:37:59 +08:00
Grissiom
694cdf5ae1 update .gitignore 2010-10-05 21:14:43 +08:00
Grissiom
2bfe4afea2 add prof target 2010-10-05 02:23:18 +08:00
Grissiom
d559c3fe2e fix bug in build debug targe 2010-10-05 02:22:33 +08:00
Grissiom
27df727ca1 don't parse the options that should be passed to fish scripts
This commit makes fish_parse_opt stop at first non-option argument,
which expected as fish script name and pass the remaining argument to
that script. I also updated the test cases.
2010-10-03 11:46:26 +08:00
Grissiom
8910226d2f only count the last line of promt when caculate prompt width 2010-09-24 19:01:13 +08:00
Grissiom
04f58b1a31 ignore tmp staff in tests/ 2010-09-24 11:34:35 +08:00
Grissiom
1b9dd0c75f Merge remote branch 'origin/otherchirps-dev' 2010-09-19 14:12:30 +08:00
Grissiom
a7af415b6a call original grep in sgrep
functions/grep.fish will set the GREP_OPTIONS, which will ruin sgrep's
effort.
2010-09-19 13:56:30 +08:00
Grissiom
f8a5a59513 Revert "match the whole command for git completion"
This reverts commit d957d23d8f.
Use __fish_git_using_command to test commands and __fish_contains_opt to
test arguments.
2010-09-19 11:04:24 +08:00
Grissiom
ac3dfb3f96 don't complete file names for git checkout 2010-09-19 00:19:44 +08:00
Grissiom
d957d23d8f match the whole command for git completion 2010-09-19 00:17:53 +08:00
Grissiom
d049947801 event_fire( 0 ); => event_fire( NULL ); 2010-09-18 21:30:02 +08:00
Grissiom
21a10c3c74 use $() in Makefile var expansion 2010-09-18 21:29:05 +08:00
Grissiom
04951f8b34 reader_read( 0... => reader_read( STDIN_FILENO 2010-09-18 20:26:54 +08:00
Grissiom
c08bae6aeb configure xsel in configure phase
... and with the same arguments of fish
2010-09-18 14:31:18 +08:00
Grissiom
3aa107c4ae add XSEL_BIN var in configure.ac 2010-09-18 13:49:03 +08:00
Grissiom
e196091714 make clean should clean xsel and make distclean should delete it 2010-09-18 13:41:27 +08:00
Grissiom
d35d65cc40 use variables as xsel target 2010-09-18 13:27:34 +08:00
Grissiom
7f7b30959b don't make xsel in subshell 2010-09-18 13:14:59 +08:00
Grissiom
70322077d2 remove trialing spaces #2 2010-09-18 10:18:26 +08:00
Grissiom
f529b2e057 upgrade xsel to 1.2.0
xsel 1.0 begin to support UFT-8.
2010-09-18 10:14:14 +08:00
Grissiom
c6372a1b3f remove trailing spaces
This is done by `sed -i -e 's/[ \t]*$//' *.[c,h]`, which should not
introduce any functionality change.
2010-09-18 09:51:16 +08:00
Grissiom
41b8db063c add git submodule completion
Merged from http://github.com/weavejester/fish-git
2010-09-17 16:38:26 +08:00
Grissiom
1b16758d7e Fix cd prompt fail on the case that CDPATH have variables 2010-09-17 16:01:44 +08:00
Grissiom
51b5adc306 ignore ~ backup files 2010-09-16 13:32:18 +08:00
Grissiom
56f8993b8c ignore po/*.gmo 2010-09-16 13:31:49 +08:00
Ben Hoskings
8c4d1ca587 Added .gitignore. 2010-09-16 13:30:59 +08:00
Christopher Nilsson
ec8b3593f3 added '-c' option to the functions.txt docs. 2010-09-12 20:29:34 +10:00
Christopher Nilsson
5c9b42e260 'functions --copy': added sanity check on new function name.
Now matches function create behaviour, running the new function name through
wcsfuncname() and parser_keywords_is_reserved(), before allowing the copy.
2010-09-12 13:16:11 +10:00
Christopher Nilsson
7914c92824 replaced the functions '--rename' option with '--copy'.
Copying the function implementation was the main point. Actually removing the original isn't necessary, as that
functionality already exists (functions -e).
2010-09-09 23:48:18 +10:00
Christopher Nilsson
208be0f4d4 Adding '--rename' option to 'functions' builtin.
Aim is to allow an existing function to be renamed, allowing some basic function chaining.

Example:

> function foo
     echo Hello
  end
> foo
Hello
> functions --rename foo bar
> foo
fish: Unknown command 'foo'
> bar
Hello
> functions --rename fish_prompt old_prompt
> function fish_prompt
      printf "{Boo!}%s" (old_prompt)
  end
{Boo!}>

Note in the last case, the new fish_prompt is calling its old definition.
2010-09-08 03:31:05 +10:00
Ben Hoskings
7cfac5bb59 Fix an fprintf() type warning in set_color.c by using "%s". 2010-04-09 16:05:19 -07:00
Ben Hoskings
1bd09bfd40 Fix casting warnings in screen.c / s_update() by casting al_get() twice to convert type and then size, instead of both at once. 2010-04-09 16:05:18 -07:00
Ben Hoskings
517751f2a3 Declare write_loop() in print_help.c to fix warning (it's declared in common.h, but including that file here breaks things badly). 2010-04-09 16:05:18 -07:00
Ben Hoskings
006952c571 Fixed incompatible pointer warning in env_universal_common.c / iconv() call. 2010-04-09 16:05:18 -07:00
Ben Hoskings
7a8b7201a1 Write formatted duration to ENV_DURATION after commands that run for > 1s wall time. 2010-04-09 15:56:32 -07:00
Ben Hoskings
1157e4d7b2 Allow newlines in fish_prompt, by joining prompt_list with newlines instead of nothing in exec_prompt(). 2010-04-09 15:56:15 -07:00
Ben Hoskings
6b8e7b16f6 Reduced timeout in select_try() from 5s to 10ms. 2010-04-09 15:56:09 -07:00
axel
1eb089d722 Bump version number
darcs-hash:20090308144106-ac50b-e64db4a3009f99b3c1d206bba1781775faef671c.gz
2009-03-09 00:41:06 +10:00
axel
e50d0c18b0 Update todo list
darcs-hash:20090308142007-ac50b-22e9cc31212ff9647f75426327cdf5aff2d30f79.gz
2009-03-09 00:20:07 +10:00
axel
810d5f9548 Fix interactive job in background busy wait bug, reported by Randall D. Wald
darcs-hash:20090301021441-ac50b-a9488a9e55f545c3b8bd52aa0fb00b2b967974a8.gz
2009-03-01 12:14:41 +10:00
James Vega
e0c317dfd4 Prevent potential infinite loop
Ignore-this: 24edfe9248e1b667fcf4d8e151dd50f2

darcs-hash:20090224183601-35ec8-5e86d44c77af33376bd80485689d60c761ff17c6.gz
2009-02-25 04:36:01 +10:00
axel
d5320fb9f9 Update copyright info, minor layout changes to section about licenses in fish
darcs-hash:20090222224540-ac50b-69c4f8dd027e4672b8d25f8240c1d5f625135ad1.gz
2009-02-23 08:45:40 +10:00
axel
14c84ffbcb Check return value of a few write calls and retry on EINTR, and fix a few other warnings, mostly by printing error messages before giving up.
darcs-hash:20090222202852-ac50b-b0e79142af5b7a99e55271d4001fa252d9684a1d.gz
2009-02-23 06:28:52 +10:00
axel
f71c6f3f0e Misc documentation updates
darcs-hash:20090222191714-ac50b-fdd090aafd60f71989ef5c63aac9f876dcad93eb.gz
2009-02-23 05:17:14 +10:00
axel
6dbb9e070d Hopefully make iconv detection work on OS X with non-gnu iconv implementation
darcs-hash:20090222191649-ac50b-4f7010fdbf662b71cb7c4c99d2ae6e00c7cccb83.gz
2009-02-23 05:16:49 +10:00
axel
47ae2a05ce Don't make complete builtin complain when used in non-interactive mode, as we can always launch a debug prompt. Who are we to question why?
darcs-hash:20090222162253-ac50b-bb3c9dc1d1fa33548a2ed7b3c7c4d21d527eba47.gz
2009-02-23 02:22:53 +10:00
axel
810262118a Fix read in noninteractive mode problems reported by James Reeves
darcs-hash:20090222162206-ac50b-c293945986f75103120606a64133b59fe82c02a6.gz
2009-02-23 02:22:06 +10:00
axel
f5be301a2f Handle exit status of processes terminated by signals
darcs-hash:20090221164656-ac50b-7bcbf6cb0bb8384560fbf9bf1059480cb4089def.gz
2009-02-22 02:46:56 +10:00
axel
b1357d11b2 Pressing Control-C (or otherwise changeing the command line content through the commandline builtin) should clear the search buffer.
darcs-hash:20090221154420-ac50b-52641fb6dd6e76aebc6244211e07c0861fb3eff0.gz
2009-02-22 01:44:20 +10:00
axel
5fc42fcaff prompt_pwd broken, this fix by James Reeves
darcs-hash:20090221104759-ac50b-35f7a896d3e62cd002605d47c090c7bec992317b.gz
2009-02-21 20:47:59 +10:00
axel
c1cf6a4071 Oops, I broke recursive wildcard completion
darcs-hash:20090221104330-ac50b-ab9d487d3fc77fab32d9c49045d23b3e9124e618.gz
2009-02-21 20:43:30 +10:00
axel
972f3e121e Document rename of save_function to func_save. Pointed out by Ovchinnikov George
darcs-hash:20090218202037-ac50b-0351e8564d3274cd4fb364c07b4a3260f8a45f20.gz
2009-02-19 06:20:37 +10:00
axel
0dd8ae4843 Added faw entry on history editing, written by Beni Cherniavsky
darcs-hash:20090216211940-ac50b-4175fb2ae8ec2f5a67ac3c6a33a48bc5ac35eea2.gz
2009-02-17 07:19:40 +10:00
axel
8a93b6f26d Make xdg-version of open handle multiple files.
darcs-hash:20090216211103-ac50b-f8268e8d50a84457bb49ac3d1e982cba09dbfec6.gz
2009-02-17 07:11:03 +10:00
axel
07717a3570 Add possibility to define greeting function, suggested by Chris Miller
darcs-hash:20090216210450-ac50b-9b4f7c5bf45afaf21d51e46ff8c2b11d171fcbf2.gz
2009-02-17 07:04:50 +10:00
Nick Pilon
79784d3e18 This patch fixes a problem where prompt_pwd was printing the full path twice under OS X and probably BSDs. (Which, needless to say, made for very long prompts) The problem was that (Free?)BSD sed and GNU sed handle ? differently. For BSD sed, ? is not special unless the -E flag is specified. The {0,1} syntax should work the same way in both.
darcs-hash:20080122180340-5b666-21f1cdb835cbfa458a0f3d7344370837db962388.gz
2008-01-23 04:03:40 +10:00
terceiro
c08c313c0a adds completion for Debian's invoke-rc.d command
Ignore-this: f9ff385e3c239cedfbc9850b06822bba

darcs-hash:20090204191757-69c1e-a55c2a720fd784c7be2534feacecd5e2ebdbeecd.gz
2009-02-05 05:17:57 +10:00
terceiro
dfd70057b3 function to put current git branch on the fish prompt
Ignore-this: 841402742571f399e012514315b8e4f0

darcs-hash:20090204190358-69c1e-2ebcf761a4e55bc049ff1d5bba272d722b2d4501.gz
2009-02-05 05:03:58 +10:00
terceiro
07dec5c3ed better git completion
Ignore-this: af7fede5c1ee1d92c89d2887cbe54c0b

darcs-hash:20090204185826-69c1e-f72e06ad575efee258b392afd17255166ac4a260.gz
2009-02-05 04:58:26 +10:00
axel
1ed5decf2c Fix warnings in FATAL_EXIT macro
darcs-hash:20090204224310-ac50b-111db6c8f5b74dad0a309441063d3d7e9bf8f55d.gz
2009-02-05 08:43:10 +10:00
Isaac Dupree
9b95dda6bf fix help for open
darcs-hash:20080605192305-6c1c4-ccf59a87bf7197b5d07a33d7aaeb31638aa0aa52.gz
2008-06-06 05:23:05 +10:00
axel
41015691db Make all fish that use universal variables binaries include iconv
darcs-hash:20090203002620-ac50b-6be533cd1bf7dd043d96547b2c2f3ab4cda30e10.gz
2009-02-03 10:26:20 +10:00
axel
7e1ac2d806 Actually escape the double-star recursive wildcard char when requested. This will make sure the syntax highlighting doesn't try to perform a recursive wildcard expansion when cheching command name existance, which killed performance
darcs-hash:20090202234751-ac50b-55dfd8b52f842826b02a69d6ab51c222108c30e3.gz
2009-02-03 09:47:51 +10:00
axel
35258bf1fb Make proper autoconf test for availability of posix nan function instead of fudging with the NAN macro.
darcs-hash:20090202232049-ac50b-0176955677ff39fdd05eeefa20dca883863c34e6.gz
2009-02-03 09:20:49 +10:00
axel
72025a6a38 Make fish avoid iterating through user list when completing file part of directory starting with tilde. Also add a timeout to the directory iteration, to protect against humongously large user databases.
darcs-hash:20090202224645-ac50b-353047a73e4d6f494f470fe2ea6c4a34b486d302.gz
2009-02-03 08:46:45 +10:00
axel
05341b055b ish's current hostname completion uses ~/.ssh/known_hosts as one of its sources of information, but ~/.ssh/config may also be useful. Gather all of the 'Host' declarations from ~/.ssh/config and filter out the ones with wildcards. Signed-off-by: James Vega <jamessan@debian.org>
darcs-hash:20090202210242-ac50b-cf50070ee33ab6113e32a4d997d464ac4b1faf24.gz
2009-02-03 07:02:42 +10:00
axel
9d7224d756 Add support for completing aliases in ssh. Written by David Bronke.
darcs-hash:20090201231805-ac50b-196d4c81981efe681677fe8ca7f1cc833a4734da.gz
2009-02-02 09:18:05 +10:00
axel
33ec8b45a0 Add effectv completions, written by Stefano Sabatini.
darcs-hash:20090201225558-ac50b-5704829043880d0264e3e3908d324a39857ada16.gz
2009-02-02 08:55:58 +10:00
axel
1dc49a4062 Fix color ls detection for BSD and OS X systems. Patch by Sven Axelsson.
darcs-hash:20090201222410-ac50b-e1e02244ae950c602d3b7e67fe567920c619024b.gz
2009-02-02 08:24:10 +10:00
axel
1123467991 Fix cd function to handle empty variables correctly. Patch by Sven Axelsson.
darcs-hash:20090201222058-ac50b-31a7ee2db9f68729c21ba153e1439cbeabff84ce.gz
2009-02-02 08:20:58 +10:00
axel
4f54da3795 Fix user completion so it can handle comments in the passwd file. Patch by Sven Axelsson.
darcs-hash:20090201221921-ac50b-ef0883afe4dc68b43c1c705d49b6b5505dbf1e73.gz
2009-02-02 08:19:21 +10:00
axel
c8de3d24c8 Add netcat completions, written by James Stanley
darcs-hash:20090201160411-ac50b-43c34e2a73477cde40f15887a810a7b365ec81c4.gz
2009-02-02 02:04:11 +10:00
axel
31439ffb52 Better warning message when trying to exit with jobs running. PAtch and suggestion from Josef Spillner.
darcs-hash:20090201151601-ac50b-64bf24877419a9087f37eda2486232dfdabea9d2.gz
2009-02-02 01:16:01 +10:00
axel
9111b85437 Fixed bug with configure.ac in autotools shipped with F10. This fix comes from James Reeves.
darcs-hash:20090201140928-ac50b-952a8ba0596e3cf4f4a4a94f226fd04ec607075f.gz
2009-02-02 00:09:28 +10:00
axel
c6427c5a47 Add mimedb infinite loop bug fix from James Reeves
darcs-hash:20090201133734-ac50b-96fb4735af616094ea57ba02266188f8a7038a0c.gz
2009-02-01 23:37:34 +10:00
axel
36c3bd4e8d Switch from ARG_MAX to getting value from sysconf, glibc no longer defines the latter. This was reported from Peter Alfredsen Matthew Wesley, among other people.
darcs-hash:20090201132329-ac50b-5b9d54731c2ea2da3868fd492e68628b7684bb76.gz
2009-02-01 23:23:29 +10:00
axel
dad549afd1 Fix slightly wrong LD_FLAG in Makefile
darcs-hash:20090201125628-ac50b-3e68d7165a6c19558c7c8d7189cb75d71b4a9875.gz
2009-02-01 22:56:28 +10:00
Ori Avtalion
e73c2be216 Add missing commas, letters and \c in the documentation
darcs-hash:20080210210053-57fc3-f7e03b3fca9dff8bdc02256dfb78478b68945015.gz
2008-02-11 07:00:53 +10:00
axel
b0d324f1a7 Fix dumb error causing fish not to compile...
darcs-hash:20080204230945-ac50b-a95529cf19c473f62b6104ae138cf8b8abcbd2ec.gz
2008-02-05 09:09:45 +10:00
axel
d7396ac59f Fix bug causing flood of error messages in terminal when trying to highlight an invalid command, reported by Denilson F. de Sa.
darcs-hash:20080204230905-ac50b-0829b69835347e5875656ae735181b724f10de2a.gz
2008-02-05 09:09:05 +10:00
liljencrantz
3f439e9cd3 Add quilt completions, written by Stefano Sabatini.
darcs-hash:20080123000021-75c98-b27ae979720c55ec2219f451c50e87e79fa38cd6.gz
2008-01-23 10:00:21 +10:00
liljencrantz
0b722864c0 Make string handling a bit more solid be making sure sb_printf returns a null terminated string even on failiure.
darcs-hash:20080120022045-75c98-a47aff63ce7278148ccf027d6ee3ff93b35ee350.gz
2008-01-20 12:20:45 +10:00
liljencrantz
75e26f0f94 Add completions for various user and group adding commands. Skip addgroup, since manual page was actually for adduser, most switches weren't applicable and I was too lazy to guess which ones.
darcs-hash:20080120020816-75c98-f937df6cb6789868a1385bfc3eb48f5ddefb3c43.gz
2008-01-20 12:08:16 +10:00
liljencrantz
8cacb33347 Add completions for m4
darcs-hash:20080119150149-75c98-d8e5060ef78c6103d51e453ee4d5265f0981c4af.gz
2008-01-20 01:01:49 +10:00
liljencrantz
bf7d62fd91 Add completions for badblocks
darcs-hash:20080119145849-75c98-657a11bc69fbf625b01f84f1f6638e0d4b767228.gz
2008-01-20 00:58:49 +10:00
liljencrantz
4ac31e637d Add completions for Battle of Wesnoth
darcs-hash:20080119145414-75c98-6d8f856062ea44cf5de56bb014765a65ac26706b.gz
2008-01-20 00:54:14 +10:00
liljencrantz
0ad64ad2e4 Improve documentaion for bind builtin, clarify how to specify key sequences.
darcs-hash:20080119003820-75c98-b1f9360ddab9206a1cdf77b94ce28e9978badb53.gz
2008-01-19 10:38:20 +10:00
liljencrantz
523096e5d8 Add simple git completions by Diggory Hardy
darcs-hash:20080118160327-75c98-33e4e011de409944143aecf4f7e7aa8995687c75.gz
2008-01-19 02:03:27 +10:00
liljencrantz
0de629e009 Fix spelling in docs and add a help page for the funced builtin. These changes where suggested by Emanuele Rusconi.
darcs-hash:20080118155413-75c98-eadff877b3af3c3271b098903f80a45082111424.gz
2008-01-19 01:54:13 +10:00
liljencrantz
1f6fa1208e Search for command-not-found in PATH on startup, since older implementations place it there
darcs-hash:20080115122953-75c98-05ef8cb650a942c59dfa35aa63b25ccd49614dde.gz
2008-01-15 22:29:53 +10:00
liljencrantz
b86856b454 In prompt_pwd, if a directory name starts with a dot, include first two characters. This patch was written by Denilson F. de Sá
darcs-hash:20080116223621-75c98-46f96c9f25d5e32cd10148d35713622e6eac50d7.gz
2008-01-17 08:36:21 +10:00
liljencrantz
6598320534 Remove useless stray argument in function call
darcs-hash:20080116222628-75c98-a307fbeacdd815edcedea05930dc8b4bb064acb3.gz
2008-01-17 08:26:28 +10:00
liljencrantz
0a66dc4a31 Correct completions for the function builtin
darcs-hash:20080116222602-75c98-c1a48b4a04fe71b25c5e004a282341148a95ab6d.gz
2008-01-17 08:26:02 +10:00
liljencrantz
88a2b622df Add more documentation on events
darcs-hash:20080116222531-75c98-ef30dabc492d7883dbb620c40ef95152469057a3.gz
2008-01-17 08:25:31 +10:00
liljencrantz
e10f75483f Fix minor bug, PWD was incorrectly set on startup
darcs-hash:20080116220738-75c98-2b7c886629857540efee8f1cab9da0aa9ed8f76d.gz
2008-01-17 08:07:38 +10:00
liljencrantz
1a66fc4c5d Drop vim feature of only completing text and gzip files
darcs-hash:20080116180249-75c98-2fdff83afcb286c7cc06d3ed66089c9cc02eca20.gz
2008-01-17 04:02:49 +10:00
liljencrantz
905b792de7 Improve code comment
darcs-hash:20080116010601-75c98-fc7e940543424479bf1016cec26af619f177f5fd.gz
2008-01-16 11:06:01 +10:00
liljencrantz
804f5ab334 Add an extra input validation check
darcs-hash:20080116010548-75c98-e6f198bb1eb5a456ce830c42f061428a9c6f755d.gz
2008-01-16 11:05:48 +10:00
liljencrantz
f974c7c416 Improve error messages on failed execve calls a bit more
darcs-hash:20080116010454-75c98-883050bf00f10bdb205724d7d273f10e6f0a1065.gz
2008-01-16 11:04:54 +10:00
liljencrantz
f3b6b74568 Oops. Made a minor but important typo in previous cleanup patch. :-(
darcs-hash:20080115004050-75c98-3f7f733cca054d8685ec5df68d6467057ea5be53.gz
2008-01-15 10:40:50 +10:00
liljencrantz
ab94a397c3 Drop minor typo, add a few code comments
darcs-hash:20080114225828-75c98-f67f17d7f3148b0bcc74ea53536d52da80667e55.gz
2008-01-15 08:58:28 +10:00
liljencrantz
537ab32dd9 Add support for the Ubuntu 'command-no-found' handler, which suggests a package to install in order to get a command.
darcs-hash:20080114223124-75c98-ab1658d54086394cf13f3a6210543c0b790362c4.gz
2008-01-15 08:31:24 +10:00
liljencrantz
a2660cfb76 Handle case insensitive completions of variables better
darcs-hash:20080114010032-75c98-6e570c2b095baeb2ed2ee4d09e32f4e7d6ae47de.gz
2008-01-14 11:00:32 +10:00
liljencrantz
3743a5758b The max size of the string buffer was too small. Push it up a bit.
darcs-hash:20080114005745-75c98-1bcad5c5e81d4257eb7e96e860f8c667f9ba3267.gz
2008-01-14 10:57:45 +10:00
James Vega
e510d10c77 Fixed various spelling errors.
darcs-hash:20080113200151-35ec8-c587f020aec07a5e613068677bd3dd4f5c6189ac.gz
2008-01-14 06:01:51 +10:00
liljencrantz
f5540ff958 Add canse insensitive tilde completion
darcs-hash:20080113193221-75c98-169804fe128001f73eaee6fab28bfb99dca7c93e.gz
2008-01-14 05:32:21 +10:00
liljencrantz
c2b28063e1 Improve Doxygen documentation generation a bit
darcs-hash:20080113164924-75c98-d9762465de42750728ac6cb9364f4739a29ae376.gz
2008-01-14 02:49:24 +10:00
liljencrantz
8d2564291d Make sure fish_indent handles io erros
darcs-hash:20080113164905-75c98-b090ce79fb50a260874951525218cac65a097a6d.gz
2008-01-14 02:49:05 +10:00
liljencrantz
87db9517e9 Add lots of new code comments.
darcs-hash:20080113164747-75c98-9d0cefd27be7aef7ba60772616d9da7e6bb52912.gz
2008-01-14 02:47:47 +10:00
liljencrantz
ab3502fc8b Bump version number
darcs-hash:20080113011626-75c98-5037824714b5f39b8e4786d724bd047275e4c718.gz
2008-01-13 11:16:26 +10:00
liljencrantz
22472ea980 Update todo list
darcs-hash:20080113011617-75c98-8a3bcc0b4a2c58e5f2b13c51f372e7349ffec32d.gz
2008-01-13 11:16:17 +10:00
liljencrantz
ef705be6a5 Raname main.c into fish.c. NAme makes more sense.
darcs-hash:20080112192135-75c98-dc3f8480f1b25f6ab866c252c7edace862298f38.gz
2008-01-13 05:21:35 +10:00
liljencrantz
d50fac7fe5 Update copyright dates
darcs-hash:20080112191848-75c98-2e9d03feebe185c70e63bbabb421ebb5ef248979.gz
2008-01-13 05:18:48 +10:00
liljencrantz
39c16a7770 Add check for existance of fish_greeting variable
darcs-hash:20080112185319-75c98-3b5231b1a956c94e8800dae033f3672622104340.gz
2008-01-13 04:53:19 +10:00
liljencrantz
2aad9d5a95 Fix silly type I caused when cleaning up ant completions. Thanks to Steven Knight for the report
darcs-hash:20080112184928-75c98-286284df7196a479c6a2789120705f1764d619b9.gz
2008-01-13 04:49:28 +10:00
liljencrantz
52aaf60510 Fix spelling, thanks to Chris Rebert
darcs-hash:20080112184042-75c98-1f776d6f099003efd9a0c4ed45100c3a02e80e19.gz
2008-01-13 04:40:42 +10:00
liljencrantz
3a2f7d0edf Add completions for the fish_indent command
darcs-hash:20080109031024-75c98-23e2782d68822c1005eb9766ae2d14e76ed5499b.gz
2008-01-09 13:10:24 +10:00
liljencrantz
605fffa9d2 Make sure the help switch to the cd command is not flagged as an error
darcs-hash:20080109030647-75c98-f82822cde746d1c8a89512481347061cfeb41e43.gz
2008-01-09 13:06:47 +10:00
liljencrantz
2229fad410 Fix bug in return and block builtins - they where unable to handle functions that do not shadow the calling scope
darcs-hash:20080109030136-75c98-05f7a48cd991ac24e15d7e8b580caef0396ff59c.gz
2008-01-09 13:01:36 +10:00
liljencrantz
8e9384e2e8 Update todo list again. :-)
darcs-hash:20080109020655-75c98-9255c6c2287859211af77869fe2eb77543390c03.gz
2008-01-09 12:06:55 +10:00
liljencrantz
394776c56b Update todo list and code comments
darcs-hash:20080109012338-75c98-745297861fd11ec82e062a79fe1d15c9084342f1.gz
2008-01-09 11:23:38 +10:00
liljencrantz
e3d3a1062d Dont change working directory during startup
darcs-hash:20080109004339-75c98-478d0024895b89e12d02f6f19273aa1f9df66ed9.gz
2008-01-09 10:43:39 +10:00
liljencrantz
b4042b18c6 Make sure case sensitive completions are ignored by the pager if case sensitive completions exist
darcs-hash:20080109000928-75c98-fc6dc6fcebca99f33a1ed484444efee87f5caa94.gz
2008-01-09 10:09:28 +10:00
liljencrantz
5379200b9e Make sure inserted completions are escaped, even when case insensitive
darcs-hash:20080109000046-75c98-baf9ef4594ad0c7024a79b5c4819c10c0697ba47.gz
2008-01-09 10:00:46 +10:00
liljencrantz
9c38ed8238 Improve ant completions. This patch comes from Steven Knight. (minor tweaks applied)
darcs-hash:20080108221608-75c98-a0c7f65c65fb2e2c68085c69e72caa4a2c86a029.gz
2008-01-09 08:16:08 +10:00
liljencrantz
cb59da7a6f Fix typo in docs on exporting rules. This issue was pointed out by Isaac Dupree.
darcs-hash:20080108213600-75c98-b68f1bc3846ca7050955ee0f133acd20282cb908.gz
2008-01-09 07:36:00 +10:00
liljencrantz
bdec900aca Minor doc updates
darcs-hash:20080108210918-75c98-7510c066f74a2c3f4bf60bda84237adcef2ca276.gz
2008-01-09 07:09:18 +10:00
Nicholas Burlett
564d19e3bd The ability to switch to sh for processing files starting with a ':' broke
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
2008-01-04 11:56:31 +10:00
liljencrantz
063c4d7e67 Add comment on CDPATh being a universal variable after comments from Isac Dupree.
darcs-hash:20080107235427-75c98-3f56a4f450bb9beb66c9949c9313a1991754d8fb.gz
2008-01-08 09:54:27 +10:00
liljencrantz
30cfa2a445 Add explanation to csh versus sh variable naming in docs.
darcs-hash:20080108194127-75c98-b44c6f18607cf270fae16179cd0df3e84f980b91.gz
2008-01-09 05:41:27 +10:00
liljencrantz
71c2cde390 Cleanup and improve the exit status numbers and the messages generated on error as well as make sure that keyboard shortcuts don't change the status
darcs-hash:20080108193145-75c98-56c8aa2dd081af643d206820aa36bf3b6e49e0f2.gz
2008-01-09 05:31:45 +10:00
liljencrantz
da4a4bcc18 Only set various startup defaults once. Even if the user removes them, do not try to reset them.
darcs-hash:20080108161856-75c98-7d228f7a0c62aa8be74f66ce72d0cadbc3030f5d.gz
2008-01-09 02:18:56 +10:00
liljencrantz
286ce1d6a4 Only set the fish greeting variable on the very first startup
darcs-hash:20080108152708-75c98-d1aa82fbcf070b74f402a6b33e687ccf615fb104.gz
2008-01-09 01:27:08 +10:00
patroclo7
5064cec16d makepkg-completions
Completions for makepkg, the archlinux tool to build packages from source

darcs-hash:20071218002337-782a0-b2f26f1e8ed35e6180785f077a7a0af99f5ea804.gz
2007-12-18 10:23:37 +10:00
patroclo7
f5f5e63ddf pacman-completion
Completion definitions for the pacman package manager, used by Archlinux.

darcs-hash:20071217231409-782a0-c17d12806fcd9732578a878b827af4074577c177.gz
2007-12-18 09:14:09 +10:00
patroclo7
ae878ed6ea option-absent-function
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
2007-12-18 09:03:15 +10:00
liljencrantz
2c5151bb78 Fix bug in key binding code causing unneeded error messages
darcs-hash:20071031091503-75c98-3ab5786c1f991e4ea37c33b76823a487f25fab64.gz
2007-10-31 19:15:03 +10:00
liljencrantz
f506f1f495 Remove unneeded code
darcs-hash:20071028233214-75c98-0b98df754e50f6fb937098506884b1d526bf15fd.gz
2007-10-29 09:32:14 +10:00
liljencrantz
374fc09af0 Minor tweaks for man page parser.
darcs-hash:20071028233110-75c98-7d900290fdb313cb8ce2194a2d452cd9d4c8dc13.gz
2007-10-29 09:31:10 +10:00
liljencrantz
54b1986986 Add command specific comlpetions for cowthink
darcs-hash:20071028230807-75c98-1706c8b0f2559c2f5fa9e6055c7aa60e8fc4a2f6.gz
2007-10-29 09:08:07 +10:00
liljencrantz
6e9489f4f5 Add command specific comlpetions for cowsay
darcs-hash:20071028230620-75c98-d137040e58b76a570234eb15603192922c4cfe01.gz
2007-10-29 09:06:20 +10:00
liljencrantz
a52bd219b9 Remove lots of things from the todo which have been implemented
darcs-hash:20071028190344-75c98-9ccc5b5dab1f788c5179d5a527e6823d207f832e.gz
2007-10-29 05:03:44 +10:00
liljencrantz
bdd1b6b4b2 Rewrite automatic completion creator from scratch. The new implementation uses a finite state machine instead of a set of regexes, which inpractice seems to make the parser more robust and the code subjectively more readable
darcs-hash:20071028185143-75c98-92c1a0cd579ff0c41f47e75c975405fe3e002ddb.gz
2007-10-29 04:51:43 +10:00
liljencrantz
6dfdb3ba6e Remove bad completion for bison
darcs-hash:20071028184743-75c98-2f74b81cb8bfe7fe7346aa65b652d6bbe8eac4a1.gz
2007-10-29 04:47:43 +10:00
liljencrantz
48d5637178 Add command specific comlpetions for gdb
darcs-hash:20071028184722-75c98-a2822e20d772dde73ef13a6ce7ca56339b13864f.gz
2007-10-29 04:47:22 +10:00
liljencrantz
d724b160ea Add command specific comlpetions for chmod
darcs-hash:20071028183924-75c98-e73d8ce3ba9da36a70ef849df3c309f9f188ba68.gz
2007-10-29 04:39:24 +10:00
liljencrantz
7a4dc6f700 Add command specific comlpetions for bison
darcs-hash:20071028183548-75c98-0027c86d0077004b7bb0408358ba3821772b2374.gz
2007-10-29 04:35:48 +10:00
liljencrantz
c9f43fb02d Add command specific comlpetions for awk
darcs-hash:20071028183140-75c98-0c649a62488fa155d8170ac04a876b9ab426dbc0.gz
2007-10-29 04:31:40 +10:00
liljencrantz
da02905250 Add command specific comlpetions for acpi
darcs-hash:20071028182810-75c98-fc6cb8818dc8a93976802c255584cfd9c86a8958.gz
2007-10-29 04:28:10 +10:00
liljencrantz
80060229f8 Minor simplification to rpm completions
darcs-hash:20071028182440-75c98-dc3d22f37e1779dca7e2e88f02fc9e0d815301c9.gz
2007-10-29 04:24:40 +10:00
liljencrantz
10b9b06ef7 Add command specific comlpetions for scons
darcs-hash:20071028182413-75c98-41bf654fd8fe0522a8ebae19b6ecaa8a4d1f2d8c.gz
2007-10-29 04:24:13 +10:00
liljencrantz
e9aba6a878 Add command specific comlpetions for xgettext
darcs-hash:20071028180724-75c98-42c8d8a3810f6bdaee4ac90da1cc34371fcfacf4.gz
2007-10-29 04:07:24 +10:00
liljencrantz
5fee5a2890 Add command specific comlpetions for msgfmt
darcs-hash:20071028095834-75c98-d749a3fef8e28c9d5bab1cd3dfbf989aac9a8049.gz
2007-10-28 19:58:34 +10:00
liljencrantz
3f3fe634c8 Do not use carriage return in translated strings
darcs-hash:20071028091145-75c98-fc211f29b5c96fa5e10cedd848dabb0a664a34b7.gz
2007-10-28 19:11:45 +10:00
liljencrantz
a5156c54cb Make sure configuration files are only run once
darcs-hash:20071028091117-75c98-735febed13f816e2870e90324758ec59d713b1e2.gz
2007-10-28 19:11:17 +10:00
liljencrantz
74cd64ba21 Make sure that function and completion paths contain contain the basic fish completions/functions on startup.
darcs-hash:20071028091042-75c98-4e201b1b39c7c7b66ff9ec71f95b05f8d6d42708.gz
2007-10-28 19:10:42 +10:00
liljencrantz
348e991d7c Indentation fixes, add a few comments, spelling, etc.
darcs-hash:20071028090840-75c98-2ae076441517cd7a0d8172fad28edaf6f034b70c.gz
2007-10-28 19:08:40 +10:00
liljencrantz
a1af86cb6b Remove non-ascii characters from completions
darcs-hash:20071028090802-75c98-06f7a48a6a5590117c0293dc75b07846e86a34a1.gz
2007-10-28 19:08:02 +10:00
liljencrantz
baa6a40d6f Fix completion bug - case insensitive competions of command names sometimes got the path prepended to them
darcs-hash:20071028090605-75c98-b623c6bf3f5a5144cdecaf0c005d4acb980e33f1.gz
2007-10-28 19:06:05 +10:00
liljencrantz
5082054bcb Some polising of english and swedish translations
darcs-hash:20071028010624-75c98-2943272173fa60e70e9e947e34a2ed05296156a7.gz
2007-10-28 11:06:24 +10:00
liljencrantz
2160777d2f Implement non-clobbering file io. Use the >? operator for this for now.
darcs-hash:20071026184232-75c98-11edcbc7548c8ad3a2d4b648cb7ae18067569f02.gz
2007-10-27 04:42:32 +10:00
liljencrantz
a97faaf664 Indentation fixes.
darcs-hash:20071015132125-75c98-c59b345017f97ac4fe9bb166bf5128245a66e05a.gz
2007-10-15 23:21:25 +10:00
liljencrantz
0c1b40e3b3 Fix swallowing of last line on prompt display. Again. How many times have I triggered this bug?
darcs-hash:20071015132106-75c98-11863d8b1743b84f6ad448b64e5ccdeb5aaa5a2f.gz
2007-10-15 23:21:06 +10:00
liljencrantz
e54ce9a147 Minor bug fix - the parse_util_set_argv function can trigger an event, hence signals have to be unblocked when it is called.
darcs-hash:20071015132006-75c98-4ec10e4e26ea63c86c57f7e1f24f3d0fc60995b5.gz
2007-10-15 23:20:06 +10:00
liljencrantz
36e08dc49e Make the maximum execve size test use sysconf. Create a fallback if sysconf is unavailable.
darcs-hash:20071015113936-75c98-078e9f8727e91d41fabc80827bf97c8e04dd97ba.gz
2007-10-15 21:39:36 +10:00
liljencrantz
dd02e96712 Second part of improved execve errors - this patch makes the memory limits nicely formated (e.g. 128kB instead of 136549 bytes).
darcs-hash:20071015095108-75c98-51c2ea6ab6edba5d1885eb5938f039054da775e2.gz
2007-10-15 19:51:08 +10:00
liljencrantz
4163040e56 First stab at better error reporting on too many arguments to execve.
darcs-hash:20071015093615-75c98-2137b887ca3c97bc3e4234e2fd14a1391b4cc85a.gz
2007-10-15 19:36:15 +10:00
liljencrantz
0bea4c46e3 Add very minimal fallback keybindings
darcs-hash:20071015085130-75c98-1c91b5d8cc1227f15d5de68b85af2ceadbf66e31.gz
2007-10-15 18:51:30 +10:00
James Vega
0f6fe652a4 Use wcscmp instead of
darcs-hash:20071013212606-35ec8-ba25df01017fb1c272ea9dae059fb4245e4c02da.gz
2007-10-14 07:26:06 +10:00
James Vega
afa0ed124f Check whether '$TERM' starts with 'screen' instead of whether it's an exact match when determining if \ek\e\\ should be recognized.
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
2007-10-14 04:43:58 +10:00
liljencrantz
8904ab47aa Remove mention of fish_inputrc in install scripts. The file no longer exists.
darcs-hash:20071014115259-75c98-f43cd2358ddd15b28eba4d47de383bef8c794615.gz
2007-10-14 21:52:59 +10:00
liljencrantz
25305c6b24 Fix bug in pager causing some keybindings to be ignoerd because other are undefined
darcs-hash:20071014111640-75c98-c4d271f9b033a4f644e1b58cdb2e8842aff198d2.gz
2007-10-14 21:16:40 +10:00
liljencrantz
89c27c6d9d Indentation fixes
darcs-hash:20071014101502-75c98-5767d159d7c10deda49c23ad9e3758d93024950f.gz
2007-10-14 20:15:02 +10:00
liljencrantz
175dd75a3d Tiny touchups of docs and code
darcs-hash:20071006105527-75c98-339c5d7ec2fbae0c2d4dc93552db85c389971a6a.gz
2007-10-06 20:55:27 +10:00
liljencrantz
9b74687384 Minor new sanity test in reader
darcs-hash:20071006105453-75c98-3f5d1a0a175a7b810f68b38dec472bb697081742.gz
2007-10-06 20:54:53 +10:00
liljencrantz
fcd474afe8 Make completion system not use quoted string escapes, since it generally looks a bit confusing there
darcs-hash:20071006105131-75c98-af770878124cc19946b964c0cf772818a5bf4216.gz
2007-10-06 20:51:31 +10:00
liljencrantz
3ca3b6209d Make the Alt-p keybinding respect the PAGER variable
darcs-hash:20071006103231-75c98-59ef22ad49526f52cff8a97d9fac9f003af19213.gz
2007-10-06 20:32:31 +10:00
liljencrantz
9299515f3e 'Misfeature' fix for eval function - make it force job control when in interactive mode, in order to make commands that expect to control the terminal happy
darcs-hash:20071006102326-75c98-b168d709d54edb21c478ec2d69420468a2c08da1.gz
2007-10-06 20:23:26 +10:00
liljencrantz
188f0454b7 Use IO redirection to make the eval function actually have a working stdin
darcs-hash:20071005150245-75c98-d6a6d2f6ec1690079ee30f0e9cccf61e30e14c08.gz
2007-10-06 01:02:45 +10:00
liljencrantz
e55739296d Don't crash when trying to close fds for a builtin command
darcs-hash:20071005150106-75c98-292df3863252c1eebd5734a241a2d80e6883f65f.gz
2007-10-06 01:01:06 +10:00
liljencrantz
68857220ac Make fish automatically realise a repaint is needed in more situations, making many keybinding calls to 'commandline -f repaint' unneeded
darcs-hash:20071005145919-75c98-ce349d3718e54df30a050b97afee48b56ab46348.gz
2007-10-06 00:59:19 +10:00
liljencrantz
713c84d821 Make the . builtin have a more useful (and posix-compatible) exit status
darcs-hash:20071005145808-75c98-17100c1e321b8bca06f75e900db1386451232f98.gz
2007-10-06 00:58:08 +10:00
liljencrantz
d34d05ca8b Comment updates, minor code cleanups and other janitorial jobs
darcs-hash:20071002100937-75c98-d4040e70a256e36a6334cca0a05d60500680132b.gz
2007-10-02 20:09:37 +10:00
liljencrantz
dac2129048 Minor comment updates and code tweaks in input code
darcs-hash:20071002092838-75c98-d98cf339d971128761f65f6878651bd7069f9f59.gz
2007-10-02 19:28:38 +10:00
liljencrantz
8cd8c3002e Actually make the previously defined function for reloading key bindings on chage of function into an event handler as intended...
darcs-hash:20070930225557-75c98-284157fbbc56effe781bf26c21499a8e5586e563.gz
2007-10-01 08:55:57 +10:00
liljencrantz
4b85eb32d7 Remove readline legacy input function 'winch' and replace its functionality with an event handler function. Once again make the null keybinding do nothing. There are various sitauations where you want to perform a repaint at just the right time, and more or less by luck it worked very well to do this on null, but this really shouldn't happen and no longer does. Hopefully if new repainting issues turn up, they can be fixed at the root instead of once again reapplying this broken bandaid.
darcs-hash:20070930225354-75c98-8e2b518aa0ef694cee889c1c599ff4f158d9eb7f.gz
2007-10-01 08:53:54 +10:00
liljencrantz
5870ee7723 Add input function completions for the commandline builtin
darcs-hash:20070930074204-75c98-670704072134326d281626dcc6c1e7dc5be66140.gz
2007-09-30 17:42:04 +10:00
liljencrantz
feec9579c2 Drop the unneeded input-function delete-line. It was only there for compatiability with readline, which we have dropped.
darcs-hash:20070930073018-75c98-d3abd6e63797c4954778486064f5f55a718f066c.gz
2007-09-30 17:30:18 +10:00
liljencrantz
dde3838f2d Drop the unneeded input-function exit. It was only there for compatiability with readline, which we have rdropped.
darcs-hash:20070929072114-75c98-db188ce2bc31a0668867f9de05ffeed098b988c2.gz
2007-09-29 17:21:14 +10:00
liljencrantz
97b77d1b3a Indentation and comments
darcs-hash:20070928213922-75c98-96ae445e28ad3273c98ddc4ca16597988eb66d37.gz
2007-09-29 07:39:22 +10:00
liljencrantz
addb5a698d Add a few extra directories to check for in path on startup
darcs-hash:20070928213855-75c98-3670b961e1b16bfdc952bbd8e6eccacdc368ff6b.gz
2007-09-29 07:38:55 +10:00
liljencrantz
db0a982570 Make path checking on startup faster by only using builtin commands
darcs-hash:20070928213821-75c98-65fb9e2159bfef7ab04468511378ac3efbf2308e.gz
2007-09-29 07:38:21 +10:00
liljencrantz
3a73b60956 Ignore errors when autoloading keybindings
darcs-hash:20070928213741-75c98-8339e7f5f5b465af315efd606fe866624f958320.gz
2007-09-29 07:37:41 +10:00
liljencrantz
f4f10a8226 Documentation improvements on new key binding system
darcs-hash:20070928213654-75c98-a4845fb417b0b29a75d4a337df18250bc488e271.gz
2007-09-29 07:36:54 +10:00
liljencrantz
d6c7e25bea Add more keys to list of kes supported by 'bind -k'
darcs-hash:20070928213616-75c98-35f276b1c34b54684ee48681e6a04375cd3152c5.gz
2007-09-29 07:36:16 +10:00
liljencrantz
f28e83d3e9 Improve error reporting for bind builtin
darcs-hash:20070928213523-75c98-bd88022a63af1409ae28ae0829280df9652dcaff.gz
2007-09-29 07:35:23 +10:00
liljencrantz
0e716763d8 Replace variadic functions like sb_append and contains_str with variadic macros without a sentinel.
darcs-hash:20070928213227-75c98-2e7b06242acfd5fd0bf02ce77c41d52374f2363a.gz
2007-09-29 07:32:27 +10:00
liljencrantz
50f5941a82 Drop tokenizer.o from list of objects to include into fish_pager, since it wasn't actually used. Reduces size of pager binary by a few kB.
darcs-hash:20070926092957-75c98-393fa9d6ddb97a60fd0a8f5e86a2de6d2422e23b.gz
2007-09-26 19:29:57 +10:00
liljencrantz
093cb71f91 Fix bug in exit code that made the exit builtin exit even if there where running jobs if called directly from the commandline
darcs-hash:20070926090159-75c98-2760c6c24e21fd14711c9ce3bef1b0890b495d65.gz
2007-09-26 19:01:59 +10:00
liljencrantz
df4fdf33c4 Make escaping of the empty string return two quotes instead of the empty string
darcs-hash:20070925161959-75c98-1a0409c5fd12c7570e54cbdd9201548c7405196b.gz
2007-09-26 02:19:59 +10:00
liljencrantz
5694d3f027 Make escaped strings more readable
darcs-hash:20070925161916-75c98-c33aa140fb099f2003e5af3dadb5f613075b59d6.gz
2007-09-26 02:19:16 +10:00
liljencrantz
cf8e746d0c First stab at dropping all support for readlines inputrc files and instead using an internal system for performing keybinding.
darcs-hash:20070925161447-75c98-1feaef88a4b518badb7879f598f06ab650a8f93b.gz
2007-09-26 02:14:47 +10:00
liljencrantz
af9c2067e1 Add missing escape highlighting for \c-style escapes and a few other escape codes
darcs-hash:20070925115514-75c98-3959f8729d32585232d191b4eead83935b36bff1.gz
2007-09-25 21:55:14 +10:00
liljencrantz
d44dd73682 Improve documentation in screen handling code
darcs-hash:20070924085602-75c98-0a60a87de51e0dbf7e64221b0382401e72745465.gz
2007-09-24 18:56:02 +10:00
liljencrantz
5938a93018 Make prompt have its own line if we things don't fit on a single line
darcs-hash:20070924084933-75c98-0b139cdab5da3f9c9f358d09275ed15fc0fbba52.gz
2007-09-24 18:49:33 +10:00
liljencrantz
79ac330afb There code for detecting when a keepalive process was needed missed lots of cases. This should fix some issues. Both the keepalive code and the code for spawning fake processes for builtins should be rethought, though.
darcs-hash:20070924082144-75c98-ab62f758374952aa3b295af709d57931972f4683.gz
2007-09-24 18:21:44 +10:00
liljencrantz
e6764f3130 Improve commenting a bit
darcs-hash:20070924081823-75c98-20dee07adff34f2337c56b30f1e453cc38f40639.gz
2007-09-24 18:18:23 +10:00
liljencrantz
710a01c945 Improve error reporting in the . builtin
darcs-hash:20070924081428-75c98-72b9f1dfe64a40b0f7893c9ebcb59f477f6c924c.gz
2007-09-24 18:14:28 +10:00
liljencrantz
0b7b20f013 Make sure that ouput with no trailing newline is not eaten. This is a regression bug fix.
darcs-hash:20070924081301-75c98-86bd87a9323044807e78b8eb904bd6c5830ee23f.gz
2007-09-24 18:13:01 +10:00
liljencrantz
819c20e1d8 Fix bug causing some fish strings not to be translated
darcs-hash:20070923211111-75c98-3bac272b81c4af4e18968a532987d9a7be1c273a.gz
2007-09-24 07:11:11 +10:00
liljencrantz
61ebc12dd4 Minor polish like adding missing whitespace, switch to using --argument switch in function definitions to make code more readable, add a few minor saftey checks, etc.
darcs-hash:20070923210730-75c98-88557ba8b6020cae04a5e437c6bb6370e39c04d9.gz
2007-09-24 07:07:30 +10:00
liljencrantz
449a75756d Fix narrow/wide encoding issues found through new test suite additions
darcs-hash:20070923210007-75c98-9ffee3b8f1ce24e1d6f178baa1f2ef52d70ee38b.gz
2007-09-24 07:00:07 +10:00
liljencrantz
5e2e9e2b9b Add escape/unescape and wide/narrow conversion tests to the test suite
darcs-hash:20070923205918-75c98-1456ea86764a6a414f94c30e16aa2918b8341be1.gz
2007-09-24 06:59:18 +10:00
liljencrantz
737935ebe4 Fix bug caused by new escap beutification code. Some strings containing a single quote where incorrectly escaped.
darcs-hash:20070923145555-75c98-1125e148af36cb1bbe2f2029c3f1d118308721a6.gz
2007-09-24 00:55:55 +10:00
liljencrantz
0679a6351f Fix bug making builtin help for the '.' builtin not show up.
darcs-hash:20070922223828-75c98-41cf335992cd61ef5c958889714766c513d5d5f7.gz
2007-09-23 08:38:28 +10:00
liljencrantz
657e3f8147 Whitespace fixes, etc.
darcs-hash:20070922222041-75c98-5aeb13041abd7ca8f9989e209fbaa5441fa78756.gz
2007-09-23 08:20:41 +10:00
liljencrantz
e6b9955fc1 Add switch fo scope hiding in output of functions builtin
darcs-hash:20070922221920-75c98-7a17d24162a3fbdfd9c05690d2358511a3ca0281.gz
2007-09-23 08:19:20 +10:00
liljencrantz
e1afe17671 Fix bug in eval function, forgot to turn off new scope creation.
darcs-hash:20070922193055-75c98-ea4a37e3ba1bce4da7d2b65ef464740cc67822e2.gz
2007-09-23 05:30:55 +10:00
liljencrantz
16e2c4805a Use quoted escaping if possible. Most people find that more readable.
darcs-hash:20070922190838-75c98-635f62df48d611be05892c09e135e8a3993e76b2.gz
2007-09-23 05:08:38 +10:00
liljencrantz
5ecd0e22bf Remove a few calls to the test command in favour of the switch builtin to speed statup up
darcs-hash:20070922190734-75c98-0e63a0ed6685edc2c9aa941f0b26c14466c7af6a.gz
2007-09-23 05:07:34 +10:00
liljencrantz
1420744669 Fix rather large performance issue on systems with slow fork syscall - a fork was used whenever redirecting output to /dev/null and using a builtin, completely unneeded.
darcs-hash:20070921214955-75c98-b513df263751506e5e82f97eafa08041228bc8de.gz
2007-09-22 07:49:55 +10:00
liljencrantz
048f903a9d Create common function for listing available character encodings, make sure it is used in all relevant places.
darcs-hash:20070921211051-75c98-5ff21df5b29e8a66ef0c4488afb96acfdb6f74a2.gz
2007-09-22 07:10:51 +10:00
liljencrantz
dab7e6c7b9 Move mkae completion function to its own file
darcs-hash:20070921210401-75c98-6b303317ba375f0c6402e81902e599e79a9c06ed.gz
2007-09-22 07:04:01 +10:00
liljencrantz
06de2602cb Clean up interactive mode init a bit. Move a few utility functions to their own files.
darcs-hash:20070921205212-75c98-b8b6f88e151e8d0d2fca21626bf8e36a22c565b1.gz
2007-09-22 06:52:12 +10:00
liljencrantz
65d223e672 Make sure all keybinding scripts repaint properly
darcs-hash:20070921151723-75c98-83f2fe86ace0f6e567db26faa4d94665971af145.gz
2007-09-22 01:17:23 +10:00
liljencrantz
c0aac8996d Improve documentation for breakpoint builtin
darcs-hash:20070921151654-75c98-550df5aebaa11855c53585202ab7fafe7c5820ad.gz
2007-09-22 01:16:54 +10:00
liljencrantz
3692074e7e Make R_NULL not repaint and document the fact that this means some keybindings need to manually tell fish to repaint
darcs-hash:20070921144426-75c98-7db4351e14733e2c18e44515e8ed78b1f1faea80.gz
2007-09-22 00:44:26 +10:00
liljencrantz
954c99a5ad Minor improvement to docs for count builtin
darcs-hash:20070921144301-75c98-02d497e712c6932322a74d82fc7a772c92e19552.gz
2007-09-22 00:43:01 +10:00
liljencrantz
8c4770a26c Add boilerplate definition when using funced on undefined function
darcs-hash:20070921142954-75c98-752f389dfe4022ea3e72092bb717a60314408d41.gz
2007-09-22 00:29:54 +10:00
liljencrantz
624878d35f Minor bug correction in new cursor movement code.
darcs-hash:20070921142301-75c98-7fc9bbdf1591e0fc24a562e69bf483845a160df5.gz
2007-09-22 00:23:01 +10:00
liljencrantz
2375578310 Add a few comments, remove debug message add function descriptions to up-or-search and down-or-search shellscript functions
darcs-hash:20070921141121-75c98-0c6b3970f766429ba5e5c674ab3f6283f1f8824c.gz
2007-09-22 00:11:21 +10:00
liljencrantz
084c0c5f80 Correct minor typos, stupid error messages, indentation and drop unused variable.
darcs-hash:20070921140752-75c98-74318b9daffa071845187bcc0b72259ca37b7e18.gz
2007-09-22 00:07:52 +10:00
liljencrantz
d2d397d9eb Make up/down cursor move up or down when in multiline mode, except if already in search mode or at the top/bottom line. Since part of this is done in script-space, this involves adding some functionality to the commandline builtin.
darcs-hash:20070921140549-75c98-ba9e83f5e6fdecae5df8f83dd863794c6af9770c.gz
2007-09-22 00:05:49 +10:00
liljencrantz
607e970659 Further improve accuracy of cd builtins error messages. Now correctly reports rotten symlinks.
darcs-hash:20070920175243-75c98-e210034c7bfc8308be9e03017a5a0d8ef7648b9c.gz
2007-09-21 03:52:43 +10:00
liljencrantz
3b39b1fa03 Significantly improve accuracy of error reporting in the cd builtin
darcs-hash:20070920172928-75c98-826cd86e1c33e1f6c746227655e340a6bb459f30.gz
2007-09-21 03:29:28 +10:00
liljencrantz
64933d31a6 Remove generated versions of scripts on 'make clean'
darcs-hash:20070920172500-75c98-29ba72a339c3681a5eb20cd346a9a877618813cb.gz
2007-09-21 03:25:00 +10:00
liljencrantz
c780f1a8c9 Do not use enter/exit_ca_mode if they don't exist in fish_pager
darcs-hash:20070909140641-75c98-7c7ff3fae5be6432998a30c51ad90ae4c6e3babe.gz
2007-09-10 00:06:41 +10:00
liljencrantz
76bb8e79b2 Add better debbuging information when writembs is called with null value.
darcs-hash:20070909140436-75c98-b6c925c441ebaa349f998b95314295296fb36252.gz
2007-09-10 00:04:36 +10:00
liljencrantz
370aeec44d Fix bug in the count builtin, causing it to exit with status 0 even if no arguments where given
darcs-hash:20070909135734-75c98-2d0495a15440e50fb6521bffef85147832771c80.gz
2007-09-09 23:57:34 +10:00
liljencrantz
b0ae3dc9cc Handle merge confligt for previous patches. The exact same bug was fixed twice.
darcs-hash:20070908222725-75c98-2e1d0b090608d71f452c6ba7c3e1281782ebec11.gz
2007-09-09 08:27:25 +10:00
axel
a900d16540 Fix insane bytemark issue on Solaris
darcs-hash:20070908191940-ac50b-f99e05c86f32a5c1c1aff35c1916951269a54d54.gz
2007-09-09 05:19:40 +10:00
axel
3fc1ba0f0e Fix incorrect escape character in unescape function
darcs-hash:20070908191855-ac50b-e98e433dc23b6357c3a23d935de4bcb55efb9da9.gz
2007-09-09 05:18:55 +10:00
axel
38ed4c0f9b Avoid void pointer arithmetic in halloc.c
darcs-hash:20070908191814-ac50b-bb024c5a7ee878810bc7e12dcbcce32ff0145090.gz
2007-09-09 05:18:14 +10:00
axel
5a61ae3e0d Avoid magic number in main.c
darcs-hash:20070908191743-ac50b-7185b9d59122cb9a090cacfbb43266822400e1ed.gz
2007-09-09 05:17:43 +10:00
axel
c9fe154c01 Avoid using test command in prompt, makes it slightly faster
darcs-hash:20070908191717-ac50b-c2d936bff0e7aead0aecad6aa9e024e63b72fc97.gz
2007-09-09 05:17:17 +10:00
axel
2a3b01a7a0 Avoid using -n switch to ecco
darcs-hash:20070908191554-ac50b-22f205c0da9dde0cbe19154ee6f4f64fed49241a.gz
2007-09-09 05:15:54 +10:00
Claes Nästén
c2c4b24174 Fix issue in error handling, reported to and fixed by Axel Liljencrantz. Change val[0] and body[0] in env universal to val[1] and body[1] to support compilation with Sun Studio. Change default prompt to use pekdon instead of whoami as it does not exist under Solaris.
darcs-hash:20070822080052-cac88-326332f0df7d17ddca4a4496c93728a47f19bba5.gz
2007-08-22 18:00:52 +10:00
Claes Nästén
74a270ea32 Add tparm fallback to use under systems having tparm with fixed number of paramters, required with Solaris curses. Updated configure script to check for c99 for compilation with Sun Studio under solaris and updated LDFlAGS for fish_pager etc to include library dependencies from common.c etc.
darcs-hash:20070822075741-cac88-5532b074490bce1d7f37289b1774a4a5e44416d8.gz
2007-08-22 17:57:41 +10:00
Claes Nästén
2994378e1a Fix compilation with Sun Studio compiler changing \e to \x1b as it does not support \e as an escape character.
darcs-hash:20070822075239-cac88-1a9768bf35295615d553192d9a494f00db26f742.gz
2007-08-22 17:52:39 +10:00
Claes Nästén
baeca81305 Fix compile issue with Sun Studio, read_redirect returns void still doing return read_direct breaks with error about returning from function returning void.
darcs-hash:20070822074900-cac88-95305ba9542eec028dc7e6bb462aab10897fb693.gz
2007-08-22 17:49:00 +10:00
liljencrantz
151943f89e Indentation, typo and formating fixes. Very minor patch.
darcs-hash:20070908222453-75c98-2236d962f0c9016820063e871fbbeaa42f36ef22.gz
2007-09-09 08:24:53 +10:00
liljencrantz
ad02bb9b48 Add a 'generic' type of event that can be emited from any piece of code or by the user. Use this event layer to perform interactive configuration startup at the correct time.
darcs-hash:20070819164230-75c98-f91b8a73de7bbbb500d80770ddf4d2d46ae592cc.gz
2007-08-20 02:42:30 +10:00
liljencrantz
e464b4270c Make the prompt different when root user. This change was suggested by Claes Nästén.
darcs-hash:20070818230302-75c98-8015683bda0bc75aeab048e2f6509afc9809ffa1.gz
2007-08-19 09:03:02 +10:00
liljencrantz
e076f2c239 Make the contains builtin not allow reordering of switches and non-switches
darcs-hash:20070814214257-75c98-a50161a8146dfd0a6c6a948e1960f93dd52275fd.gz
2007-08-15 07:42:57 +10:00
liljencrantz
3cb24e0681 Add missing file creation mask for open. This fixes a compilation bug on the upcoming Fedora 8. Thanks to Oliver Falk for reporting the issue as well as figuring out the cause.
darcs-hash:20070814213722-75c98-5466a6be1e29984da67d5de0d1fe8e04ec1373bb.gz
2007-08-15 07:37:22 +10:00
patroclo7
27baa6e62b Completions for prt-get and pkgutils, the package management utilities for CRUX (Giorgio Lando)
darcs-hash:20070803202253-782a0-e2140559cdf45e3a543c3e9d915fe84537ee73a6.gz
2007-08-04 06:22:53 +10:00
Giorgio Lando
fa9d00a81a Completions for ports, a tool for port management in CRUX linux
darcs-hash:20070804110916-cbd54-5a9d129b9cfc7bf1b8f09248631ddbfbfc0dda22.gz
2007-08-04 21:09:16 +10:00
liljencrantz
04948702e0 Add a mino-prompt when the normal prompt is too large to display. The old behaviour was to simply not print any proimpt, but that lead to thinking fish had hanged since there was no prompt at all.
darcs-hash:20070802225939-75c98-16623ffd640c6036331844334b0ff6f9f211934d.gz
2007-08-03 08:59:39 +10:00
liljencrantz
20526687b2 Drop contains function, since we now have a builtin.
darcs-hash:20070801225554-75c98-cbaba63efdd06277364cc9b3ef871b9e76a7edb9.gz
2007-08-02 08:55:54 +10:00
liljencrantz
0a0870180d Fix duplicate switch antry in builtin_status. Don't know if this was caused by patch bug or typo.
darcs-hash:20070801225421-75c98-8c91f5fb00ccc05ac40ef12ffbfc68fec5e64dd0.gz
2007-08-02 08:54:21 +10:00
liljencrantz
972edef341 Replace the contains function with a builtin for performance reasons. The contains function used at lots of forks, which was noticable on systems such as OS X with slow forks, as well as on completions that do a lot of tests, like svn
darcs-hash:20070801225318-75c98-48cc4d685ab665c7c2eb93ac3c374bf5afecd28a.gz
2007-08-02 08:53:18 +10:00
James Vega
8ed521c817 Update status builtin to properly handle and document all of its options.
darcs-hash:20070801194450-35ec8-e2fe5b798e728d1caef474295a92230c35c79c17.gz
2007-08-02 05:44:50 +10:00
axel
88199d6b51 Implement a minimal 'dumb terminal mode'. This mode is used to at least get the relevant information on-screen when using a dumb terminal, though the interface is pretty crippled.
darcs-hash:20070801190754-ac50b-4a07ba05455f3ff55e337a78320dc4302cd3502c.gz
2007-08-02 05:07:54 +10:00
axel
782a739736 Remove confusing and misleading error message when trying to repaint the prompt during startup, reported by Chris Rebert.
darcs-hash:20070801180901-ac50b-43abf47182fcaa19fdbd993d480ac07f2915b6ed.gz
2007-08-02 04:09:01 +10:00
axel
cd19320ab2 Minor bug fix in mime-completion-filter - correctly handle when there is no mimetype
darcs-hash:20070801173955-ac50b-0459fc6049e9ee1907c368b8a5a01b6aa1973e45.gz
2007-08-02 03:39:55 +10:00
axel
58fd6b895a Minor error handling improvements and minor code polish
darcs-hash:20070801173801-ac50b-11a281d9f622e935c1f138355babd20269068f35.gz
2007-08-02 03:38:01 +10:00
axel
df55e89bbb Spelling fixes from Chris Rebert
darcs-hash:20070801173524-ac50b-760d9ddf0e68aa24cd570b542824a7f2b3248ff5.gz
2007-08-02 03:35:24 +10:00
axel
91de143003 Replace the count function with a builtin for performance reasons. The count function used at least two forks, which was noticable on systems such as OS X with slow forks
darcs-hash:20070731212332-ac50b-8f5b2e70008ddb131dc8bae3f361d8d65a294948.gz
2007-08-01 07:23:32 +10:00
axel
748d726ddf Replace the count function with a builtin for performance reasons. The count function used at least two forks, which was noticable on systems such as OS X with slow forks
darcs-hash:20070731212320-ac50b-3bae489646f359ca86bb1f049901860ce9aedd5f.gz
2007-08-01 07:23:20 +10:00
axel
2caaa7526d Make sure completion descriptions generated by make_vcs_completions.fish are properly escaped. Thanks to Claes Næstén for the bug report.
darcs-hash:20070605105111-ac50b-e2cbb17047be6c6b0ddf5847507986f50c97be4c.gz
2007-06-05 20:51:11 +10:00
axel
778aa1c304 Print 'unknown' if 'mimedb -d' fails
darcs-hash:20070524171053-ac50b-c9374e0da7f4cf1458a19d9234e4752ae156e37e.gz
2007-05-25 03:10:53 +10:00
axel
c40eb8a716 Update regexps in mimedb to work on NetBSD. (NetBSD does not support having empty subexpressions. This bug was reported and diagnosed by Claes Nästén.
darcs-hash:20070524063728-ac50b-9377f6d2ba709e997c00d716e766a912cc1ee23e.gz
2007-05-24 16:37:28 +10:00
axel
1c6236831c Fix character set conversions in both directions in universal variable code. This fixes encoding issues on NetBSD. This patch was written by Claes Nästén.
darcs-hash:20070515194610-ac50b-9da1b06c8235dd94ae26074f2a42809d5b856743.gz
2007-05-16 05:46:10 +10:00
axel
c1b4fa847f Improved error reporting in mimedb for failed regexps. This patch was written by Claes Nästén.
darcs-hash:20070515193751-ac50b-8221971ea524cddaba3e8e72a61b151b399ea7b6.gz
2007-05-16 05:37:51 +10:00
axel
a6644631d9 Show hints on how to proceed if xsel fails to build
darcs-hash:20070510192411-ac50b-ec68699d6ca6ba2b315e5f283e30dfba4bad75b4.gz
2007-05-11 05:24:11 +10:00
axel
e4f5bc69e2 Make sure that the PWD and HOME variables are always in canonical form
darcs-hash:20070510191128-ac50b-dd51a75617d62e4f403094ddc7527a82c5de3103.gz
2007-05-11 05:11:28 +10:00
axel
03f322c715 Use ucs4 or ucs2 as a fallback character set if wchar_t encoding is not supported by iconv
darcs-hash:20070510061428-ac50b-ae9bfda1cc24bc29c2c492f902854440da319bfc.gz
2007-05-10 16:14:28 +10:00
axel
a72d877752 Add missing -b switch for the commandline builtin. This issue was reported by philip ganchev
darcs-hash:20070427223131-ac50b-f7a40d4cf7622cbce4b9d73cc2bc5e2d27ce386f.gz
2007-04-28 08:31:31 +10:00
axel
d0585befb3 Make sure that io redirections are respected by the '.' builtin. This was not the case earlier, which caused various bugs, especially after eval was made into a function that internally used '.'
darcs-hash:20070425183002-ac50b-d7d93e3b74e7274fe3e0aad98e95dd608bb903ae.gz
2007-04-26 04:30:02 +10:00
axel
784c5d9fa3 Update todo list
darcs-hash:20070424205314-ac50b-2b1048b8a50fd21fd264eba5b00647f3bdf23304.gz
2007-04-25 06:53:14 +10:00
axel
52e7a7ec1c Actually add the count function. Thanks to Tassilo Horn for the report.
darcs-hash:20070424153317-ac50b-f6ab71ad0ea9d74351169d18f1dc856a442ee3f4.gz
2007-04-25 01:33:17 +10:00
axel
c00e1fcf26 Fix bug in stack trace printing code
darcs-hash:20070424060620-ac50b-174e68e78bc2b1d6e5e3f5787e4a252cad95911c.gz
2007-04-24 16:06:20 +10:00
axel
5425970706 Add a fes minor completion corrections
darcs-hash:20070423220148-ac50b-460b1d404dca7169054459ab6c7f9845dad51a05.gz
2007-04-24 08:01:48 +10:00
axel
419b3166c8 Implement count as ashellscript function instead of a command in order to support very long argument lists. Note that this implementation is painfully slow for more than 1000 arguments.
darcs-hash:20070423220026-ac50b-69c4b06c88e6120429b6358f1b61f6076d392ce5.gz
2007-04-24 08:00:26 +10:00
axel
e2714b05eb Launch debug shell on TRAP signal.
darcs-hash:20070423211026-ac50b-fccf4fb588775fbacc5cdc9f121abe417970066f.gz
2007-04-24 07:10:26 +10:00
axel
2c02b59703 Replace the eval builtin with a function
darcs-hash:20070422221806-ac50b-28cffc6c3063c14cd8ab30f999e3530314c78af2.gz
2007-04-23 08:18:06 +10:00
axel
ee94424b0f Add the possibility for functions which do not shadow the arguments of the calling function
darcs-hash:20070422221033-ac50b-d9544c87d0ddab10f7f503b5a1707292f266efe4.gz
2007-04-23 08:10:33 +10:00
axel
2b7535bb51 Make the . (source) builtin able to read commands from stdin
darcs-hash:20070422211947-ac50b-b8d33d81fcef5e0b7e76a8d2a9f0bcbcf3ac67b7.gz
2007-04-23 07:19:47 +10:00
axel
c5805cfd47 Validate variables names when using named arguments for functions
darcs-hash:20070422211624-ac50b-11920a8a00c7bae97c3556bc7ce47b3022c34f08.gz
2007-04-23 07:16:24 +10:00
axel
7ca76ef743 Make 'functions' builtin print named arguments of functions
darcs-hash:20070422211534-ac50b-3293f1d733a8a3be760f344598bfae8b77647b2f.gz
2007-04-23 07:15:34 +10:00
axel
2c743173d3 Fix minor memory leak on printing help for builtins
darcs-hash:20070422211451-ac50b-42293b46e39cd5d0cfdf2ca63effe12faa048970.gz
2007-04-23 07:14:51 +10:00
axel
003dfb99da Prettyfy output of 'functions' builtin a tiny bit
darcs-hash:20070422185627-ac50b-99b7c27d06f5a6d5e7a7b66da864317bf1019fe2.gz
2007-04-23 04:56:27 +10:00
axel
dd48de068d Add funced function, which works like vared, but with functions
darcs-hash:20070422185539-ac50b-9080fb745cec45609e7e29971b55b96e073806e6.gz
2007-04-23 04:55:39 +10:00
axel
cb179c448b Minor tweaks to the indent program
darcs-hash:20070422185429-ac50b-f054a56d16ba55d2bbbd1d61e8bbfcb6c17a23a9.gz
2007-04-23 04:54:29 +10:00
axel
c323fc226f Add support for changing token separator in command substitution. IT is not the first character of IFS, same as in various other shells
darcs-hash:20070422184956-ac50b-7e03b375feb9fd22e11aa7a7d8f8add8e3b717a5.gz
2007-04-23 04:49:56 +10:00
axel
176c1a487b Minor improvements to the completion generator and gcc completions
darcs-hash:20070422101414-ac50b-07612cd287d524a361e358369732c26fc9ff3b67.gz
2007-04-22 20:14:14 +10:00
axel
2872df66d7 Add source code prettyfier program called fish_indent
darcs-hash:20070422100312-ac50b-a073999b7dc172259c8200f3e740c921647222a0.gz
2007-04-22 20:03:12 +10:00
axel
45412f2b1f Move keyword detection code to separate file
darcs-hash:20070422095026-ac50b-77a840e2830370f46b7a48fd8863095d2cd7a5f0.gz
2007-04-22 19:50:26 +10:00
axel
e9790db64a Fix bug in parser, on incomplete blocks. This bug was handled correctly by the error handler, so it was non-critical.
darcs-hash:20070422094847-ac50b-f8aff4c2939725e256b2f6d020f98240d2658d50.gz
2007-04-22 19:48:47 +10:00
axel
8ab1d0254c Add missing help building dependency
darcs-hash:20070421081244-ac50b-e78d648a50ec2ec48ef6bf95f5540e3c1a684633.gz
2007-04-21 18:12:44 +10:00
axel
4c858a10c9 Minor code edits (comments, function rename)
darcs-hash:20070421081122-ac50b-fdd497a6ff8a1d2507509f21a168c9130ed59ad7.gz
2007-04-21 18:11:22 +10:00
axel
b4ccce2dc3 Add completion support for named function arguments
darcs-hash:20070421080931-ac50b-c3e482ad145c619d23cc5f19256010b5b0697c57.gz
2007-04-21 18:09:31 +10:00
axel
06688fb9ea Change output format of complete -C to make writing case insensitive command specific completions more transparent
darcs-hash:20070420195506-ac50b-b5f56bb2964e65d13abfb9281ce26db2b8c341b7.gz
2007-04-21 05:55:06 +10:00
axel
4d5c50cbb3 Fix minor bug - the description would occasionally get appended to command specific tab completions in case insensitive mode
darcs-hash:20070420193430-ac50b-13e34ac41cf1662a74f0af329fb41d872df5d691.gz
2007-04-21 05:34:30 +10:00
axel
91d1dee06b Add completions for evince
darcs-hash:20070418224801-ac50b-83713782420d5f820add93e47b57d2289f289b61.gz
2007-04-19 08:48:01 +10:00
axel
3e030bc6c6 Add a completion function for completiong file url:s
darcs-hash:20070418224611-ac50b-4e457b2218751a182989f3635bb98c5e8a8b9766.gz
2007-04-19 08:46:11 +10:00
axel
b9009eba96 Remove explicit directory completion from __fish_complete_mime, we only want directory completion as a fallback in order to minimize the number of reasonable completions that are ignored. This issue was reported by Claes Nästén.
darcs-hash:20070417225658-ac50b-26178885ea4f8693858a74cec57a743831430634.gz
2007-04-18 08:56:58 +10:00
axel
90c5cea43d Fix URL character encoding bug in mimedb
darcs-hash:20070417062932-ac50b-7816e307ab180be02fc247f6c4796e7fa774862d.gz
2007-04-17 16:29:32 +10:00
axel
52f9560b4f Rename save_function to funcsave to keep consistency between function/variable functions
darcs-hash:20070416214453-ac50b-9ec9559fc468256dc149e92e9fece37da940ad7e.gz
2007-04-17 07:44:53 +10:00
axel
91ca8610ee Use cpp macro to avoid manually adding sentinel value to varargs functions
darcs-hash:20070416214041-ac50b-f682569c0d29ab3519bb59335debba525a640175.gz
2007-04-17 07:40:41 +10:00
axel
2efb88a30a Minor code cleanup in history search code
darcs-hash:20070416212615-ac50b-ca37865e50d0773abb5a4fdc7f71e5fa9a503c34.gz
2007-04-17 07:26:15 +10:00
axel
87223c68f4 Fix bug where case insensitive completions would miss the leading slash in file completions. This bug was reported by Claes Nästén.
darcs-hash:20070416210605-ac50b-eb1bc315ec360f8ccd5f37194c274796be97c607.gz
2007-04-17 07:06:05 +10:00
axel
5c9570eb56 Minor code tweaks
darcs-hash:20070416201053-ac50b-99d3ee51ef2b3642c737c3809bc2a4bfbe103b67.gz
2007-04-17 06:10:53 +10:00
axel
778b6a31ad Fix warning caused by bad casting
darcs-hash:20070416201034-ac50b-89a7257eadbf9098222cfb5ddc4bcf4bb88a8681.gz
2007-04-17 06:10:34 +10:00
axel
4d6751c274 Allow named arguments to function instead of only $argv. Philip Ganchev once suggested this, and it was suggested again by Egil Möller.
darcs-hash:20070416200611-ac50b-5eb42c94a65a4e72cae12cd9c04424bdc3b2b4f8.gz
2007-04-17 06:06:11 +10:00
axel
a03a4d1ba3 Add newline to error message in alias.fish. This problem was reported by flixil.
darcs-hash:20070412115221-ac50b-0ff23d6e2158522d10c7e799dc9f1594112f1869.gz
2007-04-12 21:52:21 +10:00
axel
5a670e2a96 Fix bug where fish would refuse to start if $HOME has an invalid value. Thanks to James Vega for the report.
darcs-hash:20070411131823-ac50b-2760c09e8939179a6c771a44220aa355381f4f0b.gz
2007-04-11 23:18:23 +10:00
axel
edf896f7cd Fix crash bug in recursive completion (e.g. 'which ls'). This bug was reported by Philip Ganchev
darcs-hash:20070326061307-ac50b-a89d4427b3f416f31e214bd833c4c76c6ebe3580.gz
2007-03-26 16:13:07 +10:00
axel
e128fa1a8e Fix a bug where io redirection of builtins would not truncate files if the builtin did not produce any output
darcs-hash:20070324223430-ac50b-3f3d6fd35f5b82c59ecaa06b459fe2b61dc8f387.gz
2007-03-25 08:34:30 +10:00
axel
e8ba091161 Move documentation on fish_prompt to the external command section
darcs-hash:20070324222135-ac50b-0b27258486492ea6178a852061dc894da60140ee.gz
2007-03-25 08:21:35 +10:00
axel
65d99117aa Minor code simplification in util.c
darcs-hash:20070324193801-ac50b-e45d88fd7de0204467a0f7d52b71ee323f4e3f0d.gz
2007-03-25 05:38:01 +10:00
axel
94a483d46b Minor tweak to vcs completion generation code. Most significantly, some svn command descriptions which where previously truncated are now complete.
darcs-hash:20070324193714-ac50b-61b10db649ef82ba8d8d658ef10cc05c2253d5f0.gz
2007-03-25 05:37:14 +10:00
axel
e750f1a3c2 Minor documentation fixes
darcs-hash:20070324191646-ac50b-0892de7e96348caf198830af2b2ad46b84f9f13e.gz
2007-03-25 05:16:46 +10:00
axel
3f4b47b4af Fix bug where case insensitive file completions would get directory components removed
darcs-hash:20070324190738-ac50b-2f94de910083eae1fe563284b9953071df706072.gz
2007-03-25 05:07:38 +10:00
axel
f6b3fcb4f5 Add missing sentinel value in function call - potential crash bug
darcs-hash:20070324190423-ac50b-e32dddfd98131c542133b98a8c49bc3d9c345fec.gz
2007-03-25 05:04:23 +10:00
axel
8fe90e4327 Include the make_vcs_completions.fish file that is used to generate various completiosn with the main tarball. Nick Pilon pointed out that it was missing. This patch also removes the make target for the file, which was used to chmod it, which is not needed since it is not used in the build chain.
darcs-hash:20070324115040-ac50b-d5b525be925d1a738b9ca6252c89e662a02a9e44.gz
2007-03-24 21:50:40 +10:00
axel
a17019e439 Do not flag a lone '-' as an error. Many commands accept it.
darcs-hash:20070324111455-ac50b-aaee0e9c80c3e57b1f0b5f421c80ed599d5c1e1b.gz
2007-03-24 21:14:55 +10:00
axel
b5baac8291 Try to fix the dependency problems with user_doc. Thanks to James Vega for investigating the cause of this.
darcs-hash:20070324110801-ac50b-ee833df5e34ae4fff8a4adb417647aadb8be9e29.gz
2007-03-24 21:08:01 +10:00
axel
f36508837b Use per-binary LDFLAGS to remove linking to useless libraries. This will reduce the size of the binaries and may also speed up startup time slightly. These changes are based on suggestions and a patch by James Vega.
darcs-hash:20070324105629-ac50b-64425ff68a18e3adf51eee141d3a4450405c1ddb.gz
2007-03-24 20:56:29 +10:00
axel
3969c1b453 Add a blacklist of console types that are known not to support terminal titles, even when in a virtual terminal
darcs-hash:20070317233846-ac50b-4030f863aefb96085368470b76ee9da146c04c96.gz
2007-03-18 09:38:46 +10:00
axel
1e524fbc7a Fix occasional shoowing of the same completion twice. Than ks to Tassilo Horn for the bug report.
darcs-hash:20070317231623-ac50b-a9447aa60d0ca654713a5391a3f6137d29d98916.gz
2007-03-18 09:16:23 +10:00
axel
3e1b0e587e Fix performance bug in command description lookup - it was performed once for every element in PATH. Thanks to Tassilo Horn for the bug report.
darcs-hash:20070317225611-ac50b-5df5227ddd88747781c981ed34a80844391573d1.gz
2007-03-18 08:56:11 +10:00
axel
2aea1d5a84 Initial checkin of code for using case insensitive completion as a fallback for regular completion. Some types of completions don't yet support the feature.
darcs-hash:20070228214327-ac50b-9b5c69a1c3e0c11b560f8c61be0441d2ee9d6404.gz
2007-03-01 07:43:27 +10:00
axel
6616543991 Add breakpoint builtin
darcs-hash:20061111105400-ac50b-18b9165f8719efd45b46e3b3786f7079edd721e7.gz
2006-11-11 20:54:00 +10:00
axel
83a3706099 Various minor codee updates. Dead code removal, comment tweaking. Spelling fixes, etc.
darcs-hash:20070225111738-ac50b-9656f807d2e41ebb06a43e10925834420740e20d.gz
2007-02-25 21:17:38 +10:00
axel
7c96cb2ff8 Second round of bug fixes and minor code improvements after the completions struct update. Fix space insertion issues on command specific completions.
darcs-hash:20070225103715-ac50b-5aaaa1c1c6ed1084ba68841fb70cc23c84f19806.gz
2007-02-25 20:37:15 +10:00
axel
a3c5718eb9 Round of bug fixes and minor code improvements after the completions struct update. Moves the file description code to wildcard.c, where it was actually used. Simplifies the memory allocations in that code significantly. Makes sure directoriy names don't get a space inserted after the completion.
darcs-hash:20070225090524-ac50b-4d095bf8da7c788a7828e707556edbdc0bbf5000.gz
2007-02-25 19:05:24 +10:00
axel
9b10fa4762 Make halloc-based list allocation work without context
darcs-hash:20070224131932-ac50b-4523781b1e3cc49e7cd7e3b2e1f21e28b1c5503f.gz
2007-02-24 23:19:32 +10:00
axel
0f51d5ec18 Do not use makefile to generate vcs completions, do it directly in the script. Also add some minor updates to the vcs completions.
darcs-hash:20070224125927-ac50b-f1242b198ea0651c993b045d584262dc32062338.gz
2007-02-24 22:59:27 +10:00
axel
73a67c2a43 Fifth phase of using a real struct for passing around completions - make expand.c and wildcard.c use the struct internally. This makes all completion code use the new struct.
darcs-hash:20070224081131-ac50b-aba4ff255c6dc1ce9ad375d6cd1acde919c7cbd6.gz
2007-02-24 18:11:31 +10:00
axel
6859e012d9 Fourth phase of using a real struct for passing around completions - make expand_string return a completion_t struct. Also make the reader sort and remove duplicates again
darcs-hash:20070218232520-ac50b-e23339ec5bba673681eced110e1b0b344eb5d976.gz
2007-02-19 09:25:20 +10:00
axel
680cf17570 Third phase of using a real struct for passing around completions - make all of complete.c use the completion_t struct
darcs-hash:20070218120841-ac50b-ae97122e9c9922271e93f9b7dd8808072820e873.gz
2007-02-18 22:08:41 +10:00
axel
854c4aee9a Second phase of using a real struct for passing around completions - make variable, user and command completion use the completion_t struct
darcs-hash:20070217110555-ac50b-8f08ade57885bc2ee17a07f5e789368e7dad9421.gz
2007-02-17 21:05:55 +10:00
axel
104ec963c2 First phase of using a real struct for passing around completions - only use it on things returned by complete(), e.g. use it in the reader
darcs-hash:20070209093350-ac50b-d91fe87be4612a56bff2139349cefa28a504cbb7.gz
2007-02-09 19:33:50 +10:00
axel
08eb92707a Fix paran mismatch bug in umount completions that popped up when dropping the N_ script
darcs-hash:20070223163630-ac50b-efa267645ce113eab089d49d240bb3e00e9f07e5.gz
2007-02-24 02:36:30 +10:00
axel
e50f43416b Add missing file for vi completions that is needed to complete files selectively based on mime types. Also use it to improve emacs completions, in order to balance my GNU karma.
darcs-hash:20070222214555-ac50b-60aa6a3e4cea77451c51d40d2a574d145f3de4fe.gz
2007-02-23 07:45:55 +10:00
axel
58755fc579 Do not make documentation generation depend on Makefile
darcs-hash:20070216200015-ac50b-981a883d95acd776e1e58d6ca74f95b5494fd305.gz
2007-02-17 06:00:15 +10:00
axel
31ca1218d4 Fix bug where fish would randomly assume completions are authorative
darcs-hash:20070209093237-ac50b-d6ccbddf652a8307c8fd43406fc0ad059a2ba834.gz
2007-02-09 19:32:37 +10:00
axel
44e8a12b66 Update darcs completions with additional command specific completion for setpref subcommand
darcs-hash:20070208172759-ac50b-2a233f8590dbb13a47ff243efa351dc6bce8f47a.gz
2007-02-09 03:27:59 +10:00
axel
fe21577a8e MArk make_mercurial_completions.fish as executable
darcs-hash:20070208172658-ac50b-c721b6a07934d11e8467dad78a2fbb206f0b24cd.gz
2007-02-09 03:26:58 +10:00
axel
a4ac924512 Bump version number
darcs-hash:20070208170725-ac50b-083a3c094fc4901b949cd71e7ff956f6dae958c4.gz
2007-02-09 03:07:25 +10:00
axel
e936629dc3 Minor documentation update to reflect change in how __fish_complete_suffix function works
darcs-hash:20070208170339-ac50b-3ce23bc61e8cd7c4874748dd5f1395739c57ad36.gz
2007-02-09 03:03:39 +10:00
axel
dfabf7f206 Update todo list
darcs-hash:20070208170232-ac50b-7413e8283f40a38c9790b391a70954897ae0bcae.gz
2007-02-09 03:02:32 +10:00
axel
7118269e4b Minor tweaks to vared function
darcs-hash:20070208170118-ac50b-76ea318d47de28a4437ecf0a50daea2c617017ea.gz
2007-02-09 03:01:18 +10:00
axel
100355c3c1 Add chengelog entry to spec file for fish
darcs-hash:20070208170032-ac50b-d748dc073ffb6ea0e209d0d99bd3dcc6eba2f2cd.gz
2007-02-09 03:00:32 +10:00
axel
4b1fced1f8 Add -u flag to case completions - case is often used to parse switches, coloring them red makes no sense
darcs-hash:20070205122839-ac50b-a87b86846216ad495f58825f3cb27692fc8bf269.gz
2007-02-05 22:28:39 +10:00
axel
abff4e5b41 Add flags for long file support in configure.ac. They should be useful when supported (e.g. Linux and Solaris) and should do no harm when unsupported.
darcs-hash:20070205122553-ac50b-93adeeafc5c4bb43397e4b088f6e9de5744b3058.gz
2007-02-05 22:25:53 +10:00
axel
25082b6528 Update vi/vim completions. Add __fish_complete_text function that completes using any text file, and __fish_filter_mime that filters a file list based on mimetype. This update was written by Velko Hristov with some suggestions and updates by me.
darcs-hash:20070204151809-ac50b-b7f3b44ac528f9e994bf0f842ee2e008866fb620.gz
2007-02-05 01:18:09 +10:00
axel
766482d90e Fix bug in read builtin - signal handlers where not correctly set, causiong ^C not to work
darcs-hash:20070201002053-ac50b-b73e22cbeecaeb364974cd2c512efbd517bb90d3.gz
2007-02-01 10:20:53 +10:00
axel
15e0a44fc7 Fix bug where pressing ^C while in the read builtin would mess up the block execution bit
darcs-hash:20070131235810-ac50b-23dde9d0e13cc028b744307073c1daf989258b54.gz
2007-02-01 09:58:10 +10:00
axel
3b653cd26a Fix indentation error - the else builtin was not properly indented
darcs-hash:20070131231820-ac50b-1c5825cd78a1636801b8a4a26c1d15eb811cb28f.gz
2007-02-01 09:18:20 +10:00
axel
ba6661e9df Fix occasional duplicate stack trace, reported by Mike Roberts. Also make fish less likely to print huge amounts of help in non-interactive mode, as per suggestion from Mike Roberts.
darcs-hash:20070131160317-ac50b-8354948f55a1478515ebfe7ddb6db14b6775dd18.gz
2007-02-01 02:03:17 +10:00
axel
55af8e4966 Add support for checking the existance of specific variable array elements
darcs-hash:20070130204344-ac50b-d006de7693722677d052f7559923753acd27a4a2.gz
2007-01-31 06:43:44 +10:00
axel
dcad2ef17b Switch various completions to the simpler format for __fish_complete_suffix
darcs-hash:20070130153435-ac50b-abe42f3f464cb96db062c83084d97ef377a72e80.gz
2007-01-31 01:34:35 +10:00
axel
418192b312 Make the first and last argument to __fish_complete_suffix optional. Use mimedb to look up descriptions if not supplied.
darcs-hash:20070130152631-ac50b-24f1c947d88ce3ad20f31a17b58adfe02cf002e2.gz
2007-01-31 01:26:31 +10:00
axel
76d9051605 Add vim completions, written by Velko Hristov
darcs-hash:20070130004233-ac50b-5c48b940b29ac4f3c377bc88e2abf2e490e9df48.gz
2007-01-30 10:42:33 +10:00
axel
ca2b2103d3 Add command specific completions for xterm, written by Velko Hristov
darcs-hash:20070130000155-ac50b-7834a733d6bc48f3b57172fa6dc49c36680d575d.gz
2007-01-30 10:01:55 +10:00
axel
14e6bdb139 Add command specific completions for totem, written by Velko Hristov
darcs-hash:20070130000128-ac50b-8aec9bbe3858d03189720ed6fc9906ce8f9d4ddc.gz
2007-01-30 10:01:28 +10:00
axel
20d42378de Remove trailing period in descriptions for darcs and svn
darcs-hash:20070129183116-ac50b-c4870570baaee554457413360c084209cb6a4090.gz
2007-01-30 04:31:16 +10:00
axel
41c9f89fcf Add memory allocation check
darcs-hash:20070129175223-ac50b-05b933837cf0522889287069d5ed2fcacaf62b6a.gz
2007-01-30 03:52:23 +10:00
axel
7953863b38 Fix bug where quiting from the read builtin could cause the prompt not to repaint
darcs-hash:20070129174501-ac50b-7e7f62ab8a1864617291208919551505bae6e156.gz
2007-01-30 03:45:01 +10:00
axel
3fff030ee2 When clearing a line in the screen handler, also make sure that the internal state reflects this. This helps avoid issues with wiping out parts of the prompt
darcs-hash:20070129174358-ac50b-73d002a44ef53ba63e33c66073eea6fec449b9d0.gz
2007-01-30 03:43:58 +10:00
axel
da9f7227f5 Fix repaint bug for read - screen needed repainting after call to read
darcs-hash:20070129162807-ac50b-c037ecfc0670a1f2795982337760f76036d6cdc5.gz
2007-01-30 02:28:07 +10:00
axel
ba932b6590 Add support for -s switch to read builtin, enables shell syntax highlighting in the read builtin
darcs-hash:20070129162624-ac50b-dff9d9ebf16ce3247b83d917efbffd4942cda83f.gz
2007-01-30 02:26:24 +10:00
axel
c02e2b1320 Empty environemnt variable array entrys are now set to the empty string - what value should they really have?
darcs-hash:20070128134331-ac50b-a1efdcd67e1d142c5f234a4018187fdb2f70b567.gz
2007-01-28 23:43:31 +10:00
axel
37a95a3096 Make parsing of --authorative switch for complete builtin more logical. Fix bug with previous approach causing some completions to be ignored.
darcs-hash:20070128134059-ac50b-de53eb223939fbdf0d247dfbe343c62fc31cce11.gz
2007-01-28 23:40:59 +10:00
axel
bbd229b206 Add command specific completions for file and locate, written by Velko Hristov
darcs-hash:20070128114415-ac50b-f5844d6523a9aed3ca0e881c6c125072caee4978.gz
2007-01-28 21:44:15 +10:00
axel
6a60377e02 Add -u switch to completions which can have unknown switches or which are incomplete
darcs-hash:20070128032652-ac50b-dae70e7b2efddbc757aae8bc7d1884ff5e010621.gz
2007-01-28 13:26:52 +10:00
axel
fc87b3c4b4 Make it possible to specify the -u switch tom complete without actually specifying any new completions, since it affects all previous completions
darcs-hash:20070128032416-ac50b-93b943d712ac072f1bdb7f568e8064f73ffb85e0.gz
2007-01-28 13:24:16 +10:00
axel
fcbdb6f2a7 Add command specific completions for mutt and sylpheed, written by Velko Hristov
darcs-hash:20070128024639-ac50b-484668bdfb13c4cd23e058224d14b8f6d52b04d0.gz
2007-01-28 12:46:39 +10:00
axel
a537b01814 Add aptitude completions, written by Velko Hristov.
darcs-hash:20070127231612-ac50b-0a3b6ef52a01b5b15b0b1a9f11df739d02fa353c.gz
2007-01-28 09:16:12 +10:00
axel
bd5a16d213 Add support for using __environ instead of environ, if it exists and environ isn't set
darcs-hash:20070127165911-ac50b-72747760d767a6918152c2e4f254febb19ab1205.gz
2007-01-28 02:59:11 +10:00
axel
be0bd50bad Remove unneeded code from isatty, fix spelling in docs
darcs-hash:20070127141215-ac50b-d15c657b62862841df80c55095a05e9c38086a11.gz
2007-01-28 00:12:15 +10:00
axel
cab5c63402 Verify that fd redirection is an int
darcs-hash:20070127135010-ac50b-d9c048edc5579c460ed2b181c366c67e9cfd7beb.gz
2007-01-27 23:50:10 +10:00
axel
d480d892c9 Do not call getc if getwc fails - mixing wide and byte-based readin may cause a crash. IT's better to simply hope that getwc can recover.
darcs-hash:20070127021026-ac50b-b85e10029d2bc0ce4857ec48945a92270e499a07.gz
2007-01-27 12:10:26 +10:00
axel
f2ccbe7374 Make get_desc_buff variable functions local static instead of global
darcs-hash:20070127020924-ac50b-0dfd72f6c30a82adc9500020df4b7bafb8d6dd56.gz
2007-01-27 12:09:24 +10:00
axel
85241817f8 Drop unneeded generic descriptions for completion of functions and builtins. Add description for count.
darcs-hash:20070127020752-ac50b-62dba47967cac04cd242894bfaa03116461883f3.gz
2007-01-27 12:07:52 +10:00
axel
8cf46bdb5c Add make target for vuilding svn and cvs completions
darcs-hash:20070127020406-ac50b-a5dee791cf05cf76dd23395deee5e2d9f347c71b.gz
2007-01-27 12:04:06 +10:00
axel
5e6d1efb56 Fix a few more trailing N_ calls
darcs-hash:20070127020240-ac50b-6081d8cc0bc5d648b53b3ddfe878ec0f65412b6e.gz
2007-01-27 12:02:40 +10:00
axel
bc1f9b6f1c Another batch of fixes for the VCS completions
darcs-hash:20070127020141-ac50b-e617fbabb234af668fa7ded7f838d66477605c8d.gz
2007-01-27 12:01:41 +10:00
axel
85d069c106 Fix crash in tab completion code when completing an imcomplete backsalsh escape
darcs-hash:20070126171413-ac50b-a9338dc73863381f2b22e09fb8b5e711f64b8f29.gz
2007-01-27 03:14:13 +10:00
axel
cfecb58bb6 Fix various completions that didno't drop the N_ no-op
darcs-hash:20070126012631-ac50b-4e13c06ddbf73f05a0a26824c71dbb96aa7ce0b9.gz
2007-01-26 11:26:31 +10:00
axel
11c2ec91d4 Update make_mercurial_completions.fish to also handle cvs. Correct bug causing issues in darcs completions.
darcs-hash:20070126012321-ac50b-caa9749f5e844ce5d06d84f2c38e282049369ed1.gz
2007-01-26 11:23:21 +10:00
axel
cc6f133368 make the make_mercurial_completions.fish script able to handle svn as well. Update svn completions.
darcs-hash:20070125153452-ac50b-60dce711d8614f99ba24ab9b24acfbd879d58bfa.gz
2007-01-26 01:34:52 +10:00
axel
350b637a1a Generalize make_mercurial_completions.fish a bit so it can be used with darcs as well. Add make targets for creating darcs/hg completions.
darcs-hash:20070125132836-ac50b-0e7a728e4be2386d696094a414a1c8bcaee771fc.gz
2007-01-25 23:28:36 +10:00
axel
f917dccf6f Use make_completions.py to make new completions for gcc
darcs-hash:20070125012757-ac50b-21408f89b71abb894850ddff452c83d130ed0401.gz
2007-01-25 11:27:57 +10:00
axel
62d380a1ee Make first stab at a manual page parser. It takes the name of a command as input and outputs completions for it.
darcs-hash:20070125012728-ac50b-442dec7a0252f7cf817f442623161e33ce50c355.gz
2007-01-25 11:27:28 +10:00
axel
65ef6cf217 Add completions for hg (Mercurial). These completions are autogenerated from the help commands for mercurial through the make_mercurial_completions.fish script
darcs-hash:20070124225136-ac50b-1636989747df4e2510905e3286dbf1871522f653.gz
2007-01-25 08:51:36 +10:00
axel
2bba0f7b8f Use MB_LEN_MAX instead of MB_CUR_MAX as the length of an array, since the latter does not need to be a constant value, meaning it is illegal as an array size
darcs-hash:20070122165125-ac50b-884456df993125e0dc16cd8dfed1e63d350d05dd.gz
2007-01-23 02:51:25 +10:00
axel
565970b8ca Fix uninitialized varialble in env.c
darcs-hash:20070122012815-ac50b-a04cfc343ce75afd4feff8e25c580f9e54d5c5ef.gz
2007-01-22 11:28:15 +10:00
axel
6ea3dd7dfe Minor edit to init scripts to reduce number of non-builtins called on init
darcs-hash:20070121155057-ac50b-1fae99ef89abc7bc08dc31eb671bfc556e34202d.gz
2007-01-22 01:50:57 +10:00
axel
8176a1253b Do not use stdout to report errors when stderr is dead - take the hint instead...
darcs-hash:20070121152242-ac50b-3e192328959cf65f03756b3bfbb794fb43dccead.gz
2007-01-22 01:22:42 +10:00
axel
4f67c38777 Use constant instead of hardcoded value for sleeptime on failed fork call
darcs-hash:20070121152026-ac50b-1daaac921f31dd10b2646d51b65af5260890d291.gz
2007-01-22 01:20:26 +10:00
axel
86beb7b109 Minor code simplification in exec.c
darcs-hash:20070121151943-ac50b-d913d1b205443cdf40a83a1d001e4d7a114c6e0c.gz
2007-01-22 01:19:43 +10:00
axel
98a6c491b1 Print stack trace when execting due to fatal problem or bug
darcs-hash:20070121150341-ac50b-66b86014963568bf402a76d5beb7c1d4e188c5f7.gz
2007-01-22 01:03:41 +10:00
axel
66c045c439 Minor code edits. Add curly brackets in various places, add or rewrite various comments, fix indentation, etc.
darcs-hash:20070121150114-ac50b-4fd6965cb2c557178923f8afa944835166e08423.gz
2007-01-22 01:01:14 +10:00
axel
a1ec38f53b Check error code when writing output from builtins - try to report errors
darcs-hash:20070121145810-ac50b-46ecb601ce9f0d862f00e4a97f25b6034e52f4cc.gz
2007-01-22 00:58:10 +10:00
axel
64f1024eb5 Make all error messages from options parsin in builtins redirectable
darcs-hash:20070121145527-ac50b-1375af219a5eba6167e99d3fe24b26dba60eba2a.gz
2007-01-22 00:55:27 +10:00
axel
b3500bfbdc Fix bug in rsync completions
darcs-hash:20070121024539-ac50b-6bef9090303c56d117633077554bb43c40f64024.gz
2007-01-21 12:45:39 +10:00
axel
f8c45324b6 Add switch completions for the rsync command
darcs-hash:20070121023815-ac50b-178776e2fe6c3d510f4f1342269c132797a7793a.gz
2007-01-21 12:38:15 +10:00
axel
bf5d4f6b07 Simplify completions for a few commands (svn, cvs, darcs, yum)
darcs-hash:20070120170940-ac50b-24c0e5b05ca03a590b90e795bbd62b15583e2bd1.gz
2007-01-21 03:09:40 +10:00
axel
1300e68fa5 Add support for backtraces - if the compiler and libc version supports it (probably only glibc/gcc) then a stack trace is printed on serious bugs
darcs-hash:20070120023649-ac50b-5efa310bea0deddfa1d8dfca1000163eee89c7cb.gz
2007-01-20 12:36:49 +10:00
axel
1a76f2ecb9 Do not purge internal history if saving history to file fails
darcs-hash:20070120023347-ac50b-8e61c5f65cfca3ffdb6dd740fc32b91a975fdb87.gz
2007-01-20 12:33:47 +10:00
axel
9c5fb0392d Make save_function print the help text when given no argumetns. Thanks to Alexander Kellett for the suggestion.
darcs-hash:20070119131538-ac50b-a77f60f557677543f38c73ffc21a209432b8b26a.gz
2007-01-19 23:15:38 +10:00
axel
f4c5eaf05b Spelling fixes in documentation
darcs-hash:20070118173337-ac50b-4bfe34ea056f6fbc007df4c0b97cde695c822923.gz
2007-01-19 03:33:37 +10:00
axel
dd90b4ece4 Fix incorrect use of the term 'alias' where 'function' was meant in documentation
darcs-hash:20070118170034-ac50b-f10d79a1aed0e91d350db13187965bf2f5c45b7e.gz
2007-01-19 03:00:34 +10:00
axel
4930db35e2 Correctly unescape tokens when performing switch completion
darcs-hash:20070118164528-ac50b-fcaa59d247c4c6b430ab47b293d5eb173a97e9fc.gz
2007-01-19 02:45:28 +10:00
axel
e6409a88d5 Add missing completion for the commandline builtin
darcs-hash:20070118163104-ac50b-e33d3888efa42218881291ce1d2636ca14f10805.gz
2007-01-19 02:31:04 +10:00
axel
77a48dc252 Minor performance improvement in the variable assignment code
darcs-hash:20070118162922-ac50b-0f4bfd125e20673fdcb928e2a7aac6af50a1dec7.gz
2007-01-19 02:29:22 +10:00
axel
029be823e2 Remove the final non-builtin call from __fish_gnu_complete, to make it even faster
darcs-hash:20070118162853-ac50b-a31f51d53ba3121eaf6dfb4006dde00491fd53c2.gz
2007-01-19 02:28:53 +10:00
axel
421aff7d67 Make command specific completions handle quoted and otherwise escaped tokens better by making sure that the output from the commandline builtin is properly unescaped
darcs-hash:20070118162700-ac50b-cd93d9a6aff5bb7629a790d60b241000eb1d0ac0.gz
2007-01-19 02:27:00 +10:00
axel
9e7094adfc Fix bug in code for unescapiong strings - when not in unescape_special mode, quotes would not get properly removed. This patch also adds the ability to check that quotes match up when unescaping. This functionality is on by default and can be disabled using a special flag.
darcs-hash:20070118160246-ac50b-b230c3fcd8440025b5243d76de2a9fd400f7ea32.gz
2007-01-19 02:02:46 +10:00
axel
19e8d60179 Make 'fish --help' display a help message, not start the help browser
darcs-hash:20070117131246-ac50b-328c735ba09b8488cf6ee5b95d73290681ce5f06.gz
2007-01-17 23:12:46 +10:00
axel
9d9869e515 Documentation touchup. Give a few examples in the section about escapeing characters
darcs-hash:20070116164834-ac50b-dd4c23ae1b8e35bbb2d3e186c2a819d8f2647ec2.gz
2007-01-17 02:48:34 +10:00
axel
54e19b1efb Add a one-item cache into the hash table. This reduces the number of hash computations by roughly 20%
darcs-hash:20070116163707-ac50b-214a16d4210d32fb50693e71a14b6b8f3fededfe.gz
2007-01-17 02:37:07 +10:00
axel
f603b6ef68 Fix potential use of ininitialized variable. Could cause fish to save the history even when unneeded.
darcs-hash:20070116151130-ac50b-6186e6da834bae3ea07f3f25a105592f5115e0f3.gz
2007-01-17 01:11:30 +10:00
axel
81e0fcbc13 Additional performance tweak for __fish_gnu_complete
darcs-hash:20070116125116-ac50b-0a702bc02f9a126b36505864dcc597661a7ca2b0.gz
2007-01-16 22:51:16 +10:00
axel
b999bd9c8c Bugfix in __fish_gnu_complete - switches could be ignored
darcs-hash:20070116112226-ac50b-6d6ce88d87f74a3779e4c6de6c62068c49354966.gz
2007-01-16 21:22:26 +10:00
axel
9c9a8f9d0f Improve speed of __fish_gnu_complete on systems with no native seq implementation by avoiding using seq at all
darcs-hash:20070116102651-ac50b-ad7e0acd325f88d1676e4c533bc863caedf91748.gz
2007-01-16 20:26:51 +10:00
axel
461ef2a508 Fix completion bug where fish would refuse to provide completion strings for '--'
darcs-hash:20070116015938-ac50b-353566d9fd8984cabd56127a9088d57695e2b7ba.gz
2007-01-16 11:59:38 +10:00
axel
7492b6cdb3 Make all descriptions for function calls use the implicit translation from the previous patch instead of explicitly using N_
darcs-hash:20070116012918-ac50b-c1c0df64333ad910ca81dbc86ad193ece6680722.gz
2007-01-16 11:29:18 +10:00
axel
34e27ff4c2 Drop use of the N_ no-op for translation descriptions. Instead, tell xgettext that any token following '--description' should be translated. This should greatly speed up completion loading on platforms where fork() is slow. (Hi, OS X)
darcs-hash:20070116011828-ac50b-fb923dc877869ded4d506bbe0bc5364eea44092f.gz
2007-01-16 11:18:28 +10:00
axel
47588c8e75 Darcs completions: Check for file existance before trying to complete using the repos file. Thanks to Alexander Kellett for the bug report.
darcs-hash:20070115205209-ac50b-60c03383f55bb2dc1d0f5317d907f71c63b2bb7b.gz
2007-01-16 06:52:09 +10:00
axel
00c6fcfe98 Document -f option for psub, add tab completions
darcs-hash:20070115181924-ac50b-6ac48aec8937e9dd172858dfa7eaaac1aca14775.gz
2007-01-16 04:19:24 +10:00
axel
c90f7c3203 Update todo list
darcs-hash:20070115175516-ac50b-8e5e316633ff0951b9165067b9b0e777753f5365.gz
2007-01-16 03:55:16 +10:00
axel
6467ead9ad Make sure read returns with a non-zero status if no string was actually given
darcs-hash:20070115175346-ac50b-9bbcfd114344f030c46456d2d603ce323406bfea.gz
2007-01-16 03:53:46 +10:00
axel
cb7caf2afc Minor edits - add a few input checks, remove a few commented pieces of debug code, add a few brackets, etc.
darcs-hash:20070115175144-ac50b-2045f2132156645222e6dde57487aa299a5316e2.gz
2007-01-16 03:51:44 +10:00
axel
c6ebb23f38 Add a -f switch to psub to use regular files instead of fifos. This makes psub work with programs that need to seek. This change was suggested by Alexander Kellet.
darcs-hash:20070115174330-ac50b-2349cef2d1a26a9e7c9356691bc74991135c1d2c.gz
2007-01-16 03:43:30 +10:00
axel
5753d63958 Check all file writes for errors when saving history file
darcs-hash:20070112161724-ac50b-21721102c5844ba871668093cb7428dc793d2ba6.gz
2007-01-13 02:17:24 +10:00
axel
e56d9765d7 Add missing completions to ulimit
darcs-hash:20070112152048-ac50b-b402f5e5fb9bfa0720b7b89de465d06bf66a1ac3.gz
2007-01-13 01:20:48 +10:00
axel
a5b7ec2624 Clarify documentation for the ulimit builtin
darcs-hash:20070112151540-ac50b-70ce1dbbad6b4e559723e1c5f8cf6fc3e271cf77.gz
2007-01-13 01:15:40 +10:00
axel
b2fa41307c Clean up the 'ulimit' builtin. There was a bug making it impossible to set the stack size, the switch '-p' was erroneously accepted, and the multiplier was not always correctly used, e.g. when reporting limits.
darcs-hash:20070112150017-ac50b-aff8db509f1bc8bb9803aa66bfad70ebc85d27b2.gz
2007-01-13 01:00:17 +10:00
axel
fce74c73c7 Minor code edits - show user name when completing home directories and minor code simplifications
darcs-hash:20070110173445-ac50b-40fd22ba766239dcfe6797155a852591b76f9253.gz
2007-01-11 03:34:45 +10:00
axel
e110b29c2f Do not complete using switches after a '--' has been encountered
darcs-hash:20070110124528-ac50b-111f01af0701f2fcc2bd22a7666b74497835356a.gz
2007-01-10 22:45:28 +10:00
axel
a3aba0269d Make it possible to cancel a long-winded wildcard match by pressing ^C
darcs-hash:20070109164705-ac50b-d8bf2c22e9ecb6bccec6892da266016dcae79a4c.gz
2007-01-10 02:47:05 +10:00
axel
e1f4aa5fcd Updates to the swedish translation
darcs-hash:20070109141310-ac50b-0fd8faccb396f0576917be3e4096701a2cdc3ca7.gz
2007-01-10 00:13:10 +10:00
axel
e19ee86b0d Update dependencies for making .po files in Makefile
darcs-hash:20070109134457-ac50b-31e9a1225e7deb5c097fb05c103bc5dc5bb58eea.gz
2007-01-09 23:44:57 +10:00
axel
6e71b5a59c A few more error checks during string to integer conversion in various places
darcs-hash:20070109134117-ac50b-8816e238b0b6aa3fe83c0a4695d719a60b0d17d4.gz
2007-01-09 23:41:17 +10:00
axel
b70092e281 Check for errors during string to integer conversion in various places
darcs-hash:20070109032005-ac50b-29514c9c8c19c70b7cfe7670a5c74899f316931f.gz
2007-01-09 13:20:05 +10:00
axel
602eac89c4 Fix typo in user message, remove a few warnings, minor indentation edits
darcs-hash:20070109025356-ac50b-328e42b8898bbc9b40b4841a032ae7871dba9e13.gz
2007-01-09 12:53:56 +10:00
axel
d8b5cc6717 Handle out of memory condition in various parts of fish by shutting down instead of crashing
darcs-hash:20070109025102-ac50b-ee7951028e626628257852fd9b5de97572609cea.gz
2007-01-09 12:51:02 +10:00
axel
76fedccf13 Make it possible to specify an error handler function for out of memory in any of the collection functions. Make the default oom handler print the line where things failed and exit.
darcs-hash:20070109013521-ac50b-dc7304cfb548cf1efc100124125eed032e392169.gz
2007-01-09 11:35:21 +10:00
axel
41206e70b4 Make the bg builtin check that all specified jobs exist before sending any of them to background. Also make sure that the string to pid conversion didn't throw errors.
darcs-hash:20070109002144-ac50b-c3954d98bab5cd95699966b2d1f2480797a9094d.gz
2007-01-09 10:21:44 +10:00
axel
bc2c37c739 Fix accidentally triggering of error condition when nothing bad happened in fish pager init code
darcs-hash:20070108230338-ac50b-c4d0a44ee06660acf107388f1c889296a535494b.gz
2007-01-09 09:03:38 +10:00
axel
4a2a47666f Fix indentation and add a few comments to fish_pager
darcs-hash:20070107164336-ac50b-d3cfa100a499d3f0996aac16288c4c892a65c1fe.gz
2007-01-08 02:43:36 +10:00
axel
94fbbb7669 Update todo list
darcs-hash:20070107142445-ac50b-391ff0eac6a84ae3dd5345d338682d243d40fb0a.gz
2007-01-08 00:24:45 +10:00
axel
63010c26ad Two very minor code touch ups
darcs-hash:20070107142430-ac50b-20cd4fe96c03c052bb6fb5c07ce207a534e86498.gz
2007-01-08 00:24:30 +10:00
axel
f398b2eafa Remove comments from apropos matching in function for getting description for command from whatis database
darcs-hash:20070107142000-ac50b-0221d36e24d3d68f0a25535e7a7b303e4fb84abe.gz
2007-01-08 00:20:00 +10:00
axel
1214067d03 Redo the interface between fish and the completion pager. The old interface has issues if the current user does not own the tty, as happens when using 'su'. It also had issues when stderr was redirected. The new interface should be more extensible as well.
darcs-hash:20070107141336-ac50b-30bdfb198674b93a67d323c0a65b8e08b43c0525.gz
2007-01-08 00:13:36 +10:00
axel
0469d05447 Make it possible to buffer input to other file descriptors than stdin. It is still only possible to buffer input on a single descriptor to any given job.
darcs-hash:20070107141052-ac50b-561265cd5acde7d882e4506870f13d61d34b3734.gz
2007-01-08 00:10:52 +10:00
axel
2fcec27e23 Make sure errno is not changed when error reporting after a failed call to execve
darcs-hash:20070107140918-ac50b-35186f2300d6ec03dbeac2cb5d5ffcee3feffc4e.gz
2007-01-08 00:09:18 +10:00
axel
42d0283489 Fix bug in IO redirection making is possible for the IO redirections to fail in cases where there are multiple pipes and buffers using file descriptors above 2.
darcs-hash:20070107140646-ac50b-dee4f380320ef2743635e77401a789c28d45f805.gz
2007-01-08 00:06:46 +10:00
axel
3fbd8036f4 Fix potential crash bug when pasting large amounts of text into the shell
darcs-hash:20070107140410-ac50b-c7b680b05f3aaf7f10e6e06a0fdc232d30c3e1b1.gz
2007-01-08 00:04:10 +10:00
axel
3b4bacb5ba Allow the user to specify name of history file to use with the read builtin
darcs-hash:20070106142430-ac50b-32ad52077e11438799b17911dc83e57f89e02f2b.gz
2007-01-07 00:24:30 +10:00
axel
7e350dab66 Update the dcop completions. This update was written by David Bitseff.
darcs-hash:20070106130722-ac50b-a73277cfccbf456595f0fb7ceeb18d23b2f744ab.gz
2007-01-06 23:07:22 +10:00
axel
9c23d50e92 Fix bug in completion pager where non-ascii characters where escaped because the locale was set after the completion strings where read in. Thanks to mikeX for the report.
darcs-hash:20070103125702-ac50b-752f6e1182dba4356e068191b52fdb05d3cb5649.gz
2007-01-03 22:57:02 +10:00
axel
2ec7428e32 Add iconv completions
darcs-hash:20061226142933-ac50b-dd385732a0337f215855db4c517dc1bab52b2aca.gz
2006-12-27 00:29:33 +10:00
Tassilo Horn
594f81ec8c svn-delete-completion.dpatch
darcs-hash:20061221212334-c06f4-2db8d07267b142165302d63fd94fdc0eb9f6f791.gz
2006-12-22 07:23:34 +10:00
axel
9767b76881 Fix minor type in 'find' completions
darcs-hash:20061219152443-ac50b-989d374683f181a5fc41d162f2a0793ca31227ac.gz
2006-12-20 01:24:43 +10:00
axel
0ace93c2a4 Fix yet another place where the 'builtin' builtin was used in stead of 'command'
darcs-hash:20061214182409-ac50b-60af38f1b1edcafcf1c0aff9c64094b92a84e5fc.gz
2006-12-15 04:24:09 +10:00
axel
c73d165165 Make the directory history keyboard shortcuts repaint the screen. Otherwise, the prompt won't reflect the new CWD. This is needed because of the reduced amounts of repainting done since 1.22.2
darcs-hash:20061214182313-ac50b-a912bcc0fac6e1d78f116e19f31f1c50ffc409cb.gz
2006-12-15 04:23:13 +10:00
axel
c1945f8275 Minor highlighting tweaks to make highlighter handle switches to 'command' and 'builtin' builtins more correctly
darcs-hash:20061214134025-ac50b-e17f79d1d4d7594ab20a358296f84dbb6356f42b.gz
2006-12-14 23:40:25 +10:00
axel
4d368dc06c Do not add --help completions for builtins at init time. These completions are already present in the commmand specific completions
darcs-hash:20061214131239-ac50b-3626c53c9c985bc3b786d5d6baff5e162a5e4951.gz
2006-12-14 23:12:39 +10:00
axel
9ff0e9cf72 Fix incorrect use of the 'builtin' builtin when the 'command' builtin was intended
darcs-hash:20061214120630-ac50b-5cee4b32042bb23c1a4b01e2a400a4af13c64c9c.gz
2006-12-14 22:06:30 +10:00
axel
a971d91a70 Make tab completion of process expansion consider other processes than those owned by the shell. Also makes tab completion of process expansion properly handle paths in command names
darcs-hash:20061214115811-ac50b-8569bcd30f97fe505dc1e7f2596d2fbd23f31525.gz
2006-12-14 21:58:11 +10:00
axel
52b74f9f34 Make sure debug() never alters errno, so that it can safely be called between an error and calling wperror()
darcs-hash:20061214100131-ac50b-b1c2e4819567fc35858233c265a26b934620fc6d.gz
2006-12-14 20:01:31 +10:00
axel
b932a9a084 Minor correction to script for extracting translation strings
darcs-hash:20061214014117-ac50b-fe792403646e1859116973494f2278c88f76072b.gz
2006-12-14 11:41:17 +10:00
axel
997f2dffbf Make syntax highlighter flag invalid command types as subcommands for 'command' or 'builtin' builtins. Also make sure that the '--' switch is understood by the highlighter
darcs-hash:20061214013537-ac50b-9d84fe371eed10ce48ade5ebe88b00442658d67a.gz
2006-12-14 11:35:37 +10:00
axel
1289e03134 Only complelete valid command types as subcommands for 'command' or 'builtin' builtins. Also make sure that the '--' switch is understood by the completions
darcs-hash:20061214000326-ac50b-3ee9130ebb3fcc9b2723686945cfca055c4f44a4.gz
2006-12-14 10:03:26 +10:00
axel
9a8e5e64ed Make sure that a command is never executed as the subcommand of the 'builtin' builtin
darcs-hash:20061214000152-ac50b-f1593dfeb4cecdbe48599ffe8d76a956989c7d24.gz
2006-12-14 10:01:52 +10:00
axel
774c050f92 Minor code tweaks. Move a few deeple nested pieces of code to their own functions. There are lots of other places where this should be done as well.
darcs-hash:20061213235838-ac50b-c3bedea3017910cc4f0d257ad6ee1da6b76efd12.gz
2006-12-14 09:58:38 +10:00
axel
478a319442 Make the builtins 'and', 'or', 'not', 'exec', 'command' and 'builtin' respect the '--' argument
darcs-hash:20061213154449-ac50b-d2ae8ff5a1cab8e753ddb97545071cc985051411.gz
2006-12-14 01:44:49 +10:00
axel
24fea5dd7b Code cleanup: Use a macro constant instead fo a literal for builtin exit codes
darcs-hash:20061213143431-ac50b-5c5cec623ecca9f52c7d44cfcb26f07fe2fcda39.gz
2006-12-14 00:34:31 +10:00
axel
2b05bdfa94 Update functions builtin so that default behaviour when not given any arguments is to print only names of all existing functions, not their definitions. Use 'functions (functions)' to get the latter.
darcs-hash:20061213142107-ac50b-16d0a9097ede4b0cd49847618d65fcbfee699393.gz
2006-12-14 00:21:07 +10:00
axel
6c8a559023 Drop unneeded '--' when using set builtin in various places
darcs-hash:20061212203727-ac50b-23fbb54bba0c5773e8a3dd2e5737ea8a670c801d.gz
2006-12-13 06:37:27 +10:00
axel
ca8c337c94 Drop unneeded '--' when using set builtin in the trap function
darcs-hash:20061212181841-ac50b-dd1fd50b80c6d3c759c123832bc6334613529ee6.gz
2006-12-13 04:18:41 +10:00
axel
8ccad65504 Minor fix to help generation to avoid creating a stray doxygen file in share/man
darcs-hash:20061212172518-ac50b-fec0999bd0b19259eaeee76c78c04b052392a6bb.gz
2006-12-13 03:25:18 +10:00
axel
fd11f294bc Use the math function instead of calling bc directly in various places
darcs-hash:20061212171118-ac50b-a40709edf008f3d725e3755d5282ae5a84818c88.gz
2006-12-13 03:11:18 +10:00
axel
b3fa76c1be Extend documentation for the math function
darcs-hash:20061212171037-ac50b-1b9d0f51b284925fe0fc3020774ec32bb1414ce7.gz
2006-12-13 03:10:37 +10:00
axel
d3dd9400e3 Make sure the rm command and not a wrapper function that could change its behaviour is used. This patch was written by David Bitseff.
darcs-hash:20061212122853-ac50b-4f3c9962bc6daed95c8f53a19af05bc3d924eac7.gz
2006-12-12 22:28:53 +10:00
axel
234034d302 Make sure cwd colors update when the variable changes. This is a common regression, it seems. This time it was caused by the repaint reductions added in 1.22.2.
darcs-hash:20061212101348-ac50b-970686fcd3317f19c6131cdc46885a841c68a6d6.gz
2006-12-12 20:13:48 +10:00
axel
edc20a7505 Update to the ':' patch by Nicholas Burlett. This patch makes sure that ':' style executing of a command is only performed if a regular call to execve fails. This should improve performance a mall bit in the common case.
darcs-hash:20061211190308-ac50b-d284fa30c8c633816898141b644bd3039f80cc62.gz
2006-12-12 05:03:08 +10:00
axel
3a29028f60 Fix broken example in the documentation for the begin builtin
darcs-hash:20061211134723-ac50b-6ea37b6dca30a85d00651129a762d8a9d95d40a2.gz
2006-12-11 23:47:23 +10:00
axel
f4af7603da Add completions for flac, written by David Bitseff
darcs-hash:20061210092326-ac50b-4de3e3473cdc73ef05052d4053f56dd790cc1403.gz
2006-12-10 19:23:26 +10:00
axel
63a28eb46f Add completions for oggenc, written by David Bitseff
darcs-hash:20061209085946-ac50b-747b61e4a0d717b5b9a5b7dcc3bdad8e33e79e18.gz
2006-12-09 18:59:46 +10:00
axel
b85d9ee737 Minor documentation update
darcs-hash:20061209011911-ac50b-2295056319c5b7a95e77df897f0310cd52c6580a.gz
2006-12-09 11:19:11 +10:00
Tassilo Horn
58042b0e9f ruby-gems-completion.dpatch
darcs-hash:20061208232818-c06f4-510633a992d3557967709713ab8ed8df94a36c05.gz
2006-12-09 09:28:18 +10:00
nickburlett
23759e6eca colon-command support
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
2006-12-09 08:04:28 +10:00
axel
1d3465698f Add dcop completions, written by David Bitseff
darcs-hash:20061208215855-ac50b-aa2ee1fc551ce7bca50d5979800e6674015a3737.gz
2006-12-09 07:58:55 +10:00
axel
b156f083be Fix off-by-one error making it impossible to edit the first element of an array using array slicing. Thanks to useer for reporting this bug.
darcs-hash:20061208133136-ac50b-3c8085ec61fcc3987356ee412133dba6c7f32d1f.gz
2006-12-08 23:31:36 +10:00
axel
f83b754cd4 Bump version number
darcs-hash:20061207224603-ac50b-a8f5ce18d44626814a15fc2c0b0fe0d51dae0567.gz
2006-12-08 08:46:03 +10:00
axel
df4a0d65bd Update comlpetions for the help function
darcs-hash:20061206131020-ac50b-f7f1a3c5aa85d90a6538583681167abca7f50e63.gz
2006-12-06 23:10:20 +10:00
axel
77b5532ce9 Make delete-or-exit work with multiline commands
darcs-hash:20061206122537-ac50b-80e3b3d6dff886eba162fbb8db5a82ff0f7a107f.gz
2006-12-06 22:25:37 +10:00
axel
d9ec65da4d Update user documentation - add section on internal completion functions, update todo list, minor documentation tweaks
darcs-hash:20061206000810-ac50b-08f12efdb74224abe46301d3722cd8180d8ba37d.gz
2006-12-06 10:08:10 +10:00
axel
4b9dcf1cf2 Add ant target completions, written by Nate Drake
darcs-hash:20061205235252-ac50b-112c0ff335e456ed0b419c6c5c7a889c517baed1.gz
2006-12-06 09:52:52 +10:00
axel
1fbac89a38 Do not highlight parameters beginning with a '-' as switches if the '--' parameter has been given
darcs-hash:20061204120707-ac50b-3c2099fd75ac615dfcdc0b0954713728142cd505.gz
2006-12-04 22:07:07 +10:00
axel
ceacfb83a8 Add completions for the env command
darcs-hash:20061204115838-ac50b-f75e067b50ee2cbc8f735110c34892613c53c4d9.gz
2006-12-04 21:58:38 +10:00
axel
d736c8cca6 Add completions for the locate command
darcs-hash:20061204114205-ac50b-1231627ff987bbb3dc4c7af1436cfdf17bd3a5c1.gz
2006-12-04 21:42:05 +10:00
axel
60769903a5 Add subcommand completion support to nice completions
darcs-hash:20061204111346-ac50b-913f68c7fcbf71117ac6d662423d64d05d38c6e5.gz
2006-12-04 21:13:46 +10:00
axel
8b73bac580 Rename __fish_complete_directory to increase consistency
darcs-hash:20061202233433-ac50b-48368a338773ad47807b0032389fd305d86b3275.gz
2006-12-03 09:34:33 +10:00
axel
c8162c2900 Flash commandline each time completion fails, not just the first one
darcs-hash:20061130235852-ac50b-de6e94a878e7a6de6ec9f34289437aec87d95b07.gz
2006-12-01 09:58:52 +10:00
axel
de181c91d5 Only flash commandline, not entire screen, when completion fails
darcs-hash:20061130235749-ac50b-436e5619f7818db7660269545de19e21c6a7e1b8.gz
2006-12-01 09:57:49 +10:00
axel
687ba1c9ef Add completions for the find command
darcs-hash:20061130231414-ac50b-4636dbd460ad23479c5740b22dcba011c2e140a3.gz
2006-12-01 09:14:14 +10:00
axel
02802b509d Make keyboard shortcuts that execute a shellscript function (^D, for example) a lot quicker. This is done by not changing the titlebar message or reexecuting the prompt. A full repaint is still performed though. This patch also changes the behaviour of the 'null' virtual keypress - it no longer reexecutes the prompt, it only causes a repaint.
darcs-hash:20061201163009-ac50b-65508b8e5aa3b2c73695feb0a47a718419868f8e.gz
2006-12-02 02:30:09 +10:00
axel
7f18dd6a4a Improve kill completions on non-Debian systems (They where fine before on Debian systems)
darcs-hash:20061130163230-ac50b-0f72c7a609b1218e30ec193362df13c76f4cb35b.gz
2006-12-01 02:32:30 +10:00
axel
2f7a472230 Remove fallback of using globals when universal variables are broken in config file- fish does the equivalen internally now
darcs-hash:20061130154838-ac50b-04861991dfc12fc4a7d1bb675dbffe4b78df920e.gz
2006-12-01 01:48:38 +10:00
axel
b8f2f46945 Use dircolors to set default colors for ls
darcs-hash:20061130154026-ac50b-d6d5e182a71516aa56ab16851e47510f2561b585.gz
2006-12-01 01:40:26 +10:00
axel
2570eb1ab8 Fix bug in save_function script
darcs-hash:20061130154006-ac50b-cb9ae4c46d3eced0fa432c47de996016519d29cd.gz
2006-12-01 01:40:06 +10:00
axel
d3062f9a97 Fix bed indentation in a few places
darcs-hash:20061130132431-ac50b-e17b1a55733c4f42264e88cb259a78b4a5cfc4e0.gz
2006-11-30 23:24:31 +10:00
axel
8619d17f43 Minor documentation, indentation tweaks
darcs-hash:20061129142102-ac50b-0ae69ec0878a54092f16261b314b34ef4eeeb5ba.gz
2006-11-30 00:21:02 +10:00
axel
8062eb3511 Makefile tweakage - make sure build messages suggest using correct make version
darcs-hash:20061129142004-ac50b-2776b3e6db870f6e04836a7d6e464e09d20f6274.gz
2006-11-30 00:20:04 +10:00
axel
e0322bf0e0 Add --without-gettext switch to optionally disable gettext support
darcs-hash:20061129141822-ac50b-64a78e7a3594827abe5024fdbf7d4c79ac21162c.gz
2006-11-30 00:18:22 +10:00
axel
ddc617f80a Fix bug in save_function that causes it to not create missing directory entries before saving function
darcs-hash:20061129140229-ac50b-525f2cff869a066d5c3624880125e37862a9fd3b.gz
2006-11-30 00:02:29 +10:00
axel
f64364cced Replace all internal uses of grep with sgrep, which is a wrapper around grep that strips away any GREP_OPTIONS. This is needed to avoid users who have added arbitrary switches to GREP_OPTIONS, thus changing its behaviour.
darcs-hash:20061129140004-ac50b-485ff6bfd71e9459ba62461f6e093ca5c9ddd664.gz
2006-11-30 00:00:04 +10:00
axel
32502bfac8 Don't use GREP_OPTIONS in 'contains' function - this is a modified version of a patch by David Bitseff
darcs-hash:20061126131150-ac50b-640bfaf2c3a4111809d9091631b79e35005e68b5.gz
2006-11-26 23:11:50 +10:00
axel
1f6a98ecb8 Make sure that non-exporeted variables can shadow exported ones. This problem was reported by David Bitseff.
darcs-hash:20061126130943-ac50b-b99cddc9a042545d5555b281d7e0aa8f667131d6.gz
2006-11-26 23:09:43 +10:00
axel
6ad0f141be Add missing rulers in faq
darcs-hash:20061124170631-ac50b-ee9823eb30fb84be07a512f7ad6dd46cbc2d0b44.gz
2006-11-25 03:06:31 +10:00
axel
0b6366aacb Fix missing code snippet in faq. Thank you to Binny V A for reporting this bug.
darcs-hash:20061124164641-ac50b-5c6594b320269aa5941b84d1d99eac70b636b332.gz
2006-11-25 02:46:41 +10:00
axel
deed3a63a3 Make completion descriptions on symlinks to directories have their own description
darcs-hash:20061123104145-ac50b-6b48de9c46593312d9c65368d17a45999d197e4a.gz
2006-11-23 20:41:45 +10:00
axel
cab80b452b Fix bug where tab completions for implicit 'cd' would ignore symbolic links to directories
darcs-hash:20061123104023-ac50b-7245f70e0f6fbbc97358e32c6dc7ca5258f24a53.gz
2006-11-23 20:40:23 +10:00
axel
338d32a7c6 Drop the old, unused fish manual page
darcs-hash:20061122185443-ac50b-aa46cf36aa38990ba49b4e08f7ce7a5c68abfdf3.gz
2006-11-23 04:54:43 +10:00
axel
88f15a6804 Simplify documentation building - again.
darcs-hash:20061122185333-ac50b-078910540c33e18265c7d5804d1f14f241ad597f.gz
2006-11-23 04:53:33 +10:00
axel
20b3f3b9a1 Add completions for the wajig command. These where generated by the create_wajig_completions.py script, written by Reuben Thomas.
darcs-hash:20061120152707-ac50b-fe478814bcc5edec9dc9d49d0da665b21ba8956c.gz
2006-11-21 01:27:07 +10:00
axel
1145a5d483 Touch up completions for builtin commands
darcs-hash:20061120152518-ac50b-cbd3d14af4fd2d67304278d442443decbac1ef7c.gz
2006-11-21 01:25:18 +10:00
axel
125ca9ff73 Minor edits, whitespace fixes, etc.
darcs-hash:20061120131412-ac50b-0d9bc9d3fb35b4c9831bdf3a606e9aa8df844478.gz
2006-11-20 23:14:12 +10:00
axel
bc1efb1556 Minor code edit - move a bit of code into its own function
darcs-hash:20061120131224-ac50b-974496cc800377e4e06475491f89998b9640fbba.gz
2006-11-20 23:12:24 +10:00
axel
7b5649097f Correctly handle multiple backslashes at end of line w.r.t. multiline handling
darcs-hash:20061120021934-ac50b-20d953c16711a4959cac9d435217309fc78aab98.gz
2006-11-20 12:19:34 +10:00
axel
c2e1d76400 Fix missing man-page generation when building from darcs tree. Also simplifys doc generation a small bit.
darcs-hash:20061120135336-ac50b-d3b7a4ce2ac6bcc307c57cfcd23db86a8ac411a8.gz
2006-11-20 23:53:36 +10:00
axel
f7435559a7 Simplify Makefile by using a wildcard to specify help files
darcs-hash:20061120010620-ac50b-1a838bdd75607a503bc8335bb39abd2aa11ac7e8.gz
2006-11-20 11:06:20 +10:00
axel
47afca1fdb Add missing help text for the save_function function
darcs-hash:20061119233640-ac50b-5fb02f7ce3ec3317aa57be2d936cc430b27276b4.gz
2006-11-20 09:36:40 +10:00
axel
372c811763 Support bold and underlined characters in help output
darcs-hash:20061119232734-ac50b-d426980ee143b44065a3ea2afc7d3808174acd5f.gz
2006-11-20 09:27:34 +10:00
axel
dd061b1dda Minor comment edits and removal of a warning
darcs-hash:20061118212459-ac50b-d6f4dddb560b4815ca850f9e9c3e8d7a5cf5ea70.gz
2006-11-19 07:24:59 +10:00
axel
eb3c99c54e Move the event handler for fish_color_cwd to init file, so it is not autounloaded. Also cache output of call to set_color command to improve performance a bit.
darcs-hash:20061118212147-ac50b-b0f44cca2acf7465dd9ff071aa35a3ac81f0615f.gz
2006-11-19 07:21:47 +10:00
axel
5d864e3f69 After processing a signal/event while waiting for commandline input, check the lookahead buffer for inserted characters
darcs-hash:20061118211531-ac50b-355fd5556f65e9cec3af5ed9e19a44af9bfe3b7b.gz
2006-11-19 07:15:31 +10:00
axel
1b71f91a01 Update documentation display code to run roff on the client system instead of pregenerating documentation and compiling it into program binaries
darcs-hash:20061117162438-ac50b-5c4c7f0bd8bf53a16e16ecfead9569e642b7160f.gz
2006-11-18 02:24:38 +10:00
axel
b30886228c Speed up history token search
darcs-hash:20061117233726-ac50b-eb7ef60b837a4dd5fee61c7a692d8210fdcc4719.gz
2006-11-18 09:37:26 +10:00
axel
f91de04269 Update todo list
darcs-hash:20061117150013-ac50b-ded7a41336a64df095ede01657a9af341f571d52.gz
2006-11-18 01:00:13 +10:00
axel
a3531db645 Add missing include in screen.c
darcs-hash:20061117145925-ac50b-267cb0b81f78672f3522cb320a0e951f84f70de2.gz
2006-11-18 00:59:25 +10:00
axel
1e8fe508f0 Tweak error messages in tokenizer a bit
darcs-hash:20061117145905-ac50b-ee735bf04d2dcbabc272c4f12cb64a8af51b83bf.gz
2006-11-18 00:59:05 +10:00
axel
54244fd33d Add a bugreport function for writing out a message about how to file bug reports
darcs-hash:20061117145825-ac50b-0480300cce24657aae9572b79f145d956db93593.gz
2006-11-18 00:58:25 +10:00
axel
4c1d1bb218 Complete using known repos in darcs
darcs-hash:20061116132251-ac50b-d62d1a1b08d21b57fa6f7e7ae105d9b77026fd39.gz
2006-11-16 23:22:51 +10:00
axel
903326ddf5 Make hitory token search interruptible. This code was written by Netocrat.
darcs-hash:20061117130612-ac50b-0f1f4e58c9794e705117bde0716f07b39e0176af.gz
2006-11-17 23:06:12 +10:00
axel
0105ec284d Don't intern as much completion data - this helps reduce memory usage when autounloading
darcs-hash:20061116130833-ac50b-b19887dc36b16476bb3b2a1593b23dd3325187ee.gz
2006-11-16 23:08:33 +10:00
axel
55b253152c Only do command description lookup if we have non-directory commands
darcs-hash:20061116130400-ac50b-47b7159276d607aab8c4a8d52a9c8a60a3f77819.gz
2006-11-16 23:04:00 +10:00
axel
6573d2b451 Use halloc to simplyfy allocations in function.c
darcs-hash:20061115141649-ac50b-aff0e3369bb19d6d88130781b13e598c9445b138.gz
2006-11-16 00:16:49 +10:00
axel
cfa9ecbfd2 Drop search highlighting when exiting search mode. Thanks to Philip Ganchev and Martin Bähr for the bug reports.
darcs-hash:20061116125803-ac50b-6eb95d76c3679a32db940a698466381ef7822b9e.gz
2006-11-16 22:58:03 +10:00
axel
b139201a33 A few additional input checks, minor code simplifications, and some indentation/documentation fixes
darcs-hash:20061115133046-ac50b-a6145bd9a63b6667357cc3ec603e185696bf1951.gz
2006-11-15 23:30:46 +10:00
axel
946b5d1528 Remove getpgid prototype from exec.c - this prototype seems to be no longer missing
darcs-hash:20061115132959-ac50b-d163141db6ad824ea0f6788338ebcec5001cbf5b.gz
2006-11-15 23:29:59 +10:00
axel
3b2670532a Make fish store universal variables locally if fishd can't be started - local changes are lost of the fishd connection is restored
darcs-hash:20061115123447-ac50b-bf17c55079e1196205cc3a4fd0ca22d9f539836c.gz
2006-11-15 22:34:47 +10:00
axel
d00bc973fe Use fcntl to automatically close fishd socken on exec instead of handling it manually
darcs-hash:20061115111857-ac50b-3e04a0bc16c8442bef02cf4a50777d4556b8eaa6.gz
2006-11-15 21:18:57 +10:00
axel
4768b37531 Add support for detecting and handling the screen-specific \ek\e\ escape sequence for setting the titlebar message in the prompt calculating code.
darcs-hash:20061114162125-ac50b-debe872f5916328f74a4560d0833b33f9eb89a40.gz
2006-11-15 02:21:25 +10:00
axel
ab162c6c25 Bump version number
darcs-hash:20061112210938-ac50b-af5fc653b1ec0da6832338aec2d56c98fba69897.gz
2006-11-13 07:09:38 +10:00
axel
5ed912bebc The incorrect pointer is used for the autounload callback, causing possible crashes
darcs-hash:20061112121725-ac50b-1f49f3f37c20d3fe2d4a12617e9dda139d2ad5ec.gz
2006-11-12 22:17:25 +10:00
axel
ec43090c16 Fix file descriptor leakage from completion pager
darcs-hash:20061112121613-ac50b-209d42c06401faf675ff123236823dcaa651d6f7.gz
2006-11-12 22:16:13 +10:00
axel
80759ee03f Fix exit status of delete-or-exit function
darcs-hash:20061112114544-ac50b-d5fd61b3819715057caba2dd8b48119df080edd1.gz
2006-11-12 21:45:44 +10:00
axel
816f473ac9 Add a few missing completions for the ls command
darcs-hash:20061111113315-ac50b-2a77e93a78571e1e83801128c1793c52bb03e13f.gz
2006-11-11 21:33:15 +10:00
axel
d59d3b4463 Minor code simplification in main.c
darcs-hash:20061111110650-ac50b-0d50d10087ea863ff0c79d05c614fdb06fa3b9bd.gz
2006-11-11 21:06:50 +10:00
axel
8784b78d84 Add a few more darcs completions. These are still unfinished, though.
darcs-hash:20061111105547-ac50b-0791e833664ff67d8ced1176577d8266fe4a3782.gz
2006-11-11 20:55:47 +10:00
axel
5005c67d76 Minor cleanups, mostly of code comments
darcs-hash:20061111105452-ac50b-24ab7965f6208ecdfced738e08cdb4cb4a565458.gz
2006-11-11 20:54:52 +10:00
axel
63732a99e9 Tweak Makefile, including fixing slight dependency problem
darcs-hash:20061111105314-ac50b-69703cc2575856a321515aa0554e97d1895a4606.gz
2006-11-11 20:53:14 +10:00
axel
04b7da336d Documentation updates
darcs-hash:20061111105208-ac50b-27e335ba701b021d3119206e91d68c8504d45c2b.gz
2006-11-11 20:52:08 +10:00
axel
5f69f2bb0c Make fish send a HUP signal to jobs when the terminal tells it to exit.
darcs-hash:20061111104840-ac50b-ae989e26bdb6c769ed93dcf11b742887c97858aa.gz
2006-11-11 20:48:40 +10:00
tassilo
fb62a35921 complete-eik-and-friends.dpatch
Completions for all tools which come with eix.
(http://dev.croup.de/proj/eix)

darcs-hash:20061110155925-a923b-fd06120f7ea5f65cb752fe437bfccb6f16c87b45.gz
2006-11-11 01:59:25 +10:00
axel
08787c7674 fix bug where off_t was assumed to be long long, causing display errors on systems with no large file support
darcs-hash:20061109175804-ac50b-b05ec0aa9ae6f7dd23b7432c321eff44b446397d.gz
2006-11-10 03:58:04 +10:00
tassilo
79de45eed5 better-emerge-completion.dpatch
- You don't need to supply the package right after -C or -u etc.
- Better descriptions

darcs-hash:20061109145341-a923b-a1a54d3a5a040396ccba350c125f3b1ba645c601.gz
2006-11-10 00:53:41 +10:00
axel
9bc9e1c08d Add completions for equery, written by Tassilo Horn.
darcs-hash:20061107211708-ac50b-6199e58e84bc8ee8729be5f2a5ff2f3518888bfc.gz
2006-11-08 07:17:08 +10:00
axel
3acdeb87a4 Update the emerge completions. They are now complete, ignore switch ordering, handle packages in different catagories with the same name. This update was made by Tassilo Horn.
darcs-hash:20061107211617-ac50b-fcd3108209671283b2d5553d3adf5a81a46869f9.gz
2006-11-08 07:16:17 +10:00
axel
9959e53985 Add alias function. Thanks to Tassilo Horn for pointing out that it was missing.
darcs-hash:20061107205539-ac50b-0053f828d40be5bcb088cdb8d669c239c201b433.gz
2006-11-08 06:55:39 +10:00
axel
4edb71325f Do not escape the ':' character. Thanks to Tassilo Horn for pointing this out.
darcs-hash:20061107205437-ac50b-51632ce51915d4ca8680ab4c4522bcd002a794b6.gz
2006-11-08 06:54:37 +10:00
axel
310768e8d2 Try to avoid the '
darcs-hash:20061107181911-ac50b-fda6044a81b3a09707f17d4017c2c3dacf4e1801.gz
2006-11-08 04:19:11 +10:00
axel
dc90e460fe Fix a bug in the help function causing help to fail when trying to open help for a builtin command. Thanks to Reuben Thomas for the report.
darcs-hash:20061107131211-ac50b-9727a813d940b34923b23b073c80a7b42c023486.gz
2006-11-07 23:12:11 +10:00
axel
d20c14b4bb Do not print a newline on empty greeting message. Thanks to Reuben Thomas for pointing this out.
darcs-hash:20061107130629-ac50b-553bc13390c0f040f4cecf2780e34da674e065fa.gz
2006-11-07 23:06:29 +10:00
axel
981f5782d8 Fix code for locating inputrc-file in users fish configuration directory. Thanks to Reuben Thomas for reporting this.
darcs-hash:20061103155335-ac50b-23ddaec5d0ca591b00e8a59ccc39e63ed8b9ff25.gz
2006-11-04 01:53:35 +10:00
axel
c2021b6225 Fix typo in documentation for the commandline builtin. Thanks to Reuben Thomas for reporting this.
darcs-hash:20061103143140-ac50b-b37fbfe68321f904936c002010045e467bc3a778.gz
2006-11-04 00:31:40 +10:00
axel
9de4dbdd03 Add the file that generated the wajig completions to the tree. This should not be installed but it should be included with the tarball. The file was written by Reuben Thomas.
darcs-hash:20061103142645-ac50b-0e13e41941b5dc990c60d775cdd8503ed8e54529.gz
2006-11-04 00:26:45 +10:00
axel
1a84a44cc2 Add completions for ps2pdf, dvipdf and dvipdfm commands, written by Reuben Thomas.
darcs-hash:20061103141945-ac50b-7592bb5784a55272747bbb0322281b9090e5fd65.gz
2006-11-04 00:19:45 +10:00
axel
80a9fc2fce Add mention of uninstalling old fish versions to the INSTALL file. Thanks to Jason Grossman for the suggestion
darcs-hash:20061103141254-ac50b-27f1f4741379bff54298b6c18d289947f66f91cf.gz
2006-11-04 00:12:54 +10:00
axel
8aac7e82c0 Try to detect seq versions installed by earlier fish versions and replace them
darcs-hash:20061103131621-ac50b-2748c958f8614f39fbaa7a45261877a912de539e.gz
2006-11-03 23:16:21 +10:00
axel
49e300d0ca Check if any libraries need to be linked in order to use iconv. This is needed on OS X. Thanks to Jason Grossman for the report
darcs-hash:20061103100004-ac50b-861ca2bc42414c475b1ab24399c8d240cf1e4651.gz
2006-11-03 20:00:04 +10:00
axel
136e99de62 Fix bugs causing all unmapped inputs below 31 to be interpreted as newlines. Thanks to Reuben Thomas for the report.
darcs-hash:20061103003457-ac50b-5f3fee63e211b12014e40dc3d8d8c94eaa22f24d.gz
2006-11-03 10:34:57 +10:00
axel
c41986a63f Add command specific completions for unrar command (No switches yet, only commands and files in archive)
darcs-hash:20061102235727-ac50b-7b7638289be4de52b4e3e3d109ad3167b7285023.gz
2006-11-03 09:57:27 +10:00
axel
bedf8ea55e Add support for completing using contents of tar archives
darcs-hash:20061102235548-ac50b-ec4a3b206c73f8fc44cc715b2a95fe6fef2d53c0.gz
2006-11-03 09:55:48 +10:00
axel
d8f1c0abcd Minor tweaks in the reader. Vastly simplyfu the insert_char function, and add a few code commants.
darcs-hash:20061102135019-ac50b-c5d4f7f307deb93b71e797bbb8a1d420a5790dc3.gz
2006-11-02 23:50:19 +10:00
axel
13a85ee3f1 Make sure fish has the currect exit status
darcs-hash:20061102134859-ac50b-692f9e9aff838ea375e5cf29eeae1e29b1b75338.gz
2006-11-02 23:48:59 +10:00
axel
fab18bae80 Updates to the documentation - add a few crossreferences, remove redundant listing of builtins and update the todo list
darcs-hash:20061102134725-ac50b-802d5cf8754ff94c4cc9533b2ff16a759e9aa2c9.gz
2006-11-02 23:47:25 +10:00
axel
6e24b26e2c Fix the code for ignoring infinite recursion
darcs-hash:20061102134537-ac50b-2dddd06dd77c362caf44c9160acc29b76278b230.gz
2006-11-02 23:45:37 +10:00
axel
7fb44d4d5f Spelling fix. Thanks to Reuben Thomas
darcs-hash:20061101231404-ac50b-8f5b08242aed565baf37035805d7b3614fe8022b.gz
2006-11-02 09:14:04 +10:00
axel
44f85d04f9 Fix formating issue for the documentation for the prevd function
darcs-hash:20061101221835-ac50b-03a9b5abc7e4a25cc75effecc734c20eb8fee342.gz
2006-11-02 08:18:35 +10:00
axel
bd71f0a096 Fix build error
darcs-hash:20061101181221-ac50b-227b2d2f6f5122c9f25c471872376884bdace13c.gz
2006-11-02 04:12:21 +10:00
506 changed files with 44271 additions and 29831 deletions

33
.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
*.o
*~
Doxyfile.help
Makefile
autom4te.cache/
command_list.txt
config.h
config.h.in
config.log
config.status
configure
doc.h
doc_src/commands.hdr
doc_src/index.hdr
etc/config.fish
po/*.gmo
fish
fish.spec
fish_indent
fish_pager
fish_tests
fishd
mimedb
seq
set_color
share/config.fish
share/man/
toc.txt
user_doc/
xsel-1.2.0/
tests/*tmp.*
tests/foo.txt

3
CHANGELOG Normal file
View 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

939
Doxyfile

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -10,8 +10,8 @@ ABBREVIATE_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
@@ -19,7 +19,7 @@ DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
ALIASES =
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
SUBGROUPING = YES
@@ -44,7 +44,7 @@ GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
@@ -53,19 +53,19 @@ WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
INPUT =
WARN_LOGFILE =
INPUT =
FILE_PATTERNS = doc.h
RECURSIVE = NO
EXCLUDE =
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
@@ -75,17 +75,17 @@ REFERENCES_RELATION = YES
VERBATIM_HEADERS = YES
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
IGNORE_PREFIX =
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER = user_doc.head.html
HTML_FOOTER =
HTML_STYLESHEET =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
@@ -99,8 +99,8 @@ LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
@@ -109,33 +109,33 @@ GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
GENERATE_AUTOGEN_DEF = NO
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
PERLMOD_MAKEVAR_PREFIX =
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
TAGFILES =
GENERATE_TAGFILE =
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
@@ -151,8 +151,8 @@ INCLUDED_BY_GRAPH = YES
CALL_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 750
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 0

25
INSTALL
View File

@@ -32,19 +32,24 @@ separate build directories or any other fancy configure options.
Simple install procedure
========================
If you have downloaded the darcs repository of fish, you need to run
the autoconf command first. Then use the following commands to compile
fish:
Always begin by uninstalling any previous fish versions. This is done
by running the command 'make uninstall' in the source directory of
your previous fish installation.
% ./configure
% make # Compile fish
% make install # Install fish
% echo /usr/local/bin/fish >>/etc/shells # Add fish to list of shells
Next, if you have downloaded a fresh copy of the darcs repository of
fish, you need to run the 'autoconf' command.
If you wish to use fish as your default shell, use the following
command:
Then, use following commands to compile fish:
% chsh -s /usr/local/bin/fish
./configure
make # Compile fish
make install # Install fish
echo /usr/local/bin/fish >>/etc/shells # Add fish to list of shells
Finally, if you wish to use fish as your default shell, use the
following command:
% chsh -s /usr/local/bin/fish
chsh will prompt you for your password, and change your default shell.

View File

@@ -1,4 +1,4 @@
#
# Copyright (C) 2005-2006 Axel Liljencrantz
#
# This program is free software; you can redistribute it and/or modify
@@ -31,6 +31,8 @@
# hallucinations.
#
# Used by docdir
PACKAGE_TARNAME = @PACKAGE_TARNAME@
#
# Programs
@@ -46,6 +48,7 @@ INSTALL:=@INSTALL@
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
bindir = @bindir@
mandir = @mandir@
@@ -55,16 +58,20 @@ localedir = @localedir@
prefix = @prefix@
optbindirs = @optbindirs@
#
# Various flags
#
MACROS=-DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\"
CFLAGS=@CFLAGS@ $(MACROS)
CPPFLAGS=@CPPFLAGS@
LDFLAGS= @LIBS@ @LDFLAGS@
MACROS = -DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\"
CFLAGS = @CFLAGS@ $(MACROS) $(EXTRA_CFLAGS)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LIBS@ @LDFLAGS@
LDFLAGS_FISH = ${LDFLAGS} @LIBS_FISH@ @LDFLAGS_FISH@
LDFLAGS_FISH_INDENT = ${LDFLAGS} @LIBS_FISH_INDENT@
LDFLAGS_FISH_PAGER = ${LDFLAGS} @LIBS_FISH_PAGER@
LDFLAGS_FISHD = ${LDFLAGS} @LIBS_FISHD@
LDFLAGS_MIMEDB = ${LDFLAGS} @LIBS_MIMEDB@
LDFLAGS_SET_COLOR = ${LDFLAGS} @LIBS_SET_COLOR@
#
# Set to 1 if we have gettext
@@ -82,21 +89,24 @@ COMMON_FILES := util.c halloc.c halloc_util.c fallback.c
#
# All objects that the system needs to build fish, except main.o
# All objects that the system needs to build fish, except fish.o
#
FISH_OBJS := function.o builtin.o complete.o env.o exec.o expand.o \
highlight.o history.o kill.o parser.o proc.o reader.o sanity.o \
tokenizer.o wildcard.o wgetopt.o wutil.o input.o output.o intern.o \
env_universal.o env_universal_common.o input_common.o event.o \
signal.o io.o parse_util.o common.o screen.o path.o
signal.o io.o parse_util.o common.o screen.o path.o \
parser_keywords.o
FISH_INDENT_OBJS := fish_indent.o print_help.o common.o \
parser_keywords.o wutil.o tokenizer.o
#
# Additional files used by builtin.o
#
BUILTIN_FILES := builtin_help.c builtin_set.c builtin_commandline.c \
BUILTIN_FILES := builtin_set.c builtin_commandline.c \
builtin_ulimit.c builtin_complete.c builtin_jobs.c
@@ -104,8 +114,9 @@ BUILTIN_FILES := builtin_help.c builtin_set.c builtin_commandline.c \
# All objects that the system needs to build fish_pager
#
FISH_PAGER_OBJS := fish_pager.o output.o wutil.o tokenizer.o \
input_common.o env_universal.o env_universal_common.o common.o
FISH_PAGER_OBJS := fish_pager.o output.o wutil.o \
input_common.o env_universal.o env_universal_common.o common.o \
print_help.o
#
@@ -119,62 +130,41 @@ FISH_TESTS_OBJS := $(FISH_OBJS) fish_tests.o
# All objects that the system needs to build fishd
#
FISHD_OBJS := fishd.o env_universal_common.o wutil.o \
doc_src/fishd.o common.o
FISHD_OBJS := fishd.o env_universal_common.o wutil.o print_help.o \
common.o
#
# All objects needed to build mimedb
#
MIME_OBJS := mimedb.o xdgmimealias.o xdgmime.o xdgmimeglob.o \
xdgmimeint.o xdgmimemagic.o xdgmimeparent.o wutil.o common.o
MIME_OBJS := mimedb.o print_help.o xdgmimealias.o xdgmime.o \
xdgmimeglob.o xdgmimeint.o xdgmimemagic.o xdgmimeparent.o wutil.o \
common.o
#
# Files containing documentation for builtins.
# Files containing user documentation
#
BUILTIN_DOC_SRC := doc_src/source.txt doc_src/and.txt \
doc_src/begin.txt doc_src/bg.txt doc_src/bind.txt \
doc_src/block.txt doc_src/break.txt doc_src/builtin.txt \
doc_src/case.txt doc_src/cd.txt doc_src/command.txt \
doc_src/commandline.txt doc_src/complete.txt doc_src/continue.txt \
doc_src/else.txt doc_src/end.txt doc_src/eval.txt doc_src/exec.txt \
doc_src/exit.txt doc_src/fg.txt doc_src/for.txt \
doc_src/function.txt doc_src/functions.txt doc_src/if.txt \
doc_src/jobs.txt doc_src/not.txt doc_src/or.txt doc_src/random.txt \
doc_src/return.txt doc_src/read.txt doc_src/set.txt \
doc_src/status.txt doc_src/switch.txt doc_src/ulimit.txt \
doc_src/while.txt
#
# These files are the source files, they contain a few @FOO@-style substitutions
#
HDR_FILES_SRC := doc_src/index.hdr.in doc_src/commands.hdr.in doc_src/design.hdr doc_src/license.hdr doc_src/faq.hdr
#
# Files generated by running doxygen on the files in $(BUILTIN_DOC_SRC)
# These are the generated result files
#
BUILTIN_DOC_HDR := $(BUILTIN_DOC_SRC:.txt=.doxygen)
HDR_FILES := doc_src/index.hdr doc_src/commands.hdr doc_src/design.hdr doc_src/license.hdr doc_src/faq.hdr
HDR_FILES := $(subst .hdr.in,.hdr,$(HDR_FILES_SRC))
#
# Files containing documentation for external commands.
# Files containing documentation for external commands.
#
CMD_DOC_SRC := doc_src/contains.txt doc_src/count.txt doc_src/dirh.txt \
doc_src/dirs.txt doc_src/fish.txt doc_src/fish_pager.txt \
doc_src/fishd.txt doc_src/help.txt doc_src/isatty.txt \
doc_src/mimedb.txt doc_src/nextd.txt doc_src/open.txt \
doc_src/popd.txt doc_src/prevd.txt doc_src/psub.txt \
doc_src/pushd.txt doc_src/set_color.txt doc_src/trap.txt \
doc_src/type.txt doc_src/umask.txt doc_src/vared.txt
#
# Files generated by running doxygen on the files in $(CMD_DOC_SRC)
#
CMD_DOC_HDR := $(CMD_DOC_SRC:.txt=.doxygen)
HELP_SRC := $(wildcard doc_src/*.txt)
#
@@ -192,39 +182,43 @@ TEST_IN := $(wildcard tests/test*.in)
# Files in ./doc_src/
#
DOC_SRC_DIR_FILES := doc_src/Doxyfile.in doc_src/index.hdr \
doc_src/license.hdr doc_src/faq.hdr doc_src/design.hdr \
$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC)
DOC_SRC_DIR_FILES := $(HDR_FILES_SRC) $(HELP_SRC)
#
# Files in ./. There is some overlap between the variables in the
# list, so when copying these files, cp will complain that some files
# are specified more than once.
# Files in ./
#
MAIN_DIR_FILES := Doxyfile Doxyfile.user Makefile.in configure \
configure.ac config.h.in install-sh set_color.c count.c \
key_reader.c gen_hdr.sh gen_hdr2.c $(MIME_OBJS:.o=.h) \
$(MIME_OBJS:.o=.c) $(FISH_OBJS:.o=.h) $(BUILTIN_FILES) \
$(COMMON_FILES) $(COMMON_FILES:.c=.h) $(FISH_OBJS:.o=.c) \
builtin_help.hdr fish.spec.in INSTALL README user_doc.head.html \
xsel-0.9.6.tar ChangeLog config.sub config.guess fish_tests.c \
main.c fish_pager.c fishd.c seq.in
MAIN_DIR_FILES_UNSORTED := Doxyfile Doxyfile.user Doxyfile.help.in \
Makefile.in configure configure.ac config.h.in install-sh \
set_color.c key_reader.c $(MIME_OBJS:.o=.h) \
$(MIME_OBJS:.o=.c) $(FISH_OBJS:.o=.h) $(BUILTIN_FILES) \
$(COMMON_FILES) $(COMMON_FILES:.c=.h) $(FISH_OBJS:.o=.c) \
fish.spec.in INSTALL README user_doc.head.html xsel-0.9.6.tar \
ChangeLog config.sub config.guess fish_tests.c fish.c fish_pager.c \
fishd.c seq.in make_vcs_completions.fish $(FISH_INDENT_OBJS:.o=.c)
#
# The sorting is not meaningful in itself, but it has the side effect
# of removing duplicates, which means there will be fewer warnings
# during building.
#
MAIN_DIR_FILES := $(sort $(MAIN_DIR_FILES_UNSORTED))
#
# Files in ./etc/
#
ETC_DIR_FILES :=etc/config.fish.in etc/fish_inputrc
ETC_DIR_FILES :=etc/config.fish.in
#
# Files in ./share/
#
SHARE_DIR_FILES :=share/config.fish.in share/config_interactive.fish.in
SHARE_DIR_FILES :=share/config.fish.in
#
@@ -253,19 +247,16 @@ FUNCTIONS_DIR_FILES := $(wildcard share/functions/*.fish)
# Programs to install
#
PROGRAMS:=fish set_color @XSEL@ @SEQ_FALLBACK@ mimedb count fish_pager fishd
SIMPLE_PROGRAMS := fish set_color mimedb fish_pager fishd fish_indent
PROGRAMS := $(SIMPLE_PROGRAMS) @XSEL_BIN@ @SEQ_FALLBACK@
#
# Manual pagess to install
# Manual pages to install
#
MANUALS:=doc_src/builtin_doc/man/man1/fish.1 @XSEL_MAN_PATH@ \
doc_src/builtin_doc/man/man1/mimedb.1 \
doc_src/builtin_doc/man/man1/set_color.1 \
doc_src/builtin_doc/man/man1/count.1 \
doc_src/builtin_doc/man/man1/fishd.1 \
doc_src/builtin_doc/man/man1/fish_pager.1
MANUALS := $(addsuffix .1, $(addprefix share/man/, \
$(SIMPLE_PROGRAMS))) @XSEL_MAN_PATH@
#
@@ -276,13 +267,20 @@ TRANSLATIONS_SRC := $(wildcard po/*.po)
TRANSLATIONS := $(TRANSLATIONS_SRC:.po=.gmo)
#
# Extra util
#
XSEL := @XSEL@
XSEL_BIN := @XSEL_BIN@
#
# Make everything needed for installing fish
#
all: $(PROGRAMS) user_doc etc/config.fish share/config.fish share/config_interactive.fish $(TRANSLATIONS)
@echo fish has now been built.
@echo Use \'make install\' to install fish.
all: $(PROGRAMS) user_doc share/man etc/config.fish share/config.fish $(TRANSLATIONS)
@echo fish has now been built.
@echo Use \'$(MAKE) install\' to install fish.
.PHONY: all
@@ -304,16 +302,22 @@ Makefile: Makefile.in configure
#
debug:
make fish CFLAGS="@CFLAGS@ $(MACROS) -O0 -Wno-unused -Werror -g"
$(MAKE) all EXTRA_CFLAGS="-O0 -Wno-unused -Werror -g"
.PHONY: debug
prof:
$(MAKE) all EXTRA_CFLAGS="-pg" LDFLAGS="-pg"
.PHONY: prof
#
# User documentation, describing the features of the fish shell.
#
user_doc: $(HDR_FILES) Doxyfile.user user_doc.head.html $(CMD_DOC_SRC) $(BUILTIN_DOC_SRC)
$(MAKE) doc.h # Depend on the sources (*.hdr) and manually make the intermediate as needed
# Depend on the sources (*.hdr.in) and manually make the
# intermediate *.hdr and doc.h files if needed
user_doc: $(HDR_FILES_SRC) Doxyfile.user user_doc.head.html $(HELP_SRC)
$(MAKE) doc.h $(HDR_FILES)
doxygen Doxyfile.user
touch user_doc
@@ -322,19 +326,19 @@ user_doc: $(HDR_FILES) Doxyfile.user user_doc.head.html $(CMD_DOC_SRC) $(BUILTIN
# Source code documentation. Also includes user documentation.
#
doc: *.h *.c doc.h Doxyfile builtin_help.c
doxygen;
doc: *.h *.c doc.h Doxyfile
doxygen;
#
# PDF version of the source code documentation.
#
doc/refman.pdf: doc
cd doc/latex;
make;
mv refman.pdf ..;
cd ../..;
doc/refman.pdf: doc
cd doc/latex;
make;
mv refman.pdf ..;
cd ../..;
rm -r doc/latex;
@@ -351,11 +355,8 @@ test: $(PROGRAMS) fish_tests
# Build the xsel program, which is maintained in its own tarball
#
xsel-0.9.6:
tar -xf xsel-0.9.6.tar
xsel-0.9.6/xsel: xsel-0.9.6
cd xsel-0.9.6; ./configure; make
$(XSEL_BIN):
$(MAKE) -C $(XSEL) || echo "Failed to build xsel - either add the required dependencies or use './configure --without-xsel' to disable it."
#
@@ -363,19 +364,32 @@ xsel-0.9.6/xsel: xsel-0.9.6
# builtins
#
doc_src/commands.hdr:$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC)
rm -f commands.tmp;
echo "/** \page commands Commands" >>commands.tmp;
echo "Fish ships with a large number of builtin commands, shellscript functions and external commandss. These are all described below. " >>commands.tmp;
for i in `printf "%s\n" $(BUILTIN_DOC_SRC) $(CMD_DOC_SRC)|sort`; do \
echo "<hr>" >>commands.tmp; \
cat $$i >>commands.tmp; \
echo >>commands.tmp; \
echo >>commands.tmp; \
echo "Back to <a href='index.html#toc-commands'>index</a>". >>commands.tmp; \
done
echo "*/" >>commands.tmp
mv commands.tmp doc_src/commands.hdr
doc_src/commands.hdr:$(HELP_SRC) doc_src/commands.hdr.in
-rm command_list.tmp $@
for i in `printf "%s\n" $(HELP_SRC)|sort`; do \
echo "<hr>" >>command_list.tmp; \
cat $$i >>command_list.tmp; \
echo >>command_list.tmp; \
echo >>command_list.tmp; \
echo "Back to <a href='index.html#toc-commands'>index</a>". >>command_list.tmp; \
done
mv command_list.tmp command_list.txt
cat $@.in | awk '{if ($$0 ~ /@command_list@/){ system("cat command_list.txt");} else{ print $$0;}}' >$@
toc.txt: $(subst index.hdr,index.hdr.in,$(HDR_FILES))
-rm toc.tmp $@
for i in $(subst index.hdr,index.hdr.in,$(HDR_FILES)); do\
NAME=`basename $$i .hdr`; \
NAME=`basename $$NAME .hdr.in`; \
sed <$$i >>toc.tmp -n \
-e 's,.*\\page *\([^ ]*\) *\(.*\)$$,- <a href="'$$NAME'.html" name="toc-'$$NAME'">\2</a>,p' \
-e 's,.*\\section *\([^ ]*\) *\(.*\)$$, - <a href="'$$NAME'.html#\1" name="toc-'$$NAME'">\2</a>,p'; \
done
mv toc.tmp $@
doc_src/index.hdr: toc.txt doc_src/index.hdr.in
cat $@.in | awk '{if ($$0 ~ /@toc@/){ system("cat toc.txt");} else{ print $$0;}}' >$@
#
@@ -385,20 +399,8 @@ doc_src/commands.hdr:$(BUILTIN_DOC_SRC) $(CMD_DOC_SRC)
# documentation.
#
doc.h:$(HDR_FILES)
rm -f doc.h
echo "/** \mainpage Fish user documentation" >doc.tmp
echo "\section toc Table of contents" >>doc.tmp
echo '- <a href="index.html" name="toc-index">Fish user documentation</a>' >>doc.tmp
for i in $(HDR_FILES); do\
sed <$$i >>doc.tmp -n \
-e 's,.*\\page *\([^ ]*\) *\(.*\)$$,- <a href="'`basename $$i .hdr`'.html" name="toc-'`basename $$i .hdr`'">\2</a>,p' \
-e 's,.*\\section *\([^ ]*\) *\(.*\)$$, - <a href="'`basename $$i .hdr`'.html#\1" name="toc-'`basename $$i .hdr`'">\2</a>,p' \
# -e 's,.*\\subsection *\([^ ]*\) *\(.*\)$$, - <a href="'`basename $$i .hdr`'.html#\1" name="toc-'`basename $$i .hdr`'">\2</a>,p'; \
done
cat $(HDR_FILES) >>doc.tmp;
mv doc.tmp doc.h
doc.h: $(HDR_FILES)
cat $(HDR_FILES) >$@
#
# This rule creates complete doxygen headers from each of the various
@@ -408,13 +410,19 @@ doc.h:$(HDR_FILES)
#
%.doxygen:%.txt
echo "/** \page " `basename $*` >$@;
cat $*.txt >>$@;
echo "/** \page " `basename $*` >$@;
cat $*.txt >>$@;
echo "*/" >>$@
%: %.in Makefile
sed <$@.in >$@ -e "s,@sysconfdir\@,$(sysconfdir),g" -e "s,@datadir\@,$(datadir),g" -e "s,@docdir\@,$(docdir),g" -e "s|@configure_input\@|$@, generated from $@.in by the Makefile. DO NOT MANUALLY EDIT THIS FILE!|g" -e "s,@prefix\@,$(prefix),g" -e "s,@optbindirs\@,$(optbindirs),g"
#-e "s,@\@,$(),"
%: %.in
sed <$@.in >$@ \
-e "s,@sysconfdir\@,$(sysconfdir),g" \
-e "s,@datadir\@,$(datadir),g" \
-e "s,@docdir\@,$(docdir),g" \
-e "s|@configure_input\@|$@, generated from $@.in by the Makefile. DO NOT MANUALLY EDIT THIS FILE!|g" \
-e "s,@prefix\@,$(prefix),g" \
-e "s,@optbindirs\@,$(optbindirs),g"
#-e "s,@\@,$(),"
#
@@ -422,7 +430,7 @@ doc.h:$(HDR_FILES)
#
%.gmo:
if test $(HAVE_GETTEXT) = 1; then \
if test "$(HAVE_GETTEXT)" = 1; then \
msgfmt -o $*.gmo $*.po; \
fi
@@ -445,10 +453,10 @@ doc.h:$(HDR_FILES)
# Create a template translation object
#
messages.pot: *.c *.h etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq
messages.pot: *.c *.h etc/*.in share/*.in share/completions/*.fish share/functions/*.fish seq
if test $(HAVE_GETTEXT) = 1;then \
xgettext -k_ -kN_ *.c *.h -o messages.pot; \
if xgettext -j -k_ -kN_ -LShell etc/*.in share/fish share/completions/*.fish share/functions/*.fish seq -o messages.pot; then true; else \
if xgettext -j -k_ -kN_ -k--description -LShell etc/*.in share/*.in share/completions/*.fish share/functions/*.fish seq -o messages.pot; then true; else \
echo "Your xgettext version is too old to build the messages.pot file"\
rm messages.pot\
false;\
@@ -462,8 +470,7 @@ common.o: $(COMMON_FILES)
#
# Generate the internal help functions by making doxygen create
# man-pages which are then converted into C code. The convertion path
# looks like this:
# man-pages. The convertion path looks like this:
#
# .txt file
# ||
@@ -475,70 +482,37 @@ common.o: $(COMMON_FILES)
# (doxygen)
# ||
# \/
# man file
# roff file
# ||
# (man)
# (__fish_print_help)
# ||
# \/
# formated text
# with escape
# formated text
# with escape
# sequences
# ||
# \/
# (gen_hdr2)
# ||
# \/
# .c file
#
# Which is an awful, clunky and ugly way of producing
# documentation. There ought to be something simpler.
#
# There ought to be something simpler.
#
doc_src/builtin_doc: $(BUILTIN_DOC_SRC) doc_src/count.txt builtin_help.hdr $(CMD_DOC_SRC)
for i in $(BUILTIN_DOC_SRC) $(CMD_DOC_SRC); do \
share/man: $(HELP_SRC)
-rm doc_src/*.doxygen # Remove temp files from previous run
-rm -r help_doc
-mkdir share/man
touch share/man
for i in $(HELP_SRC); do \
FILE=doc_src/`basename $$i .txt`.doxygen; \
echo "/** \page" `basename $$i .txt` >$$FILE; \
cat $$i >>$$FILE; \
echo "*/" >>$$FILE; \
done
cd doc_src; doxygen; cd ..;
for i in doc_src/builtin_doc/man/man1/*.1; do \
CMD_NAME=`basename $$i .1`; \
sed -e "s/\(.\)\\.SH/\1/" -e "s/$$CMD_NAME *\\\\- *\"\(.*\)\"/\1/" <$$i >$$i.tmp; \
mv $$i.tmp $$i; \
done
touch doc_src/builtin_doc
builtin_help.c: doc_src/builtin_doc gen_hdr.sh
$(MAKE) gen_hdr2 # Don't depend on gen_hdr2, because then we would need to rebuild the docs whenever we use a fresh tarball
cp builtin_help.hdr builtin_help.c;
if test -x gen_hdr.sh; then true; else chmod 755 gen_hdr.sh; fi
for i in $(BUILTIN_DOC_HDR) doc_src/count.doxygen ; do \
echo ' hash_put( &tbl, L"'`basename $$i .doxygen`'",' >>$@; \
./gen_hdr.sh $$i >>$@; \
printf " );\n\n" >>$@; \
done;
echo "}" >>builtin_help.c
#
# Generate help texts for external fish commands, like set_color and
# mimedb.
#
%.c : %.doxygen
$(MAKE) gen_hdr2 builtin_help.c # These should really be filed as dependencis for %.c above instead, but that seems to confuse make
echo "// This file was automatically generated, do not edit" >$@
echo "#include <stdlib.h>" >>$@
echo "#include <stdio.h>" >>$@
echo >>$@
echo "void print_help()" >>$@
echo "{" >>$@
echo ' printf( "%s",' >>$@
chmod 755 gen_hdr.sh
./gen_hdr.sh $*.doxygen >>$@
echo ");" >>$@
echo "}" >>$@
doxygen Doxyfile.help
for i in $(HELP_SRC); do \
CMD_NAME=`basename $$i .txt`; \
sed -e "s/\(.\)\\.SH/\1/" -e "s/$$CMD_NAME *\\\\- *\"\(.*\)\"/\1/" <help_doc/man/man1/$$CMD_NAME.1 >share/man/$$CMD_NAME.1; \
done
rm doc_src/*.doxygen # Clean up intermediate files in doc_src/
rm -r help_doc # Clean up intermediate help_doc tree
#
# The build rules for installing/uninstalling fish
@@ -556,8 +530,8 @@ check-uninstall:
echo;\
echo An older fish installation using an incompatible filesystem hierarchy was detected;\
echo You must uninstall this fish version before proceeding;\
echo type \'make uninstall-legacy\' to uninstall these files,;\
echo or type \'make force-install\' to force installation.;\
echo type \'$(MAKE) uninstall-legacy\' to uninstall these files,;\
echo or type \'$(MAKE) force-install\' to force installation.;\
echo The latter may result in a broken installation.;\
echo;\
false;\
@@ -568,7 +542,7 @@ check-uninstall:
echo;\
echo An older fish installation using an incompatible filesystem hierarchy was detected;\
echo You must remove the file $(DESTDIR)$(sysconfdir)/fish before proceeding;\
echo type \'make uninstall-legacy\' to uninstall this file,;\
echo type \'$(MAKE) uninstall-legacy\' to uninstall this file,;\
echo or remove it manually using \'rm $(DESTDIR)$(sysconfdir)/fish\'.;\
echo;\
false;\
@@ -583,7 +557,7 @@ check-uninstall:
#
install-sh:
if test -x install-sh; then true; else chmod 755 install-sh; fi
if test -x $@; then true; else chmod 755 $@; fi
.PHONY: install-sh
@@ -601,7 +575,7 @@ install: all install-sh check-uninstall install-force
#
install-force: all install-translations
$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
for i in $(PROGRAMS); do\
$(INSTALL) -m 755 $$i $(DESTDIR)$(bindir) ; \
done;
@@ -609,16 +583,18 @@ install-force: all install-translations
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/completions
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/functions
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/man
$(INSTALL) -m 644 etc/config.fish $(DESTDIR)$(sysconfdir)/fish/
$(INSTALL) -m 644 share/config.fish $(DESTDIR)$(datadir)/fish/
$(INSTALL) -m 644 share/config_interactive.fish $(DESTDIR)$(datadir)/fish/
for i in $(COMPLETIONS_DIR_FILES); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/completions/; \
done;
for i in $(FUNCTIONS_DIR_FILES); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/functions/; \
done;
$(INSTALL) -m 644 etc/fish_inputrc $(DESTDIR)$(sysconfdir)/fish/fish_inputrc;
for i in share/man/*.1; do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/man/; \
done;
$(INSTALL) -m 755 -d $(DESTDIR)$(docdir)
for i in user_doc/html/* ChangeLog; do \
if test -f $$i; then \
@@ -629,7 +605,7 @@ install-force: all install-translations
for i in $(MANUALS); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(mandir)/man1/; \
done;
@echo fish is now installed on your system.
@echo fish is now installed on your system.
@echo To run fish, type \'fish\' in your terminal.
@echo
@echo To use fish as your login shell:
@@ -650,7 +626,6 @@ uninstall: uninstall-translations
done;
-rm -f $(DESTDIR)$(bindir)/xsel
-rm -f $(DESTDIR)$(sysconfdir)/fish/config.fish
-rm -f $(DESTDIR)$(sysconfdir)/fish/fish_inputrc
-rmdir $(DESTDIR)$(sysconfdir)/fish
-if test -d $(DESTDIR)$(datadir)/fish; then \
rm -r $(DESTDIR)$(datadir)/fish; \
@@ -675,6 +650,7 @@ uninstall-legacy: uninstall
-rm -f $(DESTDIR)$(sysconfdir)/fish.d/fish_interactive.fish
-rm -f $(DESTDIR)$(sysconfdir)/fish.d/fish_complete.fish
-rm -f $(DESTDIR)$(sysconfdir)/fish.d/fish_function.fish
-rm -f $(DESTDIR)$(sysconfdir)/fish/fish_inputrc
-if test -d $(DESTDIR)$(sysconfdir)/fish.d/completions; then \
for i in $(COMPLETIONS_DIR_FILES); do \
basename=`basename $$i`; \
@@ -686,7 +662,7 @@ uninstall-legacy: uninstall
-rmdir $(DESTDIR)$(sysconfdir)/fish.d/completions
-rmdir $(DESTDIR)$(sysconfdir)/fish.d
-rm $(DESTDIR)$(sysconfdir)/fish
@echo The previous fish installation has been removed.
@echo The previous fish installation has been removed.
.PHONY: uninstall-legacy
install-translations: $(TRANSLATIONS)
@@ -699,7 +675,7 @@ install-translations: $(TRANSLATIONS)
fi;
.PHONY: install-translations
uninstall-translations:
uninstall-translations:
if test $(HAVE_GETTEXT) = 1; then \
for i in $(TRANSLATIONS_SRC); do \
rm -f $(DESTDIR)$(datadir)/locale/*/LC_MESSAGES/fish.mo; \
@@ -716,8 +692,8 @@ uninstall-translations:
# Build the fish program.
#
fish: $(FISH_OBJS) main.o
$(CC) $(FISH_OBJS) main.o $(LDFLAGS) -o $@
fish: $(FISH_OBJS) fish.o
$(CC) $(FISH_OBJS) fish.o $(LDFLAGS_FISH) -o $@
#
@@ -725,15 +701,15 @@ fish: $(FISH_OBJS) main.o
#
fish_pager: $(FISH_PAGER_OBJS)
$(CC) $(FISH_PAGER_OBJS) $(LDFLAGS) -o $@
$(CC) $(FISH_PAGER_OBJS) $(LDFLAGS_FISH_PAGER) -o $@
#
# Build the fishd program.
#
fishd: $(FISHD_OBJS)
$(CC) $(FISHD_OBJS) $(LDFLAGS) -o $@
fishd: $(FISHD_OBJS)
$(CC) $(FISHD_OBJS) $(LDFLAGS_FISHD) -o $@
#
@@ -741,7 +717,7 @@ fishd: $(FISHD_OBJS)
#
fish_tests: $(FISH_TESTS_OBJS)
$(CC) $(FISH_TESTS_OBJS) $(LDFLAGS) -o $@
$(CC) $(FISH_TESTS_OBJS) $(LDFLAGS_FISH) -o $@
#
@@ -750,26 +726,16 @@ fish_tests: $(FISH_TESTS_OBJS)
# mimedb does not need any libraries, so we don't use LDFLAGS here.
#
mimedb: $(MIME_OBJS) doc_src/mimedb.o
$(CC) $(MIME_OBJS) doc_src/mimedb.o $(LDFLAGS) -o $@
#
# Build the count program.
#
# count does not need any libraries, so we don't use LDFLAGS here.
#
count: count.o
$(CC) count.o -o $@
mimedb: $(MIME_OBJS)
$(CC) $(MIME_OBJS) $(LDFLAGS_MIMEDB) -o $@
#
# Build the set_color program
#
set_color: set_color.o doc_src/set_color.o common.o
$(CC) set_color.o doc_src/set_color.o common.o wutil.o $(LDFLAGS) -o $@
set_color: set_color.o print_help.o common.o
$(CC) set_color.o print_help.o common.o wutil.o $(LDFLAGS_SET_COLOR) -o $@
#
@@ -780,33 +746,40 @@ tokenizer_test: tokenizer.c tokenizer.h wutil.o common.o
$(CC) $(CFLAGS) tokenizer.c wutil.o common.o -D TOKENIZER_TEST $(LDFLAGS) -o $@
#
# Build the fish_indent program.
#
fish_indent: $(FISH_INDENT_OBJS)
$(CC) $(FISH_INDENT_OBJS) $(LDFLAGS_FISH_INDENT) -o $@
#
# Neat little program to show output from terminal
#
key_reader: key_reader.o input_common.o common.o env_universal.o env_universal_common.o wutil.o
$(CC) key_reader.o input_common.o common.o env_universal.o env_universal_common.o wutil.o $(LDFLAGS) -o $@
$(CC) key_reader.o input_common.o common.o env_universal.o env_universal_common.o wutil.o $(LDFLAGS_FISH) -o $@
#
# Update dependencies
#
depend:
makedepend -fMakefile.in -Y *.c
makedepend -fMakefile.in -Y *.c
./config.status
.PHONY: depend
#
# Copy all the source files into a new directory and use tar to create
# an archive from it. Simplest way I could think of to make an archive
# witout backups, autogenerated files, etc.
#
# Uses install instead of mkdir so build won't fail if the directory
# Uses install instead of mkdir so build won't fail if the directory
# exists
#
fish-@PACKAGE_VERSION@.tar: $(DOC_SRC_DIR_FILES) $(MAIN_DIR_FILES) $(ETC_DIR_FILES) $(TEST_DIR_FILES) $(SHARE_DIR_FILES) $(FUNCTIONS_DIR_FILES) $(COMPLETIONS_DIR_FILES) ChangeLog user_doc doc_src/builtin_doc
fish-@PACKAGE_VERSION@.tar: $(DOC_SRC_DIR_FILES) $(MAIN_DIR_FILES) $(ETC_DIR_FILES) $(TEST_DIR_FILES) $(SHARE_DIR_FILES) $(FUNCTIONS_DIR_FILES) $(COMPLETIONS_DIR_FILES) ChangeLog user_doc share/man
rm -rf fish-@PACKAGE_VERSION@
$(INSTALL) -d fish-@PACKAGE_VERSION@
$(INSTALL) -d fish-@PACKAGE_VERSION@/doc_src
@@ -815,6 +788,7 @@ fish-@PACKAGE_VERSION@.tar: $(DOC_SRC_DIR_FILES) $(MAIN_DIR_FILES) $(ETC_DIR_FIL
$(INSTALL) -d fish-@PACKAGE_VERSION@/share
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/completions
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/functions
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/man
$(INSTALL) -d fish-@PACKAGE_VERSION@/tests
$(INSTALL) -d fish-@PACKAGE_VERSION@/po
cp -f $(DOC_SRC_DIR_FILES) fish-@PACKAGE_VERSION@/doc_src
@@ -825,8 +799,8 @@ fish-@PACKAGE_VERSION@.tar: $(DOC_SRC_DIR_FILES) $(MAIN_DIR_FILES) $(ETC_DIR_FIL
cp -f $(FUNCTIONS_DIR_FILES) fish-@PACKAGE_VERSION@/share/functions/
cp -f $(TESTS_DIR_FILES) fish-@PACKAGE_VERSION@/tests/
cp -f $(TRANSLATIONS_SRC) fish-@PACKAGE_VERSION@/po/
cp -f share/man/*.1 fish-@PACKAGE_VERSION@/share/man/
cp -rf user_doc fish-@PACKAGE_VERSION@/
cp -rf doc_src/builtin_doc fish-@PACKAGE_VERSION@/doc_src/
tar -c fish-@PACKAGE_VERSION@ >fish-@PACKAGE_VERSION@.tar
rm -rf fish-@PACKAGE_VERSION@
@@ -853,13 +827,14 @@ dist: fish-@PACKAGE_VERSION@.tar.bz2
.PHONY: dist
#
# Build the RPM spec file.
# Build the RPM spec file.
#
fish.spec: fish.spec.in
./config.status
#
# Create .rpm file for the current systems architecture and an
# .src.rpm file.
@@ -889,9 +864,10 @@ rpm: fish-@PACKAGE_VERSION@.tar.bz2 fish.spec
#
distclean: clean
rm -f fish.spec doc_src/Doxyfile
rm -f etc/config.fish share/config_interactive.fish seq share/config.fish
rm -f fish.spec Doxyfile.help
rm -f etc/config.fish seq share/config.fish
rm -f config.status config.log config.h Makefile
rm -rf $(XSEL)
.PHONY: distclean
@@ -903,50 +879,51 @@ distclean: clean
clean:
rm -f *.o doc.h doc.tmp doc_src/*.doxygen doc_src/*.c doc_src/*.o doc_src/commands.hdr
rm -f tests/tmp.err tests/tmp.out tests/tmp.status tests/foo.txt
rm -f tokenizer_test fish key_reader set_color gen_hdr2 mimedb
rm -f fishd fish_pager count fish_tests
rm -f fish-@PACKAGE_VERSION@.tar
rm -f fish-@PACKAGE_VERSION@.tar.gz
rm -f $(PROGRAMS) fish_tests tokenizer_test key_reader
rm -f share/config.fish etc/config.fish doc_src/index.hdr doc_src/commands.hdr
rm -f fish-@PACKAGE_VERSION@.tar
rm -f fish-@PACKAGE_VERSION@.tar.gz
rm -f fish-@PACKAGE_VERSION@.tar.bz2
rm -rf doc;
rm -rf doc;
rm -rf fish-@PACKAGE_VERSION@
rm -rf xsel-0.9.6/
rm -f $(TRANSLATIONS)
test ! -d "$(XSEL)" || make -C $(XSEL) clean
.PHONY: clean
# DO NOT DELETE THIS LINE -- make depend depends on it.
builtin.o: config.h fallback.h util.h wutil.h builtin.h function.h complete.h
builtin.o: proc.h io.h parser.h event.h reader.h env.h common.h wgetopt.h
builtin.o: sanity.h tokenizer.h wildcard.h input_common.h input.h intern.h
builtin.o: signal.h halloc.h halloc_util.h parse_util.h expand.h path.h
builtin.o: builtin_help.c builtin_set.c builtin_commandline.c
builtin.o: builtin_complete.c builtin_ulimit.c builtin_jobs.c
builtin.o: config.h fallback.h util.h wutil.h builtin.h io.h function.h
builtin.o: complete.h proc.h parser.h event.h reader.h env.h common.h
builtin.o: wgetopt.h sanity.h tokenizer.h wildcard.h input_common.h input.h
builtin.o: intern.h signal.h exec.h highlight.h halloc.h halloc_util.h
builtin.o: parse_util.h parser_keywords.h expand.h path.h builtin_set.c
builtin.o: builtin_commandline.c builtin_complete.c builtin_ulimit.c
builtin.o: builtin_jobs.c
builtin_commandline.o: config.h signal.h fallback.h util.h wutil.h builtin.h
builtin_commandline.o: common.h wgetopt.h reader.h proc.h io.h parser.h
builtin_commandline.o: io.h common.h wgetopt.h reader.h proc.h parser.h
builtin_commandline.o: event.h tokenizer.h input_common.h input.h
builtin_commandline.o: parse_util.h
builtin_complete.o: config.h signal.h fallback.h util.h wutil.h builtin.h
builtin_complete.o: common.h complete.h wgetopt.h parser.h proc.h io.h
builtin_complete.o: io.h common.h complete.h wgetopt.h parser.h proc.h
builtin_complete.o: event.h reader.h
builtin_help.o: config.h util.h common.h halloc_util.h
builtin_jobs.o: config.h fallback.h util.h wutil.h builtin.h proc.h io.h
builtin_jobs.o: config.h fallback.h util.h wutil.h builtin.h io.h proc.h
builtin_jobs.o: parser.h event.h common.h wgetopt.h
builtin_set.o: config.h signal.h fallback.h util.h wutil.h builtin.h env.h
builtin_set.o: expand.h common.h wgetopt.h proc.h io.h parser.h event.h
builtin_ulimit.o: config.h fallback.h util.h builtin.h common.h wgetopt.h
builtin_set.o: config.h signal.h fallback.h util.h wutil.h builtin.h io.h
builtin_set.o: env.h expand.h common.h wgetopt.h proc.h parser.h event.h
builtin_ulimit.o: config.h fallback.h util.h builtin.h io.h common.h
builtin_ulimit.o: wgetopt.h
common.o: config.h fallback.h util.h wutil.h common.h expand.h proc.h io.h
common.o: wildcard.h parser.h event.h util.c halloc.c halloc.h halloc_util.c
common.o: fallback.c
complete.o: config.h signal.h fallback.h util.h tokenizer.h wildcard.h proc.h
complete.o: io.h parser.h event.h function.h complete.h builtin.h env.h
complete.o: exec.h expand.h common.h reader.h history.h intern.h parse_util.h
complete.o: halloc.h halloc_util.h wutil.h path.h
count.o: config.h
complete.o: parser_keywords.h halloc.h halloc_util.h wutil.h path.h
env.o: config.h signal.h fallback.h util.h wutil.h proc.h io.h common.h env.h
env.o: sanity.h expand.h history.h reader.h parser.h event.h env_universal.h
env.o: env_universal_common.h input_common.h complete.h
env.o: env_universal_common.h input_common.h path.h halloc.h halloc_util.h
env.o: complete.h
env_universal.o: config.h signal.h fallback.h util.h common.h wutil.h
env_universal.o: env_universal_common.h env_universal.h
env_universal_common.o: config.h signal.h fallback.h util.h common.h wutil.h
@@ -955,36 +932,41 @@ event.o: config.h signal.h fallback.h util.h wutil.h function.h proc.h io.h
event.o: parser.h event.h common.h halloc_util.h
exec.o: config.h signal.h fallback.h util.h common.h wutil.h proc.h io.h
exec.o: exec.h parser.h event.h builtin.h function.h env.h wildcard.h
exec.o: sanity.h expand.h env_universal.h env_universal_common.h halloc.h
exec.o: halloc_util.h parse_util.h
exec.o: sanity.h expand.h halloc.h halloc_util.h parse_util.h
expand.o: config.h signal.h fallback.h util.h common.h wutil.h env.h proc.h
expand.o: io.h parser.h event.h expand.h wildcard.h exec.h tokenizer.h
expand.o: complete.h parse_util.h halloc.h halloc_util.h
fallback.o: config.h fallback.h util.h
fishd.o: config.h signal.h fallback.h util.h common.h wutil.h
fishd.o: env_universal_common.h halloc.h halloc_util.h path.h
fish.o: config.h signal.h fallback.h util.h common.h reader.h io.h builtin.h
fish.o: function.h complete.h wutil.h env.h sanity.h proc.h parser.h event.h
fish.o: expand.h intern.h exec.h output.h halloc.h halloc_util.h history.h
fish.o: path.h
fish_indent.o: config.h fallback.h util.h common.h wutil.h halloc.h
fish_indent.o: halloc_util.h tokenizer.h print_help.h parser_keywords.h
fish_pager.o: config.h signal.h fallback.h util.h wutil.h common.h complete.h
fish_pager.o: output.h input_common.h env_universal.h env_universal_common.h
fish_pager.o: halloc.h halloc_util.h
fish_pager.o: halloc.h halloc_util.h print_help.h
fish_tests.o: config.h signal.h fallback.h util.h common.h proc.h io.h
fish_tests.o: reader.h builtin.h function.h complete.h wutil.h env.h expand.h
fish_tests.o: parser.h event.h tokenizer.h output.h exec.h halloc_util.h
fish_tests.o: parser.h event.h tokenizer.h output.h exec.h path.h halloc.h
fish_tests.o: halloc_util.h
fishd.o: config.h signal.h fallback.h util.h common.h wutil.h
fishd.o: env_universal_common.h halloc.h halloc_util.h path.h print_help.h
function.o: config.h signal.h wutil.h fallback.h util.h function.h proc.h
function.o: io.h parser.h event.h common.h intern.h reader.h parse_util.h
function.o: env.h expand.h
function.o: parser_keywords.h env.h expand.h halloc.h halloc_util.h
halloc.o: config.h fallback.h util.h common.h halloc.h
halloc_util.o: config.h fallback.h util.h common.h halloc.h
highlight.o: config.h signal.h fallback.h util.h wutil.h highlight.h
highlight.o: tokenizer.h proc.h io.h parser.h event.h parse_util.h builtin.h
highlight.o: function.h env.h expand.h sanity.h common.h complete.h output.h
highlight.o: halloc.h halloc_util.h wildcard.h path.h
history2.o: config.h fallback.h util.h wutil.h history.h common.h halloc.h
history2.o: halloc_util.h intern.h path.h
highlight.o: tokenizer.h proc.h io.h parser.h event.h parse_util.h
highlight.o: parser_keywords.h builtin.h function.h env.h expand.h sanity.h
highlight.o: common.h complete.h output.h halloc.h halloc_util.h wildcard.h
highlight.o: path.h
history.o: config.h fallback.h util.h wutil.h history.h common.h halloc.h
history.o: halloc_util.h intern.h path.h signal.h
input.o: config.h signal.h fallback.h util.h wutil.h reader.h proc.h io.h
input.o: config.h signal.h fallback.h util.h wutil.h reader.h io.h proc.h
input.o: common.h sanity.h input_common.h input.h parser.h event.h env.h
input.o: expand.h output.h intern.h
input.o: expand.h output.h intern.h halloc.h halloc_util.h
input_common.o: config.h fallback.h util.h common.h wutil.h input_common.h
input_common.o: env_universal.h env_universal_common.h
intern.o: config.h fallback.h util.h wutil.h common.h intern.h
@@ -992,48 +974,44 @@ io.o: config.h fallback.h util.h wutil.h exec.h proc.h io.h common.h halloc.h
key_reader.o: config.h fallback.h input_common.h
kill.o: config.h signal.h fallback.h util.h wutil.h kill.h proc.h io.h
kill.o: sanity.h common.h env.h exec.h halloc.h path.h
main.o: config.h signal.h fallback.h util.h common.h reader.h builtin.h
main.o: function.h complete.h wutil.h env.h sanity.h proc.h io.h parser.h
main.o: event.h expand.h intern.h exec.h output.h halloc.h halloc_util.h
main.o: history.h path.h
mimedb.o: config.h xdgmime.h fallback.h util.h
mimedb.o: config.h xdgmime.h fallback.h util.h print_help.h
output.o: config.h signal.h fallback.h util.h wutil.h expand.h common.h
output.o: output.h halloc_util.h highlight.h
parser.o: config.h signal.h fallback.h util.h common.h wutil.h proc.h io.h
parser.o: parser.h event.h tokenizer.h exec.h wildcard.h function.h builtin.h
parser.o: env.h expand.h reader.h sanity.h env_universal.h
parser.o: env_universal_common.h intern.h parse_util.h halloc.h halloc_util.h
parser.o: path.h
parse_util.o: config.h fallback.h util.h wutil.h common.h tokenizer.h
parse_util.o: parse_util.h expand.h intern.h exec.h proc.h io.h env.h
parse_util.o: wildcard.h halloc_util.h
parse_util.o: signal.h wildcard.h halloc_util.h
parser.o: config.h signal.h fallback.h util.h common.h wutil.h proc.h io.h
parser.o: parser.h event.h parser_keywords.h tokenizer.h exec.h wildcard.h
parser.o: function.h builtin.h env.h expand.h reader.h sanity.h
parser.o: env_universal.h env_universal_common.h intern.h parse_util.h
parser.o: halloc.h halloc_util.h path.h
parser_keywords.o: config.h fallback.h common.h util.h parser_keywords.h
path.o: config.h fallback.h util.h common.h env.h wutil.h halloc.h
path.o: halloc_util.h path.h expand.h
print_help.o: print_help.h
proc.o: config.h signal.h fallback.h util.h wutil.h proc.h io.h common.h
proc.o: reader.h sanity.h env.h parser.h event.h halloc.h halloc_util.h
proc.o: output.h
reader.o: config.h signal.h fallback.h util.h wutil.h highlight.h reader.h
reader.o: proc.h io.h parser.h event.h complete.h history.h common.h sanity.h
reader.o: io.h proc.h parser.h event.h complete.h history.h common.h sanity.h
reader.o: env.h exec.h expand.h tokenizer.h kill.h input_common.h input.h
reader.o: function.h output.h screen.h parse_util.h
reader.o: function.h output.h screen.h halloc.h halloc_util.h parse_util.h
sanity.o: config.h signal.h fallback.h util.h common.h sanity.h proc.h io.h
sanity.o: history.h reader.h kill.h wutil.h
screen.o: config.h fallback.h common.h util.h wutil.h output.h highlight.h
screen.o: screen.h
set_color.o: config.h fallback.h
screen.o: screen.h env.h
set_color.o: config.h fallback.h print_help.h
signal.o: config.h signal.h common.h util.h fallback.h wutil.h event.h
signal.o: reader.h proc.h io.h
test.o: stringtab.h
signal.o: reader.h io.h proc.h
tokenizer.o: config.h fallback.h util.h wutil.h tokenizer.h common.h
tokenizer.o: wildcard.h
util.o: config.h fallback.h util.h common.h wutil.h
wgetopt.o: config.h wgetopt.h wutil.h fallback.h
wildcard.o: config.h fallback.h util.h wutil.h complete.h common.h wildcard.h
wildcard.o: reader.h expand.h
wildcard.o: reader.h io.h expand.h exec.h proc.h halloc_util.h
wutil.o: config.h fallback.h util.h common.h wutil.h halloc.h halloc_util.h
xdgmimealias.o: xdgmimealias.h xdgmime.h xdgmimeint.h
xdgmime.o: xdgmime.h xdgmimeint.h xdgmimeglob.h xdgmimemagic.h xdgmimealias.h
xdgmime.o: xdgmimeparent.h
xdgmimealias.o: xdgmimealias.h xdgmime.h xdgmimeint.h
xdgmimeglob.o: xdgmimeglob.h xdgmime.h xdgmimeint.h
xdgmimeint.o: xdgmimeint.h xdgmime.h
xdgmimemagic.o: xdgmimemagic.h xdgmime.h xdgmimeint.h

1733
builtin.c

File diff suppressed because it is too large Load Diff

View File

@@ -8,6 +8,7 @@
#include <wchar.h>
#include "util.h"
#include "io.h"
enum
{
@@ -35,12 +36,12 @@ enum
/**
Error message on multiple scope levels for variables
*/
#define BUILTIN_ERR_GLOCAL _( L"%ls: Variable scope can only be one of universal, global and local\n%ls\n" )
#define BUILTIN_ERR_GLOCAL _( L"%ls: Variable scope can only be one of universal, global and local\n" )
/**
Error message for specifying both export and unexport to set/read
*/
#define BUILTIN_ERR_EXPUNEXP _( L"%ls: Variable can't be both exported and unexported\n%ls\n" )
#define BUILTIN_ERR_EXPUNEXP _( L"%ls: Variable can't be both exported and unexported\n" )
/**
Error message for unknown switch
@@ -63,7 +64,7 @@ enum
#define BUILTIN_FOR_ERR_IN _( L"%ls: Second argument must be 'in'\n" )
/**
Error message for insufficient number of arguments
Error message for insufficient number of arguments
*/
#define BUILTIN_FOR_ERR_COUNT _( L"%ls: Expected at least two arguments, got %d\n")
@@ -107,7 +108,7 @@ extern int builtin_err_redirect;
/**
Initialize builtin data.
Initialize builtin data.
*/
void builtin_init();
@@ -122,16 +123,17 @@ void builtin_destroy();
int builtin_exists( wchar_t *cmd );
/**
Execute a builtin command
Execute a builtin command
\param argv Array containing the command and parameters
\param argv Array containing the command and parameters
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.
\param io the io redirections to perform on this builtin.
\return the exit status of the builtin command
*/
int builtin_run( wchar_t **argv );
int builtin_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.
@@ -164,12 +166,11 @@ const wchar_t *builtin_complete_get_temporary_buffer();
/**
Return the help text for the specified builtin command. Use
non-wide characters since wide characters have some issues with
string formating escape sequences sometimes.
\param cmd The command for which to obtain help text
Run the __fish_print_help function to obtain the help information
for the specified command. The resulting string will be valid until
the next time this function is called, and must never be free'd manually.
*/
char *builtin_help_get( const wchar_t *cmd );
wchar_t *builtin_help_get( const wchar_t *cmd );
#endif

View File

@@ -1,6 +1,6 @@
/** \file builtin_commandline.c Functions defining the commandline builtin
Functions used for implementing the commandline builtin.
Functions used for implementing the commandline builtin.
*/
#include "config.h"
@@ -52,7 +52,15 @@ enum
}
;
/**
Pointer to what the commandline builtin considers to be the current
contents of the command line buffer.
*/
static wchar_t *current_buffer=0;
/**
What the commandline builtin considers to be the current cursor
position.
*/
static int current_cursor_pos = -1;
/**
@@ -88,20 +96,20 @@ static void replace_part( const wchar_t *begin,
const wchar_t *buff = get_buffer();
string_buffer_t out;
int out_pos=get_cursor_pos();
sb_init( &out );
sb_append_substring( &out, buff, begin-buff );
switch( append_mode)
{
case REPLACE_MODE:
{
sb_append( &out, insert );
out_pos = wcslen( insert ) + (begin-buff);
out_pos = wcslen( insert ) + (begin-buff);
break;
}
case APPEND_MODE:
{
@@ -115,7 +123,7 @@ static void replace_part( const wchar_t *begin,
sb_append_substring( &out, begin, cursor );
sb_append( &out, insert );
sb_append_substring( &out, begin+cursor, end-begin-cursor );
out_pos += wcslen( insert );
out_pos += wcslen( insert );
break;
}
}
@@ -123,7 +131,7 @@ static void replace_part( const wchar_t *begin,
reader_set_buffer( (wchar_t *)out.buff, out_pos );
sb_destroy( &out );
}
/**
Output the specified selection.
@@ -132,11 +140,11 @@ static void replace_part( const wchar_t *begin,
\param cut_at_cursor whether printing should stop at the surrent cursor position
\param tokenize whether the string should be tokenized, printing one string token on every line and skipping non-string tokens
*/
static void write_part( const wchar_t *begin,
const wchar_t *end,
int cut_at_cursor,
static void write_part( const wchar_t *begin,
const wchar_t *end,
int cut_at_cursor,
int tokenize )
{
{
tokenizer tok;
string_buffer_t out;
wchar_t *buff;
@@ -146,11 +154,10 @@ static void write_part( const wchar_t *begin,
if( tokenize )
{
buff = wcsndup( begin, end-begin );
// fwprintf( stderr, L"Subshell: %ls, end char %lc\n", buff, *end );
sb_init( &out );
for( tok_init( &tok, buff, TOK_ACCEPT_UNFINISHED );
tok_has_next( &tok );
tok_next( &tok ) )
@@ -158,34 +165,45 @@ static void write_part( const wchar_t *begin,
if( (cut_at_cursor) &&
(tok_get_pos( &tok)+wcslen(tok_last( &tok)) >= pos) )
break;
// fwprintf( stderr, L"Next token %ls\n", tok_last( &tok ) );
switch( tok_last_type( &tok ) )
{
case TOK_STRING:
sb_append2( &out, tok_last( &tok), L"\n", (void *)0 );
{
wchar_t *tmp = unescape( tok_last( &tok ), UNESCAPE_INCOMPLETE );
sb_append( &out, tmp, L"\n", (void *)0 );
free( tmp );
break;
}
}
}
}
if( out.buff )
sb_append( sb_out,
(wchar_t *)out.buff );
sb_append( sb_out,
(wchar_t *)out.buff );
free( buff );
tok_destroy( &tok );
sb_destroy( &out );
}
else
{
wchar_t *buff;
if( cut_at_cursor )
{
end = begin+pos;
end = begin+pos;
}
sb_append_substring( sb_out, begin, end-begin );
sb_append( sb_out, L"\n" );
buff = wcsndup( begin, end-begin );
// debug( 0, L"woot2 %ls -> %ls", buff, esc );
sb_append( sb_out, buff );
sb_append( sb_out, L"\n" );
free( buff );
}
}
@@ -199,15 +217,17 @@ static int builtin_commandline( wchar_t **argv )
int buffer_part=0;
int cut_at_cursor=0;
int argc = builtin_count_args( argv );
int append_mode=0;
int function_mode = 0;
int tokenize = 0;
int tokenize = 0;
int cursor_mode = 0;
int line_mode = 0;
int search_mode = 0;
wchar_t *begin, *end;
current_buffer = (wchar_t *)builtin_complete_get_temporary_buffer();
@@ -223,19 +243,29 @@ static int builtin_commandline( wchar_t **argv )
if( !get_buffer() )
{
sb_append2( sb_err,
argv[0],
L": Can not set commandline in non-interactive mode\n",
(void *)0 );
if (is_interactive_session)
{
/*
Prompt change requested while we don't have
a prompt, most probably while reading the
init files. Just ignore it.
*/
return 1;
}
sb_append( sb_err,
argv[0],
L": Can not set commandline in non-interactive mode\n",
(void *)0 );
builtin_print_help( argv[0], sb_err );
return 1;
}
return 1;
}
woptind=0;
while( 1 )
{
const static struct woption
static const struct woption
long_options[] =
{
{
@@ -261,11 +291,11 @@ static int builtin_commandline( wchar_t **argv )
{
L"current-token", no_argument, 0, 't'
}
,
,
{
L"current-buffer", no_argument, 0, 'b'
}
,
,
{
L"cut-at-cursor", no_argument, 0, 'c'
}
@@ -282,7 +312,7 @@ static int builtin_commandline( wchar_t **argv )
L"help", no_argument, 0, 'h'
}
,
{
{
L"input", required_argument, 0, 'I'
}
,
@@ -291,21 +321,29 @@ static int builtin_commandline( wchar_t **argv )
}
,
{
0, 0, 0, 0
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"aijpctwforhI:C",
long_options,
argv,
L"abijpctwforhI:CLS",
long_options,
&opt_index );
if( opt == -1 )
break;
switch( opt )
{
case 0:
@@ -318,11 +356,16 @@ static int builtin_commandline( wchar_t **argv )
builtin_print_help( argv[0], sb_err );
return 1;
case L'a':
append_mode = APPEND_MODE;
break;
case L'b':
buffer_part = STRING_MODE;
break;
case L'i':
append_mode = INSERT_MODE;
break;
@@ -330,11 +373,11 @@ static int builtin_commandline( wchar_t **argv )
case L'r':
append_mode = REPLACE_MODE;
break;
case 'c':
cut_at_cursor=1;
break;
case 't':
buffer_part = TOKEN_MODE;
break;
@@ -359,51 +402,59 @@ static int builtin_commandline( wchar_t **argv )
current_buffer = woptarg;
current_cursor_pos = wcslen( woptarg );
break;
case 'C':
cursor_mode = 1;
break;
case 'L':
line_mode = 1;
break;
case 'S':
search_mode = 1;
break;
case 'h':
builtin_print_help( argv[0], sb_out );
return 0;
case L'?':
builtin_print_help( argv[0], sb_err );
return 1;
builtin_unknown_option( argv[0], argv[woptind-1] );
return 1;
}
}
}
if( function_mode )
{
int i;
/*
Check for invalid switch combinations
*/
if( buffer_part || cut_at_cursor || append_mode || tokenize || cursor_mode )
if( buffer_part || cut_at_cursor || append_mode || tokenize || cursor_mode || line_mode || search_mode )
{
sb_printf(sb_err,
BUILTIN_ERR_COMBO,
argv[0] );
builtin_print_help( argv[0], sb_err );
return 1;
}
if( argc == woptind )
{
sb_printf( sb_err,
BUILTIN_ERR_MISSING,
argv[0] );
builtin_print_help( argv[0], sb_err );
return 1;
}
for( i=woptind; i<argc; i++ )
{
wint_t c = input_get_code( argv[i] );
wint_t c = input_function_get_code( argv[i] );
if( c != -1 )
{
/*
@@ -416,24 +467,24 @@ static int builtin_commandline( wchar_t **argv )
else
{
sb_printf( sb_err,
_(L"%ls: Unknown readline function '%ls'\n"),
argv[0],
argv[i] );
_(L"%ls: Unknown input function '%ls'\n"),
argv[0],
argv[i] );
builtin_print_help( argv[0], sb_err );
return 1;
}
}
return 0;
return 0;
}
/*
Check for invalid switch combinations
*/
if( cursor_mode && (argc-woptind > 1) )
if( (search_mode || line_mode || cursor_mode) && (argc-woptind > 1) )
{
sb_append2( sb_err,
sb_append( sb_err,
argv[0],
L": Too many arguments\n",
(void *)0 );
@@ -441,16 +492,16 @@ static int builtin_commandline( wchar_t **argv )
return 1;
}
if( (buffer_part || tokenize || cut_at_cursor) && cursor_mode )
{
if( (buffer_part || tokenize || cut_at_cursor) && (cursor_mode || line_mode || search_mode) )
{
sb_printf( sb_err,
BUILTIN_ERR_COMBO,
argv[0] );
builtin_print_help( argv[0], sb_err );
return 1;
}
}
if( (tokenize || cut_at_cursor) && (argc-woptind) )
{
@@ -458,7 +509,7 @@ static int builtin_commandline( wchar_t **argv )
BUILTIN_ERR_COMBO2,
argv[0],
L"--cut-at-cursor and --tokenize can not be used when setting the commandline" );
builtin_print_help( argv[0], sb_err );
return 1;
@@ -471,7 +522,7 @@ static int builtin_commandline( wchar_t **argv )
argv[0],
L"insertion mode switches can not be used when not in insertion mode" );
builtin_print_help( argv[0], sb_err );
builtin_print_help( argv[0], sb_err );
return 1;
}
@@ -482,7 +533,7 @@ static int builtin_commandline( wchar_t **argv )
{
append_mode = REPLACE_MODE;
}
if( !buffer_part )
{
buffer_part = STRING_MODE;
@@ -495,17 +546,17 @@ static int builtin_commandline( wchar_t **argv )
wchar_t *endptr;
int new_pos;
errno = 0;
new_pos = wcstol( argv[woptind], &endptr, 10 );
if( *endptr || errno )
{
sb_printf( sb_err,
BUILTIN_ERR_NOT_NUMBER,
argv[0],
argv[woptind] );
BUILTIN_ERR_NOT_NUMBER,
argv[0],
argv[woptind] );
builtin_print_help( argv[0], sb_err );
}
current_buffer = reader_get_buffer();
new_pos = maxi( 0, mini( new_pos, wcslen( current_buffer ) ) );
reader_set_buffer( current_buffer, new_pos );
@@ -516,84 +567,98 @@ static int builtin_commandline( wchar_t **argv )
sb_printf( sb_out, L"%d\n", reader_get_cursor_pos() );
return 0;
}
}
if( line_mode )
{
int pos = reader_get_cursor_pos();
wchar_t *buff = reader_get_buffer();
sb_printf( sb_out, L"%d\n", parse_util_lineno( buff, pos ) );
return 0;
}
if( search_mode )
{
return !reader_search_mode();
}
switch( buffer_part )
{
case STRING_MODE:
{
{
begin = get_buffer();
end = begin+wcslen(begin);
break;
break;
}
case PROCESS_MODE:
{
parse_util_process_extent( get_buffer(),
get_cursor_pos(),
&begin,
&begin,
&end );
break;
}
case JOB_MODE:
{
parse_util_job_extent( get_buffer(),
get_cursor_pos(),
&begin,
&end );
break;
&end );
break;
}
case TOKEN_MODE:
{
parse_util_token_extent( get_buffer(),
get_cursor_pos(),
&begin,
&end,
&begin,
&end,
0, 0 );
break;
break;
}
}
switch(argc-woptind)
{
case 0:
{
{
write_part( begin, end, cut_at_cursor, tokenize );
break;
}
case 1:
{
replace_part( begin, end, argv[woptind], append_mode );
break;
}
}
default:
{
string_buffer_t sb;
int i;
sb_init( &sb );
sb_append( &sb, argv[woptind] );
for( i=woptind+1; i<argc; i++ )
{
sb_append( &sb, L"\n" );
sb_append( &sb, argv[i] );
}
replace_part( begin, end, (wchar_t *)sb.buff, append_mode );
sb_destroy( &sb );
break;
}
}
}
return 0;
}

View File

@@ -1,6 +1,6 @@
/** \file builtin_complete.c Functions defining the complete builtin
Functions used for implementing the complete builtin.
Functions used for implementing the complete builtin.
*/
#include "config.h"
@@ -28,7 +28,7 @@ Functions used for implementing the complete builtin.
/**
Internal storage for the builtin_get_temporary_buffer() function.
*/
const static wchar_t *temporary_buffer;
static const wchar_t *temporary_buffer;
/*
builtin_complete_* are a set of rather silly looping functions that
@@ -46,117 +46,133 @@ static void builtin_complete_add2( const wchar_t *cmd,
int cmd_type,
const wchar_t *short_opt,
array_list_t *gnu_opt,
array_list_t *old_opt,
int result_mode,
int authorative,
array_list_t *old_opt,
int result_mode,
const wchar_t *condition,
const wchar_t *comp,
const wchar_t *desc )
const wchar_t *desc,
int flags )
{
int i;
const wchar_t *s;
for( s=short_opt; *s; s++ )
{
complete_add( cmd,
complete_add( cmd,
cmd_type,
*s,
0,
0,
result_mode,
authorative,
condition,
comp,
desc );
desc,
flags );
}
for( i=0; i<al_get_count( gnu_opt ); i++ )
{
complete_add( cmd,
complete_add( cmd,
cmd_type,
0,
(wchar_t *)al_get(gnu_opt, i ),
0,
result_mode,
authorative,
condition,
comp,
desc );
desc,
flags );
}
for( i=0; i<al_get_count( old_opt ); i++ )
{
complete_add( cmd,
complete_add( cmd,
cmd_type,
0,
(wchar_t *)al_get(old_opt, i ),
1,
result_mode,
authorative,
condition,
comp,
desc );
}
desc,
flags );
}
if( al_get_count( old_opt )+al_get_count( gnu_opt )+wcslen(short_opt) == 0 )
{
complete_add( cmd,
complete_add( cmd,
cmd_type,
0,
0,
0,
result_mode,
authorative,
condition,
comp,
desc );
}
desc,
flags );
}
}
/**
Silly function
*/
static void builtin_complete_add( array_list_t *cmd,
static void builtin_complete_add( array_list_t *cmd,
array_list_t *path,
const wchar_t *short_opt,
array_list_t *gnu_opt,
array_list_t *old_opt,
int result_mode,
int authorative,
array_list_t *old_opt,
int result_mode,
int authoritative,
const wchar_t *condition,
const wchar_t *comp,
const wchar_t *desc )
const wchar_t *desc,
int flags )
{
int i;
for( i=0; i<al_get_count( cmd ); i++ )
{
builtin_complete_add2( al_get( cmd, i ),
COMMAND,
short_opt,
short_opt,
gnu_opt,
old_opt,
result_mode,
authorative,
condition,
comp,
desc );
old_opt,
result_mode,
condition,
comp,
desc,
flags );
if( authoritative != -1 )
{
complete_set_authoritative( al_get( cmd, i ),
COMMAND,
authoritative );
}
}
for( i=0; i<al_get_count( path ); i++ )
{
builtin_complete_add2( al_get( path, i ),
PATH,
short_opt,
short_opt,
gnu_opt,
old_opt,
result_mode,
authorative,
condition,
comp,
desc );
old_opt,
result_mode,
condition,
comp,
desc,
flags );
if( authoritative != -1 )
{
complete_set_authoritative( al_get( path, i ),
PATH,
authoritative );
}
}
}
/**
@@ -165,17 +181,17 @@ static void builtin_complete_add( array_list_t *cmd,
static void builtin_complete_remove3( wchar_t *cmd,
int cmd_type,
wchar_t short_opt,
array_list_t *long_opt )
array_list_t *long_opt )
{
int i;
for( i=0; i<al_get_count( long_opt ); i++ )
{
complete_remove( cmd,
cmd_type,
short_opt,
(wchar_t *)al_get( long_opt, i ) );
}
}
}
/**
@@ -198,7 +214,7 @@ static void builtin_complete_remove2( wchar_t *cmd,
cmd_type,
*s,
0 );
}
else
{
@@ -223,42 +239,42 @@ static void builtin_complete_remove2( wchar_t *cmd,
cmd_type,
0,
old_opt );
}
}
}
/**
Silly function
*/
static void builtin_complete_remove( array_list_t *cmd,
static void builtin_complete_remove( array_list_t *cmd,
array_list_t *path,
const wchar_t *short_opt,
array_list_t *gnu_opt,
array_list_t *old_opt )
{
int i;
for( i=0; i<al_get_count( cmd ); i++ )
{
builtin_complete_remove2( (wchar_t *)al_get( cmd, i ),
COMMAND,
short_opt,
short_opt,
gnu_opt,
old_opt );
}
for( i=0; i<al_get_count( path ); i++ )
{
builtin_complete_remove2( (wchar_t *)al_get( path, i ),
PATH,
short_opt,
short_opt,
gnu_opt,
old_opt );
}
}
@@ -278,61 +294,57 @@ static int builtin_complete( wchar_t **argv )
int argc=0;
int result_mode=SHARED;
int remove = 0;
int authorative = 1;
int authoritative = -1;
int flags = COMPLETE_AUTO_SPACE;
string_buffer_t short_opt;
array_list_t gnu_opt, old_opt;
wchar_t *comp=L"", *desc=L"", *condition=L"";
wchar_t *do_complete = 0;
array_list_t cmd;
array_list_t path;
static int recursion_level=0;
if( !is_interactive_session )
{
debug( 1, _(L"%ls: Command only available in interactive sessions"), argv[0] );
}
al_init( &cmd );
al_init( &path );
sb_init( &short_opt );
al_init( &gnu_opt );
al_init( &old_opt );
argc = builtin_count_args( argv );
argc = builtin_count_args( argv );
woptind=0;
while( res == 0 )
{
const static struct woption
static const struct woption
long_options[] =
{
{
L"exclusive", no_argument, 0, 'x'
L"exclusive", no_argument, 0, 'x'
}
,
{
L"no-files", no_argument, 0, 'f'
L"no-files", no_argument, 0, 'f'
}
,
{
L"require-parameter", no_argument, 0, 'r'
L"require-parameter", no_argument, 0, 'r'
}
,
{
L"path", required_argument, 0, 'p'
}
,
,
{
L"command", required_argument, 0, 'c'
L"command", required_argument, 0, 'c'
}
,
,
{
L"short-option", required_argument, 0, 's'
L"short-option", required_argument, 0, 's'
}
,
{
@@ -340,7 +352,7 @@ static int builtin_complete( wchar_t **argv )
}
,
{
L"old-option", required_argument, 0, 'o'
L"old-option", required_argument, 0, 'o'
}
,
{
@@ -356,7 +368,11 @@ static int builtin_complete( wchar_t **argv )
}
,
{
L"unauthorative", no_argument, 0, 'u'
L"unauthoritative", no_argument, 0, 'u'
}
,
{
L"authoritative", no_argument, 0, 'A'
}
,
{
@@ -371,22 +387,22 @@ static int builtin_complete( wchar_t **argv )
L"help", no_argument, 0, 'h'
}
,
{
0, 0, 0, 0
{
0, 0, 0, 0
}
}
;
;
int opt_index = 0;
int opt = wgetopt_long( argc,
argv,
L"a:c:p:s:l:o:d:frxeun:C::h",
long_options,
argv,
L"a:c:p:s:l:o:d:frxeuAn:C::h",
long_options,
&opt_index );
if( opt == -1 )
break;
switch( opt )
{
case 0:
@@ -396,28 +412,25 @@ static int builtin_complete( wchar_t **argv )
BUILTIN_ERR_UNKNOWN,
argv[0],
long_options[opt_index].name );
sb_append( sb_err,
parser_current_line() );
builtin_print_help( argv[0], sb_err );
res = 1;
break;
case 'x':
case 'x':
result_mode |= EXCLUSIVE;
break;
case 'f':
case 'f':
result_mode |= NO_FILES;
break;
case 'r':
case 'r':
result_mode |= NO_COMMON;
break;
case 'p':
case 'p':
case 'c':
{
wchar_t *a = unescape( woptarg, 1);
@@ -428,27 +441,31 @@ static int builtin_complete( wchar_t **argv )
else
{
sb_printf( sb_err, L"%ls: Invalid token '%ls'\n", argv[0], woptarg );
res = 1;
}
res = 1;
}
break;
}
case 'd':
desc = woptarg;
break;
case 'u':
authorative=0;
authoritative=0;
break;
case 'A':
authoritative=1;
break;
case 's':
sb_append( &short_opt, woptarg );
break;
case 'l':
al_push( &gnu_opt, woptarg );
break;
case 'o':
al_push( &old_opt, woptarg );
break;
@@ -456,7 +473,7 @@ static int builtin_complete( wchar_t **argv )
case 'a':
comp = woptarg;
break;
case 'e':
remove = 1;
break;
@@ -464,25 +481,22 @@ static int builtin_complete( wchar_t **argv )
case 'n':
condition = woptarg;
break;
case 'C':
do_complete = woptarg?woptarg:reader_get_buffer();
break;
case 'h':
builtin_print_help( argv[0], sb_out );
return 0;
case '?':
sb_append( sb_err,
parser_current_line() );
builtin_print_help( argv[0], sb_err );
builtin_unknown_option( argv[0], argv[woptind-1] );
res = 1;
break;
}
}
if( !res )
@@ -492,17 +506,17 @@ static int builtin_complete( wchar_t **argv )
if( parser_test( condition, 0, 0, 0 ) )
{
sb_printf( sb_err,
L"%ls: Condition '%ls' contained a syntax error\n",
L"%ls: Condition '%ls' contained a syntax error\n",
argv[0],
condition );
parser_test( condition, 0, sb_err, argv[0] );
res = 1;
}
}
}
if( !res )
{
if( comp && wcslen( comp ) )
@@ -510,12 +524,12 @@ static int builtin_complete( wchar_t **argv )
if( parser_test_args( comp, 0, 0 ) )
{
sb_printf( sb_err,
L"%ls: Completion '%ls' contained a syntax error\n",
L"%ls: Completion '%ls' contained a syntax error\n",
argv[0],
comp );
parser_test_args( comp, sb_err, argv[0] );
res = 1;
}
}
@@ -525,44 +539,62 @@ static int builtin_complete( wchar_t **argv )
{
if( do_complete )
{
array_list_t comp;
array_list_t *comp;
int i;
const wchar_t *prev_temporary_buffer = temporary_buffer;
temporary_buffer = do_complete;
wchar_t *token;
parse_util_token_extent( do_complete, wcslen( do_complete ), &token, 0, 0, 0 );
temporary_buffer = do_complete;
if( recursion_level < 1 )
{
recursion_level++;
al_init( &comp );
complete( do_complete, &comp );
for( i=0; i<al_get_count( &comp ); i++ )
comp = al_halloc( 0 );
complete( do_complete, comp );
for( i=0; i<al_get_count( comp ); i++ )
{
wchar_t *next = (wchar_t *)al_get( &comp, i );
wchar_t *sep = wcschr( next, COMPLETE_SEP );
if( sep )
*sep = L'\t';
sb_printf( sb_out, L"%ls\n", next );
completion_t *next = (completion_t *)al_get( comp, i );
wchar_t *prepend;
if( next->flags & COMPLETE_NO_CASE )
{
prepend = L"";
}
else
{
prepend = token;
}
if( next->description )
{
sb_printf( sb_out, L"%ls%ls\t%ls\n", prepend, next->completion, next->description );
}
else
{
sb_printf( sb_out, L"%ls%ls\n", prepend, next->completion );
}
}
al_foreach( &comp, &free );
al_destroy( &comp );
halloc_free( comp );
recursion_level--;
}
temporary_buffer = prev_temporary_buffer;
temporary_buffer = prev_temporary_buffer;
}
else if( woptind != argc )
{
sb_printf( sb_err,
sb_printf( sb_err,
_( L"%ls: Too many arguments\n" ),
argv[0] );
sb_append( sb_err,
parser_current_line() );
builtin_print_help( argv[0], sb_err );
res = 1;
@@ -571,7 +603,7 @@ static int builtin_complete( wchar_t **argv )
{
/* No arguments specified, meaning we print the definitions of
* all specified completions to stdout.*/
complete_print( sb_out );
complete_print( sb_out );
}
else
{
@@ -581,25 +613,26 @@ static int builtin_complete( wchar_t **argv )
&path,
(wchar_t *)short_opt.buff,
&gnu_opt,
&old_opt );
&old_opt );
}
else
{
builtin_complete_add( &cmd,
builtin_complete_add( &cmd,
&path,
(wchar_t *)short_opt.buff,
&gnu_opt,
&old_opt,
result_mode,
authorative,
&old_opt,
result_mode,
authoritative,
condition,
comp,
desc );
desc,
flags );
}
}
}
}
al_foreach( &cmd, &free );
al_foreach( &path, &free );

View File

@@ -1,45 +0,0 @@
/** \file builtin_help.c
Functions for printing usage information of builtin commands. This
file is automatically generated from the file builtin_help.hdr and
various help files in the doc_src directory.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <sys/types.h>
#include "util.h"
#include "common.h"
#include "halloc_util.h"
/**
Hashtable storing the help text
*/
static hash_table_t tbl;
static void builtin_help_init();
char *builtin_help_get( const wchar_t *cmd )
{
builtin_help_init();
return (char *)hash_get( &tbl, (void *)cmd );
}
/**
Initialize help hash table. Don't invoke it manually,
it is called by builtin_help_get automatically.
*/
static void builtin_help_init()
{
static int is_help_init = 0;
if( is_help_init )
return;
is_help_init=1;
halloc_register_function( global_context, (void (*)(void *))&hash_destroy, &tbl );
hash_init( &tbl, &hash_wcs_func, &hash_wcs_cmp );

View File

@@ -96,7 +96,7 @@ static void builtin_jobs_print( job_t *j, int mode, int header )
#ifdef HAVE__PROC_SELF_STAT
sb_printf( sb_out, L"%d%%\t", cpu_use(j) );
#endif
sb_append2( sb_out,
sb_append( sb_out,
job_is_stopped(j)?_(L"stopped"):_(L"running"),
L"\t",
j->command,
@@ -173,7 +173,7 @@ static int builtin_jobs( wchar_t **argv )
while( 1 )
{
const static struct woption
static const struct woption
long_options[] =
{
{
@@ -222,8 +222,6 @@ static int builtin_jobs( wchar_t **argv )
argv[0],
long_options[opt_index].name );
sb_append( sb_err,
parser_current_line() );
builtin_print_help( argv[0], sb_err );
@@ -250,11 +248,10 @@ static int builtin_jobs( wchar_t **argv )
case 'h':
builtin_print_help( argv[0], sb_out );
return 0;
return 0;
case '?':
builtin_print_help( argv[0], sb_err );
builtin_unknown_option( argv[0], argv[woptind-1] );
return 1;
}

View File

@@ -1,6 +1,6 @@
/** \file builtin_set.c Functions defining the set builtin
Functions used for implementing the set builtin.
Functions used for implementing the set builtin.
*/
#include "config.h"
@@ -46,10 +46,9 @@ Functions used for implementing the set builtin.
*/
static int is_path_variable( const wchar_t *env )
{
return contains_str( env,
return contains( env,
L"PATH",
L"CDPATH",
(void *)0 );
L"CDPATH" );
}
/**
@@ -62,19 +61,19 @@ static int my_env_set( const wchar_t *key, array_list_t *val, int scope )
int i;
int retcode = 0;
wchar_t *val_str=0;
if( is_path_variable( key ) )
{
int error = 0;
for( i=0; i<al_get_count( val ); i++ )
{
int show_perror = 0;
int show_hint = 0;
struct stat buff;
wchar_t *dir = (wchar_t *)al_get( val, i );
if( wstat( dir, &buff ) )
{
error = 1;
@@ -84,55 +83,55 @@ static int my_env_set( const wchar_t *key, array_list_t *val, int scope )
if( !( S_ISDIR(buff.st_mode) ) )
{
error = 1;
}
if( error )
{
wchar_t *colon;
sb_printf( sb_err,
sb_printf( sb_err,
_(BUILTIN_SET_PATH_ERROR),
L"set",
dir,
L"set",
dir,
key );
colon = wcschr( dir, L':' );
if( colon && *(colon+1) )
if( colon && *(colon+1) )
{
show_hint = 1;
}
}
if( show_perror )
{
builtin_wperror( L"set" );
}
if( show_hint )
{
sb_printf( sb_err,
sb_printf( sb_err,
_(BUILTIN_SET_PATH_HINT),
L"set",
key,
key,
wcschr( dir, L':' )+1);
}
if( error )
{
break;
}
}
if( error )
{
return 1;
}
}
sb_init( &sb );
@@ -141,16 +140,17 @@ static int my_env_set( const wchar_t *key, array_list_t *val, int scope )
{
for( i=0; i<al_get_count( val ); i++ )
{
sb_append( &sb, (wchar_t *)al_get( val, i ) );
wchar_t *next =(wchar_t *)al_get( val, i );
sb_append( &sb, next?next:L"" );
if( i<al_get_count( val )-1 )
{
sb_append( &sb, ARRAY_SEP_STR );
}
}
val_str = (wchar_t *)sb.buff;
}
switch( env_set( key, val_str, scope | ENV_USER ) )
{
case ENV_PERM:
@@ -159,7 +159,7 @@ static int my_env_set( const wchar_t *key, array_list_t *val, int scope )
retcode=1;
break;
}
case ENV_INVALID:
{
sb_printf( sb_err, _(L"%ls: Unknown error"), L"set" );
@@ -173,13 +173,13 @@ static int my_env_set( const wchar_t *key, array_list_t *val, int scope )
return retcode;
}
/**
/**
Extract indexes from a destination argument of the form name[index1 index2...]
\param indexes the list to insert the new indexes into
\param src the source string to parse
\param name the name of the element. Return null if the name in \c src does not match this name
\param var_count the number of elements in the array to parse.
\param var_count the number of elements in the array to parse.
\return the total number of indexes parsed, or -1 on error
*/
@@ -189,52 +189,57 @@ static int parse_index( array_list_t *indexes,
int var_count )
{
int len;
int count = 0;
const wchar_t *src_orig = src;
if (src == 0)
{
return 0;
}
while (*src != L'\0' && (iswalnum(*src) || *src == L'_'))
{
src++;
}
if (*src != L'[')
{
sb_printf( sb_err, _(BUILTIN_SET_ARG_COUNT), L"set" );
sb_printf( sb_err, _(BUILTIN_SET_ARG_COUNT), L"set" );
return 0;
}
len = src-src_orig;
if( (wcsncmp( src_orig, name, len )!=0) || (wcslen(name) != (len)) )
{
sb_printf( sb_err,
sb_printf( sb_err,
_(L"%ls: Multiple variable names specified in single call (%ls and %.*ls)\n"),
L"set",
L"set",
name,
len,
src_orig);
return 0;
}
src++;
src++;
while (iswspace(*src))
while (iswspace(*src))
{
src++;
}
while (*src != L']')
while (*src != L']')
{
wchar_t *end;
long l_ind = wcstol(src, &end, 10);
if (end == src)
long l_ind;
errno = 0;
l_ind = wcstol(src, &end, 10);
if( end==src || errno )
{
sb_printf(sb_err, _(L"%ls: Invalid index starting at '%ls'\n"), L"set", src);
return 0;
@@ -244,7 +249,7 @@ static int parse_index( array_list_t *indexes,
{
l_ind = var_count+l_ind+1;
}
al_push_long(indexes, l_ind);
src = end;
count++;
@@ -263,30 +268,30 @@ static int parse_index( array_list_t *indexes,
\return 0 if the operation was successfull, non-zero otherwise
*/
static int update_values( array_list_t *list,
static int update_values( array_list_t *list,
array_list_t *indexes,
array_list_t *values )
array_list_t *values )
{
int i;
/* Replace values where needed */
for( i = 0; i < al_get_count(indexes); i++ )
for( i = 0; i < al_get_count(indexes); i++ )
{
/*
The '- 1' below is because the indices in fish are
one-based, but the array_lsit_t uses zero-based indices
one-based, but the array_list_t uses zero-based indices
*/
long ind = al_get_long(indexes, i) - 1;
void *new = (void *) al_get(values, i);
if( ind <= 0 )
if( ind < 0 )
{
return 1;
}
free((void *) al_get(list, ind));
al_set(list, ind, new != 0 ? wcsdup(new) : wcsdup(L""));
}
return 0;
}
@@ -300,42 +305,42 @@ static int al_contains_long( array_list_t *list,
{
int i;
for (i = 0; i < al_get_count(list); i++)
for (i = 0; i < al_get_count(list); i++)
{
long current = al_get_long(list, i);
if( current != 0 && current == val )
if( current != 0 && current == val )
{
return 1;
}
}
return 0;
}
/**
Erase from a list values at specified indexes
Erase from a list values at specified indexes
*/
static void erase_values(array_list_t *list, array_list_t *indexes)
static void erase_values(array_list_t *list, array_list_t *indexes)
{
long i;
array_list_t result;
al_init(&result);
for (i = 0; i < al_get_count(list); i++)
for (i = 0; i < al_get_count(list); i++)
{
if (!al_contains_long(indexes, i + 1))
if (!al_contains_long(indexes, i + 1))
{
al_push(&result, al_get(list, i));
}
else
else
{
free( (void *)al_get(list, i));
}
}
al_truncate(list,0);
al_truncate(list,0);
al_push_all( list, &result );
al_destroy(&result);
}
@@ -345,31 +350,31 @@ static void erase_values(array_list_t *list, array_list_t *indexes)
Print the names of all environment variables in the scope, with or without values,
with or without escaping
*/
static void print_variables(int include_values, int esc, int scope)
static void print_variables(int include_values, int esc, int scope)
{
array_list_t names;
int i;
al_init( &names );
env_get_names( &names, scope );
sort_list( &names );
for( i = 0; i < al_get_count(&names); i++ )
{
wchar_t *key = (wchar_t *)al_get( &names, i );
wchar_t *e_key = esc ? escape(key, 0) : wcsdup(key);
sb_append(sb_out, e_key);
if( include_values )
if( include_values )
{
wchar_t *value = env_get(key);
wchar_t *e_value;
if( value )
{
int shorten = 0;
if( wcslen( value ) > 64 )
{
shorten = 1;
@@ -379,12 +384,12 @@ static void print_variables(int include_values, int esc, int scope)
DIE_MEM();
}
}
e_value = esc ? expand_escape_variable(value) : wcsdup(value);
sb_append2(sb_out, L" ", e_value, (void *)0);
sb_append(sb_out, L" ", e_value, (void *)0);
free(e_value);
if( shorten )
{
sb_append(sb_out, L"\u2026");
@@ -393,7 +398,7 @@ static void print_variables(int include_values, int esc, int scope)
}
}
sb_append(sb_out, L"\n");
free(e_key);
}
@@ -406,57 +411,57 @@ static void print_variables(int include_values, int esc, int scope)
The set builtin. Creates, updates and erases environment variables
and environemnt variable arrays.
*/
static int builtin_set( wchar_t **argv )
static int builtin_set( wchar_t **argv )
{
/**
Variables used for parsing the argument list
*/
const static struct woption
long_options[] =
static const struct woption
long_options[] =
{
{
L"export", no_argument, 0, 'x'
{
L"export", no_argument, 0, 'x'
}
,
{
L"global", no_argument, 0, 'g'
{
L"global", no_argument, 0, 'g'
}
,
{
L"local", no_argument, 0, 'l'
{
L"local", no_argument, 0, 'l'
}
,
{
L"erase", no_argument, 0, 'e'
{
L"erase", no_argument, 0, 'e'
}
,
{
L"names", no_argument, 0, 'n'
}
{
L"names", no_argument, 0, 'n'
}
,
{
L"unexport", no_argument, 0, 'u'
}
{
L"unexport", no_argument, 0, 'u'
}
,
{
L"universal", no_argument, 0, 'U'
}
{
L"universal", no_argument, 0, 'U'
}
,
{
L"query", no_argument, 0, 'q'
}
{
L"query", no_argument, 0, 'q'
}
,
{
L"help", no_argument, 0, 'h'
}
{
L"help", no_argument, 0, 'h'
}
,
{
0, 0, 0, 0
{
0, 0, 0, 0
}
}
;
const wchar_t *short_options = L"+xglenuUqh";
int argc = builtin_count_args(argv);
@@ -467,7 +472,7 @@ static int builtin_set( wchar_t **argv )
int local = 0, global = 0, export = 0;
int erase = 0, list = 0, unexport=0;
int universal = 0, query=0;
/*
Variables used for performing the actual work
@@ -477,22 +482,22 @@ static int builtin_set( wchar_t **argv )
int scope;
int slice=0;
int i;
wchar_t *bad_char;
/* Parse options to obtain the requested operation and the modifiers */
woptind = 0;
while (1)
while (1)
{
int c = wgetopt_long(argc, argv, short_options, long_options, 0);
if (c == -1)
if (c == -1)
{
break;
}
switch(c)
switch(c)
{
case 0:
break;
@@ -534,7 +539,7 @@ static int builtin_set( wchar_t **argv )
return 0;
case '?':
builtin_print_help( argv[0], sb_err );
builtin_unknown_option( argv[0], argv[woptind-1] );
return 1;
default:
@@ -554,22 +559,20 @@ static int builtin_set( wchar_t **argv )
if( query && (erase || list || global || local || universal || export || unexport ) )
{
sb_printf(sb_err,
BUILTIN_ERR_COMBO2,
argv[0],
parser_current_line() );
BUILTIN_ERR_COMBO,
argv[0] );
builtin_print_help( argv[0], sb_err );
return 1;
}
/* We can't both list and erase varaibles */
if( erase && list )
if( erase && list )
{
sb_printf(sb_err,
BUILTIN_ERR_COMBO2,
argv[0],
parser_current_line() );
BUILTIN_ERR_COMBO,
argv[0] );
builtin_print_help( argv[0], sb_err );
return 1;
@@ -578,12 +581,11 @@ static int builtin_set( wchar_t **argv )
/*
Variables can only have one scope
*/
if( local + global + universal > 1 )
if( local + global + universal > 1 )
{
sb_printf( sb_err,
BUILTIN_ERR_GLOCAL,
argv[0],
parser_current_line() );
argv[0] );
builtin_print_help( argv[0], sb_err );
return 1;
}
@@ -591,12 +593,11 @@ static int builtin_set( wchar_t **argv )
/*
Variables can only have one export status
*/
if( export && unexport )
if( export && unexport )
{
sb_printf( sb_err,
BUILTIN_ERR_EXPUNEXP,
argv[0],
parser_current_line() );
argv[0] );
builtin_print_help( argv[0], sb_err );
return 1;
}
@@ -604,7 +605,7 @@ static int builtin_set( wchar_t **argv )
/*
Calculate the scope value for variable assignement
*/
scope = (local ? ENV_LOCAL : 0) | (global ? ENV_GLOBAL : 0) | (export ? ENV_EXPORT : 0) | (unexport ? ENV_UNEXPORT : 0) | (universal ? ENV_UNIVERSAL:0) | ENV_USER;
scope = (local ? ENV_LOCAL : 0) | (global ? ENV_GLOBAL : 0) | (export ? ENV_EXPORT : 0) | (unexport ? ENV_UNEXPORT : 0) | (universal ? ENV_UNIVERSAL:0) | ENV_USER;
if( query )
{
@@ -615,35 +616,79 @@ static int builtin_set( wchar_t **argv )
int i;
for( i=woptind; i<argc; i++ )
{
if( !env_exist( argv[i], scope ) )
wchar_t *arg = argv[i];
int slice=0;
if( !(dest = wcsdup(arg)))
{
retcode++;
DIE_MEM();
}
if( wcschr( dest, L'[' ) )
{
slice = 1;
*wcschr( dest, L'[' )=0;
}
if( slice )
{
array_list_t indexes;
array_list_t result;
int j;
al_init( &result );
al_init( &indexes );
tokenize_variable_array( env_get( dest ), &result );
if( !parse_index( &indexes, arg, dest, al_get_count( &result ) ) )
{
builtin_print_help( argv[0], sb_err );
retcode = 1;
break;
}
for( j=0; j<al_get_count( &indexes ); j++ )
{
long idx = al_get_long( &indexes, j );
if( idx < 1 || idx > al_get_count( &result ) )
{
retcode++;
}
}
}
else
{
if( !env_exist( arg, scope ) )
{
retcode++;
}
}
free( dest );
}
return retcode;
}
if( list )
if( list )
{
/* Maybe we should issue an error if there are any other arguments? */
print_variables(0, 0, scope);
return 0;
}
}
if( woptind == argc )
{
/*
Print values of variables
*/
if( erase )
if( erase )
{
sb_printf( sb_err,
_(L"%ls: Erase needs a variable name\n%ls\n"),
argv[0],
parser_current_line() );
_(L"%ls: Erase needs a variable name\n%ls\n"),
argv[0] );
builtin_print_help( argv[0], sb_err );
retcode = 1;
}
@@ -651,13 +696,13 @@ static int builtin_set( wchar_t **argv )
{
print_variables( 1, 1, scope );
}
return retcode;
}
if( !(dest = wcsdup(argv[woptind])))
{
DIE_MEM();
DIE_MEM();
}
if( wcschr( dest, L'[' ) )
@@ -665,7 +710,7 @@ static int builtin_set( wchar_t **argv )
slice = 1;
*wcschr( dest, L'[' )=0;
}
if( !wcslen( dest ) )
{
free( dest );
@@ -673,7 +718,7 @@ static int builtin_set( wchar_t **argv )
builtin_print_help( argv[0], sb_err );
return 1;
}
if( (bad_char = wcsvarname( dest ) ) )
{
sb_printf( sb_err, BUILTIN_ERR_VARCHAR, argv[0], *bad_char );
@@ -681,7 +726,7 @@ static int builtin_set( wchar_t **argv )
free( dest );
return 1;
}
if( slice && erase && (scope != ENV_USER) )
{
free( dest );
@@ -689,12 +734,12 @@ static int builtin_set( wchar_t **argv )
builtin_print_help( argv[0], sb_err );
return 1;
}
/*
set assignment can work in two modes, either using slices or
using the whole array. We detect which mode is used here.
*/
if( slice )
{
@@ -705,22 +750,22 @@ static int builtin_set( wchar_t **argv )
array_list_t values;
array_list_t indexes;
array_list_t result;
al_init(&values);
al_init(&indexes);
al_init(&result);
tokenize_variable_array( env_get(dest), &result );
for( ; woptind<argc; woptind++ )
{
{
if( !parse_index( &indexes, argv[woptind], dest, al_get_count( &result ) ) )
{
builtin_print_help( argv[0], sb_err );
retcode = 1;
break;
}
val_count = argc-woptind-1;
idx_count = al_get_count( &indexes );
@@ -739,7 +784,7 @@ static int builtin_set( wchar_t **argv )
break;
}
}
}
}
if( !retcode )
{
@@ -757,12 +802,12 @@ static int builtin_set( wchar_t **argv )
array_list_t value;
al_init(&value);
while( woptind < argc )
while( woptind < argc )
{
al_push(&value, argv[woptind++]);
}
if( update_values( &result,
if( update_values( &result,
&indexes,
&value ) )
{
@@ -770,14 +815,14 @@ static int builtin_set( wchar_t **argv )
sb_printf( sb_err, ARRAY_BOUNDS_ERR );
sb_append( sb_err, L"\n" );
}
my_env_set(dest,
&result,
scope);
al_destroy( &value );
}
}
}
al_foreach( &result, &free );
@@ -785,12 +830,12 @@ static int builtin_set( wchar_t **argv )
al_destroy(&indexes);
al_destroy(&values);
}
else
{
woptind++;
/*
No slicing
*/
@@ -798,10 +843,9 @@ static int builtin_set( wchar_t **argv )
{
if( woptind != argc )
{
sb_printf( sb_err,
_(L"%ls: Values cannot be specfied with erase\n%ls\n"),
argv[0],
parser_current_line() );
sb_printf( sb_err,
_(L"%ls: Values cannot be specfied with erase\n"),
argv[0] );
builtin_print_help( argv[0], sb_err );
retcode=1;
}
@@ -814,21 +858,21 @@ static int builtin_set( wchar_t **argv )
{
array_list_t val;
al_init( &val );
for( i=woptind; i<argc; i++ )
{
al_push( &val, argv[i] );
}
retcode = my_env_set( dest, &val, scope );
al_destroy( &val );
}
al_destroy( &val );
}
}
free( dest );
return retcode;
}

View File

@@ -1,6 +1,6 @@
/** \file builtin_ulimit.c Functions defining the ulimit builtin
Functions used for implementing the ulimit builtin.
Functions used for implementing the ulimit builtin.
*/
#include "config.h"
@@ -38,18 +38,18 @@ struct resource_t
/**
Switch used on commandline to specify resource
*/
wchar_t switch_char;
wchar_t switch_char;
/**
The implicit multiplier used when setting getting values
*/
int multiplier;
int multiplier;
}
;
/**
Array of resource_t structs, describing all known resource types.
*/
const static struct resource_t resource_arr[] =
static const struct resource_t resource_arr[] =
{
{
RLIMIT_CORE, L"Maximum size of core files created", L'c', 1024
@@ -96,7 +96,7 @@ const static struct resource_t resource_arr[] =
#ifdef RLIMIT_AS
{
RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v', 1024
}
}
,
#endif
{
@@ -111,7 +111,7 @@ const static struct resource_t resource_arr[] =
static int get_multiplier( int what )
{
int i;
for( i=0; resource_arr[i].desc; i++ )
{
if( resource_arr[i].resource == what )
@@ -123,14 +123,16 @@ static int get_multiplier( int what )
}
/**
Return the value for the specified resource limit
Return the value for the specified resource limit. This function
does _not_ multiply the limit value by the multiplier constant used
by the commandline ulimit.
*/
static rlim_t get( int resource, int hard )
{
struct rlimit ls;
getrlimit( resource, &ls );
return hard ? ls.rlim_max:ls.rlim_cur;
}
@@ -144,8 +146,8 @@ static void print( int resource, int hard )
if( l == RLIM_INFINITY )
sb_append( sb_out, L"unlimited\n" );
else
sb_printf( sb_out, L"%d\n", l );
sb_printf( sb_out, L"%d\n", l / get_multiplier( resource ) );
}
/**
@@ -155,12 +157,12 @@ static void print_all( int hard )
{
int i;
int w=0;
for( i=0; resource_arr[i].desc; i++ )
{
w=maxi( w, my_wcswidth(resource_arr[i].desc));
}
for( i=0; resource_arr[i].desc; i++ )
{
struct rlimit ls;
@@ -169,19 +171,24 @@ static void print_all( int hard )
l = hard ? ls.rlim_max:ls.rlim_cur;
wchar_t *unit = ((resource_arr[i].resource==RLIMIT_CPU)?L"(seconds, ":(get_multiplier(resource_arr[i].resource)==1?L"(":L"(kB, "));
sb_printf( sb_out,
L"%-*ls %10ls-%lc) ",
w,
resource_arr[i].desc,
L"%-*ls %10ls-%lc) ",
w,
resource_arr[i].desc,
unit,
resource_arr[i].switch_char);
if( l == RLIM_INFINITY )
{
sb_append( sb_out, L"unlimited\n" );
}
else
sb_printf( sb_out, L"%d\n", l );
{
sb_printf( sb_out, L"%d\n", l/get_multiplier(resource_arr[i].resource) );
}
}
}
/**
@@ -190,7 +197,7 @@ static void print_all( int hard )
static const wchar_t *get_desc( int what )
{
int i;
for( i=0; resource_arr[i].desc; i++ )
{
if( resource_arr[i].resource == what )
@@ -202,34 +209,34 @@ static const wchar_t *get_desc( int what )
}
/**
Set the new value of the specified resource limit
Set the new value of the specified resource limit. This function
does _not_ multiply the limit value by the multiplier constant used
by the commandline ulimit.
*/
static int set( int resource, int hard, int soft, rlim_t value )
{
struct rlimit ls;
getrlimit( resource, &ls );
if( value != RLIM_INFINITY )
value *= get_multiplier( resource );
if( hard )
{
ls.rlim_max = value;
}
if( soft )
{
ls.rlim_cur = value;
/*
Do not attempt to set the soft limit higher than the hard limit
*/
if( ( value == RLIM_INFINITY && ls.rlim_max != RLIM_INFINITY ) ||
if( ( value == RLIM_INFINITY && ls.rlim_max != RLIM_INFINITY ) ||
( value != RLIM_INFINITY && ls.rlim_max != RLIM_INFINITY && value > ls.rlim_max))
{
ls.rlim_cur = ls.rlim_max;
}
}
}
if( setrlimit( resource, &ls ) )
{
if( errno == EPERM )
@@ -237,24 +244,8 @@ static int set( int resource, int hard, int soft, rlim_t value )
else
builtin_wperror( L"ulimit" );
return 1;
}
return 0;
}
/**
Set all resource limits
*/
static int set_all( int hard, int soft, rlim_t value )
{
int i;
int res=0;
for( i=0; resource_arr[i].desc; i++ )
{
if( set( resource_arr[i].resource, hard, soft, value ) )
res = 1;
}
return res;
return 0;
}
/**
@@ -265,17 +256,17 @@ static int builtin_ulimit( wchar_t ** argv )
{
int hard=0;
int soft=0;
int what = RLIMIT_FSIZE;
int report_all = 0;
int argc = builtin_count_args( argv );
woptind=0;
while( 1 )
{
const static struct woption
static const struct woption
long_options[] =
{
{
@@ -315,7 +306,7 @@ static int builtin_ulimit( wchar_t ** argv )
}
,
{
L"pipe-size", no_argument, 0, 'p'
L"stack-size", no_argument, 0, 's'
}
,
{
@@ -330,27 +321,27 @@ static int builtin_ulimit( wchar_t ** argv )
L"virtual-memory-size", no_argument, 0, 'v'
}
,
{
L"help", no_argument, 0, 'h'
}
{
L"help", no_argument, 0, 'h'
}
,
{
0, 0, 0, 0
0, 0, 0, 0
}
}
;
;
int opt_index = 0;
int opt = wgetopt_long( argc,
argv,
L"aHScdflmnptuvh",
long_options,
argv,
L"aHScdflmnstuvh",
long_options,
&opt_index );
if( opt == -1 )
break;
switch( opt )
{
case 0:
@@ -363,7 +354,7 @@ static int builtin_ulimit( wchar_t ** argv )
builtin_print_help( argv[0], sb_err );
return 1;
case L'a':
report_all=1;
break;
@@ -373,17 +364,17 @@ static int builtin_ulimit( wchar_t ** argv )
break;
case L'S':
soft=1;
soft=1;
break;
case L'c':
what=RLIMIT_CORE;
break;
case L'd':
what=RLIMIT_DATA;
break;
case L'f':
what=RLIMIT_FSIZE;
break;
@@ -393,63 +384,76 @@ static int builtin_ulimit( wchar_t ** argv )
break;
#endif
#ifdef RLIMIT_RSS
#ifdef RLIMIT_RSS
case L'm':
what=RLIMIT_RSS;
break;
#endif
case L'n':
what=RLIMIT_NOFILE;
break;
case L's':
what=RLIMIT_STACK;
break;
case L't':
what=RLIMIT_CPU;
break;
#ifdef RLIMIT_NPROC
#ifdef RLIMIT_NPROC
case L'u':
what=RLIMIT_NPROC;
break;
#endif
#ifdef RLIMIT_AS
#ifdef RLIMIT_AS
case L'v':
what=RLIMIT_AS;
break;
#endif
case L'h':
builtin_print_help( argv[0], sb_out );
builtin_print_help( argv[0], sb_out );
return 0;
case L'?':
builtin_print_help( argv[0], sb_err );
return 1;
builtin_unknown_option( argv[0], argv[woptind-1] );
return 1;
}
}
}
if( report_all )
{
if( argc - woptind == 0 )
{
print_all( hard );
}
else
{
sb_append( sb_err,
argv[0],
L": Too many arguments\n",
(void *)0 );
builtin_print_help( argv[0], sb_err );
return 1;
}
return 0;
}
switch( argc - woptind )
{
case 0:
{
/*
Show current limit value
*/
if( report_all )
{
print_all( hard );
}
else
{
print( what, hard );
}
print( what, hard );
break;
}
case 1:
{
/*
@@ -457,7 +461,7 @@ static int builtin_ulimit( wchar_t ** argv )
*/
rlim_t new_limit;
wchar_t *end;
/*
Set both hard and soft limits if nothing else was specified
*/
@@ -465,7 +469,6 @@ static int builtin_ulimit( wchar_t ** argv )
{
hard=soft=1;
}
if( wcscasecmp( argv[woptind], L"unlimited" )==0)
{
@@ -481,41 +484,33 @@ static int builtin_ulimit( wchar_t ** argv )
}
else
{
errno=0;
errno=0;
new_limit = wcstol( argv[woptind], &end, 10 );
if( errno || *end )
{
sb_printf( sb_err,
L"%ls: Invalid limit '%ls'\n",
argv[0],
sb_printf( sb_err,
L"%ls: Invalid limit '%ls'\n",
argv[0],
argv[woptind] );
builtin_print_help( argv[0], sb_err );
return 1;
}
new_limit *= get_multiplier( what );
}
if( report_all )
{
return set_all( hard, soft, new_limit );
}
else
{
return set( what, hard, soft, new_limit );
}
break;
return set( what, hard, soft, new_limit );
}
default:
sb_append2( sb_err,
{
sb_append( sb_err,
argv[0],
L": Too many arguments\n",
(void *)0 );
builtin_print_help( argv[0], sb_err );
return 1;
break;
}
}
return 0;
return 0;
}

721
common.c

File diff suppressed because it is too large Load Diff

193
common.h
View File

@@ -40,10 +40,30 @@
*/
#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
*/
extern struct termios shell_modes;
extern struct termios shell_modes;
/**
The character to use where the text has been truncated. Is an
@@ -72,23 +92,34 @@ extern wchar_t *program_name;
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 exit status of the current function on failiure.
parameter is the return value of the current function on failiure.
*/
#define CHECK( arg, retval ) \
if( !(arg) ) \
{ \
debug( 1, \
_( L"function %s called with null value for argument %s. " \
L"This is a bug. " \
L"If you can reproduce it, please send a bug report to %s." ), \
debug( 0, \
_( L"function %s called with null value for argument %s. " ), \
__func__, \
#arg, \
PACKAGE_BUGREPORT ); \
#arg ); \
bugreport(); \
show_stackframe(); \
return retval; \
}
/**
Exit program at once, leaving an error message about running out of memory
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() \
{ \
@@ -96,50 +127,53 @@ extern wchar_t *program_name;
L"fish: Out of memory on line %d of file %s, shutting down fish\n", \
__LINE__, \
__FILE__ ); \
exit(1); \
FATAL_EXIT(); \
}
/**
Cause fish to crash. This should only be usd for debugging.
Check if signals are blocked. If so, print an error message and
return from the function performing this check.
*/
#define CRASH() \
{ \
int *n = 0; \
*n = 1; \
}
/**
Check if signals are blocked
*/
#define CHECK_BLOCK( retval ) \
#define CHECK_BLOCK( retval ) \
if( signal_is_blocked() ) \
{ \
debug( 0, \
L"function %s called while blocking signals. " \
L"This is a bug. " \
L"If you can reproduce it, please send a bug report to %s.", \
__func__, \
PACKAGE_BUGREPORT ); \
return retval; \
_( 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.
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
*/
#define contains( str,... ) contains_internal( str, __VA_ARGS__, (void *)0 )
/**
Concatenate all the specified strings into a single newly allocated one
*/
#define wcsdupcat( str,... ) wcsdupcat_internal( str, __VA_ARGS__, (void *)0 )
/**
Print a stack trace to stderr
*/
void show_stackframe();
/**
Take an array_list_t containing wide strings and converts them to a
single null-terminated wchar_t **. The array is allocated using
halloc, and uses the \c context parameter as context. If \c context
is not noll, all elements of the \c array_list_t are also
registered to \c context using \c halloc_register().
malloc, and needs to be fred's by the caller.
*/
wchar_t **list_to_char_arr( array_list_t *l );
@@ -147,7 +181,7 @@ wchar_t **list_to_char_arr( array_list_t *l );
Read a line from the stream f into the buffer buff of length len. If
buff is to small, it will be reallocated, and both buff and len will
be updated to reflect this. Returns the number of bytes read or -1
on failiure.
on failiure.
If the carriage return character is encountered, it is
ignored. fgetws() considers the line to end if reading the file
@@ -211,17 +245,12 @@ char **wcsv2strv( const wchar_t **in );
*/
wchar_t **strv2wcsv( const char **in );
/**
Returns a newly allocated concatenation of the specified wide
character strings
*/
wchar_t *wcsdupcat( const wchar_t *a, const wchar_t *b );
/**
Returns a newly allocated concatenation of the specified wide
character strings. The last argument must be a null pointer.
*/
__sentinel wchar_t *wcsdupcat2( const wchar_t *a, ... );
__sentinel wchar_t *wcsdupcat_internal( const wchar_t *a, ... );
/**
Test if the given string is a valid variable name
@@ -229,7 +258,7 @@ __sentinel wchar_t *wcsdupcat2( const wchar_t *a, ... );
/**
Test if the given string is a valid variable name.
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
*/
@@ -238,7 +267,7 @@ wchar_t *wcsvarname( const wchar_t *str );
/**
Test if the given string is a valid function name.
Test if the given string is a valid function name.
\return null if this is a valid name, and a pointer to the first invalid character otherwise
*/
@@ -246,7 +275,7 @@ wchar_t *wcsvarname( const wchar_t *str );
wchar_t *wcsfuncname( const wchar_t *str );
/**
Test if the given string is valid in a variable name
Test if the given string is valid in a variable name
\return 1 if this is a valid name, 0 otherwise
*/
@@ -282,33 +311,44 @@ void error_reset();
This function behaves exactly like a wide character equivalent of
the C function setlocale, except that it will also try to detect if
the user is using a Unicode character set, and if so, use the
unicode ellipsis character as ellipsis, instead of '$'.
unicode ellipsis character as ellipsis, instead of '$'.
*/
const wchar_t *wsetlocale( int category, const wchar_t *locale );
/**
Checks if \c needle is included in the list of strings specified. A warning is printed if needle is zero.
\param needle the string to search for in the list
\param needle the string to search for in the list
\return zero is needle is not found, of if needle is null, non-zero otherwise
\return zero if needle is not found, of if needle is null, non-zero otherwise
*/
__sentinel int contains_str( const wchar_t *needle, ... );
__sentinel int contains_internal( const wchar_t *needle, ... );
/**
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.
*/
int read_blocked(int fd, void *buf, size_t count);
/**
Loop a write request while failiure is non-critical. Return -1 and set errno
in case of critical error.
*/
ssize_t write_loop(int fd, char *buff, size_t count);
/**
Issue a debug message with printf-style string formating and
automatic line breaking. The string will begin with the string \c
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 msg the message format string.
\param msg the message format string.
Example:
@@ -320,7 +360,7 @@ void debug( int level, const wchar_t *msg, ... );
/**
Replace special characters with backslash escape sequences. Newline is
replaced with \n, etc.
replaced with \n, etc.
\param in The string to be escaped
\param escape_all Whether all characters wich hold special meaning in fish (Pipe, semicolon, etc,) should be escaped, or only unprintable characters
@@ -340,32 +380,32 @@ wchar_t *escape( const wchar_t *in, int escape_all );
an invalid sequence is specified, 0 is returned.
*/
wchar_t *unescape( const wchar_t * in,
wchar_t *unescape( const wchar_t * in,
int escape_special );
/**
Attempt to acquire a lock based on a lockfile, waiting LOCKPOLLINTERVAL
milliseconds between polls and timing out after timeout seconds,
Attempt to acquire a lock based on a lockfile, waiting LOCKPOLLINTERVAL
milliseconds between polls and timing out after timeout seconds,
thereafter forcibly attempting to obtain the lock if force is non-zero.
Returns 1 on success, 0 on failure.
To release the lock the lockfile must be unlinked.
A unique temporary file named by appending characters to the lockfile name
A unique temporary file named by appending characters to the lockfile name
is used; any pre-existing file of the same name is subject to deletion.
*/
int acquire_lock_file( const char *lockfile, const int timeout, int force );
/**
Returns the width of the terminal window, so that not all
functions that use these values continually have to keep track of
it.
/**
Returns the width of the terminal window, so that not all
functions that use these values continually have to keep track of
it separately.
Only works if common_handle_winch is registered to handle winch signals.
Only works if common_handle_winch is registered to handle winch signals.
*/
int common_get_width();
/**
Returns the height of the terminal window, so that not all
functions that use these values continually have to keep track of
it.
it separatly.
Only works if common_handle_winch is registered to handle winch signals.
*/
@@ -388,19 +428,40 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff );
Tokenize the specified string into the specified array_list_t.
Each new element is allocated using malloc and must be freed by the
caller.
\param val the input string. The contents of this string is not changed.
\param out the list in which to place the elements.
\param out the list in which to place the elements.
*/
void tokenize_variable_array( const wchar_t *val, array_list_t *out );
/**
Make sure the specified direcotry exists. If no, try to create it.
Make sure the specified direcotry exists. If needed, try to create
it and any currently not existing parent directories..
\return 0 if the directory exists, -1 otherwise.
\return 0 if, at the time of function return the directory exists, -1 otherwise.
*/
int create_directory( wchar_t *d );
/**
Print a short message about how to file a bug report to stderr
*/
void bugreport();
/**
Format the specified size (in bytes, kilobytes, etc.) into the specified stringbuffer.
*/
void sb_format_size( string_buffer_t *sb,
long long sz );
/**
Return the number of seconds from the UNIX epoch, with subsecond
precision. This function uses the gettimeofday function, and will
have the same precision as that function.
If an error occurs, NAN is returned.
*/
double timef();
#endif

1627
complete.c

File diff suppressed because it is too large Load Diff

View File

@@ -16,39 +16,39 @@
#include "util.h"
/**
Use all completions
/**
Use all completions
*/
#define SHARED 0
/**
Do not use file completion
/**
Do not use file completion
*/
#define NO_FILES 1
/**
Require a parameter after completion
/**
Require a parameter after completion
*/
#define NO_COMMON 2
/**
/**
Only use the argument list specifies with completion after
option. This is the same as (NO_FILES & NO_COMMON)
*/
#define EXCLUSIVE 3
/**
Command is a path
/**
Command is a path
*/
#define PATH 1
/**
Command is not a path
/**
Command is not a path
*/
#define COMMAND 0
/**
/**
Separator between completion and description
*/
#define COMPLETE_SEP L'\004'
/**
/**
Separator between completion and description
*/
#define COMPLETE_SEP_STR L"\004"
@@ -67,22 +67,82 @@
#define PROG_COMPLETE_SEP L'\t'
/**
Terminator for completions sent to the fish_pager
Do not insert space afterwards if this is the only completion. (The
default is to try insert a space)
*/
#define COMPLETE_TERMINATOR L'\006'
#define COMPLETE_NO_SPACE 1
/**
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
*/
#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
typedef struct
{
/**
The completion string
*/
const wchar_t *completion;
/**
The description for this completion
*/
const wchar_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.
*/
int flags;
}
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:
The command 'gcc -o' requires that a file follows it, so the
NO_COMMON option is suitable. This can be done using the following
line:
complete -c gcc -s o -r
The command 'grep -d' required that one of the strings 'read',
@@ -99,7 +159,7 @@
will be interpreted as the command name.
\param short_opt The single character name of an option. (-a is a short option, --all and -funroll are long options)
\param long_opt The multi character name of an option. (-a is a short option, --all and -funroll are long options)
\param long_mode Whether to use old style, single dash long options.
\param long_mode Whether to use old style, single dash long options.
\param result_mode Whether to search further completions when this
completion has been succesfully matched. If result_mode is SHARED,
any other completions may also be used. If result_mode is NO_FILES,
@@ -109,28 +169,35 @@
file completion is not performed.
\param comp A space separated list of completions which may contain subshells.
\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 flags A set of completion flags
*/
void complete_add( const wchar_t *cmd,
int cmd_type,
wchar_t short_opt,
const wchar_t *long_opt,
int long_mode,
int result_mode,
int authorative,
const wchar_t *condition,
const wchar_t *comp,
const wchar_t *desc );
void complete_add( const wchar_t *cmd,
int cmd_type,
wchar_t short_opt,
const wchar_t *long_opt,
int long_mode,
int result_mode,
const wchar_t *condition,
const wchar_t *comp,
const wchar_t *desc,
int flags );
/**
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.
*/
void complete_set_authoritative( const wchar_t *cmd,
int cmd_type,
int authoritative );
/**
Remove a previously defined completion
*/
void complete_remove( const wchar_t *cmd,
int cmd_type,
wchar_t short_opt,
const wchar_t *long_opt );
void complete_remove( const wchar_t *cmd,
int cmd_type,
wchar_t short_opt,
const wchar_t *long_opt );
/**
Find all completions of the command cmd, insert them into out. The
@@ -145,34 +212,25 @@ void complete_remove( const wchar_t *cmd,
void complete( const wchar_t *cmd, array_list_t *out );
/**
Print a list of all current completions into the string_buffer_t.
Print a list of all current completions into the string_buffer_t.
\param out The string_buffer_t to write completions to
*/
void complete_print( string_buffer_t *out );
/**
Obtain a description string for the file specified by the filename.
The returned value is a string constant and should not be freed.
\param filename The file for which to find a description string
*/
const wchar_t *complete_get_desc( const wchar_t *filename );
/**
Tests if the specified option is defined for the specified command
*/
int complete_is_valid_option( const wchar_t *str,
const wchar_t *opt,
int complete_is_valid_option( const wchar_t *str,
const wchar_t *opt,
array_list_t *errors );
/**
Tests if the specified argument is valid for the specified option
and command
*/
int complete_is_valid_argument( const wchar_t *str,
const wchar_t *opt,
int complete_is_valid_argument( const wchar_t *str,
const wchar_t *opt,
const wchar_t *arg );
@@ -187,4 +245,18 @@ int complete_is_valid_argument( const wchar_t *str,
*/
void complete_load( const wchar_t *cmd, int reload );
/**
Create a new completion entry
\param context The halloc context to use for allocating new memory
\param comp The completion string
\param desc The description of the completion
\param flags completion flags
*/
void completion_allocate( array_list_t *context,
const wchar_t *comp,
const wchar_t *desc,
int flags );
#endif

View File

@@ -9,8 +9,35 @@
# configure the build process.
#
AC_INIT(fish,1.22.0,fish-users@lists.sf.net)
AC_INIT(fish,1.23.1,fish-users@lists.sf.net)
#
# preserve configure arguments for xsel
#
conf_arg=$@
#
# List of output variables produced by this configure script
#
AC_SUBST(docdir)
AC_SUBST(HAVE_GETTEXT)
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(LIBS_SET_COLOR)
AC_SUBST(localedir)
AC_SUBST(optbindirs)
AC_SUBST(prefix)
AC_SUBST(SEQ_FALLBACK)
AC_SUBST(XSEL)
AC_SUBST(XSEL_MAN)
AC_SUBST(XSEL_BIN)
AC_SUBST(XSEL_MAN_PATH)
#
# If needed, run autoconf to regenerate the configure file
@@ -33,7 +60,7 @@ if test configure -ot configure.ac; then
fi
exit 1
else
AC_MSG_ERROR(
AC_MSG_ERROR(
[cannot find the autoconf program in your path.
This program needs to be run whenever the configure.ac file is modified.
Please install it and try again.]
@@ -58,11 +85,11 @@ if test ! -f ./config.h.in -o config.h.in -ot configure.ac; then
AC_MSG_NOTICE([running autoheader])
autoheader || exit 1
else
AC_MSG_ERROR(
AC_MSG_ERROR(
[cannot find the autoheader program in your path.
This program needs to be run whenever the configure.ac file is modified.
Please install it and try again.]
)
)
fi
else
AC_MSG_RESULT([no])
@@ -86,7 +113,7 @@ for i in /usr/pkg /sw /opt /opt/local; do
CPPFLAGS="$CPPFLAGS -I$i/include/"
CFLAGS="$CFLAGS -I$i/include/"
else
AC_MSG_RESULT(no)
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([for $i/lib library directory])
@@ -94,7 +121,7 @@ for i in /usr/pkg /sw /opt /opt/local; do
AC_MSG_RESULT(yes)
LDFLAGS="$LDFLAGS -L$i/lib/ -R$i/lib/"
else
AC_MSG_RESULT(no)
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([for $i/bin command directory])
@@ -102,16 +129,14 @@ for i in /usr/pkg /sw /opt /opt/local; do
AC_MSG_RESULT(yes)
optbindirs="$optbindirs $i/bin"
else
AC_MSG_RESULT(no)
AC_MSG_RESULT(no)
fi
done
AC_SUBST( optbindirs, $optbindirs )
#
# Tell autoconf to create config.h header
# Tell autoconf to create config.h header
#
AC_CONFIG_HEADERS(config.h)
@@ -125,8 +150,8 @@ AH_BOTTOM([#if __GNUC__ >= 3
#define __warn_unused __attribute__ ((warn_unused_result))
#define __sentinel __attribute__ ((sentinel))
#else
#define __warn_unused
#define __sentinel
#define __warn_unused
#define __sentinel
#endif])
@@ -134,11 +159,13 @@ AH_BOTTOM([#if __GNUC__ >= 3
# Set up various programs needed for install
#
AC_PROG_CC
# Here we look for c99 before cc as Sun Studio compiler supports c99
# through the c99 binary.
AC_PROG_CC([gcc c99 cc])
AC_PROG_CPP
AC_PROG_INSTALL
#
# Check for seq command. If missing, make sure fallback shellscript
# implementation is installed.
@@ -147,76 +174,127 @@ AC_PROG_INSTALL
AC_CHECK_PROG( SEQ_FALLBACK, seq, [ ], [seq])
if test "$SEQ_FALLBACK"; then
#
# We already have seq. Check if the seq version is installed by an
# earlier fish version. If it is, we'll replace it.
#
file=`which seq`
if test -f "$file"; then
AC_MSG_CHECKING([if seq comes from a previous fish version])
shebang=`grep "\(^#!/.*/fish\|^#!/usr/bin/env fish\)" $file`
if test "$shebang"; then
SEQ_FALLBACK=seq
AC_MSG_RESULT(yes, replace it)
else
AC_MSG_RESULT(no, keep it)
fi
fi
fi
#
# Optionally drop xsel command
#
AC_ARG_WITH(
xsel,
AC_ARG_WITH(
xsel,
AC_HELP_STRING(
[--without-xsel],
[do not build the xsel program needed for X clipboard integration]
[do not build the xsel program needed for X clipboard integration.
If build xsel, it will be configured with the same options as fish.]
),
[xsel=$withval],
[xsel=with_xsel]
[xsel=with_xsel]
)
if [[ "$xsel" = "with_xsel" ]]; then
AC_SUBST( XSEL,[xsel-0.9.6/xsel])
AC_SUBST( XSEL_MAN,[xsel.1x])
AC_SUBST( XSEL_MAN_PATH,[xsel-0.9.6/xsel.1x])
else
AC_SUBST( XSEL,[ ])
AC_SUBST( XSEL_MAN,[ ])
AC_SUBST( XSEL_MAN_PATH,[ ])
XSEL=xsel-1.2.0
XSEL_BIN=$XSEL/xsel
XSEL_MAN=xsel.1x
XSEL_MAN_PATH=$XSEL/xsel.1x
fi
#
# Optionally drop gettext support
#
AC_ARG_WITH(
gettext,
AC_HELP_STRING(
[--without-gettext],
[do not translate messages, even if gettext is available]
),
[local_gettext=$withval],
[local_gettext=yes]
)
if test x$local_gettext != xno; then
AC_DEFINE([USE_GETTEXT],[1],[Perform string translations with gettext])
fi
#
# Test if the compiler accepts the -std=c99 flag. If so, using it
# increases the odds of correct compilation, since we want to use the
# *wprintf functions, which where defined in C99.
# *wprintf functions, which where defined in C99.
#
# NOTE: Never versions of autoconf has AC_CHECK_PROG_CC_C99
#
XCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=c99"
XCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -std=c99"
AC_MSG_CHECKING(if -std=c99 works)
if test "$CC" != "c99"; then
XCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=c99"
XCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -std=c99"
AC_MSG_CHECKING(if -std=c99 works)
AC_CACHE_VAL(
local_cv_has__std_c99,
[
AC_TRY_RUN(
[
#include <stdlib.h>
#include <stdio.h>
AC_CACHE_VAL(
local_cv_has__std_c99,
[
AC_TRY_RUN(
[
#include <stdlib.h>
#include <stdio.h>
int main()
{
return 0;
}
],
local_cv_has__std_c99=yes,
local_cv_has__std_c99=no,
)
]
)
int main()
{
return 0;
}
],
local_cv_has__std_c99=yes,
local_cv_has__std_c99=no,
)
]
)
AC_MSG_RESULT($local_cv_has__std_c99)
case x$local_cv_has__std_c99 in
xno)
CFLAGS="$XCFLAGS"
CPPFLAGS="$XCPPFLAGS" ;;
esac
AC_MSG_RESULT($local_cv_has__std_c99)
case x$local_cv_has__std_c99 in
xno)
CFLAGS="$XCFLAGS"
CPPFLAGS="$XCPPFLAGS" ;;
esac
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
# other systems, this should do nothing. (Hopefully)
#
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64"
#
# If we are using gcc, set some flags that increase the odds of the
# compiler producing a working binary...
#
if test "$CC" = gcc; then
if test "$GCC" = yes; then
#
# -fno-optimize-sibling-calls seems to work around a bug where
@@ -237,6 +315,12 @@ if test "$CC" = gcc; then
CFLAGS="$CFLAGS -Wall"
#
# This is needed in order to get the really cool backtraces
#
LDFLAGS_FISH="$LDFLAGS_FISH -rdynamic"
fi
@@ -262,9 +346,9 @@ AC_RUN_IFELSE(
return STATUS;
]
)
],
[glibc=yes],
[glibc=no]
],
[glibc=yes],
[glibc=no]
)
if test "$glibc" = yes; then
@@ -297,7 +381,7 @@ fi
AC_CANONICAL_TARGET
if test $target_cpu = powerpc; then
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
AC_DEFINE([TPUTS_KLUDGE],[1],[Evil kludge to get Power based machines to work])
fi
@@ -307,7 +391,7 @@ fi
AC_MSG_CHECKING([if we are under Solaris])
case $target_os in
solaris*)
solaris*)
AC_DEFINE( __EXTENSIONS__, 1, [Macro to enable additional prototypes under Solaris])
AC_MSG_RESULT(yes)
;;
@@ -316,6 +400,34 @@ 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
@@ -323,7 +435,7 @@ esac
AC_MSG_CHECKING([if we are under BSD])
case $target_os in
*bsd*)
*bsd*)
AC_DEFINE( __BSD_VISIBLE, 1, [Macro to enable additional prototypes under BSD])
AC_DEFINE( _NETBSD_SOURCE, 1, [Macro to enable additional prototypes under BSD])
AC_MSG_RESULT(yes)
@@ -342,10 +454,7 @@ esac
#
if [[ "$prefix" = NONE ]]; then
export prefix=/usr/local
AC_SUBST( prefix, /usr/local)
else
AC_SUBST( prefix, [$prefix])
prefix=/usr/local
fi
@@ -357,9 +466,9 @@ fi
AC_ARG_VAR( [docdir], [Documentation direcotry] )
if test -z $docdir; then
AC_SUBST(docdir, [$datadir/doc/fish] )
docdir=$datadir/doc/fish
else
AC_SUBST(docdir, [$docdir])
docdir=$docdir
fi
@@ -368,7 +477,7 @@ fi
# installed.
#
AC_SUBST( [localedir], [$datadir/locale])
localedir=$datadir/locale
#
@@ -385,38 +494,125 @@ AC_CHECK_FILES([/proc/self/stat])
#
AC_DEFINE(
[HAVE_TRANSLATE_H],
[HAVE_TRANSLATE_H],
[1],
[Define to 1 if the wgettext function should be used for translating strings.]
)
#
# Check presense of various libraries
# Check presense of various libraries. This is done on a per-binary
# level, since including various extra libraries in all binaries only
# because thay are used by some of them can cause extra bloat and
# slower compiles when developing fish.
#
AC_SEARCH_LIBS( gettext, intl,,)
# 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( 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_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_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 for libraries needed by set_color
#
LIBS_COMMON=$LIBS
LIBS="$LIBS_SHARED"
if test x$local_gettext != xno; then
AC_SEARCH_LIBS( gettext, intl,,)
fi
LIBS_SET_COLOR=$LIBS
LIBS=$LIBS_COMMON
#
# Check presense of various header files
#
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h sys/termios.h])
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h sys/termios.h libintl.h execinfo.h])
AC_CHECK_HEADER(
[regex.h],
[
AC_DEFINE(
[HAVE_REGEX_H],
[1],
[HAVE_REGEX_H],
[1],
[Define to 1 if you have the <regex.h> header file.]
)],
[AC_MSG_ERROR([Could not find the header regex.h, needed to build fish])
]
)
],
[AC_MSG_ERROR([Could not find the header regex.h, needed to build fish])]
)
@@ -424,7 +620,7 @@ AC_CHECK_HEADER(
# On some platforms (Solaris 10) adding -std=c99 in turn requires that
# _POSIX_C_SOURCE be defined to 200112L otherwise several
# POSIX-specific, non-ISO-C99 types/prototypes are made unavailable
# e.g. siginfo_t. Defining _XOPEN_SOURCE to 600 is compatible with
# e.g. siginfo_t. Defining _XOPEN_SOURCE to 600 is compatible with
# the _POSIX_C_SOURCE value and provides a little assurance that
# extension functions' prototypes are available, e.g. killpg().
#
@@ -509,10 +705,10 @@ for i in "" "-D_POSIX_C_SOURCE=200112L" "-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=2
/* Extended-POSIX: might be unhidden by _XOPEN_SOURCE. */
ret += killpg( 0, 0 );
/* Non-standard: might be hidden by the macros. */
{
{
struct winsize termsize;
ret += (int)(void *)&termsize;
ret += SIGWINCH + TIOCGWINSZ + SIGIO;
ret += SIGWINCH + TIOCGWINSZ + SIGIO;
}
return ret;
@@ -546,17 +742,19 @@ fi
# Check for presense of various functions used by fish
#
AC_CHECK_FUNCS( gettext wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
AC_CHECK_FUNCS( wcsdup wcsndup wcslen wcscasecmp wcsncasecmp fwprintf )
AC_CHECK_FUNCS( futimes wcwidth wcswidth wcstok fputwc fgetwc )
AC_CHECK_FUNCS( wcstol dcgettext wcslcat wcslcpy lrand48_r killpg)
AC_CHECK_FUNCS( wcstol wcslcat wcslcpy lrand48_r killpg gettext )
AC_CHECK_FUNCS( dcgettext backtrace backtrace_symbols sysconf )
#
# The Makefile also needs to know if we have gettext, so it knows if
# the translations should be installed.
#
AC_CHECK_FUNC( gettext, AC_SUBST( HAVE_GETTEXT, 1 ), AC_SUBST( HAVE_GETTEXT, 0 ) )
if test x$local_gettext != xno; then
AC_CHECK_FUNC( gettext, HAVE_GETTEXT=1, HAVE_GETTEXT=0 )
fi
#
# Here follows a list of small programs used to test for various
@@ -578,22 +776,22 @@ AC_RUN_IFELSE(
#include <stdlib.h>
],
[
int status;
char *res;
res = realpath( "somefile", 0 );
status = !(res != 0 || errno == ENOENT);
int status;
char *res;
res = realpath( "somefile", 0 );
status = !(res != 0 || errno == ENOENT);
exit( status );
]
)
],
[have_realpath_null=yes],
[have_realpath_null=no]
],
[have_realpath_null=yes],
[have_realpath_null=no]
)
if test "$have_realpath_null" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(
[HAVE_REALPATH_NULL],
[HAVE_REALPATH_NULL],
[1],
[Define to 1 if realpath accepts null for its second argument.]
)
@@ -620,15 +818,15 @@ AC_LINK_IFELSE(
#endif
],
[
struct winsize termsize = {0};
struct winsize termsize = {0};
TIOCGWINSZ;
]
)
],
],
[
AC_MSG_RESULT(yes);
AC_MSG_RESULT(yes);
AC_DEFINE([HAVE_WINSIZE], [1], [Define to 1 if the winsize struct and TIOCGWINSZ macro exist])
],
],
[
AC_MSG_RESULT(no)
]
@@ -658,13 +856,13 @@ if test "$ac_cv_func_fwprintf" = yes; then
]
)
],
[
[
AC_MSG_RESULT(no)
],
[
[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_BROKEN_FWPRINTF], [1], [Define to 1 one if the implemented fwprintf is broken])
]
]
)
fi
@@ -680,21 +878,46 @@ AC_TRY_LINK(
],
[
extern int _nl_msg_cat_cntr;
int tmp = _nl_msg_cat_cntr;
int tmp = _nl_msg_cat_cntr;
exit(tmp);
],
have__nl_msg_cat_cntr=yes,
have__nl_msg_cat_cntr=yes,
have__nl_msg_cat_cntr=no
)
if test "$have__nl_msg_cat_cntr" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(
[HAVE__NL_MSG_CAT_CNTR],
[HAVE__NL_MSG_CAT_CNTR],
[1],
[Define to 1 if the _nl_msg_cat_cntr symbol is exported.]
)
)
else
AC_MSG_RESULT(no)
AC_MSG_RESULT(no)
fi
# Check for __environ symbol
AC_MSG_CHECKING([for __environ symbol])
AC_TRY_LINK(
[
#include <unistd.h>
],
[
extern char **__environ;
char **tmp = __environ;
exit(tmp!=0);
],
have___environ=yes,
have___environ=no
)
if test "$have___environ" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(
[HAVE___ENVIRON],
[1],
[Define to 1 if the __environ symbol is exported.]
)
else
AC_MSG_RESULT(no)
fi
# Check if getopt_long exists and works
@@ -709,28 +932,28 @@ AC_TRY_LINK(
static struct option
long_options[] =
{
0, 0, 0, 0
0, 0, 0, 0
}
;
int opt = getopt_long( 0,
0,
0,
long_options,
0,
long_options,
0 );
],
have_working_getopt_long=yes,
have_working_getopt_long=yes,
have_working_getopt_long=no
)
if test "$have_working_getopt_long" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(
[HAVE_WORKING_GETOPT_LONG],
[HAVE_WORKING_GETOPT_LONG],
[1],
[Define to 1 if getopt_long exists and works.]
)
)
else
AC_MSG_RESULT(no)
AC_MSG_RESULT(no)
fi
# Check if del_curterm is broken - in that case we redefine
@@ -752,7 +975,7 @@ case $target_os in
esac
# Tell the world what we know
AC_CONFIG_FILES([Makefile fish.spec doc_src/Doxyfile seq])
AC_CONFIG_FILES([Makefile fish.spec Doxyfile.help seq])
AC_OUTPUT
if test ! x$local_found_posix_switch = xyes; then
@@ -760,6 +983,12 @@ if test ! x$local_found_posix_switch = xyes; then
echo "Some fish features may be disabled."
fi
if [[ "$xsel" = "with_xsel" ]]; then
echo "Now configure xsel with $conf_arg"
rm -rf $XSEL
tar xf $XSEL.tar.gz
cd $XSEL && ./configure $conf_arg
fi
echo "fish is now configured."
echo "Use 'make' and 'make install' to build and install fish."

24
count.c
View File

@@ -1,24 +0,0 @@
/** \file count.c
The length command, used for determining the number of items in an
environment variable array.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
/**
The main function. Does nothing but return the number of arguments.
This command, unlike all other fish commands, does not feature a -h
or --help option. This is because we want to avoid errors on arrays
that have -h or --help as entries, which is very common when
parsing options, etc. For this reason, the main fish binary does a
check and prints help usage if -h or --help is explicitly given to
the command, but not if it is the contents of a variable.
*/
int main( int argc, char **argv )
{
printf( "%d\n", argc-1 );
return argc==1;
}

121
create_wajig_completions.py Executable file
View File

@@ -0,0 +1,121 @@
#!/usr/bin/env python
# -*- python -*-
# Program to generate fish completion function for wajig.
# It runs 'wajig command' and analyzes the output to build a
# completion file which it writes to stdout.
# To use the result, direct stdout to
# ~/.fish.d/completions/wajig.fish.
# Author Reuben Thomas, from Don Rozenberg's bash_completion.py and
# fish's apt-get.fish.
import os
import re
import pprint
pp = pprint.PrettyPrinter()
def escape_quotes(s):
return re.sub('\'', '\\\'', s)
# Run wajig command
f = os.popen('wajig commands', 'r')
lines = f.readlines()
option_patt = r'^-([a-z]*)\|--([a-z]*) +([^ ].*)'
option_patt_r = re.compile(option_patt)
command_patt = r'^([a-z-]*) +([^ ].*)'
command_patt_r = re.compile(command_patt)
os_str = []
os_str.append('')
ol_str = []
ol_str.append('')
oh_str = []
oh_str.append('')
o_i = 0
c_str = []
c_str.append('')
ch_str = []
ch_str.append('')
c_i = 0
for l in lines:
l = l.strip()
if l == '' or l.find(':') > -1 or l.find('Run') == 0:
continue
if l.find('-') == 0:
mo = option_patt_r.search(l)
if mo == None:
continue
os_str[o_i] = mo.group(1)
os_str.append('')
ol_str[o_i] = mo.group(2)
ol_str.append('')
oh_str[o_i] = escape_quotes(mo.group(3))
oh_str.append('')
o_i += 1
else:
mo = command_patt_r.search(l)
if mo == None:
continue
c_str[c_i] = mo.group(1)
c_str.append('')
ch_str[c_i] = escape_quotes(mo.group(2))
ch_str.append('')
c_i += 1
# For debugging, print the commands and options.
#print
#pp.pprint(c_str)
#print
#pp.pprint(os_str)
#print
#pp.pprint(ol_str)
part1 = '''function __fish_wajig_no_subcommand -d (N_ 'Test if wajig has yet to be given the subcommand')
for i in (commandline -opc)
if contains -- $i'''
part2 = '''
return 1
end
end
return 0
end
function __fish_wajig_use_package -d (N_ 'Test if wajig command should have packages as potential completion')
for i in (commandline -opc)
if contains -- $i contains bug build build-depend changelog dependents describe detail hold install installr installrs installs list list-files news package purge purge-depend readme recursive recommended reconfigure reinstall remove remove-depend repackage show showinstall showremove showupgrade size sizes source suggested unhold upgrade versions whatis
return 0
end
end
return 1
end
complete -c wajig -n '__fish_wajig_use_package' -a '(__fish_print_packages)' -d (N_ 'Package')'''
wajig = part1
#add the commands.
for i in range(0, len(c_str) - 1):
wajig = "%s %s" % (wajig, c_str[i])
#add part2
wajig = "%s%s" % (wajig, part2)
#add the options.
wajig = "%s%s" % (wajig, os_str[0].lstrip())
for i in range(1, len(os_str) - 1):
wajig = "%s\ncomplete -c apt-get -s %s -l %s -d (N_ '%s')" % (wajig, os_str[i], ol_str[i], oh_str[i])
#add the commands.
for i in range(0, len(c_str) - 1):
wajig = "%s\ncomplete -f -n '__fish_wajig_no_subcommand' -c wajig -a '%s' -d(N_ '%s')" % (wajig, c_str[i], ch_str[i])
#print it all
print wajig

18
doc_src/alias.txt Normal file
View File

@@ -0,0 +1,18 @@
\section alias alias - create a function
\subsection alias-synopsis Synopsis
<pre>alias NAME DEFINITION
alias NAME=DEFINITION</pre>
\subsection alias-description Description
Alias is a shellscript wrapper around 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>.
Alias does not keep track of which functions have been defined using
alias, nor does it allow erasing of aliases.
- NAME is the name of the function to define
- DEFINITION is the body of the function. The string " $argv" will be appended to the body.

View File

@@ -10,10 +10,14 @@ 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
The following code runs the \c make command to build a program, if the
build succceds, the program is installed. If either step fails,
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

View File

@@ -23,11 +23,11 @@ scope, they will be automatically deleted when the block ends.
<pre>
begin
set -x PIRATE Yarrr
set -l PIRATE Yarrr
...
end
# This will not output anything, since PIRATE went out of scope at the end of
# the block and was killed
# This will not output anything, since the PIRATE variable went out
# of scope at the end of the block
echo $PIRATE
</pre>
@@ -37,7 +37,7 @@ In the following code, all output is redirected to the file out.html.
begin
echo $xml_header
echo $html_header
if test -e $file
if test -e $file
...
end
...

View File

@@ -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
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>.
\subsection bg-example Example

View File

@@ -1,23 +1,60 @@
\section bind bind - handle key bindings
\section bind bind - handle fish key bindings
\subsection bind-synopsis Synopsis
<tt>bind [OPTIONS] [BINDINGS...]</tt>
The <tt>bind</tt> builtin causes fish to add the readline style bindings specified by BINDINGS to the list of key bindings, as if they appeared in your <tt>~/.fish_inputrc</tt> file.
For more information on the syntax keyboard bindings, use <tt>man
readline</tt> to access the readline documentation. The availiable commands
are listed in the <a href="index.html#editor">Command Line Editor</a> section
of the fish manual - but you may also use any fish command! To write such
commands, see the <a href="#commandline">commandline</a> builtin. It's good
practice to put the code into a <tt><a href="#function">function</a> -b</tt>
and bind to the function name.
<tt>bind [OPTIONS] SEQUENCE COMMAND</tt>
\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
<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

10
doc_src/breakpoint.txt Normal file
View File

@@ -0,0 +1,10 @@
\section breakpoint breakpoint - Launch debug mode
\subsection breakpoint-synopsis Synopsis
<tt>breakpoint</tt>
\subsection breakpoint-description Description
The \c breakpoint builtin is used to halt a running script and launch
an interactive debug prompt.

View File

@@ -7,7 +7,7 @@
- <tt>-n</tt> or <tt>--names</tt> List the names of all defined builtins
Prefixing a command with the word 'builtin' forces fish to ignore any aliases with the same name.
Prefixing a command with the word 'builtin' forces fish to ignore any functions with the same name.
\subsection builtin-example Example

View File

@@ -19,7 +19,7 @@ regular wildcard expansion using filenames.
Note that fish does not fall through on case statements. Though the
syntax may look a bit like C switch statements, it behaves more like
the case stamantes of traditional shells.
the case statements of traditional shells.
Also note that command substitutions in a case statement will be
evaluated even if it's body is not taken. This may seem

View File

@@ -4,11 +4,11 @@
<tt>command COMMANDNAME [OPTIONS...]</tt>
\subsection command-description Description
prefixing a command with the word 'command' forces fish to ignore any aliases or builtins with the same name.
prefixing a command with the word 'command' forces fish to ignore any functions or builtins with the same name.
\subsection command-example Example
<tt>command ls</tt>
causes fish to execute the ls program, even if there exists a 'ls' alias.
causes fish to execute the ls program, even if there exists a 'ls' function.

View File

@@ -7,20 +7,22 @@
- \c CMD is the new value of the commandline. If unspecified, the
current value of the commandline is written to standard output.
current value of the commandline is written to standard output. All
output from the commandline builtin is escaped, i.e. quotes are
removed, backslash escapes are expanded, etc..
The following switches change what the commandline builtin does
- \c -C or \c --cursor set or get the current cursor position, not
- \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
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 can not 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 keypresses are read.
actual key presses are read.
The following switches change the way \c commandline updates the
@@ -39,10 +41,10 @@ or updated
- \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.
- \c -t or \c --current-token select the current token.
The following switch changes the way \c commandline prints the current
commandline buffer
commandline buffer
- \c -c or \c --cut-at-cursor only print selection up until the
current cursor position

6
doc_src/commands.hdr.in Normal file
View File

@@ -0,0 +1,6 @@
/** \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@
*/

View File

@@ -6,7 +6,7 @@
\subsection complete-description Description
For an introduction to how to specify completions, see the section <a
href='index.html#completions-own'>Writing your own completions</a> of
href='index.html#completion-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
@@ -21,7 +21,8 @@ the fish manual.
- <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>--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>
Command specific tab-completions in \c fish are based on the notion

View File

@@ -5,17 +5,18 @@
\subsection count-description Description
<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, but this is not the only potential usage for
the count command.
The <tt>count</tt> builtin 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, but this is not the only
potential usage for the count command.
The count command does not accept any options, not even '-h'. This way
the user does not have to worry about an array containing elements
such as dashes. \c fish performs a special check when invoking the
count program, and if the user uses a help option, this help page is
count command, and if the user uses a help option, this help page is
displayed, but if a help option is contained inside of a variable or
is the result of expansion, it will be passed on to the count program.
is the result of expansion, it will simply be counted like any other
argument.
Count exits with a non-zero exit status if no arguments where passed
to it, with zero otherwise.

View File

@@ -7,8 +7,8 @@ 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.
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.
@@ -33,7 +33,7 @@ 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.
- 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 \$''.
@@ -57,14 +57,14 @@ 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
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
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
@@ -122,8 +122,8 @@ 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
- 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
@@ -147,7 +147,7 @@ until the next time she/he uses the same program.
Examples:
- Everything should be tab-completable, and every tab completion should have a description
- 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.

View File

@@ -3,6 +3,6 @@
\subsection dirh-synopsis Synopsis
<tt>dirh</tt>
\subsection dirh-description Description
\subsection dirh-description Description
<tt>dirh</tt> prints the current directory history. The current position in the
history is highlighted using <tt>$fish_color_history_current</tt>.

View File

@@ -3,5 +3,5 @@
\subsection dirs-synopsis Synopsis
<tt>dirs</tt>
\subsection dirs-description Description
\subsection dirs-description Description
<tt>dirs</tt> prints the current directory stack.

View File

@@ -13,5 +13,5 @@ status is 0, the commands COMMANDS_TRUE will execute. If it is not 0 and
The command <tt>if test -f foo.txt; echo foo.txt exists; else; echo foo.txt does not exist; end</tt>
will print <tt>foo.txt exists</tt> if the file foo.txt
exists and is a regular file, otherwise it will print
exists and is a regular file, otherwise it will print
<tt>foo.txt does not exist</tt>.

19
doc_src/emit.txt Normal file
View File

@@ -0,0 +1,19 @@
\section emit emit - Emit a generic event
\subsection block-synopsis Synopsis
<tt>emit EVENT_NAME</tt>
\subsection emit-description Description
The emit builtin fires a generic fish event. Such events can be caught by special functions called event handlers.
\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.
<pre>function event_test --on-event test_event
echo event test!!!
end
emit test_event</pre>

View File

@@ -1,10 +1,10 @@
\section eval eval - eval the specified commands
\section eval eval - evaluate the specified commands
\subsection eval-synopsis Synopsis
<tt>eval [COMMANDS...]</tt>
\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.
\subsection eval-example Example

View File

@@ -7,6 +7,7 @@
- <a href='#faq-default'>How do I make fish my default shell?</a>
- <a href='#faq-titlebar'>I'm seeing weird output before each prompt when using screen. What's wrong?</a>
- <a href='#faq-greeting'>How do I change the greeting message?</a>
- <a href='#faq-history'>Why doesn't history substitution ("!$" etc.) work?</a>
<hr>
@@ -32,7 +33,7 @@ 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.
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
@@ -55,9 +56,9 @@ feature, write <code>set CDPATH .</code> on the commandline.
If fish is unable to locate a command with a given name, 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 type
<code>~</code>.
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>
@@ -71,6 +72,8 @@ in a nonstandard location. Please contact the <a
href='mailto:fish-users@lists.sf.net'>fish mailing list</a>, and
hopefully this can be resolved.
<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
@@ -78,6 +81,23 @@ 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:
<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:
<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 <code>which fish</code> if you are unsure of where fish is installed.
Unfortunatly, 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:
@@ -85,7 +105,7 @@ Quick answer:
Run the following command in fish:
<pre>
echo function fish_title;end ~/.config/fish/config.fish
echo 'function fish_title;end' &gt; ~/.config/fish/config.fish
</pre>
Problem solved!
@@ -106,21 +126,6 @@ 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.
<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:
<code>chsh -s /usr/bin/fish</code>
You may need to adjust the above path to e.g. /usr/local/bin/fish.
You will need to log out and back in again for the change to take
effect.
<hr>
\section faq-greeting How do I change the greeting message?
@@ -132,5 +137,25 @@ the greeting use:
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.
*/

View File

@@ -7,7 +7,7 @@
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.
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>.
\subsection fg-example Example

View File

@@ -1,27 +0,0 @@
.TH fish 1 "February 25, 2005" "version @PACKAGE_VERSION@" "USER COMMANDS"
.SH NAME
fish - friendly interactive shell
.SH SYNOPSIS
.B fish
[\-h] [\-v] [\-c command] [FILE [ARGUMENTS...]]
.SH DESCRIPTION
A shell written mainly with interactive use in mind. The complete fish manuals are written in HTML format. You can find them by using the
.I
help
command from inside the fish shell.
.SH OPTIONS
.TP
\-h
display help and exit
.TP
\-c
Evaluate the specified commands instead of reading from the commandline
.TP
\-i
Specify that fish is to run in interactive mode
.TP
\-v
display version and exit
.SH AUTHOR
Axel Liljencrantz ( @PACKAGE_BUGREPORT@ )

View File

@@ -5,7 +5,9 @@ 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.
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.
@@ -16,3 +18,6 @@ A commandline shell written mainly with interactive use in mind. The full manual
- <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
exit status is 127.

17
doc_src/fish_indent.txt Normal file
View File

@@ -0,0 +1,17 @@
\section fish_indent fish_indent - indenter and prettifier
\subsection fish_indent-synopsis Synopsis
<tt>fish_indent [options]</tt>
\subsection fish_indent-description Description
\c fish_indent is used to indent or otherwise prettify a piece of fish
code. \c fish_indent reads commands from standard input and outputs
them to standard output.
\c fish_indent understands the following options:
- <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

23
doc_src/fish_prompt.txt Normal file
View File

@@ -0,0 +1,23 @@
\section fish_prompt fish_prompt - define the apperance of the command line prompt
\subsection fish_promt-synopsis Synopsis
<pre>function fish_prompt
...
end</pre>
\subsection fish_prompt-description Description
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.
\subsection fish_prompt-example Example
A simple prompt:
<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)
end
</pre>

View File

@@ -11,7 +11,7 @@ not be executed at all.
\subsection for-example Example
The command
The command
<tt>for i in foo bar baz; echo $i; end</tt>
@@ -21,5 +21,5 @@ would output:
foo
bar
baz
</pre>
</pre>

9
doc_src/funced.txt Normal file
View File

@@ -0,0 +1,9 @@
\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.

12
doc_src/funcsave.txt Normal file
View File

@@ -0,0 +1,12 @@
\section funcsave funcsave - save the definition of a function to the users autoload directory
\subsection funcsave-synopsis Synopsis
<tt>funcsave FUNCTION_NAME</tt>
\subsection funcsave-description Description
funcsave is used to save the current definition of a function to
a file which will be autoloaded 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.

View File

@@ -6,6 +6,7 @@
\subsection function-description Description
- <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)
@@ -26,6 +27,11 @@ will write <code>hello</code> whenever the user enters \c hi.
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.
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
<pre>

View File

@@ -8,6 +8,7 @@
This builtin command is used to print or erase functions.
- <code>-a</code> or <code>--all</code> list 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> 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
@@ -17,11 +18,14 @@ This builtin command is used to print or erase functions.
The default behavior of \c functions when called with no arguments,
is to print the names and definitions of all defined functions. If any
non-switch parameters are given, only the definition of the specified
functions are printed.
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.
Function copies, created with -c, will not have any event/signal/on-exit
notifications that the original may have had.
The exit status of the functions builtin is the number functions
specified in the argument list that do not exist.

View File

@@ -4,10 +4,20 @@
<tt>if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end</tt>
\subsection if-description Description
<tt>if</tt> 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
<tt>else</tt> is given, COMMANDS_FALSE will be executed. Hint: use
<a href="#begin"><tt>begin; ...; end</tt></a> for complex conditions.
<tt>if</tt> 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 <tt>else</tt> is given, 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"><tt>begin; ...; end</tt></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.
\subsection if-example Example
@@ -19,5 +29,5 @@ else
end
</pre>
will print <tt>foo.txt exists</tt> if the file foo.txt
exists and is a regular file, otherwise it will print
exists and is a regular file, otherwise it will print
<tt>foo.txt does not exist</tt>.

View File

@@ -1,3 +1,10 @@
/** \mainpage Fish user documentation
\section toc Table of contents
- <a href="index.html" name="toc-index">Fish user documentation</a>
@toc@
\section introduction Introduction
This is the documentation for \c fish, the friendly interactive
@@ -26,7 +33,7 @@ assigning variables, commands for treating a group of commands as a
single command, etc.. And every single command follows the same simple
syntax.
If you wish to find out more about the echo command used above, read
If you want to find out more about the echo command used above, read
the manual page for the echo command by writing:
<code>man echo</code>
@@ -52,7 +59,7 @@ Here is a list of some useful commands:
- \c mv, move (rename) files
- \c cp, copy files
- \c open, open files with the default application associated with each filetype
- \c less, list the contents of files
- \c less, list the contents of files
Commands and parameters are separated by the space character
(&nbsp;). Every command ends with either a newline (i.e. by pressing
@@ -63,7 +70,7 @@ A switch is a very common special type of argument. Switches almost
always start with one or more hyphens (-) and alter the way a command
operates. For example, the \c ls command usually lists all the files
and directories in the current working directory, but by using the \c
-l switch, the behaviour of ls is changed to not only display the
-l switch, the behavior of ls is changed to not only display the
filename, but also the size, permissions, owner and modification time
of each file. Switches differ between commands and are documented in
the manual page for each command. Some switches are common to most
@@ -128,18 +135,23 @@ these characters, so called escape sequences are provided. These are:
- <code>'\\\<'</code>, escapes the less than character
- <code>'\\\>'</code>, escapes the more than character
- <code>'\\^'</code>, escapes the circumflex character
- <code>'\\x<i>xx</i>'</code>, where <code><i>xx</i></code> is a hexadecimal number, escapes the ascii character with the specified value
- <code>'\\&'</code>, escapes the ampersand character
- <code>'\\;'</code>, escapes the semicolon character
- <code>'\\"'</code>, escapes the quote character
- <code>'\\''</code>, escapes the apostrophe character
- <code>'\\x<i>xx</i>'</code>, where <code><i>xx</i></code> is a hexadecimal number, escapes the ascii character with the specified value. For example, \\x9 is the tab character.
- <code>'\\X<i>xx</i>'</code>, where <code><i>xx</i></code> is a hexadecimal number, escapes a byte of data with the specified value. If you are using a mutibyte encoding, this can be used to enter invalid strings. Only use this if you know what you are doing.
- <code>'\\<i>ooo</i>'</code>, where <code><i>ooo</i></code> is an octal number, escapes the ascii character with the specified value
- <code>'\\u<i>xxxx</i>'</code>, where <code><i>xxxx</i></code> is a hexadecimal number, escapes the 16-bit unicode character with the specified value
- <code>'\\U<i>xxxxxxxx</i>'</code>, where <code><i>xxxxxxxx</i></code> is a hexadecimal number, escapes the 32-bit unicode character with the specified value
- <code>'\\<i>ooo</i>'</code>, where <code><i>ooo</i></code> is an octal number, escapes the ascii character with the specified value. For example, \\011 is the tab character.
- <code>'\\u<i>xxxx</i>'</code>, where <code><i>xxxx</i></code> is a hexadecimal number, escapes the 16-bit Unicode character with the specified value. For example, \\u9 is the tab character.
- <code>'\\U<i>xxxxxxxx</i>'</code>, where <code><i>xxxxxxxx</i></code> is a hexadecimal number, escapes the 32-bit Unicode character with the specified value. For example, \\U9 is the tab character.
- <code>'\\c<i>x</i>'</code>, where <code><i>x</i></code> is a letter of the alphabet, escapes the control sequence generated by pressing the control key and the specified letter. For example, \\ci is the tab character
\subsection redirects IO redirection
Most program use three types of input/output (IO), each represented by
a number called a file descriptor (FD). These are:
- Standard input, FD 0, for reading, defaults to reading from the keyboard.
- Standard input, FD 0, for reading, defaults to reading from the keyboard.
- Standard output, FD 1, for writing, defaults to writing to the screen.
- Standard error, FD 2, for writing errors and warnings, defaults to writing to the screen.
@@ -152,13 +164,13 @@ default through a simple mechanism called a redirection.
An example of a file redirection is <code> echo hello \>output.txt</code>,
which directs the output of the echo command to the file error.txt.
- To redirect standard input, write <code>\<SOURCE_FILE</code>
- To redirect standard output, write <code>\>DESTINATION</code>
- To redirect standard error, write <code>^DESTINATION</code>
- To redirect standard input, write <code>\<SOURCE_FILE</code>
- To redirect standard output, write <code>\>DESTINATION</code>
- To redirect standard error, write <code>^DESTINATION</code>
- To redirect standard output to a file which will be appended, write <code>\>\>DESTINATION_FILE</code>
- To redirect standard error to a file which will be appended, write <code>^^DESTINATION_FILE</code>
- To redirect standard error to a file which will be appended, write <code>^^DESTINATION_FILE</code>
<code>DESTINATION</code> can be one of the following:
<code>DESTINATION</code> can be one of the following:
- A filename. The output will be written to the specified file.
- An ampersand (\&) followed by the number of another file descriptor. The file descriptor will be a duplicate of the specified file descriptor.
@@ -174,7 +186,7 @@ Any FD can be redirected in an arbitrary way by prefixing the
redirection with the number of the FD.
- To redirect input of FD number N, write <code>N\<DESTINATION</code>
- To redirect output of FD number N, write <code>N\>DESTINATION</code>
- To redirect output of FD number N, write <code>N\>DESTINATION</code>
- To redirect output of FD number N to a file which will be appended, write <code>N\>\>DESTINATION_FILE</code>
Example: <code>echo Hello 2\>-</code> and <code>echo Hello ^-</code> are
@@ -222,7 +234,7 @@ Example:
<code>emacs \&</code>
will start the emacs text editor in the background.
will start the emacs text editor in the background.
\subsection syntax-job-control Job control
@@ -262,12 +274,31 @@ the example above, these are simply passed on to the ls command. For
more information on functions, see the documentation for the <a
href='commands.html#function'>function</a> builtin.
\subsubsection Autoloading functions
\subsubsection syntax-function-wrappers Defining wrapper functions
One of the most common used for functions is to slightly alter the
behavior of an already existing command. For example, one might want
to redefine the \c ls command to display colors. The switch for
turning on colors on GNU systems is \c '--color=auto'. A wrapper
around \c ls might look like this:
<pre>function ls
ls --color=auto $argv
end
</pre>
There are a few important things that need to be noted about wrapper
functions:
- Wrappers should always take care to add the $argv variable to the list of parameters to the wrapped command. This makes sure that if the user specifies any additional parameters to the function, they are passed on to the underlying command.
- If the wrapped command is not the first command to be called by the wrapper, it is necessary to prefix the call to the command with the word 'command' in order to tell fish that the function should not call itself, but rather a command with the same name. Failing to do so will cause infinite recursion bugs.
\subsubsection syntax-function-autoloading Autoloading functions
Functions can be defined on the commandline or in a configuration
file, but they can also be automatically loaded. This method of
defining functions has several advantages. An autoloaded function
becomes avaialble automatically to all running shells, if the function
becomes available automatically to all running shells, if the function
definition is changed, all running shells will automatically reload
the altered version, startup time and memory usage is improved, etc.
@@ -279,7 +310,7 @@ a filename consisting of the name of the function plus the suffix
The default value for \$fish_function_path is \c ~/.config/fish/functions
\c /etc/fish/functions \c /usr/share/fish/functions. The exact path
to the last two of these may be slighly different depending on what
to the last two of these may be slightly different depending on what
install path prefix was chosen at configuration time. The rationale
behind having three different directories is that the first one is for
user specific functions, the second one is for system-wide additional
@@ -293,6 +324,25 @@ definition for the specified function and nothing else, otherwise it
is possible that autoloading a function files requires that the
function already be loaded, i.e. a circular dependency.
\subsection syntax-conditional Conditional execution of code
There are four fish builtins that let you execute commands only if a
specific criterion is met. These builtins are
<a href="commands.html#if">if</a>,
<a href="commands.html#switch">switch</a>,
<a href="commands.html#and">and</a> and
<a href="commands.html#or">or</a>.
The \c switch command is used to execute one of possibly many blocks
of commands depending on the value of a string. See the documentation
for <a href="commands.html#switch">switch</a> for more information.
The other conditionals use the <a href='#variables-status'>exit
status</a> of a command to decide if a command or a block of commands
should be executed. See the documentation for
<a href="commands.html#if">if</a>, <a href="commands.html#and">and</a>
and <a href="commands.html#or">or</a> for more information.
\subsection syntax-words Some common words
This is a short explanation of some of the commonly used words in fish.
@@ -300,11 +350,11 @@ This is a short explanation of some of the commonly used words in fish.
- argument, a parameter given to a command
- builtin, a command that is implemented in the shell. Builtins are commands that are so closely tied to the shell that it is impossible to implement them as external commands.
- command, a program that the shell can run.
- function, a block of commands and arguments that can be called as if they where a single command. By using functions, it is possible to string together multiple smaller commands into one more advanced command.
- function, a block of commands that can be called as if they where a single command. By using functions, it is possible to string together multiple smaller commands into one more advanced command.
- job, a running pipeline or command
- pipeline, a set of commands stringed together so that the output of one command is the input of the next command
- redirection, a operation that changes one of the input/output streams associated with a job
- switch, a special flag sent as an argument to a command that will alter the behavious of the command. A switch almost always begins with one or two hyphens.
- switch, a special flag sent as an argument to a command that will alter the behavior of the command. A switch almost always begins with one or two hyphens.
\section help Help
@@ -326,13 +376,13 @@ shell. By tapping the tab key, the user asks \c fish to guess the rest
of the command or parameter that the user is currently typing. If \c
fish can only find one possible completion, \c fish will write it
out. If there is more than one completion, \c fish will write out the
longest common prefix that all completions have in common. If all
completions differ on the first character, a list of all possible
completions is printed. The list features descriptions of the
completions and if the list doesn't fit the screen, it is scrollable
by using the arrow keys, the page up/page down keys or the space
bar. Press any other key will exit the list and insert the pressed key
into the command line.
longest prefix that all completions have in common. If the completions
differ on the first character, a list of all possible completions is
printed. The list features descriptions of the completions and if the
list doesn't fit the screen, it is scrollable by using the arrow keys,
the page up/page down keys, the tab key or the space bar. Pressing any
other key will exit the list and insert the pressed key into the
command line.
These are the general purpose tab completions that \c fish provides:
@@ -346,19 +396,19 @@ These are the general purpose tab completions that \c fish provides:
of these completions are simple options like the \c -l option for \c
ls, but some are more advanced. The latter include:
- The programs 'man' and 'whatis' show all installed
- The programs 'man' and 'whatis' show all installed
manual pages as completions.
- The 'make' program uses all targets in the Makefile in
- The 'make' program uses all targets in the Makefile in
the current directory as completions.
- The 'mount' command uses all mount points specified in fstab as completions.
- The 'ssh' command uses all hosts in that are stored
in the known_hosts file as completions. (see the ssh documentation for more information)
- The 'ssh' command uses all hosts that are stored
in the known_hosts file as completions. (see the ssh documentation for more information)
- The 'su' command uses all users on the system as completions.
- The \c apt-get, \c rpm and \c yum commands use all installed packages as completions.
\subsection completion-own Writing your own completions
Specifying your own completions is not complicated. To specify a
Specifying your own completions is not difficult. To specify a
completion, use the \c complete command. \c complete takes
as a parameter the name of the command to specify a completion
for. For example, to add a completion for the program \c myprog, one
@@ -369,7 +419,7 @@ this can be specified as <code>complete -c myprog -a 'start
stop'</code>. The argument to the \c -a switch is always a single
string. At completion time, it will be tokenized on spaces and tabs,
and variable expansion, command substitution and other forms of
parameter expansion will take place.
parameter expansion will take place.
Fish has a special syntax to support specifying switches accepted by a
command. The switches \c -s, \c -l and \c -o are used to specify a
@@ -393,6 +443,65 @@ For examples of how to write your own complex completions, study the
completions in /usr/share/fish/completions. (The exact path depends on
your chosen installation prefix and may be slightly different)
\subsection completion-func Useful functions for writing completions
Fish ships with several functions that are very useful when writing
command specific completions. Most of these functions name begins with
the string '__fish_'. Such functions are internal to fish and their
name and interface may change in future fish versions. Still, some of
them may be very useful when writing completions. A few of these
functions are described here. Be aware that they may be removed or
changed in future versions of fish.
Functions beginning with the string '__fish_print_' print a
newline-separated list of strings. For example,
__fish_print_filesystems prints a list of all known file systems. Functions
beginning with '__fish_complete_' print out a newline separated list of
completions with descriptions. The description is separated from the
completion by a tab character.
<pre>__fish_complete_directories STRING DESCRIPTION</pre>
performs path completion on STRING, allowing only directories, and giving them the description DESCRIPTION.
<pre>__fish_complete_groups</pre>
prints a list of all user groups with the groups members as description.
<pre>__fish_complete_pids</pre>
prints a list of all processes IDs with the command name as description.
<pre>__fish_complete_suffix SUFFIX</pre>
performs file completion allowing only files ending in SUFFIX. The mimetype database is used to find a suitable description.
<pre>__fish_complete_users</pre>
prints a list of all users with their full name as description.
<pre>__fish_print_filesystems</pre>
prints a list of all known file systems. Currently, this is a static
list, and not dependent on what file systems the host operating system
actually understands.
<pre>__fish_print_hostnames</pre>
prints a list of all known hostnames. This functions searches the
fstab for nfs servers, ssh for known hosts and checks the /etc/hosts file.
<pre>__fish_print_interfaces</pre>
prints a list of all known network interfaces.
<pre>__fish_print_packages</pre>
prints a list of all installed packages. This function currently handles
Debian, rpm and Gentoo packages.
\subsection completion-path Where to put completions
Completions can be defined on the commandline or in a configuration
@@ -404,7 +513,7 @@ of the name of the command to complete and the suffix '.fish'.
The default value for \$fish_complete_path is ~/.config/fish/completions,
/etc/fish/completions and /usr/share/fish/completions. The exact
path to the last two of these may be slighly different depending on
path to the last two of these may be slightly different depending on
what install path prefix was chosen at configuration time. If a
suitable file is found in one of these directories, it will be
automatically loaded and the search will be stopped. The rationale
@@ -414,26 +523,38 @@ completions and the last one is for default fish completions.
If you have written new completions for a common
Unix command, please consider sharing your work by sending it to <a
href='mailto: fish-users@lists.sf.net'>the fish mailinglist</a>.
href='mailto: fish-users@lists.sf.net'>the fish mailing list</a>.
\section expand Parameter expansion (Globbing)
When an argument for a program is given on the commandline, it
undergoes the process of parameter expansion before it is sent on to
the command. There are many ways in which the user can specify a
parameter to be expanded. These include:
the command. Parameter expansion is a powerful set of mechanisms that
allow you to expand the parameter in various ways, including
performing wildcard matching on files, inserting the value of
environment variables into the parameter or even using the output of
another command as a parameter list.
\subsection expand-wildcard Wildcards
\subsection expand-wildcard Wildcards
If a star (*) or a question mark (?) is present in the parameter, \c
fish attempts to match the given parameter to any files in such a
way that:
- '?' can match any character except '/'.
- '?' can match any single character except '/'.
- '*' can match any string of characters not containing '/'. This includes matching an empty string.
- '**' matches any string of characters. This includes matching an empty string. The string may include the '/' character but does not need to.
Wildcard matches are sorted case insensitively. When sorting matches
containing numbers, consecutive digits are considered to be one
element, so that the strings '1' '5' and '12' would be sorted in the
order given.
File names beginning with a dot are not considered when wildcarding
unless a dot is specifically given as the first character of the file
name.
Examples:
<code>a*</code> matches any files beginning with an 'a' in the current directory.
@@ -451,7 +572,7 @@ warning will also be printed.
\subsection expand-command-substitution Command substitution
If a parameter contains a set of parenthesis, the text enclosed by the
parenthesis will be interpreted as a list of commands. Om expansion,
parenthesis will be interpreted as a list of commands. On expansion,
this list is executed, and substituted by the output. If the output is
more than one line long, each line will be expanded to a new
parameter.
@@ -492,7 +613,7 @@ href="#variables"> Environment variables</a> section.
Example:
<code> echo \$HOME</code> prints the home directory of the current
user.
user.
If you wish to combine environment variables with text, you can
encase the variables within braces to embed a variable inside running
@@ -503,9 +624,8 @@ The {$USER}san syntax might need a bit of an elaboration. Posix
shells allow you to specify a variable name using '$VARNAME' or
'${VARNAME}'. Fish supports the former, and has no support whatsoever
for the latter or anything like it. So what is '{$VARNAME}' then?
Well, '{WHATEVER}' is <a href='#brace'>brace expansion</a>, identical
to that supported by e.g. bash. 'a{b,c}d' -> 'abd acd' works
both in bash and on fish. So '{$VARNAME}' is a bracket-expansion with
Well, '{WHATEVER}' is <a href='#brace'>brace expansion</a>, e.g. 'a{b,c}d' -> 'abd acd'.
So '{$VARNAME}' is a bracket-expansion with
only a single element, i.e. it becomes expanded to '$VARNAME', which
will be variable expanded to the value of the variable 'VARNAME'. So
you might think that the brackets don't actually do anything, and that
@@ -546,11 +666,11 @@ end
</pre>
The above code demonstrates how to use multiple '$' symbols to expand
the value of a variable as a variable name. One can simply think of
the value of a variable as a variable name. One can think of
the $-symbol as a variable dereference operator. When using this
feature together with array brackets, the brackets will always match
the innermost $ dereference. Thus, $$foo[5] will always mean the fift
element of the foo variable should be dereferenced and never that the fift
the innermost $ dereference. Thus, $$foo[5] will always mean the fifth
element of the foo variable should be dereferenced and never that the fifth
element of the doubly dereferenced variable foo. The latter can
instead be expressed as $$foo[1][5].
@@ -567,12 +687,12 @@ The \% (percent) character at the beginning of a parameter followed by
a string is expanded into a process id. The following expansions are
performed:
- If the string is the entire word \c self, the shells pid is the result
- If the string is the entire word \c self, the shells pid is the result.
- Otherwise, if the string is the id of a job, the result is the process
group id of the job.
- Otherwise, if any child processes match the specified string, their
pids are the result of the expansion.
- Otherwise, if any processes owned by the user match the specified
- Otherwise, if any child processes match the specified string, their
pids are the result of the expansion.
- Otherwise, if any processes owned by the user match the specified
string, their pids are the result of the expansion.
This form of expansion is useful for commands like kill and fg, which
@@ -593,6 +713,17 @@ All of the above expansions can be combined. If several expansions
result in more than one parameter, all possible combinations are
created.
When combining multiple parameter expansions, expansions are performed in the following order:
- Command substitutions
- Variable expansions
- Bracket expansion
- Pid expansion
- Wildcard expansion
Expansions are performed from right to left, nested bracket expansions
are performed from the inside and out.
Example:
If the current directory contains the files 'foo' and 'bar', the command
@@ -611,19 +742,20 @@ expansion</a>.
To set a variable value, use the <a href="commands.html#set"> \c set
command</a>.
Example:
Example:
To set the variable \c smurf to the value \c blue, use the command
<code>set smurf blue</code>.
To set the variable \c smurf_color to the value \c blue, use the command
<code>set smurf_color blue</code>.
After a variable has been set, you can use the value of a variable in
the shell through <a href="expand-variable">variable expansion</a>.
Example:
To use the value of a the variable \c smurf, write $ (dollar symbol)
To use the value of the variable \c smurf, write $ (dollar symbol)
followed by the name of the variable, like <code>echo Smurfs are
$smurf</code>, which would print the result 'Smurfs are blue'.
usually $smurf_color</code>, which would print the result 'Smurfs are
usually blue'.
\subsection variables-scope Variable scope
@@ -725,7 +857,7 @@ 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 global or local and has never before been defined, the variable will not be exported.
-# If a variable is not explicitly set to be either exported or not exported and has never before been defined, the variable will not be exported.
\subsection variables-arrays Arrays
@@ -739,8 +871,8 @@ echo $PATH[3]
</pre>
Note that array indices start at 1 in fish, not 0, as is more common
in other languages. This is because many common unix tools like seq
are more suited to such use.
in other languages. This is because many common Unix tools like seq
are more suited to such use.
If you do not use any brackets, all the elements of the array will be
written as separate items. This means you can easily iterate over an
@@ -783,7 +915,7 @@ The user can change the settings of \c fish by changing the values of
certain environment variables.
- \c BROWSER, which is the users preferred web browser. If this variable is set, fish will use the specified browser instead of the system default browser to display the fish documentation.
- \c CDPATH, which is an array of directories in which to search for the new directory for the \c cd builtin.
- \c CDPATH, which is an array of directories in which to search for the new directory for the \c cd builtin. The fish init files defined CDPATH to be a universal variable with the values . and ~.
- A large number of variable starting with the prefixes \c fish_color and \c fish_pager_color. See <a href='#variables-color'>Variables for changing highlighting colors</a> for more information.
- \c fish_greeting, which is the greeting message printed on startup.
- \c LANG, \c LC_ALL, \c LC_COLLATE, \c LC_CTYPE, \c LC_MESSAGES, \c LC_MONETARY, \c LC_NUMERIC and \c LC_TIME set the language option for the shell and subprograms. See the section <a href='#variables-locale'>Locale variables</a> for more information.
@@ -792,31 +924,39 @@ certain environment variables.
\c fish also sends additional information to the user through the
values of certain environment variables. The user can not change the
values of most of these variables.
values of most of these variables.
- \c _, which is the name of the currently running command.
- \c argv, which is an array of arguments to the shell or function. \c argv is only defined when inside a function call, or if fish was invoked with a list of arguments, like 'fish myscript.fish foo bar'. This variable can be changed by the user.
- \c history, which is an array containing the last commands that where entered.
- \c HOME, which is the users home directory. This variable can only be changed by the root user.
- \c PWD, which is the current working directory.
- \c status, which is the exit status of the last foreground job to exit.
- \c PWD, which is the current working directory.
- \c status, which is the exit status of the last foreground job to exit. If the job was terminated through a signal, the exit status will be 128 plus the signal number.
- \c USER, which is the username. This variable can only be changed by the root user.
The names of these variables are mostly derived from the csh family of
shells and differ from the ones used by Bourne style shells such as
bash. The csh names where chosen because Bourne style names, such as
?, * and @ lead to significantly less readable code, and much larger
discoverability problems, and given the existence of tab completion,
the keystroke savings are minimal.
Variables whose name are in uppercase are exported to the commands
started by fish, those in lowercase are not exported. This rule is not
enforced by fish, but it is good coding practice to use casing to
distinguish between exported and unexported variables. \c fish also
uses several variables internally. Such variables are prefixed with
the string __FISH or __fish. These should be ignored by the user.
the string __FISH or __fish. These should never be used by the
user. Changing their value may break fish.
\subsection variables-status The status variable
Whenever a process exits, an exit status is returned to the program
that started it. This exit status is an integer number, which tells
the calling application how the execution of the command went. In
general, a zero exit status means that the command executed without
problem, but a non-zero exit status means there was some form of
problem.
that started it (usually the shell). This exit status is an integer
number, which tells the calling application how the execution of the
command went. In general, a zero exit status means that the command
executed without problem, but a non-zero exit status means there was
some form of problem.
Fish stores the exit status of the last process in the last job to
exit in the \c status variable.
@@ -825,9 +965,12 @@ If fish encounters a problem while executing a command, the status
variable may also be set to a specific value:
- 1 is the generally the exit status from fish builtins if they where supplied with invalid arguments
- 125 means an unknown error occured while trying to execute the command
- 126 means that the command was not executed because none of the wildcards in the command produced any matches
- 127 means that no command with the given name could be located
- 124 means that the command was not executed because none of the wildcards in the command produced any matches
- 125 means that while an executable with the specified name was located, the operating system could not actually execute the command
- 126 means that while a file with the specified name was located, it was not executable
- 127 means that no function, builtin or command with the given name could be located
If a process exits through a signal, the exit status will be 128 plus the number of the signal.
\subsection variables-color Variables for changing highlighting colors
@@ -837,7 +980,7 @@ variables can be one of the colors accepted by the <a
href='commands.html#set_color'>set_color</a> command. The \c --bold
or \c -b switches accepted by \c set_color are also accepted.
The following variables are available to change the highligting colors
The following variables are available to change the highlighting colors
in fish:
- \c fish_color_normal, the default color
@@ -871,7 +1014,7 @@ To make errors highlighted and red, use:
\subsection variables-locale Locale variables
The most common way to set the locale to use a command like 'set -x
LANG en_GB.utf8', which sets the current locale to be the english
LANG en_GB.utf8', which sets the current locale to be the English
language, as used in Great Britain, using the UTF-8 character set. For
a list of available locales, use 'locale -a'.
@@ -884,7 +1027,7 @@ variables set the specified aspect of the locale information. LANG
is a fallback value, it will be used if none of the LC_ variables are
specified.
\section builtin-overview Builtins
\section builtin-overview Builtins
Many other shells have a large library of builtin commands. Most of
these commands are also available as standalone commands, but have
@@ -893,67 +1036,16 @@ code duplication, and to avoid the confusion of subtly differing
versions of the same command, \c fish only implements builtins for
actions which cannot be performed by a regular command.
\section bundle Commands bundled with fish
The following commands are distributed with fish. Many of them are
builtins or shellscript functions, and can only be used inside fish.
- <a href="commands.html#source">.</a>, read and execute the commands in a file
- <a href="commands.html#and">and</a>, execute command if previous command suceeded
- <a href="commands.html#bg">bg</a>, set a command to the background
- <a href="commands.html#begin">begin</a>, execute a block of commands
- <a href="commands.html#bind">bind</a>, change keyboard bindings
- <a href="commands.html#break">break</a>, stop the execution of a loop
- <a href="commands.html#block">block</a>, Temporarily block delivery of events
- <a href="commands.html#builtin">builtin</a>, execute a builtin command
- <a href="commands.html#case">case</a>, conditionally execute a block of commands
- <a href="commands.html#cd">cd</a>, change the current directory
- <a href="commands.html#command">command</a>, execute an external program
- <a href="commands.html#commandline">commandline</a>, set or get the contents of the commandline buffer
- <a href="commands.html#complete">complete</a>, add and remove completions
- <a href="commands.html#continue">continue</a>, skip the rest of the current lap of a loop
- <a href="commands.html#count">count</a>, count the number of arguments
- <a href="commands.html#dirh">dirh</a>, view the directory history
- <a href="commands.html#dirs">dirs</a>, view the directory stack
- <a href="commands.html#end">end</a>, end a block of commands
- <a href="commands.html#else">else</a>, conditionally execute a block of commands
- <a href="commands.html#eval">eval</a>, evaluate a string as a command
- <a href="commands.html#exec">exec</a>, replace the current process image with a new command
- <a href="commands.html#exit">exit</a>, causes \c fish to quit
- <a href="commands.html#fg">fg</a>, set a command to the foreground
- <a href="commands.html#fishd">fishd</a>, the universal variable daemon
- <a href="commands.html#for">for</a>, perform a block of commands once for every element in a list
- <a href="commands.html#function">function</a>, define a new function
- <a href="commands.html#functions">functions</a>, print or erase functions
- <a href="commands.html#help">help</a>, show the fish documentation
- <a href="commands.html#if">if</a>, conditionally execute a block of commands
- <a href="commands.html#jobs">jobs</a>, print the currently running jobs
- <a href="commands.html#mimedb">mimedb</a>, view mimedata about a file
- <a href="commands.html#nextd">nextd</a>, move forward in the directory history
- <a href="commands.html#not">not</a>, negates the exit status of any command
- <a href="commands.html#or">or</a>, execute a command if previous command failed
- <a href="commands.html#popd">popd</a>, move to the topmost directory on the directory stack
- <a href="commands.html#prevd">prevd</a>, move backwards in the direcotry stack
- <a href="commands.html#pushd">pushd</a>, push the surrent directory onto the directory stack
- <a href="commands.html#random">random</a>, calculate a pseudo-random number
- <a href="commands.html#return">return</a>, return from a function
- <a href="commands.html#read">read</a>, read from a stream into an environment variable
- <a href="commands.html#set">set</a>, set environment variables
- <a href="commands.html#set_color">set_color</a>, change the terminal colors
- <a href="commands.html#switch">switch</a>, conditionally execute a block of commands
- <a href="commands.html#tokenize">tokenize</a>, split a string up into multiple tokens
- <a href="commands.html#ulimit">ulimit</a>, set or get the shells resurce usage limits
- <a href="commands.html#umask">umask</a>, set or get the file creation mask
- <a href="commands.html#while">while</a>, perform a block of commands while a condition is met
For more information about these commands, use the <code>--help</code>
option of the command to display a longer explanation.
For a list of all builtins, functions and commands shipped with fish,
see the <a href="#toc-commands">table of contents</a>. The
documentation is also available by using the <code>--help</code>
switch of the command.
\section editor Command Line editor
The \c fish editor features copy and paste, a searchable history and
many editor functions that can be bound to special keyboard
shortcuts. The most important keybinding is probably the tab key, which is bound to the complete function.
shortcuts. The most important keybinding is probably the tab key, which is bound to the complete function.
Here are some of the commands available in the editor:
- Tab completes the current token
@@ -963,7 +1055,7 @@ Here are some of the commands available in the editor:
- Alt-left and Alt-right moves one word left or right, or moves forward/backward in the directory history if the commandline is empty
- Up and down search the command history for the previous/next command containing the string that was specified on the commandline before the search was started. If the commandline was empty when the search started, all commands match. See the <a href='#history'>history </a>section for more information on history searching.
- Alt-up and Alt-down search the command history for the previous/next token containing the token under the cursor before the search was started. If the commandline was not on a token when the search started, all tokens match. See the <a href='#history'>history </a>section for more information on history searching.
- Delete and backspace removes one character forwards or backwards respecitvely
- Delete and backspace removes one character forwards or backwards respectively
- Ctrl-c deletes entire line
- Ctrl-d delete one character to the right of the cursor, unless the buffer is empty, in which case the shell will exit
- Ctrl-k move contents from the cursor to the end of line to the <a href="#killring">killring</a>
@@ -971,18 +1063,12 @@ Here are some of the commands available in the editor:
- Ctrl-l clear and repaint screen
- Ctrl-w move previous word to the <a href="#killring">killring</a>
- Alt-d move next word to the <a href="#killring">killring</a>
- Alt-w prints a short description of the command under the cursor
- Alt-l lists the contents of the current directory, unless the cursor is over a directory argument, in which case the contents of that directory will be listed
- Alt-w prints a short description of the command under the cursor
- Alt-l lists the contents of the current directory, unless the cursor is over a directory argument, in which case the contents of that directory will be listed
- Alt-p adds the string '| less;' to the end of the job under the cursor. The result is that the output of the command will be paged.
You can change these key bindings by making an inputrc file. To do
this, copy the file /etc/fish/fish_inputrc to your home directory and
rename it to '.config/fish/fish_inputrc'. Now you can edit the file
to change your key bindings. The fileformat of this file is described
in the manual page for readline. Use the command <code>man readline</code>
to read up on this syntax. Please note that the list of key binding
functions in fish is different to that offered by readline. Currently,
the following functions are available:
You can change these key bindings using the
<a href="commands.html#bind">bind</a> builtin command.
- \c backward-char, moves one character to the left
@@ -1009,13 +1095,11 @@ the following functions are available:
- \c yank, insert the latest entry of the killring into the buffer
- \c yank-pop, rotate to the previous entry of the killring
You can also bind a pice of shellscript to a key using the same
syntax. For example, the Alt-p functionality described above is
implemented using the following keybinding.
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.
<pre>"\M-p": if commandline -j|grep -v 'less *$' &gt;/dev/null; commandline -aj "|less;"; end</pre>
\subsection killring Copy and paste (Kill Ring)
\subsection killring Copy and paste (Kill Ring)
\c fish uses an Emacs style kill ring for copy and paste
functionality. Use Ctrl-K to cut from the current cursor position to
@@ -1026,7 +1110,7 @@ Meta-Y to rotate to the previous kill.
If the environment variable DISPLAY is set, \c fish will try to
connect to the X-windows server specified by this variable, and use
the clipboard on the X server for copying and pasting.
the clipboard on the X server for copying and pasting.
\subsection history Searchable history
@@ -1040,7 +1124,7 @@ the string entered into the command line are shown.
By pressing Alt-up and Alt-down, a history search is also performed,
but instead of searching for a complete commandline, each commandline
is tokenized into separate elements just like it would be before
execution, and each such token is matched agains the token under the
execution, and each such token is matched against the token under the
cursor when the search began.
History searches can be aborted by pressing the escape key.
@@ -1061,7 +1145,7 @@ than a single line:
- Pressing the enter key while a block of commands is unclosed, i.e. when one or more block commands such as 'for', 'begin' or 'if' do not have a corresponding 'end' command.
- Pressing Alt-enter instead of pressing the enter key.
- By backslash escaping a newline, i.e. by inserting a backslash (\\) character pefore pressing the enter key.
- By backslash escaping a newline, i.e. by inserting a backslash (\\) character before pressing the enter key.
The fish commandline editor works exactly the same in single line mode
and in multiline mode. To move between lines use the left and right
@@ -1075,9 +1159,9 @@ fish will be stopped until the program finishes. Sometimes this is not
desirable. For example, you may wish to start an application with a
graphical user interface from the terminal, and then be able to
continue using the shell. In such cases, there are several ways in
which the user can change <code>fish</code>'s behaviour.
which the user can change <code>fish</code>'s behavior.
-# By ending a command with the \& (ampersand) symbol, the user tells \c fish to put the specified command into the background. A background process will be run simultaneous with \c fish. \c fish will retain control of the terminal, so the program will not be able to read from the keyboard.
-# By ending a command with the \& (ampersand) symbol, the user tells \c fish to put the specified command into the background. A background process will be run simultaneous with \c fish. \c fish will retain control of the terminal, so the program will not be able to read from the keyboard.
-# By pressing ^Z, the user stops a currently running foreground program and returns control to \c fish. Some programs do not support this feature, or remap it to another key. Gnu emacs uses ^X z to stop running.
-# By using the <a href="commands.html#fg">fg</a> and <a href="commands.html#bg">bg</a> builtin commands, the user can send any currently running job into the foreground or background.
@@ -1153,28 +1237,6 @@ Issuing <code>set fish_color_error black --background=red
--bold</code> will make all commandline errors be written in a black,
bold font, with a red background.
\subsection prompt Programmable prompt
By defining the \c fish_prompt function, the user can choose a custom
prompt. The \c fish_prompt function is executed and the output is used
as a prompt.
Example:
<p>
The default \c fish prompt is
</p>
<p>
<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)
end
</pre>
where \c prompt_pwd is a shellscript function that displays a condensed version of the current working direcotry.
</p>
\subsection title Programmable title
When using most virtual terminals, it is possible to set the message
@@ -1184,11 +1246,11 @@ fish_title function is executed before and after a new command is
executed or put into the foreground and the output is used as a
titlebar message. The $_ environment variable will always contain the
name of the job to be put into the foreground (Or 'fish' if control is
returning to the shell) when the fish_prompt function is called.
returning to the shell) when the \c fish_prompt function is called.
Example:
<p>
The default \c fish title is
The default \c fish title is
</p>
<p>
<pre>
@@ -1199,6 +1261,12 @@ end
</pre>
</p>
\subsection greeting Configurable greeting
If a function named fish_greeting exists after initialization, it will
be run when entering interactive mode. Otherwise,if an environment
variable named fish_greeting exists, it will be printed.
\subsection event Event handlers
When defining a new function in fish, it is possible to make it into an
@@ -1208,6 +1276,8 @@ specific event takes place. Events that can trigger a handler currently are:
- When a signal is delivered
- When a process or job exits
- When the value of a variable is updated
- When the prompt is about to be shown
- When a command lookup fails
Example:
@@ -1222,11 +1292,25 @@ For more information on how to define new event handlers, see the
documentation for the <a href='commands.html#function'>function</a>
command.
\subsection debugging Debugging fish scripts
Fish includes a built in debugger. The debugger allows you to stop
execution of a script at an arbitrary point and launch a prompt. This
prompt can then be used to check or change the value of any variables
or perform any shellscript command. To resume normal execution of the
script, simply exit the prompt.
To start the debugger, simply call the builtin command
'breakpoint'. The default action of the TRAP signal is to call this
builtin, so a running script can be debugged by sending it the TRAP
signal. Once in the debugger, it is easy to insert new breakpoints by
using the funced function to edit the definition of a function.
\section issues Common issues with fish
If you install fish in your home directory, fish will not work
correctly for any other user than yourself. This is because fish needs
its initalization files to function properly. To solve this
its initialization files to function properly. To solve this
problem, either copy the initialization files to each fish users home
directory, or install them in /etc.
@@ -1238,7 +1322,7 @@ making a translation. Currently, only the shell itself can be
translated, a future version of fish should also include translated
manuals.
To make a translation of fish, you will first need the sourcecode,
To make a translation of fish, you will first need the source code,
available from the <a href='http://www.fishshell.org'>fish
homepage</a>. Download the latest version, and then extract it using a
command like <code>tar -zxf fish-VERSION.tar.gz</code>.
@@ -1246,7 +1330,7 @@ command like <code>tar -zxf fish-VERSION.tar.gz</code>.
Next, cd into the newly created fish directory using <code>cd
fish-VERSION</code>.
You will now need to configure the sourcecode using the command
You will now need to configure the source code using the command
<code>./configure</code>. This step might take a while.
Before you continue, you will need to know the ISO 639 language code
@@ -1254,7 +1338,7 @@ of the language you are translating to. These codes can be found <a
href='http://www.w3.org/WAI/ER/IG/ert/iso639.htm'>here</a>. For
example, the language code for Uighur is ug.
Now you have the sourcecode and it is properly configured. Lets start
Now you have the source code and it is properly configured. Lets start
translating. To do this, first create an empty translation table for
the language you wish to translate to by writing <code>make
po/[LANGUAGE CODE].po</code> in the fish terminal. For example, if you
@@ -1273,8 +1357,8 @@ msgid "%ls: No suitable job\n"
msgstr ""
</pre>
The first line is the english string to translate, the second line
should contain your translation. For example, in swedish the above
The first line is the English string to translate, the second line
should contain your translation. For example, in Swedish the above
might become:
<pre>
@@ -1298,70 +1382,62 @@ href='fish-users@lists.sf.net'>fish-users@lists.sf.net</a>.
\subsection todo-features Missing features
- Complete vi-mode key bindings
- More completions (for example xterm, vim,
konsole, gnome-terminal, dcop, cron,
rlogin, rsync, arch, finger, nice, locate,
bibtex, aspell, xpdf,
compress, wine, xmms, dig, batch, cron,
g++, javac, java, gcj, lpr, doxygen, whois, find)
- More completions (for example konsole, gnome-terminal,
rlogin, rsync, arch, finger, bibtex, aspell, xpdf,
compress, wine, dig, batch,
g++, javac, java, gcj, lpr, doxygen, whois)
- Undo support
- Check keybinding commands for output - if nothing has happened, don't repaint to reduce flicker
- wait shellscript
- Support for the screen clipboard
- It should be possible to test in a script if a function is autoloaded or manually defined
- The validator should be better about error reporting unclosed quotes. They are usually reported as something else.
\subsection todo-possible Possible features
- tab completion could use smart casing
- Completions could support options beginning with a plus (like xterm
+fbx) and options without dashes (like top p) Do we really want to
complicate the code additionally for such a small number of programs?
- mouse support like zsh has with http://stchaz.free.fr/mouse.zsh
- mouse support like zsh has with http://stchaz.free.fr/mouse.zsh
installed would be awesome
- suggest a completion on unique matches by writing it out in an understated color
- With a bit of tweakage, quite a few of the readline key-binding functions could be implemented in shellscript.
- Highlight beginning/end of block when moving over a block command
- Inclusion guards for the init files to make them evaluate only once, even if the user has installed fish both in /etc and in $HOME
- command specific wildcarding (use case * instead of case '*', etc.)
- Map variables. (export only the values. When expanding with no key specified, expand to all values.)
- Descriptions for variables using 'set -d'.
- Parse errors should when possible honor IO redirections
- Support for writing strings like /u/l/b/foo and have them expand to /usr/local/bin/foo - perhaps through tab expansion
- Autoreload inputrc-file on updates
- Right-side prompt
- Selectable completions in the pager
- Per process output redirection
- Reduce the space of the pager by one line to allow the commandline to remain visible.
- down-arrow could be used to save the current command to the history. Or give the next command in-sequnce. Or both.
- A pretty-printer.
- Help messages for builtin should not be compiled into fish, they should be kept in a separate directory
- Shellscript functions should be able to show help on the commandline instead of launching a browser
- Drop support for inputrc-files. Use shellscripts and the bind builtin. Also, redo the syntax for the bind builtin to something more sane.
- down-arrow could be used to save the current command to the history. Or give the next command in-sequence. Or both.
- History could reload itself when the file is updated. This would need to be done in a clever way to avoid chain reactions
- The error function should probably be moved into it's own library, and be made mere general purpose.
- The code validation functions should be moved from the parser to parse_util.
- The parser_is_* functions should be moved to parse_util. Possibly, they should be made into a single function, i.e. parse_util_classify( "begin", BLOCK_COMMAND);
- Try to remove more malloc calls to reduce memory usage. The time_t arrays used by the autoloader sound like a good candidate.
- Try to remove more malloc calls to reduce memory usage. The time_t arrays used by the autoloader sound like a good candidate.
- The code validator should warn about unknown commands.
- The large number of interned strings means that autounloading frees less memory than it should. Completion strings should probably be either refcounted or not shared at all.
- Auto-newlines
- A fault injector could be written to increase robustness and testing of error recovery paths
- The parser/validator could be more clever in order to make things like writing 'function --help' work as expected
- Some event handler functions make much more sense as oneshots - maybe they should be automatically deleted after firing?
- exec_subshell should be either merged with eval or moved to parser.c
- Don't use expand_string to perform completions. wildcard_complete can be called directly, the brace expansion handling should be universal, and the process expansion can be moved to complete.c.
- Make the history search support incremental searching
- An automatic logout feature
- Make tab completions completely silent by default, i.e. kill stderr when running completion commands. This needs to be overridalbe for debugging purposes.
- Move history to an environment variable
\subsection bugs Known bugs and issues
\subsection bugs Known bugs
- Completion for gcc -\#\#\# option doesn't work.
- Suspending and then resuming pipelines containing a builtin is broken. How should this be handled?
- screen handling code can't handle tabs in input.
- Suspending and then resuming pipelines containing a builtin or a shellscript function is broken. Ideally, the exec function in exec.c should be able to resume execution of a partially executed job.
- delete-word is broken on the commandline 'sudo update-alternatives --config x-'
- Sometimes autoheader needs to be run on a fresh tarball. Fix dates before creating tarballs.
- The completion autoloader does not remember which completions where actually autoloaded, and may unload manually specified completions.
- There have been stray reports of issues with strange values of the PATH variable during startup.
- bindings in config.fish are overwritten by default key bindings.
- Adding 'bind -k ...' doesn't overwrite non-keybinding binds of the same sequence.
- History file does not remove duplicates.
- History file should apply some kind of maximum history length.
- Older versions of Doxygen has bugs in the man-page generation which cause the builtin help to render incorrectly. Version 1.2.14 is known to have this problem.
If you think you have found a bug not described here, please send a
report to <a href="mailto:axel@liljencrantz.se"> axel@liljencrantz.se
</a>.
\subsection issues Known issues
Older versions of Doxygen has bugs in the man-page generation which
cause the builtin help to render incorrectly. Version 1.2.14 is known
to have this problem.
report to <a href="mailto:fish-users@lists.sf.net">fish-users@lists.sf.net</a>.
*/

View File

@@ -1,4 +1,4 @@
\section isatty isatty - test if the specidied file descriptor is a tty
\section isatty isatty - test if the specified file descriptor is a tty
\subsection isatty-synopsis Synopsis
<tt>isatty [FILE DESCRIPTOR]</tt>

View File

@@ -1,28 +1,11 @@
/** \page license Licenses
Fish Copyright (C) 2005 Axel Liljencrantz. Fish is released under the
GNU General Public License, version 2. The license agreement is
<h2>License for fish</h2>
Fish Copyright (C) 2005-2009 Axel Liljencrantz. Fish is released under
the GNU General Public License, version 2. The license agreement is
included below.
Fish contains code under the BSD license, namely versions of the
two functions strlcat and strlcpy, modified for use with wide
character strings. This code is copyrighted by Todd C. Miller. The
license agreement is included below.
The XSel command, written and copyrighted by Conrad Parker, is
distributed together with, and used by fish. It is released under the MIT
license. The license agreement is included below.
The xdgmime library, written and copyrighted by Red Hat, Inc, is used
by the mimedb command, which is a part of fish. It is released under
the LGPL. The license agreement is included below.
Fish contains code from the glibc library, namely the wcstok
function. This code is licensed under the LGPL. The license agreement
is included below.
<HR>
<H2><A NAME="SEC1" HREF="gpl.html#TOC1">GNU GENERAL PUBLIC LICENSE</A></H2>
<P>
@@ -31,7 +14,7 @@ Version 2, June 1991
</P>
<PRE>
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
@@ -464,7 +447,7 @@ PERFORMANCE OF THIS SOFTWARE.
<h2>License for XSel</h2>
The XSel command, written and copyrighted by Conrad Parker, is
distributed together with \c fish.
distributed together with \c fish.
It is Copyright (C) 2001 Conrad Parker <conrad@vergenet.net>
@@ -480,6 +463,18 @@ without express or implied warranty.
<HR>
<h2>License for xdgmime and glibc</h2>
The xdgmime library, written and copyrighted by Red Hat, Inc, is used
by the mimedb command, which is a part of fish. It is released under
the LGPL, version 2 or later, or under the Academic Free License,
version 2. Version 2 of the LGPL license agreement is included below.
Fish contains code from the glibc library, namely the wcstok
function. This code is licensed under the LGPL, version 2 or
later. Version 2 of the LPGL license agreement is included below.
<H2><A NAME="SEC1" HREF="#TOC1">GNU LESSER GENERAL PUBLIC LICENSE</A></H2>
<P>
@@ -807,7 +802,7 @@ of these things:
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
<LI><STRONG>b)</STRONG> Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,

20
doc_src/math.txt Normal file
View File

@@ -0,0 +1,20 @@
\section math math - Perform mathematics calculations
\subsection math-synopsis Synopsis
<tt>math EXPRESSION</tt>
\subsection math-description Description
math is used to perform mathematical calculations. It is only a very
thin wrapper for the bc program, that makes it possible to specify an
expression from the command line without using non-standard extensions
or a pipeline. Simply use a command like <code>math 1+1</code>.
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.

View File

@@ -5,7 +5,7 @@
\subsection mimedb-description Description
- \c FILES is a list of files to analyse
- \c FILES is a list of files to analyse
- \c -t, \c --input-file-data the specified files type should be determined both by their filename and by their contents (Default)
- \c -f, \c --input-filename the specified files type should be determined by their filename
- \c -i, \c --input-mime the arguments are not files but mimetypes
@@ -18,7 +18,7 @@
The mimedb command is used to query the mimetype database and the
.desktop files installed on the system in order to find information on
a file. The information that mimedb can retrive includes the mimetype
a file. The information that mimedb can retrieve includes the mimetype
for a file, a description of the type and what its default action
is. mimedb can also be used to launch the default action for this
file.

View File

@@ -5,7 +5,7 @@
\subsection not-description Description
The \c not builtin is used to negate the exit status of another command.
The \c not builtin is used to negate the exit status of another command.
\subsection not-example Example

View File

@@ -1,12 +1,12 @@
\section open open - open file in it's default application
\section open open - open file in its default application
\subsection open-synopsis Synopsis
<tt>open FILES...</tt>
\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
<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.

View File

@@ -10,10 +10,14 @@ 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
The following code runs the \c make command to build a program, if the
build succceds, the program is installed. If either step fails,
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

View File

@@ -3,6 +3,6 @@
\subsection popd-synopsis Synopsis
<tt>popd</tt>
\subsection popd-description Description
<tt>popd</tt> removes the top directory from the directory stack and
\subsection popd-description Description
<tt>popd</tt> removes the top directory from the directory stack and
cd's to the new top directory.

View File

@@ -1,10 +1,11 @@
\section prevd prevd - move backward through direcotry history
\section prevd prevd - move backward through directory history
\subsection prevd-synopsis Synopsis
<tt>prevd [-l | --list] [pos]</tt>
\subsection prevd-description Description <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-description Description
<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.

View File

@@ -1,7 +1,7 @@
\section psub psub - perform process substitution
\subsection psub-synopsis Synopsis
<tt>COMMAND1 (COMMAND2|psub) </tt>
<tt>COMMAND1 (COMMAND2|psub [-f]) </tt>
\subsection psub-description Description
@@ -14,6 +14,12 @@ filename of the named pipe sent as an argument to the calling
program. The psub shellscript function, which when combined with a
regular command substitution provides the same functionality.
If the \c -f or \c --file switch is given to psub, psub will use a
regular file instead of a named pipe to communicate with the calling
process. This will cause psub to be significantly slower when large
amounts of data are involved, but has the advantage that the reading
process can seek in the stream.
\subsection psub-example Example
<tt>diff (sort a.txt|psub) (sort b.txt|psub)</tt> shows the difference

View File

@@ -3,7 +3,7 @@
\subsection pushd-synopsis Synopsis
<tt>pushd [DIRECTORY]</tt>
\subsection pushd-description Description
\subsection pushd-description Description
The <tt>pushd</tt> function adds DIRECTORY to the top of the directory stack
and makes it the current directory. Use <tt>popd</tt> to pop it off and and
return to the original directory.

View File

@@ -21,4 +21,4 @@ for i in (seq (random) -1 1)
echo $i
sleep
end
</pre>
</pre>

View File

@@ -6,12 +6,14 @@
\subsection read-description Description
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>-g</tt> or <tt>--global</tt> specifies that the variables will be made global.
- <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>-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

View File

@@ -3,7 +3,7 @@
\subsection return-synopsis Synopsis
<tt>function NAME; [COMMANDS...;] return [STATUS]; [COMMANDS...;] end</tt>
\subsection return-description Description
\subsection return-description Description
The \c return builtin is used to halt a currently running function. It
is usually added inside of a conditional block such as an <a

View File

@@ -43,7 +43,7 @@ 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 previos variable scope is used.
-# 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
@@ -51,7 +51,7 @@ 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 global or local and has never before been defined, the variable will not be exported.
-# 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.

View File

@@ -7,7 +7,7 @@
Change the foreground and/or background color of the terminal.
COLOR is one of black, red, green, brown, yellow, blue, magenta,
purple, cyan, white and normal.
purple, cyan, white and normal.
- \c -b, \c --background Set the background color
- \c -c, \c --print-colors Prints a list of all valid color names
@@ -28,3 +28,9 @@ result in a white font color.
Not all terminal emulators support all these features. This is not a
bug in set_color but a missing feature in the terminal emulator.
set_color uses the terminfo database to look up how to change terminal
colors on whatever terminal is in use. Some systems have old and
incomplete terminfo databases, and may lack color information for
terminals that support it. Download and install the latest version of
ncurses and recompile fish against it in order to fix this issue.

View File

@@ -1,15 +1,24 @@
\section source . - evaluate contents of file.
\subsection source-synopsis Synopsis
<tt>. FILENAME</tt>
<tt>. FILENAME [ARGUMENTS...]</tt>
\subsection source-description Description
\subsection source-description Description
Evaluates the commands of the specified file in the current
shell. This is different from starting a new process to perform the
commands (i.e. <tt>fish < FILENAME</tt>) since the commands will be
evaluated by the current shell, which means that changes in
environment variables, etc., will remain.
environment variables, etc., will remain. If additional arguments are
specified after the file name, they will be inserted into the $argv
variable.
If no file is specified, or if the file name '-' is used, stdin will
be read.
The return status of . is the return status of the last job to
execute. If something goes wrong while opening or reading the file,
. exits with a non-zero status.
\subsection source-example Example

View File

@@ -8,3 +8,11 @@
- <tt>-b</tt> or <tt>--is-block</tt> returns 0 if fish is currently executing a block of code
- <tt>-i</tt> or <tt>--is-interactive</tt> returns 0 if fish is interactive, i.e.connected to a keyboard
- <tt>-l</tt> or <tt>--is-login</tt> returns 0 if fish is a login shell, i.e. if fish should perform login tasks such as setting up the PATH.
- <tt>--is-full-job-control</tt> returns 0 if full job control is enabled
- <tt>--is-interactive-job-control</tt> returns 0 if interactive job control is enabled
- <tt>--is-no-job-control</tt> returns 0 if no job control is enabled
- <tt>-f</tt> or <tt>--current-filename</tt> prints the filename of the currently running script
- <tt>-n</tt> or <tt>--current-line-number</tt> prints the line number of the currently running script
- <tt>-j CONTROLTYPE</tt> or <tt>--job-control=CONTROLTYPE</tt> set the job control type. Can be one of: none, full, interactive
- <tt>-t</tt> or <tt>--print-stack-trace</tt> prints a stack trace of all function calls on the call stack
- <tt>-h</tt> or <tt>--help</tt> display a help message and exit

View File

@@ -19,7 +19,7 @@ regular wildcard expansion using filenames.
Note that fish does not fall through on case statements. Though the
syntax may look a bit like C switch statements, it behaves more like
the case stamantes of traditional shells.
the case statements of traditional shells.
Also note that command substitutions in a case statement will be
evaluated even if it's body is not taken. This may seem

View File

@@ -5,22 +5,13 @@
\subsection ulimit-description Description
The ulimit builtin provides control over the resources available to
the shell and to processes started by it. The -H and -S options
specify that the hard or soft limit is set for the given resource. A
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:
The ulimit builtin is used to set the resource usage limits of the
shell and any processes spawned by it. If a new limit value is
omitted, the current value of the limit of the resource is printed.
- <code>-a</code> or <code>--all</code> Set or get all current limits
- <code>-c</code> or <code>--core-size</code> The maximum size of core files created
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. 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>-l</code> or <code>--lock-size</code> The maximum size that may be locked into memory
@@ -31,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>-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
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
values. The return status is 0 unless an invalid option or argument is
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 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 getting the values of multiple limits in one command, except by using the -a switch
- 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 or setting multiple limits in one command, except reporting all values using the -a switch
\subsection ulimit-example Example

View File

@@ -1,4 +1,4 @@
\section umask umask - set or get the shells resource usage limits
\section umask umask - set or get the file-creation mask
\subsection umask-synopsis Synopsis
<code>umask [OPTIONS] [MASK]</code>
@@ -43,7 +43,7 @@ in bash.
\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
all for any other users.

View File

@@ -1,4 +1,4 @@
\section vared vared - interactively edit the value of an environment variable
\section vared vared - interactively edit the value of an environment variable
\subsection vared-synopsis Synopsis
<tt>vared VARIABLE_NAME</tt>
@@ -7,7 +7,7 @@
vared is used to interactively edit the value of an environment
variable. Array variables as a whole can not be edited using vared,
but individual array elements can.
but individual array elements can.
\subsection vared-example Example

687
env.c

File diff suppressed because it is too large Load Diff

13
env.h
View File

@@ -63,7 +63,7 @@ void env_destroy();
/**
Set the value of the environment variable whose name matches key to val.
Set the value of the environment variable whose name matches key to val.
Memory policy: All keys and values are copied, the parameters can and should be freed by the caller afterwards
@@ -79,7 +79,7 @@ void env_destroy();
* ENV_INVALID, the variable name or mode was invalid
*/
int env_set( const wchar_t *key,
int env_set( const wchar_t *key,
const wchar_t *val,
int mode );
@@ -104,7 +104,7 @@ int env_exist( const wchar_t *key, int mode );
/**
Remove environemnt variable
\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. The mode may also specify the scope of the variable that should be erased.
@@ -132,4 +132,11 @@ char **env_export_arr( int recalc );
*/
void env_get_names( array_list_t *l, int flags );
/**
Update the PWD variable
directory
*/
int env_set_pwd();
#endif

View File

@@ -70,6 +70,11 @@ static int barrier_reply = 0;
void env_universal_barrier();
static int is_dead()
{
return env_universal_server.fd < 0;
}
/**
Get a socket for reading from the server
@@ -78,27 +83,27 @@ static int get_socket( int fork_ok )
{
int s, len;
struct sockaddr_un local;
char *name;
wchar_t *wdir;
wchar_t *wuname;
wchar_t *wuname;
char *dir =0, *uname=0;
get_socket_count++;
wdir = path;
wuname = user;
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
{
wperror(L"socket");
return -1;
}
if( wdir )
dir = wcs2str(wdir );
else
dir = strdup("/tmp");
if( wuname )
uname = wcs2str(wuname );
else
@@ -107,53 +112,53 @@ static int get_socket( int fork_ok )
pw = getpwuid( getuid() );
uname = strdup( pw->pw_name );
}
name = malloc( strlen(dir) +
strlen(uname) +
strlen(SOCK_FILENAME) +
strlen(uname) +
strlen(SOCK_FILENAME) +
2 );
strcpy( name, dir );
strcat( name, "/" );
strcat( name, SOCK_FILENAME );
strcat( name, uname );
free( dir );
free( uname );
debug( 3, L"Connect to socket %s at fd %2", name, s );
local.sun_family = AF_UNIX;
strcpy(local.sun_path, name );
free( name );
len = sizeof(local);
if( connect( s, (struct sockaddr *)&local, len) == -1 )
if( connect( s, (struct sockaddr *)&local, len) == -1 )
{
close( s );
if( fork_ok && start_fishd )
{
debug( 2, L"Could not connect to socket %d, starting fishd", s );
start_fishd();
return get_socket( 0 );
}
debug( 2, L"Could not connect to socket %d, already tried manual restart (or no command supplied), 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?" );
return -1;
}
if( fcntl( s, F_SETFL, O_NONBLOCK ) != 0 )
if( (fcntl( s, F_SETFL, O_NONBLOCK ) != 0) || (fcntl( s, F_SETFD, FD_CLOEXEC ) != 0) )
{
wperror( L"fcntl" );
close( s );
close( s );
return -1;
}
debug( 3, L"Connected to fd %d", s );
return s;
}
@@ -161,7 +166,7 @@ static int get_socket( int fork_ok )
Callback function used whenever a new fishd message is recieved
*/
static void callback( int type, const wchar_t *name, const wchar_t *val )
{
{
if( type == BARRIER_REPLY )
{
barrier_reply = 1;
@@ -169,8 +174,8 @@ static void callback( int type, const wchar_t *name, const wchar_t *val )
else
{
if( external_callback )
external_callback( type, name, val );
}
external_callback( type, name, val );
}
}
/**
@@ -181,23 +186,48 @@ static void check_connection()
{
if( !init )
return;
if( env_universal_server.killme )
{
debug( 3, L"Lost connection to universal variable server." );
if( close( env_universal_server.fd ) )
{
wperror( L"close" );
}
env_universal_server.fd = -1;
env_universal_server.killme=0;
env_universal_server.input.used=0;
env_universal_server.input.used=0;
env_universal_read_all();
}
}
}
/**
Remove all universal variables.
*/
static void env_universal_remove_all()
{
array_list_t lst;
int i;
al_init( &lst );
env_universal_common_get_names( &lst,
1,
1 );
for( i=0; i<al_get_count( &lst ); i++ )
{
wchar_t *key = (wchar_t *)al_get( &lst, i );
env_universal_common_remove( key );
}
al_destroy( &lst );
}
/**
Try to establish a new connection to fishd. If successfull, end
with call to env_universal_barrier(), to make sure everything is in
@@ -207,36 +237,37 @@ static void reconnect()
{
if( get_socket_count >= RECONNECT_COUNT )
return;
debug( 3, L"Get new fishd connection" );
init = 0;
env_universal_server.buffer_consumed = env_universal_server.buffer_used = 0;
env_universal_server.fd = get_socket(1);
init = 1;
if( env_universal_server.fd >= 0 )
{
env_universal_remove_all();
env_universal_barrier();
}
}
void env_universal_init( wchar_t * p,
wchar_t *u,
void env_universal_init( wchar_t * p,
wchar_t *u,
void (*sf)(),
void (*cb)( int type, const wchar_t *name, const wchar_t *val ))
{
path=p;
user=u;
start_fishd=sf;
start_fishd=sf;
external_callback = cb;
connection_init( &env_universal_server, -1 );
env_universal_server.fd = get_socket(1);
env_universal_common_init( &callback );
env_universal_read_all();
init = 1;
env_universal_read_all();
init = 1;
if( env_universal_server.fd >= 0 )
{
env_universal_barrier();
@@ -254,7 +285,7 @@ void env_universal_destroy()
{
wperror( L"fcntl" );
}
try_send_all( &env_universal_server );
try_send_all( &env_universal_server );
}
connection_destroy( &env_universal_server );
@@ -274,22 +305,22 @@ int env_universal_read_all()
if( env_universal_server.fd == -1 )
{
reconnect();
reconnect();
if( env_universal_server.fd == -1 )
return 0;
return 0;
}
if( env_universal_server.fd != -1 )
{
read_message( &env_universal_server );
check_connection();
check_connection();
return 1;
}
else
{
debug( 2, L"No connection to universal variable server" );
return 0;
}
}
}
wchar_t *env_universal_get( const wchar_t *name )
@@ -298,7 +329,7 @@ wchar_t *env_universal_get( const wchar_t *name )
return 0;
CHECK( name, 0 );
return env_universal_common_get( name );
}
@@ -308,7 +339,7 @@ int env_universal_get_export( const wchar_t *name )
return 0;
CHECK( name, 0 );
return env_universal_common_get_export( name );
}
@@ -317,7 +348,7 @@ void env_universal_barrier()
message_t *msg;
fd_set fds;
if( !init || ( env_universal_server.fd == -1 ))
if( !init || is_dead() )
return;
barrier_reply = 0;
@@ -335,19 +366,19 @@ void env_universal_barrier()
debug( 3, L"Create barrier" );
while( 1 )
{
try_send_all( &env_universal_server );
check_connection();
try_send_all( &env_universal_server );
check_connection();
if( q_empty( &env_universal_server.unsent ) )
break;
if( env_universal_server.fd == -1 )
{
reconnect();
debug( 2, L"barrier interrupted, exiting" );
return;
return;
}
FD_ZERO( &fds );
FD_SET( env_universal_server.fd, &fds );
select( env_universal_server.fd+1, 0, &fds, 0, 0 );
@@ -363,10 +394,10 @@ void env_universal_barrier()
{
reconnect();
debug( 2, L"barrier interrupted, exiting (2)" );
return;
}
return;
}
FD_ZERO( &fds );
FD_SET( env_universal_server.fd, &fds );
FD_SET( env_universal_server.fd, &fds );
select( env_universal_server.fd+1, &fds, 0, 0, 0 );
env_universal_read_all();
}
@@ -377,49 +408,62 @@ void env_universal_barrier()
void env_universal_set( const wchar_t *name, const wchar_t *value, int export )
{
message_t *msg;
if( !init )
return;
CHECK( name, );
debug( 3, L"env_universal_set( \"%ls\", \"%ls\" )", name, value );
msg = create_message( export?SET_EXPORT:SET,
name,
value);
if( !msg )
debug( 3, L"env_universal_set( \"%ls\", \"%ls\" )", name, value );
if( is_dead() )
{
debug( 1, L"Could not create universal variable message" );
return;
env_universal_common_set( name, value, export );
}
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();
}
int env_universal_remove( const wchar_t *name )
{
int res;
message_t *msg;
if( !init )
return 1;
CHECK( name, 1 );
res = !env_universal_common_get( name );
debug( 3,
L"env_universal_remove( \"%ls\" )",
name );
msg= create_message( ERASE, name, 0);
msg->count=1;
q_put( &env_universal_server.unsent, msg );
env_universal_barrier();
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();
}
return res;
}
@@ -430,8 +474,10 @@ void env_universal_get_names( array_list_t *l,
{
if( !init )
return;
env_universal_common_get_names( l,
CHECK( l, );
env_universal_common_get_names( l,
show_exported,
show_unexported );
show_unexported );
}

View File

@@ -1,5 +1,5 @@
/** \file env_universal.h
Universal variable client library
Universal variable client library.
*/
#ifndef ENV_UNIVERSAL_H
@@ -40,7 +40,7 @@ int env_universal_get_export( const wchar_t *name );
void env_universal_set( const wchar_t *name, const wchar_t *val, int export );
/**
Erase a universal variable
\return zero if the variable existed, and non-zero if the variable did not exist
*/
int env_universal_remove( const wchar_t *name );
@@ -52,7 +52,7 @@ int env_universal_read_all();
/**
Get the names of all universal variables
\param l the list to insert the names into
\param show_exported whether exported variables should be shown
\param show_unexported whether unexported variables should be shown

View File

@@ -93,13 +93,13 @@
typedef struct var_uni_entry
{
int export; /**< Whether the variable should be exported */
wchar_t val[0]; /**< The value of the variable */
wchar_t val[1]; /**< The value of the variable */
}
var_uni_entry_t;
static void parse_message( wchar_t *msg,
connection_t *src );
connection_t *src );
/**
The table of all universal variables
@@ -109,11 +109,10 @@ hash_table_t env_universal_var;
/**
Callback function, should be called on all events
*/
void (*callback)( int type,
const wchar_t *key,
void (*callback)( int type,
const wchar_t *key,
const wchar_t *val );
/**
Variable used by env_get_names to communicate auxiliary information
to add_key_to_hash
@@ -125,37 +124,109 @@ static int get_names_show_exported;
*/
static int get_names_show_unexported;
/**
List of names for the UTF-8 character set.
*/
static char *iconv_utf8_names[]=
{
"utf-8", "UTF-8",
"utf8", "UTF8",
0
}
;
wchar_t *utf2wcs( const char *in )
/**
List of wide character names, undefined byte length.
*/
static char *iconv_wide_names_unknown[]=
{
"wchar_t", "WCHAR_T",
"wchar", "WCHAR",
0
}
;
/**
List of wide character names, 4 bytes long.
*/
static char *iconv_wide_names_4[]=
{
"wchar_t", "WCHAR_T",
"wchar", "WCHAR",
"ucs-4", "UCS-4",
"ucs4", "UCS4",
"utf-32", "UTF-32",
"utf32", "UTF32",
0
}
;
/**
List of wide character names, 2 bytes long.
*/
static char *iconv_wide_names_2[]=
{
"wchar_t", "WCHAR_T",
"wchar", "WCHAR",
"ucs-2", "UCS-2",
"ucs2", "UCS2",
"utf-16", "UTF-16",
"utf16", "UTF16",
0
}
;
/**
Convert utf-8 string to wide string
*/
static wchar_t *utf2wcs( const char *in )
{
iconv_t cd=(iconv_t) -1;
int i,j;
wchar_t *out;
char *to_name[]=
{
"wchar_t", "WCHAR_T", "wchar", "WCHAR", 0
}
;
/*
Try to convert to wchar_t. If that is not a valid character set,
try various names for ucs-4. We can't be sure that ucs-4 is
really the character set used by wchar_t, but it is the best
assumption we can make.
*/
char **to_name=0;
char *from_name[]=
switch (sizeof (wchar_t))
{
"utf-8", "UTF-8", "utf8", "UTF8", 0
case 2:
to_name = iconv_wide_names_2;
break;
case 4:
to_name = iconv_wide_names_4;
break;
default:
to_name = iconv_wide_names_unknown;
break;
}
;
/*
The line protocol fish uses is always utf-8.
*/
char **from_name = iconv_utf8_names;
size_t in_len = strlen( in );
size_t out_len = sizeof( wchar_t )*(in_len+1);
size_t out_len = sizeof( wchar_t )*(in_len+2);
size_t nconv;
char *nout;
out = malloc( out_len );
nout = (char *)out;
if( !out )
return 0;
for( i=0; to_name[i]; i++ )
{
for( j=0; from_name[j]; j++ )
@@ -165,7 +236,7 @@ wchar_t *utf2wcs( const char *in )
if( cd != (iconv_t) -1)
{
goto start_conversion;
}
}
}
@@ -175,74 +246,108 @@ wchar_t *utf2wcs( const char *in )
if (cd == (iconv_t) -1)
{
/* Something went wrong. */
debug( 0, L"Could not perform utf-8 conversion" );
debug( 0, L"Could not perform utf-8 conversion" );
if(errno != EINVAL)
wperror( L"iconv_open" );
/* Terminate the output string. */
free(out);
return 0;
return 0;
}
nconv = iconv( cd, (char **)&in, &in_len, &nout, &out_len );
if (nconv == (size_t) -1)
{
debug( 0, L"Error while converting from utf string" );
return 0;
}
*((wchar_t *) nout) = L'\0';
/*
Check for silly iconv behaviour inserting an bytemark in the output
string.
*/
if (*out == L'\xfeff' || *out == L'\xffef' || *out == L'\xefbbbf')
{
wchar_t *out_old = out;
out = wcsdup(out+1);
if (! out )
{
debug(0, L"FNORD!!!!");
free( out_old );
return 0;
}
free( out_old );
}
if (iconv_close (cd) != 0)
wperror (L"iconv_close");
return out;
return out;
}
char *wcs2utf( const wchar_t *in )
/**
Convert wide string to utf-8
*/
static char *wcs2utf( const wchar_t *in )
{
iconv_t cd=(iconv_t) -1;
int i,j;
char *char_in = (char *)in;
char *out;
char *from_name[]=
{
"wchar_t", "WCHAR_T", "wchar", "WCHAR", 0
}
;
/*
Try to convert to wchar_t. If that is not a valid character set,
try various names for ucs-4. We can't be sure that ucs-4 is
really the character set used by wchar_t, but it is the best
assumption we can make.
*/
char **from_name=0;
char *to_name[]=
switch (sizeof (wchar_t))
{
"utf-8", "UTF-8", "utf8", "UTF8", 0
case 2:
from_name = iconv_wide_names_2;
break;
case 4:
from_name = iconv_wide_names_4;
break;
default:
from_name = iconv_wide_names_unknown;
break;
}
;
char **to_name = iconv_utf8_names;
size_t in_len = wcslen( in );
size_t out_len = sizeof( char )*( (MAX_UTF8_BYTES*in_len)+1);
size_t nconv;
char *nout;
out = malloc( out_len );
nout = (char *)out;
in_len *= sizeof( wchar_t );
if( !out )
return 0;
for( i=0; to_name[i]; i++ )
{
for( j=0; from_name[j]; j++ )
{
cd = iconv_open ( to_name[i], from_name[j] );
if( cd != (iconv_t) -1)
{
goto start_conversion;
}
}
}
@@ -252,17 +357,17 @@ char *wcs2utf( const wchar_t *in )
if (cd == (iconv_t) -1)
{
/* Something went wrong. */
debug( 0, L"Could not perform utf-8 conversion" );
debug( 0, L"Could not perform utf-8 conversion" );
if(errno != EINVAL)
wperror( L"iconv_open" );
/* Terminate the output string. */
free(out);
return 0;
return 0;
}
nconv = iconv( cd, &char_in, &in_len, &nout, &out_len );
if (nconv == (size_t) -1)
{
@@ -270,13 +375,13 @@ char *wcs2utf( const wchar_t *in )
debug( 0, L"Error while converting from to string" );
return 0;
}
*nout = '\0';
if (iconv_close (cd) != 0)
wperror (L"iconv_close");
return out;
return out;
}
@@ -304,6 +409,9 @@ void env_universal_common_destroy()
hash_destroy( &env_universal_var );
}
/**
Read one byte of date form the specified connection
*/
static int read_byte( connection_t *src )
{
@@ -313,9 +421,9 @@ static int read_byte( connection_t *src )
int res;
res = read( src->fd, src->buffer, ENV_UNIVERSAL_BUFFER_SIZE );
// debug(4, L"Read chunk '%.*s'", res, src->buffer );
if( res < 0 )
{
@@ -324,20 +432,20 @@ static int read_byte( connection_t *src )
{
return ENV_UNIVERSAL_AGAIN;
}
return ENV_UNIVERSAL_ERROR;
}
if( res == 0 )
{
return ENV_UNIVERSAL_EOF;
}
src->buffer_consumed = 0;
src->buffer_used = res;
}
return src->buffer[src->buffer_consumed++];
}
@@ -347,10 +455,10 @@ void read_message( connection_t *src )
{
while( 1 )
{
int ib = read_byte( src );
char b;
switch( ib )
{
case ENV_UNIVERSAL_AGAIN:
@@ -375,43 +483,43 @@ void read_message( connection_t *src )
{
char c = 0;
b_append( &src->input, &c, 1 );
debug( 1,
L"Universal variable connection closed while reading command. Partial command recieved: '%s'",
debug( 1,
L"Universal variable connection closed while reading command. Partial command recieved: '%s'",
(wchar_t *)src->input.buff );
}
return;
}
}
b = (char)ib;
if( b == '\n' )
{
wchar_t *msg;
b = 0;
b_append( &src->input, &b, 1 );
msg = utf2wcs( src->input.buff );
/*
Before calling parse_message, we must empty reset
everything, since the callback function could
potentially call read_message.
*/
src->input.used=0;
if( msg )
{
parse_message( msg, src );
parse_message( msg, src );
}
else
{
debug( 0, _(L"Could not convert message '%s' to wide character string"), src->input.buff );
}
free( msg );
}
else
{
@@ -423,10 +531,10 @@ void read_message( connection_t *src )
/**
Remove variable with specified name
*/
static void remove_entry( wchar_t *name )
void env_universal_common_remove( const wchar_t *name )
{
void *k, *v;
hash_remove( &env_universal_var,
hash_remove( &env_universal_var,
name,
&k,
&v );
@@ -445,85 +553,102 @@ static int match( const wchar_t *msg, const wchar_t *cmd )
if( msg[len] && msg[len]!= L' ' && msg[len] != L'\t' )
return 0;
return 1;
}
void env_universal_common_set( const wchar_t *key, const wchar_t *val, int export )
{
var_uni_entry_t *entry;
wchar_t *name;
CHECK( key, );
CHECK( val, );
entry = malloc( sizeof(var_uni_entry_t) + sizeof(wchar_t)*(wcslen(val)+1) );
name = wcsdup(key);
if( !entry || !name )
DIE_MEM();
entry->export=export;
wcscpy( entry->val, val );
env_universal_common_remove( name );
hash_put( &env_universal_var, name, entry );
if( callback )
{
callback( export?SET_EXPORT:SET, name, val );
}
}
/**
Parse message msg
*/
static void parse_message( wchar_t *msg,
static void parse_message( wchar_t *msg,
connection_t *src )
{
// debug( 3, L"parse_message( %ls );", msg );
if( msg[0] == L'#' )
return;
if( match( msg, SET_STR ) || match( msg, SET_EXPORT_STR ))
{
wchar_t *name, *val, *tmp;
wchar_t *name, *tmp;
int export = match( msg, SET_EXPORT_STR );
name = msg+(export?wcslen(SET_EXPORT_STR):wcslen(SET_STR));
while( wcschr( L"\t ", *name ) )
name++;
tmp = wcschr( name, L':' );
if( tmp )
{
wchar_t *key =malloc( sizeof( wchar_t)*(tmp-name+1));
wchar_t *key;
wchar_t *val;
key = malloc( sizeof( wchar_t)*(tmp-name+1));
memcpy( key, name, sizeof( wchar_t)*(tmp-name));
key[tmp-name]=0;
val = tmp+1;
val = tmp+1;
val = unescape( val, 0 );
var_uni_entry_t *entry =
malloc( sizeof(var_uni_entry_t) + sizeof(wchar_t)*(wcslen(val)+1) );
if( !entry )
DIE_MEM();
entry->export=export;
wcscpy( entry->val, val );
remove_entry( key );
hash_put( &env_universal_var, key, entry );
if( callback )
{
callback( export?SET_EXPORT:SET, key, val );
}
free(val );
env_universal_common_set( key, val, export );
free( val );
free( key );
}
else
{
debug( 1, PARSE_ERR, msg );
}
}
}
else if( match( msg, ERASE_STR ) )
{
wchar_t *name, *tmp;
name = msg+wcslen(ERASE_STR);
while( wcschr( L"\t ", *name ) )
name++;
tmp = name;
while( iswalnum( *tmp ) || *tmp == L'_')
tmp++;
*tmp = 0;
if( !wcslen( name ) )
{
debug( 1, PARSE_ERR, msg );
}
remove_entry( name );
env_universal_common_remove( name );
if( callback )
{
callback( ERASE, name, 0 );
@@ -546,7 +671,7 @@ static void parse_message( wchar_t *msg,
else
{
debug( 1, PARSE_ERR, msg );
}
}
}
/**
@@ -559,7 +684,7 @@ static int try_send( message_t *msg,
{
debug( 3,
L"before write of %d chars to fd %d", strlen(msg->body), fd );
L"before write of %d chars to fd %d", strlen(msg->body), fd );
int res = write( fd, msg->body, strlen(msg->body) );
@@ -571,26 +696,26 @@ static int try_send( message_t *msg,
{
debug( 4, L"Failed to write message '%s'", msg->body );
}
if( res == -1 )
{
switch( errno )
{
case EAGAIN:
return 0;
default:
debug( 2,
L"Error while sending universal variable message to fd %d. Closing connection",
fd );
if( debug_level > 2 )
wperror( L"write" );
return -1;
}
}
}
msg->count--;
if( !msg->count )
{
free( msg );
@@ -601,7 +726,7 @@ static int try_send( message_t *msg,
void try_send_all( connection_t *c )
{
/* debug( 3,
L"Send all updates to connection on fd %d",
L"Send all updates to connection on fd %d",
c->fd );*/
while( !q_empty( &c->unsent) )
{
@@ -610,12 +735,12 @@ void try_send_all( connection_t *c )
case 1:
q_get( &c->unsent);
break;
case 0:
debug( 4,
L"Socket full, send rest later" );
L"Socket full, send rest later" );
return;
case -1:
c->killme = 1;
return;
@@ -623,6 +748,9 @@ void try_send_all( connection_t *c )
}
}
/**
Escape specified string
*/
static wchar_t *full_escape( const wchar_t *in )
{
string_buffer_t out;
@@ -651,16 +779,16 @@ static wchar_t *full_escape( const wchar_t *in )
message_t *create_message( int type,
const wchar_t *key_in,
const wchar_t *key_in,
const wchar_t *val_in )
{
message_t *msg=0;
char *key=0;
size_t sz;
// debug( 4, L"Crete message of type %d", type );
if( key_in )
{
if( wcsvarname( key_in ) )
@@ -668,7 +796,7 @@ message_t *create_message( int type,
debug( 0, L"Illegal variable name: '%ls'", key_in );
return 0;
}
key = wcs2utf(key_in);
if( !key )
{
@@ -678,8 +806,8 @@ message_t *create_message( int type,
return 0;
}
}
switch( type )
{
case SET:
@@ -689,29 +817,29 @@ message_t *create_message( int type,
{
val_in=L"";
}
wchar_t *esc = full_escape( val_in );
if( !esc )
break;
char *val = wcs2utf(esc );
free(esc);
sz = strlen(type==SET?SET_MBS:SET_EXPORT_MBS) + strlen(key) + strlen(val) + 4;
msg = malloc( sizeof( message_t ) + sz );
if( !msg )
DIE_MEM();
strcpy( msg->body, (type==SET?SET_MBS:SET_EXPORT_MBS) );
strcat( msg->body, " " );
strcat( msg->body, key );
strcat( msg->body, ":" );
strcat( msg->body, val );
strcat( msg->body, "\n" );
free( val );
break;
}
@@ -722,7 +850,7 @@ message_t *create_message( int type,
if( !msg )
DIE_MEM();
strcpy( msg->body, ERASE_MBS " " );
strcat( msg->body, key );
strcat( msg->body, "\n" );
@@ -731,14 +859,14 @@ message_t *create_message( int type,
case BARRIER:
{
msg = malloc( sizeof( message_t ) +
msg = malloc( sizeof( message_t ) +
strlen( BARRIER_MBS ) +2);
if( !msg )
DIE_MEM();
strcpy( msg->body, BARRIER_MBS "\n" );
break;
}
case BARRIER_REPLY:
{
msg = malloc( sizeof( message_t ) +
@@ -748,7 +876,7 @@ message_t *create_message( int type,
strcpy( msg->body, BARRIER_REPLY_MBS "\n" );
break;
}
default:
{
debug( 0, L"create_message: Unknown message type" );
@@ -762,19 +890,19 @@ message_t *create_message( int type,
// debug( 4, L"Message body is '%s'", msg->body );
return msg;
return msg;
}
/**
Function used with hash_foreach to insert keys of one table into
another
*/
static void add_key_to_hash( void *key,
static void add_key_to_hash( void *key,
void *data,
void *aux )
{
var_uni_entry_t *e = (var_uni_entry_t *)data;
if( ( e->export && get_names_show_exported) ||
if( ( e->export && get_names_show_exported) ||
( !e->export && get_names_show_unexported) )
al_push( (array_list_t *)aux, key );
}
@@ -785,18 +913,18 @@ void env_universal_common_get_names( array_list_t *l,
{
get_names_show_exported = show_exported;
get_names_show_unexported = show_unexported;
hash_foreach2( &env_universal_var,
hash_foreach2( &env_universal_var,
add_key_to_hash,
l );
}
wchar_t *env_universal_common_get( const wchar_t *name )
{
var_uni_entry_t *e = (var_uni_entry_t *)hash_get( &env_universal_var, name );
var_uni_entry_t *e = (var_uni_entry_t *)hash_get( &env_universal_var, name );
if( e )
return e->val;
return 0;
return 0;
}
int env_universal_common_get_export( const wchar_t *name )
@@ -824,17 +952,17 @@ static void enqueue( void *k,
const wchar_t *key = (const wchar_t *)k;
const var_uni_entry_t *val = (const var_uni_entry_t *)v;
dyn_queue_t *queue = (dyn_queue_t *)q;
message_t *msg = create_message( val->export?SET_EXPORT:SET, key, val->val );
msg->count=1;
q_put( queue, msg );
}
void enqueue_all( connection_t *c )
{
hash_foreach2( &env_universal_var,
&enqueue,
&enqueue,
(void *)&c->unsent );
try_send_all( c );
}
@@ -846,15 +974,23 @@ void connection_init( connection_t *c, int fd )
c->fd = fd;
b_init( &c->input );
q_init( &c->unsent );
c->buffer_consumed = c->buffer_used = 0;
c->buffer_consumed = c->buffer_used = 0;
}
void connection_destroy( connection_t *c)
{
q_destroy( &c->unsent );
b_destroy( &c->input );
if( close( c->fd ) )
/*
A connection need not always be open - we only try to close it
if it is open.
*/
if( c->fd >= 0 )
{
wperror( L"close" );
if( close( c->fd ) )
{
wperror( L"close" );
}
}
}

View File

@@ -76,9 +76,9 @@ typedef struct connection
newline is encountered, the buffer is parsed and cleared.
*/
buffer_t input;
/**
The read buffer.
The read buffer.
*/
char buffer[ENV_UNIVERSAL_BUFFER_SIZE];
@@ -86,12 +86,12 @@ typedef struct connection
Number of bytes that have already been consumed.
*/
int buffer_consumed;
/**
Number of bytes that have been read into the buffer.
Number of bytes that have been read into the buffer.
*/
int buffer_used;
/**
Link to the next connection
@@ -103,7 +103,7 @@ typedef struct connection
/**
A struct representing a message to be sent between client and server
*/
typedef struct
typedef struct
{
/**
Number of queues that contain this message. Once this reaches zero, the message should be deleted
@@ -112,7 +112,7 @@ typedef struct
/**
Message body. The message must be allocated using enough memory to actually contain the message.
*/
char body[0];
char body[1];
}
message_t;
@@ -143,19 +143,50 @@ void env_universal_common_destroy();
/**
Add all variable names to the specified list
This function operate agains the local copy of all universal
variables, it does not communicate with any other process.
*/
void env_universal_common_get_names( array_list_t *l,
int show_exported,
int show_unexported );
/**
Perform the specified variable assignment.
This function operate agains the local copy of all universal
variables, it does not communicate with any other process.
Do not call this function. Create a message to do it. This function
is only to be used when fishd is dead.
*/
void env_universal_common_set( const wchar_t *key, const wchar_t *val, int export );
/**
Remove the specified variable.
This function operate agains the local copy of all universal
variables, it does not communicate with any other process.
Do not call this function. Create a message to do it. This function
is only to be used when fishd is dead.
*/
void env_universal_common_remove( const wchar_t *key );
/**
Get the value of the variable with the specified name
This function operate agains the local copy of all universal
variables, it does not communicate with any other process.
*/
wchar_t *env_universal_common_get( const wchar_t *name );
/**
Get the export flag of the variable with the specified
name. Returns 0 if the variable doesn't exist.
This function operate agains the local copy of all universal
variables, it does not communicate with any other process.
*/
int env_universal_common_get_export( const wchar_t *name );
@@ -164,8 +195,17 @@ int env_universal_common_get_export( const wchar_t *name );
*/
void enqueue_all( connection_t *c );
/**
Fill in the specified connection_t struct. Use the specified file
descriptor for communication.
*/
void connection_init( connection_t *c, int fd );
/**
Close and destroy the specified connection struct. This frees
allstructures allocated by the connection, such as ques of unsent
messages.
*/
void connection_destroy( connection_t *c);
#endif

View File

@@ -3,12 +3,6 @@
#
# @configure_input@
#
# Set default field separators
#
set -g IFS \ \t\n
#
# Some things should only be done for login terminals
#
@@ -45,7 +39,7 @@ if status --is-login
end
#
# There are variables that contain colons that are not arrays. This
# There are variables that contain colons that are not arrays. This
# reverts them back to regular strings.
#
@@ -63,4 +57,5 @@ if test -d include
for i in include/*.fish
. $i
end
end
end

View File

@@ -1,28 +0,0 @@
#
# This file contains key bindings for fish
#
# Include system-wide inputrc file before including fish-specific key
# bindings if it exists
$include /etc/inputrc
$if fish
"\M-l": __fish_list_current_token
"\M-w": set tok (commandline -pt); if test $tok[1]; whatis $tok[1]; end
"\C-l": clear
"\C-c": delete-line
"\C-u": backward-kill-line
"\M-d": kill-word
"\C-w": backward-kill-word
"\M-k": dump-functions
"\M-d": if test -z (commandline); dirh; else; commandline -f kill-word; end
"\C-d": delete-or-exit
# This will make sure the output of the current command is paged using the less pager when you press Meta-p
"\M-p": if commandline -j|grep -v 'less *$' >/dev/null; commandline -aj "|less;"; end
$endif
# Include user-specific inputrc file after including fish-specific
# bindings so that they will override fish defaults
$include ~/.inputrc

239
event.c
View File

@@ -44,11 +44,11 @@ typedef struct
/**
Whether signals have been skipped
*/
int overflow;
int overflow;
/**
Array of signal events
*/
int signal[SIG_UNHANDLED_MAX];
int signal[SIG_UNHANDLED_MAX];
}
signal_list_t;
@@ -78,11 +78,6 @@ static array_list_t *killme;
*/
static array_list_t *blocked;
/**
String buffer used for formating event descriptions in event_get_desc()
*/
static string_buffer_t *get_desc_buff=0;
/**
Tests if one event instance matches the definition of a event
class. If both the class and the instance name a function,
@@ -91,6 +86,7 @@ static string_buffer_t *get_desc_buff=0;
*/
static int event_match( event_t *class, event_t *instance )
{
if( class->function_name && instance->function_name )
{
if( wcscmp( class->function_name, instance->function_name ) != 0 )
@@ -99,23 +95,23 @@ static int event_match( event_t *class, event_t *instance )
if( class->type == EVENT_ANY )
return 1;
if( class->type != instance->type )
return 0;
switch( class->type )
{
case EVENT_SIGNAL:
if( class->param1.signal == EVENT_ANY_SIGNAL )
return 1;
return class->param1.signal == instance->param1.signal;
case EVENT_VARIABLE:
return wcscmp( instance->param1.variable,
class->param1.variable )==0;
case EVENT_EXIT:
if( class->param1.pid == EVENT_ANY_PID )
return 1;
@@ -123,12 +119,17 @@ static int event_match( event_t *class, event_t *instance )
case EVENT_JOB_ID:
return class->param1.job_id == instance->param1.job_id;
case EVENT_GENERIC:
return wcscmp( instance->param1.param,
class->param1.param )==0;
}
/**
This should never be reached
*/
return 0;
return 0;
}
@@ -139,8 +140,10 @@ static int event_match( event_t *class, event_t *instance )
static event_t *event_copy( event_t *event, int copy_arguments )
{
event_t *e = malloc( sizeof( event_t ) );
if( !e )
DIE_MEM();
memcpy( e, event, sizeof(event_t));
if( e->function_name )
@@ -148,7 +151,9 @@ static event_t *event_copy( event_t *event, int copy_arguments )
if( e->type == EVENT_VARIABLE )
e->param1.variable = wcsdup( e->param1.variable );
else if( e->type == EVENT_GENERIC )
e->param1.param = wcsdup( e->param1.param );
al_init( &e->arguments );
if( copy_arguments )
{
@@ -157,9 +162,9 @@ static event_t *event_copy( event_t *event, int copy_arguments )
{
al_push( &e->arguments, wcsdup( (wchar_t *)al_get( &event->arguments, i ) ) );
}
}
return e;
}
@@ -170,7 +175,7 @@ static int event_is_blocked( event_t *e )
{
block_t *block;
event_block_t *eb;
for( block = current_block; block; block = block->outer )
{
for( eb = block->first_event_block; eb; eb=eb->next )
@@ -188,15 +193,20 @@ static int event_is_blocked( event_t *e )
if( eb->type & (1<<e->type) )
return 1;
return 1;
}
return 0;
}
const wchar_t *event_get_desc( event_t *e )
{
/*
String buffer used for formating event descriptions in event_get_desc()
*/
static string_buffer_t *get_desc_buff=0;
CHECK( e, 0 );
if( !get_desc_buff )
@@ -207,18 +217,18 @@ const wchar_t *event_get_desc( event_t *e )
{
sb_clear( get_desc_buff );
}
switch( e->type )
{
case EVENT_SIGNAL:
sb_printf( get_desc_buff, _(L"signal handler for %ls (%ls)"), sig2wcs(e->param1.signal ), signal_get_desc( e->param1.signal ) );
break;
case EVENT_VARIABLE:
sb_printf( get_desc_buff, _(L"handler for variable '%ls'"), e->param1.variable );
break;
case EVENT_EXIT:
if( e->param1.pid > 0 )
{
@@ -232,9 +242,9 @@ const wchar_t *event_get_desc( event_t *e )
else
sb_printf( get_desc_buff, _(L"exit handler for job with process group %d"), -e->param1.pid );
}
break;
case EVENT_JOB_ID:
{
job_t *j = job_get( e->param1.job_id );
@@ -245,9 +255,17 @@ const wchar_t *event_get_desc( event_t *e )
break;
}
case EVENT_GENERIC:
sb_printf( get_desc_buff, _(L"handler for generic event '%ls'"), e->param1.param );
break;
default:
sb_printf( get_desc_buff, _(L"Unknown event type") );
break;
}
return (const wchar_t *)get_desc_buff->buff;
}
@@ -257,7 +275,7 @@ void event_add_handler( event_t *event )
event_t *e;
CHECK( event, );
e = event_copy( event, 0 );
if( !events )
@@ -267,8 +285,8 @@ void event_add_handler( event_t *event )
{
signal_handle( e->param1.signal, 1 );
}
al_push( events, e );
al_push( events, e );
}
void event_remove( event_t *criterion )
@@ -276,7 +294,7 @@ void event_remove( event_t *criterion )
int i;
array_list_t *new_list=0;
event_t e;
CHECK( criterion, );
/*
@@ -287,19 +305,19 @@ void event_remove( event_t *criterion )
that shouldn't be killed to new_list, and then drops the empty
events-list.
*/
if( !events )
return;
for( i=0; i<al_get_count( events); i++ )
{
event_t *n = (event_t *)al_get( events, i );
event_t *n = (event_t *)al_get( events, i );
if( event_match( criterion, n ) )
{
if( !killme )
killme = al_new();
al_push( killme, n );
al_push( killme, n );
/*
If this event was a signal handler and no other handler handles
@@ -311,11 +329,11 @@ void event_remove( event_t *criterion )
e.type = EVENT_SIGNAL;
e.param1.signal = n->param1.signal;
e.function_name = 0;
if( event_get( &e, 0 ) == 1 )
{
signal_handle( e.param1.signal, 0 );
}
}
}
}
else
@@ -326,7 +344,7 @@ void event_remove( event_t *criterion )
}
}
al_destroy( events );
free( events );
free( events );
events = new_list;
}
@@ -334,21 +352,21 @@ int event_get( event_t *criterion, array_list_t *out )
{
int i;
int found = 0;
if( !events )
return 0;
return 0;
CHECK( criterion, 0 );
for( i=0; i<al_get_count( events); i++ )
{
event_t *n = (event_t *)al_get( events, i );
event_t *n = (event_t *)al_get( events, i );
if( event_match(criterion, n ) )
{
found++;
if( out )
al_push( out, n );
}
}
}
return found;
}
@@ -361,7 +379,7 @@ static void event_free_kills()
int i;
if( !killme )
return;
for( i=0; i<al_get_count( killme ); i++ )
{
event_t *roadkill = (event_t *)al_get( killme, i );
@@ -378,16 +396,16 @@ static int event_is_killed( event_t *e )
int i;
if( !killme )
return 0;
for( i=0; i<al_get_count( killme ); i++ )
{
event_t *roadkill = (event_t *)al_get( events, i );
if( roadkill ==e )
return 1;
}
return 0;
}
}
/**
Perform the specified event. Since almost all event firings will
@@ -400,11 +418,11 @@ static void event_fire_internal( event_t *event )
int i, j;
string_buffer_t *b=0;
array_list_t *fire=0;
/*
First we free all events that have been removed
*/
event_free_kills();
event_free_kills();
if( !events )
return;
@@ -419,7 +437,7 @@ static void event_fire_internal( event_t *event )
for( i=0; i<al_get_count( events ); i++ )
{
event_t *criterion = (event_t *)al_get( events, i );
/*
Check if this event is a match
*/
@@ -430,21 +448,22 @@ static void event_fire_internal( event_t *event )
al_push( fire, criterion );
}
}
/*
No matches. Time to return.
*/
if( !fire )
return;
/*
Iterate over our list of matching events
*/
for( i=0; i<al_get_count( fire ); i++ )
{
event_t *criterion = (event_t *)al_get( fire, i );
int prev_status;
/*
Check if this event has been removed, if so, dont fire it
*/
@@ -458,48 +477,50 @@ static void event_fire_internal( event_t *event )
b = sb_new();
else
sb_clear( b );
sb_append( b, criterion->function_name );
for( j=0; j<al_get_count(&event->arguments); j++ )
{
wchar_t *arg_esc = escape( (wchar_t *)al_get( &event->arguments, j), 1 );
wchar_t *arg_esc = escape( (wchar_t *)al_get( &event->arguments, j), 1 );
sb_append( b, L" " );
sb_append( b, arg_esc );
free( arg_esc );
free( arg_esc );
}
// debug( 1, L"Event handler fires command '%ls'", (wchar_t *)b->buff );
/*
Event handlers are not part of the main flow of code, so
they are marked as non-interactive
*/
proc_push_interactive(0);
prev_status = proc_get_last_status();
parser_push_block( EVENT );
current_block->param1.event = event;
eval( (wchar_t *)b->buff, 0, TOP );
parser_pop_block();
proc_pop_interactive();
proc_pop_interactive();
proc_set_last_status( prev_status );
}
if( b )
{
sb_destroy( b );
free( b );
free( b );
}
if( fire )
{
al_destroy( fire );
free( fire );
}
/*
Free killed events
*/
event_free_kills();
event_free_kills();
}
/**
@@ -511,7 +532,7 @@ static void event_fire_delayed()
int i;
/*
If is_event is one, we are running the event-handler non-recursively.
If is_event is one, we are running the event-handler non-recursively.
When the event handler has called a piece of code that triggers
another event, we do not want to fire delayed events because of
@@ -520,7 +541,7 @@ static void event_fire_delayed()
if( blocked && is_event==1)
{
array_list_t *new_blocked = 0;
for( i=0; i<al_get_count( blocked ); i++ )
{
event_t *e = (event_t *)al_get( blocked, i );
@@ -528,24 +549,24 @@ static void event_fire_delayed()
{
if( !new_blocked )
new_blocked = al_new();
al_push( new_blocked, e );
al_push( new_blocked, e );
}
else
{
event_fire_internal( e );
event_free( e );
}
}
}
al_destroy( blocked );
free( blocked );
blocked = new_blocked;
}
while( sig_list[active_list].count > 0 )
{
signal_list_t *lst;
event_t e;
al_init( &e.arguments );
al_init( &e.arguments );
/*
Switch signal lists
@@ -555,47 +576,47 @@ static void event_fire_delayed()
active_list=1-active_list;
/*
Set up
Set up
*/
e.type=EVENT_SIGNAL;
e.function_name=0;
lst = &sig_list[1-active_list];
if( lst->overflow )
{
debug( 0, _( L"Signal list overflow. Signals have been ignored." ) );
}
/*
Send all signals in our private list
*/
for( i=0; i<lst->count; i++ )
{
e.param1.signal = lst->signal[i];
al_set( &e.arguments, 0, sig2wcs( e.param1.signal ) );
al_set( &e.arguments, 0, sig2wcs( e.param1.signal ) );
if( event_is_blocked( &e ) )
{
if( !blocked )
blocked = al_new();
al_push( blocked, event_copy(&e, 1) );
al_push( blocked, event_copy(&e, 1) );
}
else
{
event_fire_internal( &e );
}
}
al_destroy( &e.arguments );
}
}
}
void event_fire( event_t *event )
{
is_event++;
if( event && (event->type == EVENT_SIGNAL) )
{
/*
@@ -611,16 +632,18 @@ void event_fire( event_t *event )
}
else
{
/*
Fire events triggered by signals
*/
event_fire_delayed();
if( event )
{
if( event_is_blocked( event ) )
{
if( !blocked )
blocked = al_new();
al_push( blocked, event_copy(event, 1) );
}
else
@@ -628,8 +651,8 @@ void event_fire( event_t *event )
event_fire_internal( event );
}
}
}
}
is_event--;
}
@@ -645,7 +668,7 @@ void event_destroy()
{
al_foreach( events, (void (*)(void *))&event_free );
al_destroy( events );
free( events );
free( events );
events=0;
}
@@ -653,9 +676,9 @@ void event_destroy()
{
al_foreach( killme, (void (*)(void *))&event_free );
al_destroy( killme );
free( killme );
killme=0;
}
free( killme );
killme=0;
}
}
void event_free( event_t *e )
@@ -670,7 +693,39 @@ void event_free( event_t *e )
free( (void *)e->function_name );
if( e->type == EVENT_VARIABLE )
{
free( (void *)e->param1.variable );
}
else if( e->type == EVENT_GENERIC )
{
free( (void *)e->param1.param );
}
free( e );
}
void event_fire_generic_internal(const wchar_t *name, ...)
{
event_t ev;
va_list va;
wchar_t *arg;
CHECK( name, );
ev.type = EVENT_GENERIC;
ev.param1.param = name;
ev.function_name=0;
al_init( &ev.arguments );
va_start( va, name );
while( (arg=va_arg(va, wchar_t *) )!= 0 )
{
al_push( &ev.arguments, arg );
}
va_end( va );
event_fire( &ev );
}

50
event.h
View File

@@ -2,6 +2,12 @@
Functions for handling event triggers
Because most of these functions can be called by signal
handler, it is important to make it well defined when these
functions produce output or perform memory allocations, since
such functions may not be safely called by signal handlers.
*/
#ifndef FISH_EVENT_H
#define FISH_EVENT_H
@@ -27,6 +33,7 @@ enum
EVENT_VARIABLE, /**< An event triggered by a variable update */
EVENT_EXIT, /**< An event triggered by a job or process exit */
EVENT_JOB_ID, /**< An event triggered by a job exit */
EVENT_GENERIC, /**< A generic event */
}
;
@@ -37,7 +44,7 @@ enum
- When used as a parameter to event_add, it represents a class of events, and function_name is the name of the function which will be called whenever an event matching the specified class occurs. This is also how events are stored internally.
- When used as a parameter to event_get, event_remove and event_fire, it represents a class of events, and if the function_name field is non-zero, only events which call the specified function will be returned.
*/
typedef struct
typedef struct
{
/**
Type of event
@@ -67,13 +74,17 @@ typedef struct
Job id for EVENT_JOB_ID type events
*/
int job_id;
/**
The parameter describing this generic event
*/
const wchar_t *param;
} param1;
/**
The name of the event handler function
*/
const wchar_t *function_name;
const wchar_t *function_name;
/**
The argument list. Only used when sending a new event using
@@ -85,21 +96,28 @@ typedef struct
event_t;
/**
Add an event handler
Add an event handler
May not be called by a signal handler, since it may allocate new memory.
*/
void event_add_handler( event_t *event );
/**
Remove all events matching the specified criterion.
Remove all events matching the specified criterion.
May not be called by a signal handler, since it may free allocated memory.
*/
void event_remove( event_t *event );
/**
Return all events which match the specified event class
Return all events which match the specified event class
This function is safe to call from a signal handler _ONLY_ if the
out parameter is null.
\param criterion Is the class of events to return. If the criterion has a non-null function_name, only events which trigger the specified function will return.
\param out the list to add events to. May be 0, in which case no events will be added, but the result count will still be valid
\return the number of found matches
*/
int event_get( event_t *criterion, array_list_t *out );
@@ -111,7 +129,14 @@ int event_get( event_t *criterion, array_list_t *out );
called. If event is a null-pointer, all pending events are
dispatched.
\param event the specific event whose handlers should fire
This function is safe to call from a signal handler _ONLY_ if the
event parameter is for a signal. Signal events not be fired, by the
call to event_fire, instead they will be fired the next time
event_fire is called with anull argument. This is needed to make
sure that no code evaluation is ever performed by a signal handler.
\param event the specific event whose handlers should fire. If
null, then all delayed events will be fired.
*/
void event_fire( event_t *event );
@@ -126,7 +151,7 @@ void event_init();
void event_destroy();
/**
Free all memory used by event
Free all memory used by the specified event
*/
void event_free( event_t *e );
@@ -136,4 +161,11 @@ void event_free( event_t *e );
*/
const wchar_t *event_get_desc( event_t *e );
/**
Fire a generic event with the specified name
*/
#define event_fire_generic( ... ) event_fire_generic_internal( __VA_ARGS__, (void *)0 )
void event_fire_generic_internal(const wchar_t *name,...);
#endif

1208
exec.c

File diff suppressed because it is too large Load Diff

4
exec.h
View File

@@ -19,7 +19,7 @@
#define PIPE_ERROR _(L"An error occurred while setting up pipe")
/**
Execute the processes specified by j.
Execute the processes specified by j.
I've put a fair bit of work into making builtins behave like other
programs as far as pipes are concerned. Unlike i.e. bash, builtins
@@ -51,7 +51,7 @@ void exec( job_t *j );
\return the status of the last job to exit, or -1 if en error was encountered.
*/
__warn_unused int exec_subshell( const wchar_t *cmd,
__warn_unused int exec_subshell( const wchar_t *cmd,
array_list_t *l );

370
expand.c
View File

@@ -1,7 +1,7 @@
/**\file expand.c
String expansion functions. These functions perform several kinds of
parameter expansion.
parameter expansion.
*/
@@ -85,7 +85,7 @@ parameter expansion.
/**
Description for short job. The job command is concatenated
*/
#define COMPLETE_JOB_DESC_VAL _( L"Job: ")
#define COMPLETE_JOB_DESC_VAL _( L"Job: %ls")
/**
Description for the shells own pid
@@ -109,11 +109,11 @@ parameter expansion.
/**
Characters which make a string unclean if they are the first
character of the string. See \c is_clean().
character of the string. See \c expand_is_clean().
*/
#define UNCLEAN_FIRST L"~%"
/**
Unclean characters. See \c is_clean().
Unclean characters. See \c expand_is_clean().
*/
#define UNCLEAN L"$*?\\\"'({})"
@@ -168,7 +168,7 @@ static int is_quotable( wchar_t *str )
case L'\t':
case L'\r':
case L'\b':
case L'\e':
case L'\x1b':
return 0;
default:
@@ -195,14 +195,14 @@ wchar_t *expand_escape_variable( const wchar_t *in )
case 0:
sb_append( &buff, L"''");
break;
case 1:
{
wchar_t *el = (wchar_t *)al_get( &l, 0 );
if( wcschr( el, L' ' ) && is_quotable( el ) )
{
sb_append2( &buff,
sb_append( &buff,
L"'",
el,
L"'",
@@ -228,7 +228,7 @@ wchar_t *expand_escape_variable( const wchar_t *in )
if( is_quotable( el ) )
{
sb_append2( &buff,
sb_append( &buff,
L"'",
el,
L"'",
@@ -272,15 +272,17 @@ static int iswnumeric( const wchar_t *n )
*/
static int match_pid( const wchar_t *cmd,
const wchar_t *proc,
int flags )
int flags,
int *offset)
{
/* Test for direct match */
if( wcsncmp( cmd, proc, wcslen( proc ) ) == 0 )
{
if( offset )
*offset = 0;
return 1;
if( flags & ACCEPT_INCOMPLETE )
return 0;
}
/*
Test if the commandline is a path to the command, if so we try
@@ -309,7 +311,11 @@ static int match_pid( const wchar_t *cmd,
if( wcsncmp( start+1, proc, wcslen( proc ) ) == 0 )
{
if( offset )
*offset = start+1-first_token;
free( first_token );
return 1;
}
}
@@ -323,14 +329,14 @@ static int match_pid( const wchar_t *cmd,
Searches for a job with the specified job id, or a job or process
which has the string \c proc as a prefix of its commandline.
If accept_incomplete is true, the remaining string for any matches
If the ACCEPT_INCOMPLETE flag is set, the remaining string for any matches
are inserted.
If accept_incomplete is false, any job matching the specified
string is matched, and the job pgid is returned. If no job
matches, all child processes are searched. If no child processes
match, and <tt>fish</tt> can understand the contents of the /proc
filesystem, all the users processes are searched for matches.
Otherwise, any job matching the specified string is matched, and
the job pgid is returned. If no job matches, all child processes
are searched. If no child processes match, and <tt>fish</tt> can
understand the contents of the /proc filesystem, all the users
processes are searched for matches.
*/
static int find_process( const wchar_t *proc,
@@ -366,14 +372,20 @@ static int find_process( const wchar_t *proc,
if( wcsncmp( proc, jid, wcslen(proc ) )==0 )
{
al_push( out,
wcsdupcat2( jid+wcslen(proc),
COMPLETE_SEP_STR,
COMPLETE_JOB_DESC_VAL,
j->command,
(void *)0 ) );
string_buffer_t desc_buff;
sb_init( &desc_buff );
sb_printf( &desc_buff,
COMPLETE_JOB_DESC_VAL,
j->command );
completion_allocate( out,
jid+wcslen(proc),
(wchar_t *)desc_buff.buff,
0 );
sb_destroy( &desc_buff );
}
}
@@ -381,13 +393,17 @@ static int find_process( const wchar_t *proc,
else
{
int jid = wcstol( proc, 0, 10 );
if( jid > 0 )
int jid;
wchar_t *end;
errno = 0;
jid = wcstol( proc, &end, 10 );
if( jid > 0 && !errno && !*end )
{
j = job_get( jid );
if( (j != 0) && (j->command != 0 ) )
{
{
result = malloc(sizeof(wchar_t)*16 );
swprintf( result, 16, L"%d", j->pgid );
@@ -403,18 +419,19 @@ static int find_process( const wchar_t *proc,
for( j=first_job; j != 0; j=j->next )
{
int offset;
if( j->command == 0 )
continue;
if( match_pid( j->command, proc, flags ) )
if( match_pid( j->command, proc, flags, &offset ) )
{
if( flags & ACCEPT_INCOMPLETE )
{
wchar_t *res = wcsdupcat2( j->command + wcslen(proc),
COMPLETE_SEP_STR,
COMPLETE_JOB_DESC,
(void *)0 );
al_push( out, res );
completion_allocate( out,
j->command + offset + wcslen(proc),
COMPLETE_JOB_DESC,
0 );
}
else
{
@@ -438,19 +455,19 @@ static int find_process( const wchar_t *proc,
continue;
for( p=j->first_process; p; p=p->next )
{
int offset;
if( p->actual_cmd == 0 )
continue;
if( match_pid( p->actual_cmd, proc, flags ) )
if( match_pid( p->actual_cmd, proc, flags, &offset ) )
{
if( flags & ACCEPT_INCOMPLETE )
{
wchar_t *res = wcsdupcat2( p->actual_cmd + wcslen(proc),
COMPLETE_SEP_STR,
COMPLETE_CHILD_PROCESS_DESC,
(void *)0);
al_push( out, res );
completion_allocate( out,
p->actual_cmd + offset + wcslen(proc),
COMPLETE_CHILD_PROCESS_DESC,
0 );
}
else
{
@@ -479,7 +496,7 @@ static int find_process( const wchar_t *proc,
pdir_name = malloc( sizeof(wchar_t)*256 );
pfile_name = malloc( sizeof(wchar_t)*64 );
wcscpy( pdir_name, L"/proc/" );
while( (next=wreaddir(dir))!=0 )
{
wchar_t *name = next->d_name;
@@ -516,7 +533,7 @@ static int find_process( const wchar_t *proc,
signal_block();
fgetws2( &cmd, &sz, cmdfile );
signal_unblock();
fclose( cmdfile );
}
else
@@ -556,16 +573,16 @@ static int find_process( const wchar_t *proc,
if( cmd != 0 )
{
if( match_pid( cmd, proc, flags ) )
int offset;
if( match_pid( cmd, proc, flags, &offset ) )
{
if( flags & ACCEPT_INCOMPLETE )
{
wchar_t *res = wcsdupcat2( cmd + wcslen(proc),
COMPLETE_SEP_STR,
COMPLETE_PROCESS_DESC,
(void *)0);
if( res )
al_push( out, res );
completion_allocate( out,
cmd + offset + wcslen(proc),
COMPLETE_PROCESS_DESC,
0 );
}
else
{
@@ -598,7 +615,7 @@ static int expand_pid( wchar_t *in,
CHECK( in, 0 );
CHECK( out, 0 );
if( *in != PROCESS_EXPAND )
{
al_push( out, in );
@@ -609,13 +626,17 @@ static int expand_pid( wchar_t *in,
{
if( wcsncmp( in+1, SELF_STR, wcslen(in+1) )==0 )
{
wchar_t *res = wcsdupcat2( SELF_STR+wcslen(in+1), COMPLETE_SEP_STR, COMPLETE_SELF_DESC, (void *)0 );
al_push( out, res );
completion_allocate( out,
SELF_STR+wcslen(in+1),
COMPLETE_SELF_DESC,
0 );
}
else if( wcsncmp( in+1, LAST_STR, wcslen(in+1) )==0 )
{
wchar_t *res = wcsdupcat2( LAST_STR+wcslen(in+1), COMPLETE_SEP_STR, COMPLETE_LAST_DESC, (void *)0 );
al_push( out, res );
completion_allocate( out,
LAST_STR+wcslen(in+1),
COMPLETE_LAST_DESC,
0 );
}
}
else
@@ -671,7 +692,7 @@ static int expand_pid( wchar_t *in,
void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
{
int stop_pos = token_pos+1;
switch( token[stop_pos] )
{
case BRACKET_BEGIN:
@@ -686,13 +707,13 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
{
post = end+1;
*end = 0;
if( !wcsvarname( name ) )
{
is_var = 1;
}
}
if( is_var )
{
error( SYNTAX_ERROR,
@@ -700,7 +721,7 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
COMPLETE_VAR_BRACKET_DESC,
cpy,
name,
post );
post );
}
else
{
@@ -712,18 +733,18 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
L"" );
}
free( cpy );
break;
}
case INTERNAL_SEPARATOR:
{
error( SYNTAX_ERROR,
error_pos,
COMPLETE_VAR_PARAN_DESC );
COMPLETE_VAR_PARAN_DESC );
break;
}
case 0:
{
error( SYNTAX_ERROR,
@@ -731,7 +752,7 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
COMPLETE_VAR_NULL_DESC );
break;
}
default:
{
error( SYNTAX_ERROR,
@@ -743,31 +764,33 @@ void expand_variable_error( const wchar_t *token, int token_pos, int error_pos )
}
}
/**
Parse an array slicing specification
*/
static int parse_slice( wchar_t *in, wchar_t **end_ptr, array_list_t *idx )
{
wchar_t *end;
int pos = 1;
// debug( 0, L"parse_slice on '%ls'", in );
while( 1 )
{
long tmp;
while( iswspace(in[pos]) || (in[pos]==INTERNAL_SEPARATOR))
pos++;
pos++;
if( in[pos] == L']' )
{
pos++;
break;
}
errno=0;
tmp = wcstol( &in[pos], &end, 10 );
if( ( errno ) || ( end == &in[pos] ) )
@@ -775,19 +798,19 @@ static int parse_slice( wchar_t *in, wchar_t **end_ptr, array_list_t *idx )
return 1;
}
// debug( 0, L"Push idx %d", tmp );
al_push_long( idx, tmp );
pos = end-in;
}
if( end_ptr )
{
// debug( 0, L"Remainder is '%ls', slice def was %d characters long", in+pos, pos );
*end_ptr = in+pos;
}
// debug( 0, L"ok, done" );
return 0;
}
@@ -820,7 +843,7 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
CHECK( in, 0 );
CHECK( out, 0 );
if( !var_tmp )
{
var_tmp = sb_halloc( global_context );
@@ -855,7 +878,7 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
wchar_t * new_in;
int is_single = (c==VARIABLE_EXPAND_SINGLE);
int var_name_stop_pos;
stop_pos = start_pos;
while( 1 )
@@ -869,15 +892,15 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
stop_pos++;
}
var_name_stop_pos = stop_pos;
/* printf( "Stop for '%c'\n", in[stop_pos]);*/
var_len = stop_pos - start_pos;
if( var_len == 0 )
{
expand_variable_error( in, stop_pos-1, -1 );
expand_variable_error( in, stop_pos-1, -1 );
is_ok = 0;
break;
}
@@ -896,17 +919,17 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
{
wchar_t *slice_end;
all_vars=0;
if( parse_slice( &in[stop_pos], &slice_end, var_idx_list ) )
{
error( SYNTAX_ERROR,
-1,
L"Invalid index value" );
L"Invalid index value" );
is_ok = 0;
}
}
stop_pos = (slice_end-in);
}
}
if( is_ok )
{
tokenize_variable_array( var_val, &var_item_list );
@@ -951,12 +974,12 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
if( is_ok )
{
if( is_single )
{
string_buffer_t res;
in[i]=0;
sb_init( &res );
sb_append( &res, in );
sb_append_char( &res, INTERNAL_SEPARATOR );
@@ -964,7 +987,7 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
for( j=0; j<al_get_count( &var_item_list); j++ )
{
wchar_t *next = (wchar_t *)al_get( &var_item_list, j );
if( is_ok )
{
if( j != 0 )
@@ -987,19 +1010,19 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
}
else
{
if( is_ok )
{
new_len = wcslen(in) - (stop_pos-start_pos+1);
new_len += wcslen( next) +2;
if( !(new_in = malloc( sizeof(wchar_t)*new_len )))
{
DIE_MEM();
}
else
{
wcslcpy( new_in, in, start_pos );
if(start_pos>1 && new_in[start_pos-2]!=VARIABLE_EXPAND)
@@ -1009,20 +1032,20 @@ static int expand_variables( wchar_t *in, array_list_t *out, int last_idx )
}
else
new_in[start_pos-1]=L'\0';
wcscat( new_in, next );
wcscat( new_in, &in[stop_pos] );
is_ok &= expand_variables( new_in, out, i );
}
}
free( next );
}
}
}
}
free(in);
al_destroy( &var_item_list );
return is_ok;
@@ -1093,7 +1116,7 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
CHECK( in, 0 );
CHECK( out, 0 );
for( pos=in;
(*pos) && !syntax_error;
pos++ )
@@ -1115,7 +1138,7 @@ static int expand_brackets( wchar_t *in, int flags, array_list_t *out )
{
bracket_end = pos;
}
if( bracket_count < 0 )
{
syntax_error = 1;
@@ -1223,12 +1246,12 @@ static int expand_cmdsubst( wchar_t *in, array_list_t *out )
array_list_t *sub_res, *tail_expand;
int i, j;
const wchar_t *item_begin;
wchar_t *tail_begin = 0;
wchar_t *tail_begin = 0;
void *context;
CHECK( in, 0 );
CHECK( out, 0 );
switch( parse_util_locate_cmdsubst(in,
@@ -1258,7 +1281,7 @@ static int expand_cmdsubst( wchar_t *in, array_list_t *out )
sub_res = al_halloc( context );
if( !(subcmd = halloc( context, sizeof(wchar_t)*(paran_end-paran_begin) )))
{
halloc_free( context );
halloc_free( context );
return 0;
}
@@ -1277,10 +1300,10 @@ static int expand_cmdsubst( wchar_t *in, array_list_t *out )
{
array_list_t *slice_idx = al_halloc( context );
wchar_t *slice_end;
if( parse_slice( tail_begin, &slice_end, slice_idx ) )
{
halloc_free( context );
halloc_free( context );
error( SYNTAX_ERROR, -1, L"Invalid index value" );
return 0;
}
@@ -1295,23 +1318,23 @@ static int expand_cmdsubst( wchar_t *in, array_list_t *out )
{
idx = al_get_count( sub_res ) + idx + 1;
}
if( idx < 1 || idx > al_get_count( sub_res ) )
{
halloc_free( context );
error( SYNTAX_ERROR, -1, L"Invalid index value" );
return 0;
}
idx = idx-1;
al_push( sub_res2, al_get( sub_res, idx ) );
// debug( 0, L"Pushing item '%ls' with index %d onto sliced result", al_get( sub_res, idx ), idx );
al_set( sub_res, idx, 0 );
}
al_foreach( sub_res, &free );
sub_res = sub_res2;
sub_res = sub_res2;
}
}
@@ -1348,16 +1371,16 @@ static int expand_cmdsubst( wchar_t *in, array_list_t *out )
sb_append_substring( &whole_item, sub_item2, item_len );
sb_append_char( &whole_item, INTERNAL_SEPARATOR );
sb_append( &whole_item, tail_item );
al_push( out, whole_item.buff );
}
free( sub_item2 );
}
free(in);
al_foreach( tail_expand, &free );
halloc_free( context );
halloc_free( context );
return 1;
}
@@ -1458,7 +1481,7 @@ static wchar_t * expand_tilde_internal( wchar_t *in )
wchar_t *expand_tilde( wchar_t *in)
{
CHECK( in, 0 );
if( in[0] == L'~' )
{
in[0] = HOME_DIRECTORY;
@@ -1475,7 +1498,7 @@ static void remove_internal_separator( const void *s, int conv )
{
wchar_t *in = (wchar_t *)s;
wchar_t *out=in;
CHECK( s, );
while( *in )
@@ -1485,7 +1508,7 @@ static void remove_internal_separator( const void *s, int conv )
case INTERNAL_SEPARATOR:
in++;
break;
case ANY_CHAR:
in++;
*out++ = conv?L'?':ANY_CHAR;
@@ -1496,6 +1519,11 @@ static void remove_internal_separator( const void *s, int conv )
*out++ = conv?L'*':ANY_STRING;
break;
case ANY_STRING_RECURSIVE:
in++;
*out++ = conv?L'*':ANY_STRING_RECURSIVE;
break;
default:
*out++ = *in++;
}
@@ -1503,6 +1531,7 @@ static void remove_internal_separator( const void *s, int conv )
*out=0;
}
/**
The real expansion function. expand_one is just a wrapper around this one.
*/
@@ -1535,7 +1564,7 @@ int expand_string( void *context,
if( EXPAND_SKIP_CMDSUBST & flags )
{
wchar_t *begin, *end;
if( parse_util_locate_cmdsubst( str,
&begin,
&end,
@@ -1568,15 +1597,21 @@ int expand_string( void *context,
{
wchar_t *next;
next = expand_unescape( (wchar_t *)al_get( in, i ),
1);
/*
We accept incomplete strings here, since complete uses
expand_string to expand incomplete strings from the
commandline.
*/
int unescape_flags = UNESCAPE_SPECIAL | UNESCAPE_INCOMPLETE;
next = expand_unescape( (wchar_t *)al_get( in, i ), unescape_flags );
free( (void *)al_get( in, i ) );
if( !next )
{
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
continue;
continue;
}
if( EXPAND_SKIP_VARIABLES & flags )
@@ -1610,8 +1645,8 @@ int expand_string( void *context,
if( !next )
{
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
continue;
}
continue;
}
if( !expand_brackets( next, flags, out ))
{
@@ -1632,8 +1667,8 @@ int expand_string( void *context,
if( !next )
{
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
continue;
}
continue;
}
if( !(next=expand_tilde_internal( next ) ) )
{
@@ -1657,7 +1692,9 @@ int expand_string( void *context,
return EXPAND_OK;
}
else
{
al_push( out, next );
}
}
else
{
@@ -1682,56 +1719,83 @@ int expand_string( void *context,
if( !next )
{
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
continue;
}
continue;
}
remove_internal_separator( next, EXPAND_SKIP_WILDCARDS & flags );
if( ((flags & ACCEPT_INCOMPLETE) && (!(flags & EXPAND_SKIP_WILDCARDS))) ||
wildcard_has( next, 1 ) )
{
wchar_t *start, *rest;
array_list_t *list = out;
if( next[0] == '/' )
{
wc_res = wildcard_expand( &next[1], L"/",flags, out );
start = L"/";
rest = &next[1];
}
else
{
wc_res = wildcard_expand( next, L"", flags, out );
start = L"";
rest = next;
}
free( next );
switch( wc_res )
if( flags & ACCEPT_INCOMPLETE )
{
case 0:
list = end_out;
}
wc_res = wildcard_expand( rest, start, flags, list );
free( next );
if( !(flags & ACCEPT_INCOMPLETE) )
{
switch( wc_res )
{
if( !(flags & ACCEPT_INCOMPLETE) )
case 0:
{
if( res == EXPAND_OK )
res = EXPAND_WILDCARD_NO_MATCH;
if( !(flags & ACCEPT_INCOMPLETE) )
{
if( res == EXPAND_OK )
res = EXPAND_WILDCARD_NO_MATCH;
break;
}
}
case 1:
{
int j;
res = EXPAND_WILDCARD_MATCH;
sort_list( out );
for( j=0; j<al_get_count( out ); j++ )
{
wchar_t *next = (wchar_t *)al_get( out, j );
if( !next )
{
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
continue;
}
al_push( end_out, next );
}
al_truncate( out, 0 );
break;
}
}
case 1:
{
int j;
res = EXPAND_WILDCARD_MATCH;
sort_list( out );
for( j=0; j<al_get_count( out ); j++ )
case -1:
{
wchar_t *next = (wchar_t *)al_get( out, j );
if( !next )
{
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
continue;
}
al_push( end_out, next );
al_foreach( out, &free );
al_destroy( in );
al_destroy( out );
return EXPAND_ERROR;
}
al_truncate( out, 0 );
break;
}
}
}
else
{
@@ -1744,6 +1808,7 @@ int expand_string( void *context,
al_push( end_out, next );
}
}
}
al_destroy( in );
al_destroy( out );
@@ -1756,7 +1821,8 @@ int expand_string( void *context,
halloc_register( context, (void *)al_get( end_out, i ) );
}
}
return res;
}
@@ -1769,13 +1835,13 @@ wchar_t *expand_one( void *context, wchar_t *string, int flags )
wchar_t *one;
CHECK( string, 0 );
if( (!(flags & ACCEPT_INCOMPLETE)) && expand_is_clean( string ) )
{
halloc_register( context, string );
return string;
}
al_init( &l );
res = expand_string( 0, string, &l, flags );
if( !res )

View File

@@ -6,7 +6,7 @@
benefit from using a more clever memory allocation scheme, perhaps
an evil combination of talloc, string buffers and reference
counting.
*/
#ifndef FISH_EXPAND_H
@@ -58,6 +58,10 @@
Use unencoded private-use keycodes for internal characters
*/
#define EXPAND_RESERVED 0xf000
/**
End of range reserved for expand
*/
#define EXPAND_RESERVED_END 0xf000f
enum
{
@@ -66,7 +70,7 @@ enum
/** Character represeting process expansion */
PROCESS_EXPAND,
/** Character representing variable expansion */
VARIABLE_EXPAND,
@@ -82,7 +86,7 @@ enum
/** Character representing separation between two bracket elements */
BRACKET_SEP,
/**
Separate subtokens in a token with this character.
Separate subtokens in a token with this character.
*/
INTERNAL_SEPARATOR,
@@ -124,7 +128,7 @@ enum
(\$VAR_NAME becomes the value of the environment variable VAR_NAME),
cmdsubst expansion and wildcard expansion. The results are inserted
into the list out.
If the parameter does not need expansion, it is copied into the list
out. If expansion is performed, the original parameter is freed and
newly allocated strings are inserted into the list out.
@@ -132,7 +136,7 @@ enum
If \c context is non-null, all the strings contained in the
array_list_t \c out will be registered to be free'd when context is
free'd.
\param context the halloc context to use for automatic deallocation
\param in The parameter to expand
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_CMDSUBST EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
@@ -148,8 +152,8 @@ __warn_unused int expand_string( void *context, wchar_t *in, array_list_t *out,
If \c context is non-null, the returning string ill be registered
to be free'd when context is free'd.
\param context the halloc context to use for automatic deallocation
\param context the halloc context to use for automatic deallocation
\param in The parameter to expand
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_CMDSUBST EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
\return The expanded parameter, or 0 on failiure

View File

@@ -47,6 +47,12 @@
#include "util.h"
#ifndef HAVE___ENVIRON
char **__environ = 0;
#endif
#ifdef TPUTS_KLUDGE
int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t))
@@ -54,11 +60,69 @@ int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t))
while( *str )
{
fish_putc( *str++ );
}
}
}
#endif
#ifdef TPARM_SOLARIS_KLUDGE
#undef tparm
/**
Checks for known string values and maps to correct number of parameters.
*/
char *tparm_solaris_kludge( char *str, ... )
{
long int param[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
va_list ap;
va_start( ap, str );
if( ( set_a_foreground && ! strcmp( str, set_a_foreground ) )
|| ( set_a_background && ! strcmp( str, set_a_background ) )
|| ( set_foreground && ! strcmp( str, set_foreground ) )
|| ( set_background && ! strcmp( str, set_background ) )
|| ( enter_underline_mode && ! strcmp( str, enter_underline_mode ) )
|| ( exit_underline_mode && ! strcmp( str, exit_underline_mode ) )
|| ( enter_standout_mode && ! strcmp( str, enter_standout_mode ) )
|| ( exit_standout_mode && ! strcmp( str, exit_standout_mode ) )
|| ( flash_screen && ! strcmp( str, flash_screen ) )
|| ( enter_subscript_mode && ! strcmp( str, enter_subscript_mode ) )
|| ( exit_subscript_mode && ! strcmp( str, exit_subscript_mode ) )
|| ( enter_superscript_mode && ! strcmp( str, enter_superscript_mode ) )
|| ( exit_superscript_mode && ! strcmp( str, exit_superscript_mode ) )
|| ( enter_blink_mode && ! strcmp( str, enter_blink_mode ) )
|| ( enter_italics_mode && ! strcmp( str, enter_italics_mode ) )
|| ( exit_italics_mode && ! strcmp( str, exit_italics_mode ) )
|| ( enter_reverse_mode && ! strcmp( str, enter_reverse_mode ) )
|| ( enter_shadow_mode && ! strcmp( str, enter_shadow_mode ) )
|| ( exit_shadow_mode && ! strcmp( str, exit_shadow_mode ) )
|| ( enter_standout_mode && ! strcmp( str, enter_standout_mode ) )
|| ( exit_standout_mode && ! strcmp( str, exit_standout_mode ) )
|| ( enter_secure_mode && ! strcmp( str, enter_secure_mode ) )
|| ( enter_bold_mode && ! strcmp ( str, enter_bold_mode ) ) )
{
param[0] = va_arg( ap, long int );
}
else if( cursor_address && ! strcmp( str, cursor_address ) )
{
param[0] = va_arg( ap, long int );
param[1] = va_arg( ap, long int );
}
va_end( ap );
return tparm( str, param[0], param[1], param[2], param[3],
param[4], param[5], param[6], param[7], param[8] );
}
// Re-defining just to make sure nothing breaks further down in this file.
#define tparm tparm_solaris_kludge
#endif
#ifndef HAVE_FWPRINTF
#define INTERNAL_FWPRINTF 1
@@ -76,11 +140,11 @@ int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t))
*/
static void pad( void (*writer)(wchar_t), int count)
{
int i;
if( count < 0 )
return;
for( i=0; i<count; i++ )
{
writer( L' ' );
@@ -107,13 +171,13 @@ static void pad( void (*writer)(wchar_t), int count)
For a full description on the usage of *printf, see use 'man 3 printf'.
*/
static int vgwprintf( void (*writer)(wchar_t),
const wchar_t *filter,
static int vgwprintf( void (*writer)(wchar_t),
const wchar_t *filter,
va_list va )
{
const wchar_t *filter_org=filter;
int count=0;
for( ;*filter; filter++)
{
if(*filter == L'%')
@@ -124,19 +188,19 @@ static int vgwprintf( void (*writer)(wchar_t),
int loop=1;
int precision=-1;
int pad_left = 1;
if( iswdigit( *filter ) )
{
width=0;
while( (*filter >= L'0') && (*filter <= L'9'))
{
width=10*width+(*filter++ - L'0');
}
}
}
while( loop )
{
switch(*filter)
{
case L'l':
@@ -155,9 +219,9 @@ static int vgwprintf( void (*writer)(wchar_t),
filter++;
pad_left=0;
break;
case L'.':
/*
/*
Set precision.
*/
filter++;
@@ -171,10 +235,10 @@ static int vgwprintf( void (*writer)(wchar_t),
while( (*filter >= L'0') && (*filter <= L'9'))
{
precision=10*precision+(*filter++ - L'0');
}
}
}
break;
default:
loop=0;
break;
@@ -189,8 +253,8 @@ static int vgwprintf( void (*writer)(wchar_t),
if( (width >= 0) && pad_left )
{
pad( writer, width-1 );
count += maxi( width-1, 0 );
pad( writer, width-1 );
count += maxi( width-1, 0 );
}
c = is_long?va_arg(va, wint_t):btowc(va_arg(va, int));
@@ -201,16 +265,16 @@ static int vgwprintf( void (*writer)(wchar_t),
if( (width >= 0) && !pad_left )
{
pad( writer, width-1 );
count += maxi( width-1, 0 );
count += maxi( width-1, 0 );
}
count++;
break;
}
case L's':
{
{
wchar_t *ss=0;
if( is_long )
{
@@ -223,41 +287,41 @@ static int vgwprintf( void (*writer)(wchar_t),
if( ns )
{
ss = str2wcs( ns );
}
}
}
if( !ss )
{
return -1;
}
if( (width >= 0) && pad_left )
{
pad( writer, width-wcslen(ss) );
count += maxi(width-wcslen(ss), 0);
pad( writer, width-wcslen(ss) );
count += maxi(width-wcslen(ss), 0);
}
wchar_t *s=ss;
int precount = count;
while( *s )
{
if( (precision > 0) && (precision <= (count-precount) ) )
break;
writer( *(s++) );
count++;
}
if( (width >= 0) && !pad_left )
{
pad( writer, width-wcslen(ss) );
count += maxi( width-wcslen(ss), 0 );
pad( writer, width-wcslen(ss) );
count += maxi( width-wcslen(ss), 0 );
}
if( !is_long )
free( ss );
break;
}
@@ -272,7 +336,7 @@ static int vgwprintf( void (*writer)(wchar_t),
char *pos;
char format[16];
int len;
format[0]=0;
strcat( format, "%");
if( precision >= 0 )
@@ -286,7 +350,7 @@ static int vgwprintf( void (*writer)(wchar_t),
strcat( format, "l" );
break;
}
len = strlen(format);
format[len++]=(char)*filter;
format[len]=0;
@@ -296,7 +360,7 @@ static int vgwprintf( void (*writer)(wchar_t),
case L'd':
case L'i':
{
switch( is_long )
{
case 0:
@@ -306,10 +370,10 @@ static int vgwprintf( void (*writer)(wchar_t),
snprintf( str, 32, format, precision, d );
else
snprintf( str, 32, format, d );
break;
}
case 1:
{
long d = va_arg( va, long );
@@ -319,7 +383,7 @@ static int vgwprintf( void (*writer)(wchar_t),
snprintf( str, 32, format, d );
break;
}
case 2:
{
long long d = va_arg( va, long long );
@@ -329,21 +393,21 @@ static int vgwprintf( void (*writer)(wchar_t),
snprintf( str, 32, format, d );
break;
}
default:
debug( 0, L"Invalid length modifier in string %ls\n", filter_org );
return -1;
}
break;
}
case L'u':
case L'o':
case L'x':
case L'X':
{
switch( is_long )
{
case 0:
@@ -355,7 +419,7 @@ static int vgwprintf( void (*writer)(wchar_t),
snprintf( str, 32, format, d );
break;
}
case 1:
{
unsigned long d = va_arg( va, unsigned long );
@@ -365,7 +429,7 @@ static int vgwprintf( void (*writer)(wchar_t),
snprintf( str, 32, format, d );
break;
}
case 2:
{
unsigned long long d = va_arg( va, unsigned long long );
@@ -375,43 +439,43 @@ static int vgwprintf( void (*writer)(wchar_t),
snprintf( str, 32, format, d );
break;
}
default:
debug( 0, L"Invalid length modifier in string %ls\n", filter_org );
return -1;
}
break;
}
default:
debug( 0, L"Invalid filter %ls in string %ls\n", *filter, filter_org );
return -1;
}
if( (width >= 0) && pad_left )
{
int l = maxi(width-strlen(str), 0 );
pad( writer, l );
count += l;
}
pos = str;
while( *pos )
{
writer( *(pos++) );
count++;
}
if( (width >= 0) && !pad_left )
{
int l = maxi(width-strlen(str), 0 );
pad( writer, l );
count += l;
}
break;
}
@@ -420,7 +484,7 @@ static int vgwprintf( void (*writer)(wchar_t),
char str[32];
char *pos;
double val = va_arg( va, double );
if( precision>= 0 )
{
if( width>= 0 )
@@ -445,21 +509,21 @@ static int vgwprintf( void (*writer)(wchar_t),
}
pos = str;
while( *pos )
{
writer( *(pos++) );
count++;
}
break;
}
case L'n':
{
int *n = va_arg( va, int *);
*n = count;
*n = count;
break;
}
case L'%':
@@ -500,14 +564,14 @@ sw_data;
static void sw_writer( wchar_t c )
{
if( sw_data.count < sw_data.max )
*(sw_data.pos++)=c;
*(sw_data.pos++)=c;
sw_data.count++;
}
int vswprintf( wchar_t *out, size_t n, const wchar_t *filter, va_list va )
{
int written;
sw_data.pos=out;
sw_data.max=n;
sw_data.count=0;
@@ -522,7 +586,7 @@ int vswprintf( wchar_t *out, size_t n, const wchar_t *filter, va_list va )
{
written=-1;
}
return written;
}
@@ -530,7 +594,7 @@ int swprintf( wchar_t *out, size_t n, const wchar_t *filter, ... )
{
va_list va;
int written;
va_start( va, filter );
written = vswprintf( out, n, filter, va );
va_end( va );
@@ -560,7 +624,7 @@ int fwprintf( FILE *f, const wchar_t *filter, ... )
{
va_list va;
int written;
va_start( va, filter );
written = vfwprintf( f, filter, va );
va_end( va );
@@ -576,7 +640,7 @@ int wprintf( const wchar_t *filter, ... )
{
va_list va;
int written;
va_start( va, filter );
written=vwprintf( filter, va );
va_end( va );
@@ -597,16 +661,16 @@ wint_t fgetwc(FILE *stream)
{
int b = fgetc( stream );
char bb;
int sz;
if( b == EOF )
return WEOF;
bb=b;
sz = mbrtowc( &res, &bb, 1, &state );
switch( sz )
{
case -1:
@@ -669,13 +733,13 @@ static size_t fish_wcsspn (const wchar_t *wcs,
for (a = accept; *a != L'\0'; ++a)
if (*p == *a)
break;
if (*a == L'\0')
return count;
else
++count;
}
return count;
return count;
}
/*
@@ -688,7 +752,7 @@ static wchar_t *fish_wcspbrk (const wchar_t *wcs, const wchar_t *accept)
++wcs;
else
return (wchar_t *) wcs;
return NULL;
return NULL;
}
/*
@@ -711,18 +775,18 @@ wchar_t *wcstok(wchar_t *wcs, const wchar_t *delim, wchar_t **save_ptr)
/* Scan leading delimiters. */
wcs += fish_wcsspn (wcs, delim);
if (*wcs == L'\0')
{
*save_ptr = NULL;
*save_ptr = NULL;
return NULL;
}
/* Find the end of the token. */
result = wcs;
wcs = fish_wcspbrk (result, delim);
if (wcs == NULL)
{
/* This token finishes the string. */
@@ -751,7 +815,7 @@ wchar_t *wcsdup( const wchar_t *in )
memcpy( out, in, sizeof( wchar_t)*(len+1));
return out;
}
#endif
@@ -791,7 +855,7 @@ int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count )
{
if( count == 0 )
return 0;
if( *a == 0 )
{
return (*b==0)?0:-1;
@@ -828,7 +892,7 @@ wchar_t *wcsndup( const wchar_t *in, int c )
return 0;
}
wcslcpy( res, in, c+1 );
return res;
return res;
}
#endif
@@ -841,22 +905,22 @@ long convert_digit( wchar_t d, int base )
}
else if( (d <= L'z') && (d >= L'a') )
{
res = d + 10 - L'a';
res = d + 10 - L'a';
}
else if( (d <= L'Z') && (d >= L'A') )
{
res = d + 10 - L'A';
res = d + 10 - L'A';
}
if( res >= base )
{
res = -1;
}
return res;
}
#ifndef HAVE_WCSTOL
long wcstol(const wchar_t *nptr,
long wcstol(const wchar_t *nptr,
wchar_t **endptr,
int base)
{
@@ -879,7 +943,7 @@ long wcstol(const wchar_t *nptr,
{
errno = EINVAL;
}
return res;
return res;
}
res = (res*base)+nxt;
is_set = 1;
@@ -921,25 +985,25 @@ long wcstol(const wchar_t *nptr,
size_t
wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
{
register wchar_t *d = dst;
register const wchar_t *s = src;
register size_t n = siz;
register size_t n = siz;
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
d++;
dlen = d - dst;
n = siz - dlen;
n = siz - dlen;
if (n == 0)
return(dlen + wcslen(s));
while (*s != '\0')
while (*s != '\0')
{
if (n != 1)
if (n != 1)
{
*d++ = *s;
n--;
@@ -979,12 +1043,12 @@ wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
register wchar_t *d = dst;
register const wchar_t *s = src;
register size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0)
{
do
{
if (n != 0 && --n != 0)
{
do
{
if ((*d++ = *s++) == 0)
break;
}
@@ -992,8 +1056,8 @@ wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0)
{
if (n == 0)
{
if (siz != 0)
*d = '\0';
/* NUL-terminate dst */
@@ -1010,7 +1074,7 @@ wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
int lrand48_r(struct drand48_data *buffer, long int *result)
{
*result = rand_r( &buffer->seed );
*result = rand_r( &buffer->seed );
return 0;
}
@@ -1079,10 +1143,10 @@ int killpg( int pgr, int sig )
#ifndef HAVE_WORKING_GETOPT_LONG
int getopt_long( int argc,
int getopt_long( int argc,
char * const argv[],
const char *optstring,
const struct option *longopts,
const struct option *longopts,
int *longindex )
{
return getopt( argc, argv, optstring );
@@ -1091,3 +1155,40 @@ int getopt_long( int argc,
#endif
#ifndef HAVE_BACKTRACE
int backtrace (void **buffer, int size)
{
return 0;
}
#endif
#ifndef HAVE_BACKTRACE_SYMBOLS
char ** backtrace_symbols (void *const *buffer, int size)
{
return 0;
}
#endif
#ifndef HAVE_SYSCONF
long sysconf(int name)
{
if( name == _SC_ARG_MAX )
{
#ifdef ARG_MAX
return ARG_MAX;
#endif
}
return -1;
}
#endif
#ifndef HAVE_NAN
double nan(char *tagp)
{
return 0.0/0.0;
}
#endif

View File

@@ -54,12 +54,21 @@ typedef char tputs_arg_t;
#endif
#ifndef HAVE_WINSIZE
struct winsize
/**
Structure used to get the size of a terminal window
*/
struct winsize
{
unsigned short ws_row;
/**
Number of rows
*/
unsigned short ws_row;
/**
Number of columns
*/
unsigned short ws_col;
}
;
;
#endif
@@ -73,6 +82,18 @@ int tputs(const char *str, int affcnt, int (*fish_putc)(tputs_arg_t));
#endif
#ifdef TPARM_SOLARIS_KLUDGE
/**
Solaris tparm has a set fixed of paramters in it's curses implementation,
work around this here.
*/
#define tparm tparm_solaris_kludge
char *tparm_solaris_kludge( char *str, ... );
#endif
#ifndef HAVE_FWPRINTF
/**
@@ -172,7 +193,7 @@ wchar_t *wcstok(wchar_t *wcs, const wchar_t *delim, wchar_t **ptr);
/**
Return the number of columns used by a character. This is a libc
function, but the prototype for this function is missing in some libc
implementations.
implementations.
Fish has a fallback implementation in case the implementation is
missing altogether. In locales without a native wcwidth, Unicode
@@ -271,8 +292,8 @@ long convert_digit( wchar_t d, int base );
supported.
*/
long wcstol(const wchar_t *nptr,
wchar_t **endptr,
int base);
wchar_t **endptr,
int base);
#endif
#ifndef HAVE_WCSLCAT
@@ -299,7 +320,7 @@ size_t wcslcat( wchar_t *dst, const wchar_t *src, size_t siz );
wcslen(src); if retval >= siz, truncation occurred.
This is the OpenBSD strlcpy function, modified for wide characters,
and renamed to reflect this change.
and renamed to reflect this change.
*/
size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz );
@@ -325,7 +346,7 @@ struct drand48_data
*/
unsigned int seed;
}
;
;
/**
Fallback implementation of lrand48_r. Internally uses rand_r, so it is pretty weak.
@@ -369,9 +390,9 @@ char * textdomain( const char * domainname );
/**
Fallback implementation of dcgettext. Just returns the original string.
*/
char * dcgettext ( const char * domainname,
const char * msgid,
int category );
char * dcgettext ( const char * domainname,
const char * msgid,
int category );
#endif
@@ -388,20 +409,38 @@ extern int _nl_msg_cat_cntr;
#ifndef HAVE_KILLPG
/**
Send specified signal to specified process group.
*/
int killpg( int pgr, int sig );
#endif
#ifndef HAVE_WORKING_GETOPT_LONG
struct option
/**
Struct describing a long getopt option
*/
struct option
{
/**
Name of option
*/
const char *name;
/**
Flag
*/
int has_arg;
/**
Flag
*/
int *flag;
int val;
/**
Return value
*/
int val;
}
;
;
#ifndef no_argument
#define no_argument 0
@@ -415,13 +454,24 @@ struct option
#define optional_argument 2
#endif
int getopt_long(int argc,
char * const argv[],
const char *optstring,
const struct option *longopts,
int *longindex);
int getopt_long(int argc,
char * const argv[],
const char *optstring,
const struct option *longopts,
int *longindex);
#endif
#ifndef HAVE_SYSCONF
#define _SC_ARG_MAX 1
long sysconf(int name);
#endif
#ifndef HAVE_NAN
double nan(char *tagp);
#endif
#endif

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2005-2006 Axel Liljencrantz
Copyright (C) 2005-2008 Axel Liljencrantz
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
@@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/** \file main.c
/** \file fish.c
The main loop of <tt>fish</tt>.
*/
@@ -66,142 +66,132 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/**
The string describing the single-character options accepted by the main fish binary
*/
#define GETOPT_STRING "hilnvc:p:d:"
#define GETOPT_STRING "+hilnvc:p:d:"
/**
Parse init files
*/
static int read_init()
{
char cwd[4096];
wchar_t *wcwd;
wchar_t *config_dir;
wchar_t *config_dir_escaped;
void *context;
string_buffer_t *eval_buff;
if( !getcwd( cwd, 4096 ) )
{
wperror( L"getcwd" );
return 0;
}
eval( L"builtin cd " DATADIR L"/fish 2>/dev/null; and builtin . config.fish 2>/dev/null", 0, TOP );
eval( L"builtin cd " SYSCONFDIR L"/fish 2>/dev/null; and builtin . config.fish 2>/dev/null", 0, TOP );
eval( L"builtin . " DATADIR "/fish/config.fish 2>/dev/null", 0, TOP );
eval( L"builtin . " SYSCONFDIR L"/fish/config.fish 2>/dev/null", 0, TOP );
/*
We need to get the configuration directory before we can source the user configuration file
*/
context = halloc( 0, 0 );
eval_buff = sb_halloc( context );
config_dir = path_get_config( context );
config_dir_escaped = escape( config_dir, 1 );
sb_printf( eval_buff, L"builtin cd %ls 2>/dev/null; and builtin . config.fish 2>/dev/null", config_dir_escaped );
eval( (wchar_t *)eval_buff->buff, 0, TOP );
halloc_free( context );
free( config_dir_escaped );
if( chdir( cwd ) == -1 )
/*
If config_dir is null then we have no configuration directory
and no custom config to load.
*/
if( config_dir )
{
/*
If we can't change back to previos directory, we go to
~. Should be a sane default behavior.
*/
eval( L"builtin cd", 0, TOP );
}
wcwd = str2wcs( cwd );
if( wcwd )
{
env_set( L"PWD", wcwd, ENV_EXPORT );
free( wcwd );
config_dir_escaped = escape( config_dir, 1 );
sb_printf( eval_buff, L"builtin . %ls/config.fish 2>/dev/null", config_dir_escaped );
eval( (wchar_t *)eval_buff->buff, 0, TOP );
free( config_dir_escaped );
}
halloc_free( context );
return 1;
}
/**
Parse the argument list, return the index of the first non-switch
arguments.
*/
static int fish_parse_opt( int argc, char **argv, char **cmd_ptr )
{
int my_optind;
int force_interactive=0;
while( 1 )
{
static struct option
long_options[] =
{
{
"command", required_argument, 0, 'c'
"command", required_argument, 0, 'c'
}
,
{
"debug-level", required_argument, 0, 'd'
"debug-level", required_argument, 0, 'd'
}
,
{
"interactive", no_argument, 0, 'i'
"interactive", no_argument, 0, 'i'
}
,
{
"login", no_argument, 0, 'l'
"login", no_argument, 0, 'l'
}
,
{
"no-execute", no_argument, 0, 'n'
"no-execute", no_argument, 0, 'n'
}
,
{
"profile", required_argument, 0, 'p'
"profile", required_argument, 0, 'p'
}
,
{
"help", no_argument, 0, 'h'
"help", no_argument, 0, 'h'
}
,
{
"version", no_argument, 0, 'v'
"version", no_argument, 0, 'v'
}
,
{
0, 0, 0, 0
{
0, 0, 0, 0
}
}
;
int opt_index = 0;
int opt = getopt_long( argc,
argv,
argv,
GETOPT_STRING,
long_options,
long_options,
&opt_index );
if( opt == -1 )
break;
switch( opt )
{
case 0:
{
break;
}
case 'c':
case 'c':
{
*cmd_ptr = optarg;
*cmd_ptr = optarg;
is_interactive_session = 0;
break;
}
case 'd':
case 'd':
{
char *end;
int tmp = strtol(optarg, &end, 10);
if( tmp >= 0 && tmp <=10 && !*end )
int tmp;
errno = 0;
tmp = strtol(optarg, &end, 10);
if( tmp >= 0 && tmp <=10 && !*end && !errno )
{
debug_level=tmp;
}
@@ -212,61 +202,69 @@ static int fish_parse_opt( int argc, char **argv, char **cmd_ptr )
}
break;
}
case 'h':
{
*cmd_ptr = "help";
*cmd_ptr = "__fish_print_help fish";
break;
}
case 'i':
{
force_interactive = 1;
break;
break;
}
case 'l':
{
is_login=1;
break;
break;
}
case 'n':
{
no_exec=1;
break;
break;
}
case 'p':
{
profile = optarg;
break;
break;
}
case 'v':
{
fwprintf( stderr,
_(L"%s, version %s\n"),
fwprintf( stderr,
_(L"%s, version %s\n"),
PACKAGE_NAME,
PACKAGE_VERSION );
exit( 0 );
exit( 0 );
}
case '?':
{
exit( 1 );
}
}
}
}
my_optind = optind;
is_login |= (strcmp( argv[0], "-fish") == 0);
/*
We are an interactive session if we have not been given an
explicit command to execute, _and_ stdin is a tty.
*/
is_interactive_session &= (*cmd_ptr == 0);
is_interactive_session &= (my_optind == argc);
is_interactive_session &= isatty(STDIN_FILENO);
is_interactive_session &= isatty(STDIN_FILENO);
/*
We are also an interactive session if we have are forced-
*/
is_interactive_session |= force_interactive;
return my_optind;
@@ -284,12 +282,13 @@ int main( int argc, char **argv )
char *cmd=0;
int my_optind=0;
halloc_util_init();
halloc_util_init();
wsetlocale( LC_ALL, L"" );
is_interactive_session=1;
program_name=L"fish";
my_optind = fish_parse_opt( argc, argv, &cmd );
/*
@@ -300,10 +299,9 @@ int main( int argc, char **argv )
debug( 1, _(L"Can not use the no-execute mode when running an interactive session") );
no_exec = 0;
}
proc_init();
event_init();
proc_init();
event_init();
wutil_init();
parser_init();
builtin_init();
@@ -312,7 +310,6 @@ int main( int argc, char **argv )
reader_init();
history_init();
if( read_init() )
{
if( cmd != 0 )
@@ -326,28 +323,28 @@ int main( int argc, char **argv )
{
if( my_optind == argc )
{
res = reader_read( 0 );
res = reader_read( STDIN_FILENO, 0 );
}
else
{
char **ptr;
char *file = *(argv+1);
int i;
char **ptr;
char *file = *(argv+(my_optind++));
int i;
string_buffer_t sb;
int fd;
wchar_t *rel_filename, *abs_filename;
if( ( fd = open(file, O_RDONLY) ) == -1 )
{
wperror( L"open" );
return 1;
}
if( *(argv+2))
if( *(argv+my_optind))
{
sb_init( &sb );
for( i=1,ptr = argv+2; *ptr; i++, ptr++ )
for( i=1,ptr = argv+my_optind; *ptr; i++, ptr++ )
{
if( i != 1 )
sb_append( &sb, ARRAY_SEP_STR );
@@ -355,34 +352,37 @@ int main( int argc, char **argv )
sb_append( &sb, val );
free( val );
}
env_set( L"argv", (wchar_t *)sb.buff, 0 );
sb_destroy( &sb );
}
rel_filename = str2wcs( file );
abs_filename = wrealpath( rel_filename, 0 );
if( !abs_filename )
{
abs_filename = wcsdup(rel_filename);
}
reader_push_current_filename( intern( abs_filename ) );
free( rel_filename );
free( abs_filename );
res = reader_read( fd );
res = reader_read( fd, 0 );
if( res )
{
debug( 1,
_(L"Error while reading file %ls\n"),
reader_current_filename()?reader_current_filename(): _(L"Standard input") );
}
debug( 1,
_(L"Error while reading file %ls\n"),
reader_current_filename()?reader_current_filename(): _(L"Standard input") );
}
reader_pop_current_filename();
}
}
}
proc_fire_event( L"PROCESS_EXIT", EVENT_EXIT, getpid(), res );
history_destroy();
proc_destroy();
@@ -399,6 +399,5 @@ int main( int argc, char **argv )
intern_free_all();
return res;
return res?STATUS_UNKNOWN_COMMAND:proc_get_last_status();
}

View File

@@ -11,7 +11,7 @@ URL: http://www.fishshell.org
Source0: http://www.fishshell.org/files/%{version}/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: ncurses-devel gettext groff
BuildRequires: ncurses-devel gettext groff
# Locate correct build time-dependencies for providing X headers
@@ -50,10 +50,10 @@ BuildRequires: %{xinclude}/X11/Intrinsic.h, %{xinclude}/X11/Xatom.h
%endif
%description
%description
fish is a shell geared towards interactive use. Its features are
focused on user friendliness and discoverability. The language syntax
fish is a shell geared towards interactive use. Its features are
focused on user friendliness and discoverability. The language syntax
is simple but incompatible with other shell languages.
@@ -75,7 +75,7 @@ make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR="$RPM_BUILD_ROOT"
make install DESTDIR="$RPM_BUILD_ROOT"
# Find translation files
%find_lang %{name}.\*
@@ -116,31 +116,29 @@ fi
# man files
%_mandir/man1/fish.1*
%_mandir/man1/xsel.1x*
%_mandir/man1/fish_pager.1*
%_mandir/man1/fish_indent.1*
%_mandir/man1/fishd.1*
%_mandir/man1/mimedb.1*
%_mandir/man1/set_color.1*
%_mandir/man1/count.1*
%_mandir/man1/fishd.1*
%_mandir/man1/fish_pager.1*
%_mandir/man1/xsel.1x*
# The program binaries
%attr(0755,root,root) %_bindir/fish
%attr(0755,root,root) %_bindir/fishd
%attr(0755,root,root) %_bindir/fish_indent
%attr(0755,root,root) %_bindir/fish_pager
%attr(0755,root,root) %_bindir/xsel
%attr(0755,root,root) %_bindir/set_color
%attr(0755,root,root) %_bindir/fishd
%attr(0755,root,root) %_bindir/mimedb
%attr(0755,root,root) %_bindir/count
%attr(0755,root,root) %_bindir/set_color
%attr(0755,root,root) %_bindir/xsel
# Configuration files
%config %_sysconfdir/fish/config.fish
%config %_sysconfdir/fish/fish_inputrc
%dir %_sysconfdir/fish
# Non-configuration initialization files
%dir %_datadir/fish
%_datadir/fish/config.fish
%_datadir/fish/config_interactive.fish
# Program specific tab-completions
%dir %_datadir/fish/completions
@@ -150,11 +148,19 @@ fi
%dir %_datadir/fish/functions
%_datadir/fish/functions/*.fish
# Documentation for builtins and shellscript functions
%dir %_datadir/fish/man
%_datadir/fish/man/*.1
%changelog
* Sat Apr 21 2007 Axel Liljencrantz<axel@liljencrantz.se> 1.23.0-0
- Add fish_indent command
* Thu Feb 8 2007 Axel Liljencrantz<axel@liljencrantz.se> 1.22.3-0
- Tell rpm about the help pages in %_datadir/fish/man/
* Sat Oct 14 2006 Axel Liljencrantz<axel@liljencrantz.se> 1.22.0-0
- Update names of various configuration files

408
fish_indent.c Normal file
View File

@@ -0,0 +1,408 @@
/*
Copyright (C) 2005-2008 Axel Liljencrantz
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/** \file fish_indent.c
The fish_indent proegram.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#include <locale.h>
#include "fallback.h"
#include "util.h"
#include "common.h"
#include "wutil.h"
#include "halloc.h"
#include "halloc_util.h"
#include "tokenizer.h"
#include "print_help.h"
#include "parser_keywords.h"
/**
The string describing the single-character options accepted by the main fish binary
*/
#define GETOPT_STRING "hvi"
/**
Read the entire contents of a file into the specified string_Buffer_t
*/
static void read_file( FILE *f, string_buffer_t *b )
{
while( 1 )
{
errno=0;
wint_t c = fgetwc( f );
if( c == WEOF )
{
if( errno )
{
wperror(L"fgetwc");
exit(1);
}
break;
}
sb_append_char( b, c );
}
}
/**
Insert the specified number of tabe into the output buffer
*/
static void insert_tabs( string_buffer_t *out, int indent )
{
int i;
for( i=0; i<indent; i++ )
{
sb_append( out, L"\t" );
}
}
/**
Indent the specified input
*/
static int indent( string_buffer_t *out, wchar_t *in, int flags )
{
tokenizer tok;
int res=0;
int is_command = 1;
int indent = 0;
int do_indent = 1;
int prev_type = 0;
int prev_prev_type = 0;
tok_init( &tok, in, TOK_SHOW_COMMENTS );
for( ; tok_has_next( &tok ); tok_next( &tok ) )
{
int type = tok_last_type( &tok );
wchar_t *last = tok_last( &tok );
switch( type )
{
case TOK_STRING:
{
if( is_command )
{
int next_indent = indent;
is_command = 0;
wchar_t *unesc = unescape( last, UNESCAPE_SPECIAL );
if( parser_keywords_is_block( unesc ) )
{
next_indent++;
}
else if( wcscmp( unesc, L"else" ) == 0 )
{
indent--;
}
/* case should have the same indent level as switch*/
else if( wcscmp( unesc, L"case" ) == 0 )
{
indent--;
}
else if( wcscmp( unesc, L"end" ) == 0 )
{
indent--;
next_indent--;
}
if( do_indent && flags && prev_type != TOK_PIPE )
{
insert_tabs( out, indent );
}
sb_printf( out, L"%ls", last );
indent = next_indent;
}
else
{
if ( prev_type != TOK_REDIRECT_FD )
sb_append( out, L" " );
sb_append( out, last );
}
break;
}
case TOK_END:
{
if( prev_type != TOK_END || prev_prev_type != TOK_END )
sb_append( out, L"\n" );
do_indent = 1;
is_command = 1;
break;
}
case TOK_PIPE:
{
sb_append( out, L" " );
if ( last[0] == '2' && !last[1] ) {
sb_append( out, L"^" );
} else if ( last[0] != '1' || last[1] ) {
sb_append( out, last, L">" );
}
sb_append( out, L"| " );
is_command = 1;
break;
}
case TOK_REDIRECT_OUT:
{
sb_append( out, L" " );
if ( wcscmp( last, L"2" ) == 0 ) {
sb_append( out, L"^" );
} else {
if ( wcscmp( last, L"1" ) != 0 )
sb_append( out, last );
sb_append( out, L">" );
}
break;
}
case TOK_REDIRECT_APPEND:
{
sb_append( out, L" " );
if ( wcscmp( last, L"2" ) == 0 ) {
sb_append( out, L"^^" );
} else {
if ( wcscmp( last, L"1" ) != 0 )
sb_append( out, last );
sb_append( out, L">>" );
}
break;
}
case TOK_REDIRECT_IN:
{
sb_append( out, L" " );
if ( wcscmp( last, L"0" ) != 0 )
sb_append( out, last );
sb_append( out, L"<" );
break;
}
case TOK_REDIRECT_FD:
{
sb_append( out, L" " );
if ( wcscmp( last, L"1" ) != 0 )
sb_append( out, last );
sb_append( out, L">&" );
break;
}
case TOK_BACKGROUND:
{
sb_append( out, L"&\n" );
do_indent = 1;
is_command = 1;
break;
}
case TOK_COMMENT:
{
if( do_indent && flags)
{
insert_tabs( out, indent );
}
sb_printf( out, L"%ls", last );
do_indent = 1;
break;
}
default:
{
debug( 0, L"Unknown token '%ls'", last );
exit(1);
}
}
prev_prev_type = prev_type;
prev_type = type;
}
tok_destroy( &tok );
return res;
}
/**
Remove any prefix and suffix newlines from the specified
string. Does not allocete a new string, edits the string in place
and returns a pointer somewhere into the string.
*/
static wchar_t *trim( wchar_t *in )
{
wchar_t *end;
while( *in == L'\n' )
{
in++;
}
end = in + wcslen(in);
while( 1 )
{
if( end < in+2 )
break;
end--;
if( (*end == L'\n' ) && ( *(end-1) == L'\n' ) )
*end=0;
else
break;
}
return in;
}
/**
The main mathod. Run the program.
*/
int main( int argc, char **argv )
{
string_buffer_t sb_in;
string_buffer_t sb_out;
int do_indent=1;
wsetlocale( LC_ALL, L"" );
program_name=L"fish_indent";
while( 1 )
{
static struct option
long_options[] =
{
{
"no-indent", no_argument, 0, 'i'
}
,
{
"help", no_argument, 0, 'h'
}
,
{
"version", no_argument, 0, 'v'
}
,
{
0, 0, 0, 0
}
}
;
int opt_index = 0;
int opt = getopt_long( argc,
argv,
GETOPT_STRING,
long_options,
&opt_index );
if( opt == -1 )
break;
switch( opt )
{
case 0:
{
break;
}
case 'h':
{
print_help( "fish_indent", 1 );
exit( 0 );
break;
}
case 'v':
{
fwprintf( stderr,
_(L"%ls, version %s\n"),
program_name,
PACKAGE_VERSION );
exit( 0 );
}
case 'i':
{
do_indent = 0;
break;
}
case '?':
{
exit( 1 );
}
}
}
halloc_util_init();
sb_init( &sb_in );
sb_init( &sb_out );
read_file( stdin, &sb_in );
wutil_init();
if( !indent( &sb_out, (wchar_t *)sb_in.buff, do_indent ) )
{
fwprintf( stdout, L"%ls", trim( (wchar_t *)sb_out.buff) );
}
else
{
/*
Indenting failed - print original input
*/
fwprintf( stdout, L"%ls", (wchar_t *)sb_in.buff );
}
wutil_destroy();
halloc_util_destroy();
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdarg.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
@@ -26,6 +26,7 @@
#include <locale.h>
#include <dirent.h>
#include <time.h>
#include "fallback.h"
#include "util.h"
@@ -44,8 +45,23 @@
#include "output.h"
#include "exec.h"
#include "event.h"
#include "path.h"
#include "halloc.h"
#include "halloc_util.h"
/**
The number of tests to run
*/
#define ESCAPE_TEST_COUNT 1000000
/**
The average length of strings to unescape
*/
#define ESCAPE_TEST_LENGTH 100
/**
The higest character number of character to try and escape
*/
#define ESCAPE_TEST_CHAR 4000
/**
Number of laps to run performance testing loop
*/
@@ -69,7 +85,7 @@ static void say( wchar_t *blah, ... )
va_list va;
va_start( va, blah );
vwprintf( blah, va );
va_end( va );
va_end( va );
wprintf( L"\n" );
}
@@ -81,10 +97,10 @@ static void err( wchar_t *blah, ... )
va_list va;
va_start( va, blah );
err_count++;
wprintf( L"Error: " );
vwprintf( blah, va );
va_end( va );
va_end( va );
wprintf( L"\n" );
}
@@ -103,13 +119,13 @@ static void pq_test( int elements )
{
int i;
int prev;
int *count = calloc( sizeof(int), 100 );
priority_queue_t q;
pq_init( &q, pq_compare );
for( i=0; i<elements; i++ )
{
long foo = rand() % 100;
@@ -117,9 +133,9 @@ static void pq_test( int elements )
pq_put( &q, (void *)foo );
count[foo]++;
}
prev = 100;
for( i=0; i<elements; i++ )
{
long pos = (long)pq_get( &q );
@@ -127,7 +143,7 @@ static void pq_test( int elements )
if( pos > prev )
err( L"Wrong order of elements in priority_queue_t" );
prev = pos;
}
for( i=0; i<100; i++ )
@@ -147,10 +163,10 @@ static int stack_test( int elements )
long i;
int res=1;
array_list_t s;
al_init( &s );
al_init( &s );
for( i=0; i<elements; i++ )
{
@@ -158,11 +174,11 @@ static int stack_test( int elements )
al_push_long( &s, i);
al_push_long( &s, i);
if( (foo=al_pop_long( &s )) != i )
{
err( L"Unexpected data" );
res = 0;
res = 0;
break;
}
}
@@ -170,18 +186,18 @@ static int stack_test( int elements )
for( i=0; i<elements; i++ )
{
long foo;
if( (foo=al_pop_long( &s )) != (elements-i-1) )
{
err( L"Unexpected data" );
res = 0;
break;
}
}
}
al_destroy( &s );
return res;
}
@@ -194,7 +210,7 @@ static int hash_func( void *data )
return rand();
*/
int foo = (int)(long)data;
return 127*((foo^0xefc7e214)) ^(foo<<11);
return 127*((foo^0xefc7e214)) ^(foo<<11);
}
/**
@@ -213,26 +229,26 @@ static int hash_test( long elements )
{
long i;
int res=1;
hash_table_t h;
hash_init( &h, hash_func, compare_func );
for( i=1; i< elements+1; i++ )
{
hash_put( &h, (void*)i, (void*)100l-i );
}
for( i=1; i< elements+1; i++ )
{
if( (long)hash_get( &h, (void*)i ) != (100l-i) )
{
err( L"Key %d gave data %d, expected data %d",
i,
i,
(long)hash_get( &h, (void*)i ),
100l-i );
res = 0;
break;
}
}
@@ -243,14 +259,14 @@ static int hash_test( long elements )
hash_get_count( &h ),
elements );
res = 0;
}
for( i=1; i<elements+1; i+=2 )
{
hash_remove( &h, (void*)i, 0, 0 );
}
if( hash_get_count( &h ) != ((elements)/2) )
@@ -260,7 +276,7 @@ static int hash_test( long elements )
elements/2 );
res = 0;
}
for( i=1; i<elements+1; i++ )
{
if( hash_contains( &h, (void*)i) != (i+1l)%2l )
@@ -279,7 +295,7 @@ static int hash_test( long elements )
hash_destroy( &h );
return res;
}
/**
@@ -287,19 +303,19 @@ static int hash_test( long elements )
*/
static void al_test( int sz)
{
long i;
long i;
array_list_t l;
al_init( &l );
al_set_long( &l, 1, 7L );
al_set_long( &l, sz, 7L );
if( al_get_count( &l ) != maxi( sz+1, 2 ) )
err( L"Wrong number of elements in array list" );
for( i=0; i<al_get_count( &l ); i++ )
{
long val = al_get_long( &l, i );
@@ -323,15 +339,15 @@ static void sb_test()
{
string_buffer_t b;
int res;
sb_init( &b );
if( (res=sb_printf( &b, L"%ls%s", L"Testing ", "string_buffer_t " )) == -1 )
{
err( L"Error %d while testing stringbuffers", res );
}
if( (res=sb_printf( &b, L"%ls", L"functionality" ))==-1)
if( (res=sb_printf( &b, L"%ls", L"functionality" ))==-1)
{
err( L"Error %d while testing stringbuffers", res );
}
@@ -346,9 +362,9 @@ static void sb_test()
err( L"numerical formating is broken, '%ls' != '%ls'", (wchar_t *)b.buff, NUM_ANS );
}
else
say( L"numerical formating works" );
say( L"numerical formating works" );
}
/**
@@ -359,7 +375,7 @@ static void test_util()
int i;
say( L"Testing utility library" );
for( i=0; i<18; i++ )
{
long t1, t2;
@@ -376,40 +392,174 @@ static void test_util()
}
sb_test();
/*
int i;
for( i=2; i<10000000; i*=2 )
{
printf( "%d", i );
t1 = get_time();
if(!hash_test(i))
exit(0);
t2 = get_time();
printf( " %d\n", (t2-t1)/i );
}
*/
*/
}
/**
Test the escaping/unescaping code by escaping/unescaping random
strings and verifying that the original string comes back.
*/
static void test_escape()
{
int i;
string_buffer_t sb;
say( L"Testing escaping and unescaping" );
sb_init( &sb );
for( i=0; i<ESCAPE_TEST_COUNT; i++ )
{
wchar_t *o, *e, *u;
sb_clear( &sb );
while( rand() % ESCAPE_TEST_LENGTH )
{
sb_append_char( &sb, (rand() %ESCAPE_TEST_CHAR) +1 );
}
o = (wchar_t *)sb.buff;
e = escape(o, 1);
u = unescape( e, 0 );
if( !o || !e || !u )
{
err( L"Escaping cycle of string %ls produced null pointer on %ls", o, e?L"unescaping":L"escaping" );
}
if( wcscmp(o, u) )
{
err( L"Escaping cycle of string %ls produced different string %ls", o, u );
}
free( e );
free( u );
}
}
/**
Test wide/narrow conversion by creating random strings and
verifying that the original string comes back thorugh double
conversion.
*/
static void test_convert()
{
/* char o[] =
{
-17, -128, -121, -68, 0
}
;
wchar_t *w = str2wcs(o);
char *n = wcs2str(w);
int i;
for( i=0; o[i]; i++ )
{
bitprint(o[i]);;
//wprintf(L"%d ", o[i]);
}
wprintf(L"\n");
for( i=0; w[i]; i++ )
{
wbitprint(w[i]);;
//wprintf(L"%d ", w[i]);
}
wprintf(L"\n");
for( i=0; n[i]; i++ )
{
bitprint(n[i]);;
//wprintf(L"%d ", n[i]);
}
wprintf(L"\n");
return;
*/
int i;
buffer_t sb;
say( L"Testing wide/narrow string conversion" );
b_init( &sb );
for( i=0; i<ESCAPE_TEST_COUNT; i++ )
{
wchar_t *w;
char *o, *n;
char c;
sb.used=0;
while( rand() % ESCAPE_TEST_LENGTH )
{
c = rand ();
b_append( &sb, &c, 1 );
}
c = 0;
b_append( &sb, &c, 1 );
o = (char *)sb.buff;
w = str2wcs(o);
n = wcs2str(w);
if( !o || !w || !n )
{
err( L"Conversion cycle of string %s produced null pointer on %s", o, w?L"str2wcs":L"wcs2str" );
}
if( strcmp(o, n) )
{
err( L"%d: Conversion cycle of string %s produced different string %s", i, o, n );
}
free( w );
free( n );
}
}
/**
Test the tokenizer
*/
static void test_tok()
{
tokenizer t;
say( L"Testing tokenizer" );
say( L"Testing invalid input" );
tok_init( &t, 0, 0 );
@@ -417,13 +567,13 @@ static void test_tok()
{
err(L"Invalid input to tokenizer was undetected" );
}
say( L"Testing use of broken tokenizer" );
if( !tok_has_next( &t ) )
{
err( L"tok_has_next() should return 1 once on broken tokenizer" );
}
tok_next( &t );
if( tok_last_type( &t ) != TOK_ERROR )
{
@@ -435,17 +585,17 @@ static void test_tok()
*/
say( L"Test destruction of broken tokenizer" );
tok_destroy( &t );
{
wchar_t *str = L"string <redirection 2>&1 'nested \"quoted\" '(string containing subshells ){and,brackets}$as[$well (as variable arrays)]";
const int types[] =
const int types[] =
{
TOK_STRING, TOK_REDIRECT_IN, TOK_STRING, TOK_REDIRECT_FD, TOK_STRING, TOK_STRING, TOK_END
}
;
int i;
say( L"Test correct tokenization" );
for( i=0, tok_init( &t, str, 0 ); i<(sizeof(types)/sizeof(int)); i++,tok_next( &t ) )
@@ -453,7 +603,7 @@ static void test_tok()
if( types[i] != tok_last_type( &t ) )
{
err( L"Tokenization error:");
wprintf( L"Token number %d of string \n'%ls'\n, expected token type %ls, got token '%ls' of type %ls\n",
wprintf( L"Token number %d of string \n'%ls'\n, expected token type %ls, got token '%ls' of type %ls\n",
i+1,
str,
tok_get_desc(types[i]),
@@ -462,9 +612,9 @@ static void test_tok()
}
}
}
}
/**
@@ -473,8 +623,8 @@ static void test_tok()
static void test_parser()
{
say( L"Testing parser" );
say( L"Testing null input to parser" );
if( !parser_test( 0, 0, 0, 0 ) )
{
@@ -484,51 +634,51 @@ static void test_parser()
say( L"Testing block nesting" );
if( !parser_test( L"if; end", 0, 0, 0 ) )
{
err( L"Incomplete if statement undetected" );
err( L"Incomplete if statement undetected" );
}
if( !parser_test( L"if test; echo", 0, 0, 0 ) )
{
err( L"Missing end undetected" );
err( L"Missing end undetected" );
}
if( !parser_test( L"if test; end; end", 0, 0, 0 ) )
{
err( L"Unbalanced end undetected" );
err( L"Unbalanced end undetected" );
}
say( L"Testing detection of invalid use of builtin commands" );
if( !parser_test( L"case foo", 0, 0, 0 ) )
{
err( L"'case' command outside of block context undetected" );
err( L"'case' command outside of block context undetected" );
}
if( !parser_test( L"switch ggg; if true; case foo;end;end", 0, 0, 0 ) )
{
err( L"'case' command outside of switch block context undetected" );
err( L"'case' command outside of switch block context undetected" );
}
if( !parser_test( L"else", 0, 0, 0 ) )
{
err( L"'else' command outside of conditional block context undetected" );
err( L"'else' command outside of conditional block context undetected" );
}
if( !parser_test( L"break", 0, 0, 0 ) )
{
err( L"'break' command outside of loop block context undetected" );
err( L"'break' command outside of loop block context undetected" );
}
if( !parser_test( L"exec ls|less", 0, 0, 0 ) || !parser_test( L"echo|return", 0, 0, 0 ))
{
err( L"Invalid pipe command undetected" );
}
err( L"Invalid pipe command undetected" );
}
say( L"Testing basic evaluation" );
if( !eval( 0, 0, TOP ) )
{
err( L"Null input when evaluating undetected" );
}
}
if( !eval( L"ls", 0, WHILE ) )
{
err( L"Invalid block mode when evaluating undetected" );
}
}
/**
Perform parameter expansion and test if the output equals the zero-terminated parameter list supplied.
@@ -538,42 +688,42 @@ static void test_parser()
static int expand_test( const wchar_t *in, int flags, ... )
{
array_list_t out;
array_list_t out;
va_list va;
int i=0;
int res=1;
wchar_t *arg;
al_init( &out );
if( expand_string( 0, wcsdup(in), &out, flags) )
{
}
va_start( va, flags );
while( (arg=va_arg(va, wchar_t *) )!= 0 )
while( (arg=va_arg(va, wchar_t *) )!= 0 )
{
if( al_get_count( &out ) == i )
{
res=0;
break;
}
if( wcscmp( al_get( &out, i ),arg) != 0 )
{
res=0;
break;
}
i++;
i++;
}
va_end( va );
al_foreach( &out, &free );
return res;
}
/**
@@ -582,7 +732,7 @@ static int expand_test( const wchar_t *in, int flags, ... )
static void test_expand()
{
say( L"Testing parameter expansion" );
if( !expand_test( L"foo", 0, L"foo", 0 ))
{
err( L"Strings do not expand to themselves" );
@@ -597,9 +747,32 @@ static void test_expand()
{
err( L"Cannot skip wildcard expansion" );
}
}
/**
Test path functions
*/
static void test_path()
{
say( L"Testing path functions" );
void *context = halloc( 0, 0 );
wchar_t *can = path_make_canonical( context, L"//foo//////bar/" );
if( wcscmp( can, L"/foo/bar" ) )
{
err( L"Bug in canonical PATH code" );
}
halloc_free( context );
}
/**
Test speed of completion calculations
*/
@@ -612,81 +785,86 @@ void perf_complete()
double t;
wchar_t str[3]=
{
0, 0, 0
0, 0, 0
}
;
int i;
say( L"Testing completion performance" );
al_init( &out );
reader_push(L"");
say( L"Here we go" );
t1 = get_time();
for( c=L'a'; c<=L'z'; c++ )
{
str[0]=c;
reader_set_buffer( str, 0 );
complete( str, &out );
matches += al_get_count( &out );
al_foreach( &out, &free );
al_truncate( &out, 0 );
}
t2=get_time();
t = (double)(t2-t1)/(1000000*26);
say( L"One letter command completion took %f seconds per completion, %f microseconds/match", t, (double)(t2-t1)/matches );
matches=0;
t1 = get_time();
for( i=0; i<LAPS; i++ )
{
str[0]='a'+(rand()%26);
str[1]='a'+(rand()%26);
reader_set_buffer( str, 0 );
complete( str, &out );
matches += al_get_count( &out );
al_foreach( &out, &free );
al_truncate( &out, 0 );
}
t2=get_time();
t = (double)(t2-t1)/(1000000*LAPS);
say( L"Two letter command completion took %f seconds per completion, %f microseconds/match", t, (double)(t2-t1)/matches );
al_destroy( &out );
reader_pop();
}
/**
Main test
Main test
*/
int main( int argc, char **argv )
{
setlocale( LC_ALL, "" );
srand( time( 0 ) );
program_name=L"(ignore)";
say( L"Testing low-level functionality");
say( L"Lines beginning with '(ignore):' are not errors, they are warning messages\ngenerated by the fish parser library when given broken input, and can be\nignored. All actual errors begin with 'Error:'." );
proc_init();
proc_init();
halloc_util_init();
event_init();
event_init();
parser_init();
function_init();
builtin_init();
@@ -694,10 +872,13 @@ int main( int argc, char **argv )
env_init();
test_util();
test_escape();
test_convert();
test_tok();
test_parser();
test_expand();
test_path();
say( L"Encountered %d errors in low-level tests", err_count );
/*
@@ -705,9 +886,9 @@ int main( int argc, char **argv )
*/
// say( L"Testing performance" );
// perf_complete();
env_destroy();
reader_destroy();
reader_destroy();
parser_destroy();
function_destroy();
builtin_destroy();
@@ -715,5 +896,5 @@ int main( int argc, char **argv )
event_destroy();
proc_destroy();
halloc_util_destroy();
}

192
fishd.c
View File

@@ -73,11 +73,12 @@ time the original barrier request was sent have been received.
#include "halloc.h"
#include "halloc_util.h"
#include "path.h"
#include "print_help.h"
/**
Maximum length of socket filename
*/
#ifndef UNIX_PATH_MAX
#ifndef UNIX_PATH_MAX
#define UNIX_PATH_MAX 100
#endif
@@ -140,11 +141,6 @@ static int sock;
*/
static int quit=0;
/**
Dynamically generated function, made from the documentation in doc_src.
*/
void print_help();
/**
Constructs the fish socket filename
*/
@@ -186,7 +182,7 @@ static char *get_socket_filename()
}
/**
Signal handler for the term signal.
Signal handler for the term signal.
*/
static void handle_term( int signal )
{
@@ -196,17 +192,17 @@ static void handle_term( int signal )
/**
Acquire the lock for the socket
Returns the name of the lock file if successful or
Returns the name of the lock file if successful or
NULL if unable to obtain lock.
The returned string must be free()d after unlink()ing the file to release
The returned string must be free()d after unlink()ing the file to release
the lock
*/
static char *acquire_socket_lock( const char *sock_name )
{
int len = strlen( sock_name );
char *lockfile = malloc( len + strlen( LOCKPOSTFIX ) + 1 );
if( lockfile == NULL )
if( lockfile == NULL )
{
wperror( L"acquire_socket_lock" );
exit( EXIT_FAILURE );
@@ -241,13 +237,13 @@ static int get_socket()
exit( EXIT_FAILURE );
}
debug( 4, L"Acquired lockfile: %s", lockfile );
local.sun_family = AF_UNIX;
strcpy( local.sun_path, sock_name );
len = sizeof(local);
debug(1, L"Connect to socket at %s", sock_name);
if( ( s = socket( AF_UNIX, SOCK_STREAM, 0 ) ) == -1 )
{
wperror( L"socket" );
@@ -266,7 +262,7 @@ static int get_socket()
exitcode = 0;
goto unlock;
}
unlink( local.sun_path );
if( bind( s, (struct sockaddr *)&local, len ) == -1 )
{
@@ -292,9 +288,9 @@ static int get_socket()
/*
End critical section protected by lock
*/
free( lockfile );
free( sock_name );
if( doexit )
@@ -315,24 +311,24 @@ static void broadcast( int type, const wchar_t *key, const wchar_t *val )
if( !conn )
return;
msg = create_message( type, key, val );
/*
Don't merge these loops, or try_send_all can free the message
prematurely
*/
for( c = conn; c; c=c->next )
{
msg->count++;
q_put( &c->unsent, msg );
}
}
for( c = conn; c; c=c->next )
{
try_send_all( c );
}
}
}
/**
@@ -349,7 +345,7 @@ static void daemonize()
debug( 0, L"Could not put fishd in background. Quitting" );
wperror( L"fork" );
exit(1);
case 0:
{
/*
@@ -370,19 +366,19 @@ static void daemonize()
sigaction( SIGTERM, &act, 0);
break;
}
default:
{
{
debug( 0, L"Parent process exiting (This is normal)" );
exit(0);
}
}
}
/*
Put ourself in out own processing group
*/
setsid();
/*
Close stdin and stdout. We only use stderr, anyway.
*/
@@ -398,7 +394,7 @@ static wchar_t *fishd_env_get( wchar_t *key )
{
char *nres, *nkey;
wchar_t *res;
nkey = wcs2str( key );
nres = getenv( nkey );
free( nkey );
@@ -411,7 +407,7 @@ static wchar_t *fishd_env_get( wchar_t *key )
res = env_universal_common_get( key );
if( res )
res = wcsdup( res );
return env_universal_common_get( key );
}
}
@@ -427,7 +423,7 @@ static wchar_t *fishd_get_config()
wchar_t *xdg_dir, *home;
int done = 0;
wchar_t *res = 0;
xdg_dir = fishd_env_get( L"XDG_CONFIG_HOME" );
if( xdg_dir )
{
@@ -443,7 +439,7 @@ static wchar_t *fishd_get_config()
free( xdg_dir );
}
else
{
{
home = fishd_env_get( L"HOME" );
if( home )
{
@@ -459,7 +455,7 @@ static wchar_t *fishd_get_config()
free( home );
}
}
if( done )
{
return res;
@@ -469,7 +465,7 @@ static wchar_t *fishd_get_config()
debug( 0, _(L"Unable to create a configuration directory for fish. Your personal settings will not be saved. Please set the $XDG_CONFIG_HOME variable to a directory where the current user has write access." ));
return 0;
}
}
/**
@@ -479,22 +475,22 @@ static void load_or_save( int save)
{
char *name;
wchar_t *wdir = fishd_get_config();
char *dir;
char *dir;
char hostname[HOSTNAME_LEN];
connection_t c;
int fd;
if( !wdir )
{
return;
}
dir = wcs2str( wdir );
free( wdir );
gethostname( hostname, HOSTNAME_LEN );
name = malloc( strlen(dir)+ strlen(FILE)+ strlen(hostname) + 2 );
strcpy( name, dir );
strcat( name, "/" );
@@ -503,20 +499,20 @@ static void load_or_save( int save)
free( dir );
debug( 4, L"Open file for %s: '%s'",
save?"saving":"loading",
debug( 4, L"Open file for %s: '%s'",
save?"saving":"loading",
name );
fd = open( name, save?(O_CREAT | O_TRUNC | O_WRONLY):O_RDONLY, 0600);
free( name );
if( fd == -1 )
{
debug( 1, L"Could not open load/save file. No previous saves?" );
wperror( L"open" );
return;
return;
}
debug( 4, L"File open on fd %d", c.fd );
@@ -524,14 +520,14 @@ static void load_or_save( int save)
if( save )
{
write( c.fd, SAVE_MSG, strlen(SAVE_MSG) );
write_loop( c.fd, SAVE_MSG, strlen(SAVE_MSG) );
enqueue_all( &c );
}
else
read_message( &c );
connection_destroy( &c );
connection_destroy( &c );
}
/**
@@ -557,10 +553,10 @@ static void init()
{
sock = get_socket();
daemonize();
daemonize();
env_universal_common_init( &broadcast );
load();
load();
}
/**
@@ -573,13 +569,13 @@ int main( int argc, char ** argv )
socklen_t t;
int max_fd;
int update_count=0;
fd_set read_fd, write_fd;
halloc_util_init();
program_name=L"fishd";
wsetlocale( LC_ALL, L"" );
wsetlocale( LC_ALL, L"" );
/*
Parse options
@@ -590,57 +586,57 @@ int main( int argc, char ** argv )
long_options[] =
{
{
"help", no_argument, 0, 'h'
"help", no_argument, 0, 'h'
}
,
{
"version", no_argument, 0, 'v'
"version", no_argument, 0, 'v'
}
,
{
0, 0, 0, 0
{
0, 0, 0, 0
}
}
;
int opt_index = 0;
int opt = getopt_long( argc,
argv,
argv,
GETOPT_STRING,
long_options,
long_options,
&opt_index );
if( opt == -1 )
break;
switch( opt )
{
case 0:
break;
break;
case 'h':
print_help();
exit(0);
print_help( argv[0], 1 );
exit(0);
case 'v':
debug( 0, L"%ls, version %s\n", program_name, PACKAGE_VERSION );
exit( 0 );
exit( 0 );
case '?':
return 1;
}
}
}
init();
while(1)
while(1)
{
connection_t *c;
int res;
t = sizeof( remote );
t = sizeof( remote );
FD_ZERO( &read_fd );
FD_ZERO( &write_fd );
FD_SET( sock, &read_fd );
@@ -649,7 +645,7 @@ int main( int argc, char ** argv )
{
FD_SET( c->fd, &read_fd );
max_fd = maxi( max_fd, c->fd+1);
if( ! q_empty( &c->unsent ) )
{
FD_SET( c->fd, &write_fd );
@@ -665,22 +661,22 @@ int main( int argc, char ** argv )
save();
exit(0);
}
if( res != -1 )
break;
if( errno != EINTR )
{
wperror( L"select" );
exit(1);
}
}
if( FD_ISSET( sock, &read_fd ) )
{
if( (child_socket =
accept( sock,
(struct sockaddr *)&remote,
if( (child_socket =
accept( sock,
(struct sockaddr *)&remote,
&t) ) == -1) {
wperror( L"accept" );
exit(1);
@@ -692,20 +688,20 @@ int main( int argc, char ** argv )
if( fcntl( child_socket, F_SETFL, O_NONBLOCK ) != 0 )
{
wperror( L"fcntl" );
close( child_socket );
close( child_socket );
}
else
{
connection_t *new = malloc( sizeof(connection_t));
connection_init( new, child_socket );
connection_init( new, child_socket );
new->next = conn;
send( new->fd, GREETING, strlen(GREETING), MSG_DONTWAIT );
enqueue_all( new );
enqueue_all( new );
conn=new;
}
}
}
for( c=conn; c; c=c->next )
{
if( FD_ISSET( c->fd, &write_fd ) )
@@ -713,7 +709,7 @@ int main( int argc, char ** argv )
try_send_all( c );
}
}
for( c=conn; c; c=c->next )
{
if( FD_ISSET( c->fd, &read_fd ) )
@@ -732,10 +728,10 @@ int main( int argc, char ** argv )
}
}
}
connection_t *prev=0;
c=conn;
while( c )
{
if( c->killme )
@@ -749,7 +745,7 @@ int main( int argc, char ** argv )
if( !msg->count )
free( msg );
}
connection_destroy( c );
if( prev )
{
@@ -759,11 +755,11 @@ int main( int argc, char ** argv )
{
conn=c->next;
}
free(c);
c=(prev?prev->next:conn);
}
else
{
@@ -775,10 +771,10 @@ int main( int argc, char ** argv )
if( !conn )
{
debug( 0, L"No more clients. Quitting" );
save();
save();
env_universal_common_destroy();
break;
}
}
}
halloc_util_destroy();

View File

@@ -1,5 +1,10 @@
/** \file function.c
Functions for storing and retrieving function information.
Prototypes for functions for storing and retrieving function
information. These functions also take care of autoloading
functions in the $fish_function_path. Actual function evaluation
is taken care of by the parser and to some degree the builtin
handling library.
*/
#include "config.h"
@@ -23,8 +28,11 @@
#include "event.h"
#include "reader.h"
#include "parse_util.h"
#include "parser_keywords.h"
#include "env.h"
#include "expand.h"
#include "halloc.h"
#include "halloc_util.h"
/**
@@ -33,9 +41,9 @@
typedef struct
{
/** Function definition */
wchar_t *cmd;
wchar_t *definition;
/** Function description */
wchar_t *desc;
wchar_t *description;
/**
File where this function was defined
*/
@@ -43,14 +51,26 @@ typedef struct
/**
Line where definition started
*/
int definition_offset;
int definition_offset;
/**
List of all named arguments for this function
*/
array_list_t *named_arguments;
/**
Flag for specifying that this function was automatically loaded
*/
int is_autoload;
/**
Set to non-zero if invoking this function shadows the variables
of the underlying function.
*/
int shadows;
}
function_data_t;
function_internal_data_t;
/**
Table containing all functions
@@ -72,12 +92,12 @@ static int load( const wchar_t *name )
{
int was_autoload = is_autoload;
int res;
function_data_t *data;
data = (function_data_t *)hash_get( &function, name );
function_internal_data_t *data;
data = (function_internal_data_t *)hash_get( &function, name );
if( data && !data->is_autoload )
return 0;
is_autoload = 1;
is_autoload = 1;
res = parse_util_load( name,
L"fish_function_path",
&function_remove,
@@ -93,13 +113,13 @@ static int load( const wchar_t *name )
static void autoload_names( array_list_t *out, int get_hidden )
{
int i;
array_list_t path_list;
const wchar_t *path_var = env_get( L"fish_function_path" );
if( ! path_var )
return;
al_init( &path_list );
tokenize_variable_array( path_var, &path_list );
@@ -109,7 +129,7 @@ static void autoload_names( array_list_t *out, int get_hidden )
DIR *dir = wopendir( ndir );
if( !dir )
continue;
struct wdirent *next;
while( (next=wreaddir(dir))!=0 )
{
@@ -117,7 +137,7 @@ static void autoload_names( array_list_t *out, int get_hidden )
wchar_t *suffix;
if( !get_hidden && fn[0] == L'_' )
continue;
suffix = wcsrchr( fn, L'.' );
if( suffix && (wcscmp( suffix, L".fish" ) == 0 ) )
{
@@ -128,26 +148,13 @@ static void autoload_names( array_list_t *out, int get_hidden )
DIE_MEM();
al_push( out, dup );
}
}
}
closedir(dir);
}
al_foreach( &path_list, &free );
al_destroy( &path_list );
}
/**
Free all contents of an entry to the function hash table
*/
static void clear_function_entry( void *key,
void *data )
{
function_data_t *d = (function_data_t *)data;
free( (void *)d->cmd );
free( (void *)d->desc );
free( (void *)d );
}
void function_init()
{
hash_init( &function,
@@ -155,54 +162,107 @@ void function_init()
&hash_wcs_cmp );
}
/**
Clear specified value, but not key
*/
static void clear_entry( void *key, void *value )
{
halloc_free( value );
}
void function_destroy()
{
hash_foreach( &function, &clear_function_entry );
hash_foreach( &function, &clear_entry );
hash_destroy( &function );
}
void function_add( const wchar_t *name,
const wchar_t *val,
const wchar_t *desc,
array_list_t *events )
void function_add( function_data_t *data )
{
int i;
wchar_t *cmd_end;
function_data_t *d;
CHECK( name, );
CHECK( val, );
function_remove( name );
d = malloc( sizeof( function_data_t ) );
function_internal_data_t *d;
CHECK( data->name, );
CHECK( data->definition, );
function_remove( data->name );
d = halloc( 0, sizeof( function_internal_data_t ) );
d->definition_offset = parse_util_lineno( parser_get_buffer(), current_block->tok_pos )-1;
d->cmd = wcsdup( val );
cmd_end = d->cmd + wcslen(d->cmd)-1;
d->desc = desc?wcsdup( desc ):0;
d->definition = halloc_wcsdup( d, data->definition );
if( data->named_arguments )
{
d->named_arguments = al_halloc( d );
for( i=0; i<al_get_count( data->named_arguments ); i++ )
{
al_push( d->named_arguments, halloc_wcsdup( d, (wchar_t *)al_get( data->named_arguments, i ) ) );
}
}
cmd_end = d->definition + wcslen(d->definition)-1;
d->description = data->description?halloc_wcsdup( d, data->description ):0;
d->definition_file = intern(reader_current_filename());
d->is_autoload = is_autoload;
hash_put( &function, intern(name), d );
for( i=0; i<al_get_count( events ); i++ )
d->shadows = data->shadows;
hash_put( &function, intern(data->name), d );
for( i=0; i<al_get_count( data->events ); i++ )
{
event_add_handler( (event_t *)al_get( events, i ) );
event_add_handler( (event_t *)al_get( data->events, i ) );
}
}
int function_copy( const wchar_t *name, const wchar_t *new_name )
{
int i;
function_internal_data_t *d, *orig_d;
CHECK( name, 0 );
CHECK( new_name, 0 );
orig_d = (function_internal_data_t *)hash_get(&function, name);
if( !orig_d )
return 0;
d = halloc(0, sizeof( function_internal_data_t ) );
d->definition_offset = orig_d->definition_offset;
d->definition = halloc_wcsdup( d, orig_d->definition );
if( orig_d->named_arguments )
{
d->named_arguments = al_halloc( d );
for( i=0; i<al_get_count( orig_d->named_arguments ); i++ )
{
al_push( d->named_arguments, halloc_wcsdup( d, (wchar_t *)al_get( orig_d->named_arguments, i ) ) );
}
d->description = orig_d->description?halloc_wcsdup(d, orig_d->description):0;
d->shadows = orig_d->shadows;
// This new instance of the function shouldn't be tied to the def
// file of the original.
d->definition_file = 0;
d->is_autoload = 0;
}
hash_put( &function, intern(new_name), d );
return 1;
}
int function_exists( const wchar_t *cmd )
{
CHECK( cmd, 0 );
if( parser_is_reserved(cmd) )
if( parser_keywords_is_reserved(cmd) )
return 0;
load( cmd );
return (hash_get(&function, cmd) != 0 );
}
@@ -211,9 +271,9 @@ void function_remove( const wchar_t *name )
{
void *key;
void *dv;
function_data_t *d;
function_internal_data_t *d;
event_t ev;
CHECK( name, );
hash_remove( &function,
@@ -221,16 +281,16 @@ void function_remove( const wchar_t *name )
&key,
&dv );
d=(function_data_t *)dv;
d=(function_internal_data_t *)dv;
if( !key )
return;
ev.type=EVENT_ANY;
ev.function_name=name;
ev.function_name=name;
event_remove( &ev );
clear_function_entry( key, d );
halloc_free( d );
/*
Notify the autoloader that the specified function is erased, but
@@ -242,47 +302,74 @@ void function_remove( const wchar_t *name )
parse_util_unload( name, L"fish_function_path", 0 );
}
}
const wchar_t *function_get_definition( const wchar_t *argv )
const wchar_t *function_get_definition( const wchar_t *name )
{
function_data_t *data;
CHECK( argv, 0 );
load( argv );
data = (function_data_t *)hash_get( &function, argv );
function_internal_data_t *data;
CHECK( name, 0 );
load( name );
data = (function_internal_data_t *)hash_get( &function, name );
if( data == 0 )
return 0;
return data->cmd;
return data->definition;
}
const wchar_t *function_get_desc( const wchar_t *argv )
array_list_t *function_get_named_arguments( const wchar_t *name )
{
function_data_t *data;
CHECK( argv, 0 );
load( argv );
data = (function_data_t *)hash_get( &function, argv );
function_internal_data_t *data;
CHECK( name, 0 );
load( name );
data = (function_internal_data_t *)hash_get( &function, name );
if( data == 0 )
return 0;
return _(data->desc);
return data->named_arguments;
}
int function_get_shadows( const wchar_t *name )
{
function_internal_data_t *data;
CHECK( name, 0 );
load( name );
data = (function_internal_data_t *)hash_get( &function, name );
if( data == 0 )
return 0;
return data->shadows;
}
const wchar_t *function_get_desc( const wchar_t *name )
{
function_internal_data_t *data;
CHECK( name, 0 );
load( name );
data = (function_internal_data_t *)hash_get( &function, name );
if( data == 0 )
return 0;
return _(data->description);
}
void function_set_desc( const wchar_t *name, const wchar_t *desc )
{
function_data_t *data;
function_internal_data_t *data;
CHECK( name, );
CHECK( desc, );
load( name );
data = (function_data_t *)hash_get( &function, name );
data = (function_internal_data_t *)hash_get( &function, name );
if( data == 0 )
return;
data->desc =wcsdup(desc);
data->description = halloc_wcsdup( data, desc );
}
/**
@@ -291,18 +378,22 @@ void function_set_desc( const wchar_t *name, const wchar_t *desc )
static int al_contains_str( array_list_t *list, const wchar_t * str )
{
int i;
CHECK( list, 0 );
CHECK( str, 0 );
for( i=0; i<al_get_count( list ); i++ )
{
if( wcscmp( al_get( list, i ), str) == 0 )
{
return 1;
}
{
return 1;
}
}
return 0;
}
/**
Helper function for removing hidden functions
Helper function for removing hidden functions
*/
static void get_names_internal( void *key,
void *val,
@@ -316,14 +407,14 @@ static void get_names_internal( void *key,
}
/**
Helper function for removing hidden functions
Helper function for removing hidden functions
*/
static void get_names_internal_all( void *key,
void *val,
void *aux )
{
wchar_t *name = (wchar_t *)key;
if( !al_contains_str( (array_list_t *)aux, name ) )
{
al_push( (array_list_t *)aux, name );
@@ -333,9 +424,9 @@ static void get_names_internal_all( void *key,
void function_get_names( array_list_t *list, int get_hidden )
{
CHECK( list, );
autoload_names( list, get_hidden );
if( get_hidden )
{
hash_foreach2( &function, &get_names_internal_all, list );
@@ -344,33 +435,33 @@ void function_get_names( array_list_t *list, int get_hidden )
{
hash_foreach2( &function, &get_names_internal, list );
}
}
const wchar_t *function_get_definition_file( const wchar_t *argv )
const wchar_t *function_get_definition_file( const wchar_t *name )
{
function_data_t *data;
function_internal_data_t *data;
CHECK( argv, 0 );
data = (function_data_t *)hash_get( &function, argv );
CHECK( name, 0 );
data = (function_internal_data_t *)hash_get( &function, name );
if( data == 0 )
return 0;
return data->definition_file;
}
int function_get_definition_offset( const wchar_t *argv )
int function_get_definition_offset( const wchar_t *name )
{
function_data_t *data;
function_internal_data_t *data;
CHECK( argv, -1 );
data = (function_data_t *)hash_get( &function, argv );
CHECK( name, -1 );
data = (function_internal_data_t *)hash_get( &function, name );
if( data == 0 )
return -1;
return data->definition_offset;
}

View File

@@ -1,8 +1,10 @@
/** \file function.h
/** \file function.h
Prototypes for functions for storing and retrieving function
information. Actual function evaluation is taken care of by the
parser and to some degree the builtin handling library.
information. These functions also take care of autoloading
functions in the $fish_function_path. Actual function evaluation
is taken care of by the parser and to some degree the builtin
handling library.
*/
#ifndef FISH_FUNCTION_H
@@ -13,32 +15,64 @@
#include "util.h"
/**
Initialize function data
Structure describing a function. This is used by the parser to
store data on a function while parsing it. It is not used
internally to store functions, the function_internal_data_t
structure is used for that purpose. Parhaps these two should be
merged.
*/
typedef struct function_data
{
/**
Name of function
*/
wchar_t *name;
/**
Description of function
*/
wchar_t *description;
/**
Function definition
*/
wchar_t *definition;
/**
List of all event handlers for this function
*/
array_list_t *events;
/**
List of all named arguments for this function
*/
array_list_t *named_arguments;
/**
Set to non-zero if invoking this function shadows the variables
of the underlying function.
*/
int shadows;
}
function_data_t;
/**
Initialize function data
*/
void function_init();
/**
Destroy function data
*/
void function_destroy();
/**
Add an function. The parameters values are copied and should be freed by the caller.
Add an function. The parameters values are copied and should be
freed by the caller.
*/
void function_add( const wchar_t *name,
const wchar_t *val,
const wchar_t *desc,
array_list_t *events );
void function_add( function_data_t *data );
/**
Remove the function with the specified name.
*/
void function_remove( const wchar_t *name );
/**
Returns true if the function with the name name uses internal variables, false otherwise.
*/
int function_use_vars( const wchar_t *name );
/**
Returns the definition of the function with the name \c name.
*/
@@ -55,28 +89,52 @@ const wchar_t *function_get_desc( const wchar_t *name );
void function_set_desc( const wchar_t *name, const wchar_t *desc );
/**
Returns true if the function witrh the name name exists.
Returns true if the function with the name name exists.
*/
int function_exists( const wchar_t *name );
/**
Insert all function names into l. These are not copies of the strings and should not be freed after use.
Insert all function names into l. These are not copies of the
strings and should not be freed after use.
\param list the list to add the names to
\param get_hidden whether to include hidden functions, i.e. ones starting with an underscore
*/
void function_get_names( array_list_t *list,
void function_get_names( array_list_t *list,
int get_hidden );
/**
Returns tha absolute path of the file where the specified function
was defined. Returns 0 if the file was defined on the commandline.
This function does not autoload functions, it will only work on
functions that have already been defined.
*/
const wchar_t *function_get_definition_file( const wchar_t *name );
/**
Returns the linenumber where the definition of the specified function started
Returns the linenumber where the definition of the specified
function started.
This function does not autoload functions, it will only work on
functions that have already been defined.
*/
int function_get_definition_offset( const wchar_t *name );
/**
Returns a list of all named arguments of the specified function.
*/
array_list_t *function_get_named_arguments( const wchar_t *name );
/**
Returns whether this function shadows variables of the underlying function
*/
int function_get_shadows( const wchar_t *name );
/**
Creates a new function using the same definition as the specified function.
Returns non-zero if copy is successful.
*/
int function_copy( const wchar_t *name, const wchar_t *new_name );
#endif

Some files were not shown because too many files have changed in this diff Show More