Commit Graph

4032 Commits

Author SHA1 Message Date
Kevin Ballard
72e8489d50 command: Rename -p/--path flag to -s/--search 2014-07-13 19:11:29 -07:00
Kevin Ballard
cfa13ed84c Update tests for new type behavior
One of the tests was using `>/dev/null` to suppress the `type` output.
That needs to be `^/dev/null` now, but instead just go ahead and use the
new `-q` flag.
2014-07-13 19:11:29 -07:00
Kevin Ballard
29b3b6b31e type: Stop claiming grep is a function
Use `functions -q` instead of searching the `functiosn -na` list for the
provided word. This may result in an automatically-loaded function being
sourced, but that happens anyway with the default output.

This change means the results of `test -q foo` can be relied upon to
indicate whether `foo` can actually be invoked. Previosly, if `foo` was
the name of an automatically-loaded function file but did not actually
define a function `foo`, and there was no execuable `foo`, then `type -q
foo` would lie and say `foo` can be invoked when it can't.
2014-07-13 19:11:29 -07:00
Kevin Ballard
533496e43a Adopt the new type -q flag in the other functions 2014-07-13 19:11:29 -07:00
Kevin Ballard
6f7a7459c1 test: Add a new --quiet flag to suppress output
The --quiet flag is useful when only the exit status matters.

Fix the documentation for the -t flag to no longer claim that `type` can
print "keyword", as it never does that.

Stop printing a blank line for functions/builtins when the -p flag has
been passed. It's just not useful.
2014-07-13 19:11:29 -07:00
Kevin Ballard
6b062b07b4 type: Separate the notion of multi and paths
Track whether -a and -f have been supplied separately. That way both
`type -a -f command` and `type -f -a command` behaves correctly, as does
`type -a -f foo` where there are multiple executables named `foo` in the
$PATH.
2014-07-13 19:11:29 -07:00
Kevin Ballard
bfd3a47380 Fix type function to work better
Stop using getopt to parse flags. It's far more expensive than
necessary, and results in long flags not being parsed on OS X. This also
allows args starting with - after the options list to be properly
interpreted as a value to test.

Print the error message to stderr as is appropriate.

Use the new `command -p` functionality when the -a flag has not been
provided (`command` does not have any equivalent to the -a flag),
instead of using `which`. This is faster and also avoids any possible
disagreement between `which` and what fish thinks is valid.

Stop testing every path to see if it's executable, that test has already
been done by `which` or `command -p`.

The end result is `type -P ls` is roughly 250% faster, according to
profiling, on my OS X machine.
2014-07-13 19:11:29 -07:00
Kevin Ballard
0933e5cab4 Fix typo in documentation for type builtin 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
Kevin Ballard
62d86b3d18 Fix documentation on variable scopes for read
The `read` docs incorrectly asserted that -g was the default for
variables. In actuality it behaves the same way that `set` does.
2014-07-14 09:12:00 +08:00
xzfc
4bbbd2dde6 Fix segfault in status builtin 2014-07-14 09:07:35 +08:00
David Adam
b884117a9e Makefile: just build key_reader with the same objs as fish 2014-07-14 09:06:40 +08:00
ridiculousfish
7def139020 Turn the 'mode' parameter of environment variables into an enum 2014-07-13 17:30:48 -07:00
ridiculousfish
b667eee351 Merge branch 'fix_set_scopes' of github.com:kballard/fish-shell into kballard-fix_set_scopes 2014-07-13 14:12:51 -07:00
ridiculousfish
891f55b2b3 Fix for crash in kill-whole-line
Fixes #1548
2014-07-13 14:06:35 -07:00
Kevin Ballard
7b12fd26f3 Change how we separate toplevel and global scopes
Instead of introducing a new local scope at the point of `set`, merely
push a new local scope at the end of env_init(). This means we have a
single toplevel local scope across the lifetime of the fish process,
which means that

    set -l foo bar
    echo $foo

behaves as expected, without modifying the global environment.
2014-07-13 13:21:06 -07:00
Kevin Ballard
387ec5c06a set: Don't create empty var when erasing index
When using `set -e foo[1]` to erase an index, if the variable doesn't
already exist, return 1 instead of creating it as an empty variable.
2014-07-12 15:43:32 -07:00
Kevin Ballard
dcc043df3b Add an optional mode to env_get_string()
The mode restricts the scope in which the variable is searched for.

Use this new restricted scope functionality in the `set` builtin. This
fixes `set -g` to not show local shadowing variable values, and also
allows for scoped erasing of slices.
2014-07-12 15:35:34 -07:00
Kevin Ballard
2457997cd9 set: Print an error when setting a special var in the wrong scope
When attempting to set a readonly or electric variable in the local or
universal scopes, print an appropriate error. Similarly, print an error
when setting an electric variable as exported. In most cases this is
simply a nicer error instead of the 'read-only' one, but for the 'umask'
variable it prevents `set -l umask 0023` from silently changing the
global value.
2014-07-12 14:07:55 -07:00
Kevin Ballard
d9bed68fe9 Mark COLUMNS/LINES as electric vars
They're dynamically calculated, so they qualify. This also removes them
from the list of exported global variables, because they're actually not
exported.
2014-07-12 14:07:55 -07:00
Kevin Ballard
2eb65b3625 set: Don't treat toplevel scope the same as global
When using the `set` command with the -l flag, if we're at the top
level, create a temporary local scope. This makes query/assignment
behavior be consistent with the value-printing behavior.

