Commit Graph

209 Commits

Author SHA1 Message Date
ridiculousfish
d4eded2376 Make octal/hex escapes in printf and echo output literal bytes
Fixes #1894
2015-01-15 11:21:07 -08:00
ridiculousfish
d1feb9bcbf Use scoped_push to save and restore real_io
Fixes a dangling pointer
2015-01-07 16:41:16 -08:00
ridiculousfish
39fe9fcfcd Tweak comment handling. Mark a parse node with a new flag when it has comments 2014-12-23 10:58:45 -08:00
Andreas Heiduk
09bac97bb4 Align fg and bg commands: With no parameters fg prints the help.
`bg` on the other hand only prints `no job`. Now both print `no job`.
2014-11-07 19:05:09 +01:00
ridiculousfish
16459099af Make C_ (gettext used in completions) return wcstring 2014-10-30 18:52:37 -07:00
Kevin Ballard
76c6985f82 A little extra tweaking so builtin_print_help looks better
The terminal width magic that __fish_print_help learned doesn't help
when builtin_print_help runs it in a subshell. Instead, add an
undocumented --tty-width flag to __fish_print_help that's used to pass
the terminal width.
2014-10-10 00:11:23 -07:00
Kevin Ballard
cfc06203e7 Add new functions flag -V/--inherit-variable
--inherit-variable takes a variable name and snapshots its current
value. When the function is executed, it will have a local variable with
this value already defined. Printing the function source will include
synthesized `set -l` lines for the values.

This is primarily useful for functions that are created on the fly, such
as in `psub`.
2014-10-02 18:41:39 -07:00
Kevin Ballard
d67800bbce Make false/true into builtins
Making `true` into a builtin is a significant optimization to `while
true` loops. As long as `true` is a builtin, we may as well make `false`
builtin as well (despite the fact that it's not typically executed in a
loop).
2014-09-29 13:39:35 -07:00
Konrad Borowski
bbce0909fe Remove dead code in history builtin. 2014-09-24 16:18:29 +02:00
Kevin Ballard
5b33e60752 Support bind SEQ to print a binding for SEQ 2014-09-22 21:30:44 -07:00
Kevin Ballard
0a3f220572 Rework mode handling of bind
Binds with the same sequence in multiple modes was not working right.
Fix up the implementation to propagate modes everywhere as necessary.
This means that `bind` will properly list distinct binds with the same
sequence, and `bind -e` will take mode into account properly as well.
Note that `bind -e seq` now assumes the bind is in the default bind
mode, whereas before it would erase the first binding with that sequence
regardless of mode.

`bind -e -a` still erases all binds in all modes, though `bind -M mode
-e -a` still only erases all binds in the selected mode.
2014-09-22 21:04:06 -07:00
Kevin Ballard
5eee7d17f6 Fix bind -e without -k
In adding `-k` support to `bind -e` I broke the ability to use `bind -e`
without specifyign `-k`. Oops.
2014-09-22 20:56:45 -07:00
Kevin Ballard
2cd7f1443c Support -k with bind -e
Also return an exit code of 1 if `bind -k` can't match the key name.
2014-09-22 19:21:08 -07:00
Kevin Ballard
4ed4b265a5 Show -M and -m flags in bind list 2014-09-22 12:37:11 -07:00
Kevin Ballard
cb40507b7b Don't suppress output for printf --help
Fixes #746.
2014-09-21 23:49:14 -07:00
Kevin Ballard
fe9cf673a2 Add --right-prompt flag to read
Add a flag to read to allow for setting the right prompt command in
addition to the existing support for setting the prompt command.

Fixes #1698.
2014-09-21 21:10:07 -07:00
Kevin Ballard
a027566295 No need for mbstate_t to be static 2014-09-21 20:47:03 -07:00
Kevin Ballard
a012aedb31 Fix incorrect error on read with 1-character input
When `read` is given a single character of input (including the
newline), it was bailing as if it had been given no input. This is
incorrect.
2014-09-21 20:00:26 -07:00
Kevin Ballard
8f8c4cdd17 Implement new read --null flag
The `--null` flag to `read` makes it split incoming lines on NUL instead
of newlines. This is intended for processing the output of a command
that uses NUL separators (such as `find -print0`).

Fixes #1694.
2014-09-21 19:27:26 -07:00
Kevin Ballard
f6da9d4d5d Add missing newline after bind -k foo error message 2014-09-08 23:37:34 -07:00
Joseph Tannhuber
4acea72700 New -n option for read builtin
Usage: read -n nchars
Reads maximum of nchars characters. If nchars <= 0, there's no limit.
2014-09-03 22:48:37 -07:00
Konrad Borowski
1f3a93a3af
Fix the compilation under gcc 4.9.0.
gcc interpretes C99's compound literals more strictly by invalid the
compound literal on implicit to pointer cast (because of automatic
storage duration, 6.5.2.5.6 in C99 standard draft).

This fixes the issue by not using compound literals at all.
2014-08-22 21:52:41 +02:00
ridiculousfish
033373f078 Merge branch 'make_type_better' of github.com:kballard/fish-shell into kballard-make_type_better 2014-08-21 21:36:39 -07:00
ridiculousfish
06400b83b1 Support for command wrapping ("aliases")
Add the --wraps option to 'complete' and 'function'. This allows a
command to (recursively) inherit the completions of a wrapped command.
Fixes #393.