This works by marking the current block as needing to pop the
environment if a local scope was pushed. I assume this is safe to do. I
also assume the current block is the right one to modify, rather than
trying to walk up the stack to the root.
2014-07-12 14:07:55 -07:00
Kevin Ballard
76fdfe6890 Rewrite env_exists() for better scope handling
env_exists() wasn't properly handling multiple scopes in some cases,
notably with readonly/electric variables. Rewrite it to operate in a
more straightforward fashion.
2014-07-12 14:07:55 -07:00
ridiculousfish
495adee269 Don't sanity_lose if INTERNAL_BLOCK_NODEs have a null argv
Fixes #1545
2014-07-12 11:01:00 -07:00
Kevin Ballard
383aaa236e Don't allow readonly/electric values to come in through the env
When initializing fish, ignore any inherited environment variables that
match any of the readonly or electric variable names.

This prevents really weird behavior when e.g. fish is launched with
COLUMNS already set to something. In that case, testing $COLUMNS within
fish behaves normally, but any subprocesses get the value that fish
itself had inherited.
2014-07-12 00:53:23 -07:00
Kevin Ballard
8c89e6bce5 Fix typo and tweak set docs
Move the docs for the `-n` flag to `set` out of the list of scopes.
2014-07-12 00:21:04 -07:00
ridiculousfish
98297e5234 Teach while loops to not hang forever with no-execute
Fixes #1543
2014-07-11 11:28:10 -07: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
d5fa4b2ccb Remove errant debug line 2014-07-07 02:01:43 -07:00
ridiculousfish
3ff104ba30 Rename lock_t to mutex_lock_t to fix Solaris compilation
Fixes #1510
2014-07-07 00:38:37 -07:00
Daniel J. Hofmann
706286c289 Fixes use-after-free issue.
Calling writer() might fail in which case launch_buff gets freed.
This patch prevents the subsequent use of memory after it was freed.
2014-07-06 20:54:19 -07:00
ridiculousfish
18c1b12741 Switch variable name in tests from foo to something less likely to be
used accidentally
2014-07-06 20:41:21 -07:00
ridiculousfish
5cda1e55e0 Must load universal variables earlier, and issue a barrier after erasing
one.

Fixes #1526
2014-07-06 18:12:18 -07:00
ridiculousfish
195cd130f8 Fix sense of test in parse_execution to issue a barrier if an external
command has run
2014-07-06 18:12:18 -07:00
ridiculousfish
b19f45e15d Add test for issue 1526 2014-07-06 18:12:18 -07:00
Maxim Gonchar
3acd0dfe48 Add dropbox completion 2014-07-06 20:40:53 +08:00
ridiculousfish
74cedbf1c5 Hopeful fix for Cygwin build (#1530) 2014-07-05 10:22:20 -07:00
Siteshwar Vashisht
7d47ec4c46 Properly handle invalid arguments in builtins
Fixes #1522
2014-07-02 17:04:58 +05:30
callesg
14cdd24f78 Added better build description closes #70
The stuff nedded to build on Ubuntu
2014-07-01 16:08:37 +02:00
David Adam
1cfd055f82 env.cpp: allow all users to change $USER and $HOME
Closes 1425 (https://github.com/fish-shell/fish-shell/issues/1425)
2014-06-28 19:16:29 +08:00
Sascha
ed5e585684 Also add forward/backward movement in insert mode 2014-06-27 22:55:27 +08:00
Sascha
32948b8dc6 Provide more useful insert mode mappings 2014-06-27 22:55:20 +08:00
Cameron Norman
ad5ad3d1ad Fix bug for systemd being installed but not PID 1 2014-06-20 11:08:35 +08:00
ridiculousfish
3bc2dda00d Merge branch 'death_of_fishd'
Incorporates more removal and cleanup of fishd remnants.
2014-06-18 11:19:28 -07:00
ridiculousfish
ee8e9c0291 Remove env_universal.h and env_universal.cpp from project 2014-06-18 10:14:35 -07:00
David Adam
f4bc1ef4a2 docs: clarify fish_greeting function and variable in FAQ
Tidy fish_greeting section in main documentation.

Closes #1506.
2014-06-18 17:29:59 +08:00
ridiculousfish
3513ce3ac0 Universal variable callbacks should only be announced for changed
values, not every value. Also support erase notifications.
2014-06-16 12:27:28 -07:00
ridiculousfish
6277a2e4a4 Migrate global functions out of env_universal. Have env operate directly
on an env_universal_t.
2014-06-15 17:30:50 -07:00
ridiculousfish
84faa60c4e Fix Linux build of env_universal_common 2014-06-13 15:35:37 -07:00
ridiculousfish
735195e8ea Teach env_universal_remove to directly report whether the variable was
successfully removed.
2014-06-13 15:15:11 -07:00
Konrad Borowski
0f15ab8d05 Allow fast failure on Travis. 2014-06-11 20:44:41 +02:00