When evaluating a completion, we inspect the entire "wrap chain" for a
command, i.e. we follow the sequence of wrapping until we either hit a
loop (which we silently ignore) or the end of the chain. We then
evaluate completions as if the wrapping command were substituted with
the wrapped command. Currently this only works for commands, i.e.
'complete --command gco --wraps git\ checkout' won't work (that would
seem to encroaching on abbreviations anyways). It might be useful to
show an error message for that case.

The commandline builtin reflects the commandline with the wrapped
command substituted in, so e.g. git completions (which inspect the
command line) will just work. This sort of command line munging is
also performed by 'complete -C' so it's not totally without precedent.

'alias will also now mark its generated function as wrapping the
'target.
2014-08-15 18:14:36 -07:00
ridiculousfish
b97a94ccc8 Clean up reader_write_title to work with wcstring 2014-08-02 21:01:40 -07:00
jianjun
87abcecca6 add command line string as $argv[1] for fish_title 2014-08-02 12:57:38 -07:00
ridiculousfish
52ae5f885e Improve history robustness against corrupt files
Fixes #1581
2014-07-29 14:42:03 -07:00
ridiculousfish
e9f870e25a Add support for history --merge to incorporate history changes from
other sessions.

Fixes #825
2014-07-25 10:49:12 -07:00
Kevin Ballard
973dd6ffbd read: Support arrays, character splitting
Enhance the `read` builtin to support creating an array with the --array
flag. With --array, only a single variable name is allowed and the
entire input is tokenized and placed into that variable as an array.

Also add custom behavior if IFS is empty or unset. In that event, split
the input on every character, instead of the previous behavior of doing
no splitting at all.
2014-07-14 00:46:38 -07:00
Kevin Ballard
72e8489d50 command: Rename -p/--path flag to -s/--search 2014-07-13 19:11:29 -07:00
Kevin Ballard
cc565fc16c Teach command builtin a -p/--path flag
Give the `command` builtin a single flag, -p/--path, that causes it to
print the full path that would be executed for the given command.
2014-07-13 19:11:29 -07:00
xzfc
4bbbd2dde6 Fix segfault in status builtin 2014-07-14 09:07:35 +08:00
ridiculousfish
3915faf382 bind should not show -k for bindings that are escape sequences, not keys 2014-07-07 10:45:26 -07:00
ridiculousfish
3cbace98a7 'echo -' should output a dash instead of treating it as options
Fixes #1459
2014-05-16 15:19:07 +08:00
Konrad Borowski
13e1e7e1e9 Fix NULL dereference when function name is not specified
It was possible to type `function ""; end`, and this caused fish to
crash because of NULL pointer.
2014-05-06 12:07:16 +02:00
Konrad Borowski
a7facfb760 Fix memory leak when displaying bind list.
This also removes duplication from the code.
2014-05-01 09:23:23 +02:00
ridiculousfish
4948508277 Squelch some more warnings on Linux 2014-04-27 18:27:34 -07:00
ridiculousfish
58ebdd4a7e Attempt to silence some warnings 2014-04-27 17:23:19 -07:00
ridiculousfish
0d3169ef70 Run restyle.sh to enforce style rules. 2014-03-31 10:01:39 -07:00
ridiculousfish
bd895aa76c Changes to bind_mode implementation based on code review and merge
errors
2014-03-30 16:58:46 -07:00
ridiculousfish
d4fafeb6d6 Merge branch 'master' into 1218_rebase
Conflicts:
	builtin.cpp
	builtin_commandline.cpp
	highlight.cpp
	input.cpp
	input.h
	reader.cpp
	screen.cpp
	screen.h
2014-03-29 14:19:45 -07:00
ridiculousfish
0325c1ba65 Teach parse_util_detect_errors to report invalid builtins, as found in
issue #1252
2014-03-26 18:20:38 -07:00
ridiculousfish
4deb46290d Remove additional dead code from old parser 2014-03-20 21:32:03 -07:00
ridiculousfish
3cfdc6d126 Fix line number reporting in new parser 2014-03-20 21:32:02 -07:00
ridiculousfish
cc12225142 Clean up various block types and state as part of new parser 2014-03-02 13:46:30 -08:00
ridiculousfish
6b3a37c597 Remove obviated builtins and additional cleanup of old parser 2014-03-02 13:11:17 -08:00
ridiculousfish
be33d3f2a4 Revert "Merge pull request #1317 from pullreq/cpp"
This reverts commit 74135c0600, reversing
changes made to 6d749789ce.

See discussion in #1317
2014-02-28 02:16:48 -08:00
Geoff Nixon
18dd6f58e3 Fixes .c -> .cpp in comments. For doxygen. 2014-02-27 06:23:40 -08:00
ridiculousfish
503bbd85b5 Test and fix issue where, if binding X is a prefix of binding Y, and X
is specified before Y, then Y will never be invoked because X will
always get there first. Now instead we order bindings in descending
order by length, so that we always test the binding before any others that
prefixes it. Fixes #1283.
2014-02-12 12:52:31 -08:00
ridiculousfish
e632d39b1f Make if statements always return success at the end, matching other
shells. Fixes #1061.
2014-02-07 17:57:53 -08:00