Commit Graph

125 Commits

Author SHA1 Message Date
ridiculousfish
c70769c656 Raise debug level to 2 on annoying Changing language to English message
Fixes #1386
2014-10-08 11:46:03 -07:00
David Adam
14724401ff env.cpp: correctly check variable_can_be_array
Closes #1746.
2014-10-08 09:53:29 +08:00
Kevin Ballard
43e451d4d8 Find fishd file even when $HOME is unset
env.cpp sets up $HOME based on the current user, if it's not inherited
from the environment. fishd_get_config should be using the same
calculated value of $HOME. To that end, move universal variable
initialization to after $HOME is set up, and read the value from the
fish environment instead of using getenv().

Fixes #1725.
2014-10-01 12:35:15 -07:00
Kevin Ballard
1be5e68e99 Export $HOME if we have to calculate it
If $HOME is unset in the environment, fish calculates it with
getpwnam(). However, it wasn't being exported. Just like the $USER
calculation, $HOME should probably be exported, because everyone will
assume that it's an environment variable (as opposed to an unexported
global variable).
2014-10-01 12:27:32 -07:00
ridiculousfish
b8181f9eb8 Further support for term24bit. Teach output.cpp what to do with it. 2014-09-19 18:45:04 -07:00
ridiculousfish
555ff00a30 Initial work to support for term-24bit ("true color") 2014-09-19 18:45:04 -07:00
Kevin Ballard
940f264ee6 Decrement SHLVL when running exec
`exec` removes fish from the shell "stack", so SHLVL needs to be
decremented to match. This means `exec fish` will result in the same
SHLVL in the new fish instance.

Also tweak the SHLVL logic to interpret an environment SHLVL of "3foo"
as garbage instead of as the value "3".

Fixes #1693.
2014-09-19 17:38:54 -07:00
Kevin Ballard
130619d6b0 Fix $SHLVL
Due to being read-only, SHLVL wasn't being incremented properly for
recursive invocations of fish.
2014-08-29 12:22:35 -07:00
Kevin Ballard
9f725bee1f set: Print an error when setting umask to a bad value
Repurpose the ENV_INVALID return value for env_set(), which wasn't
currently used by anything. When a bad value is passed for the 'umask'
key, return ENV_INVALID to signal this and print a good error message
from the `set` builtin.

This makes `set umask foo` properly produce an error.
2014-08-21 19:06:21 -07:00
ridiculousfish
52ae5f885e Improve history robustness against corrupt files
Fixes #1581
2014-07-29 14:42:03 -07:00
ridiculousfish
30ae473d85 Clean up default environment variables.
This stops unconditionally setting values for HOME and USER,
if we find those values in the environment. It also saves about 16KB
on OS X, which getpwuid allocates.
2014-07-25 10:49:13 -07:00
ridiculousfish
7def139020 Turn the 'mode' parameter of environment variables into an enum 2014-07-13 17:30:48 -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
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
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
ridiculousfish
5cda1e55e0 Must load universal variables earlier, and issue a barrier after erasing
one.

Fixes #1526
2014-07-06 18:12:18 -07: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
ridiculousfish
ee8e9c0291 Remove env_universal.h and env_universal.cpp from project 2014-06-18 10:14:35 -07: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
735195e8ea Teach env_universal_remove to directly report whether the variable was
successfully removed.
2014-06-13 15:15:11 -07:00
ridiculousfish
ef646f0f78 Removal of more fishd artifacts and headers 2014-06-09 12:07:40 -07:00
ridiculousfish
ecf56606dc Remove large parts of fishd interaction, including
env_universal_server
2014-06-06 10:34:42 -07:00
David Adam
3225d7e169 avoid symlink attacks in __fish_print_packages and spawning fishd
* use $XDG_CACHE_HOME for __fish_print_packages completion caches
 * when starting fishd, redirect fishd output to /dev/null, not a
   predictable path

Fix for CVE-2014-3219.

Closes #1440.
2014-05-12 09:30:05 +08:00
Konrad Borowski
f8e35de18d Shorten compilation times
Now fish shell stores version is a small file called by other files.
This means that a slight change which modifies one file won't cause
many of files to recompile.

The compilation unit is intentionally small, this is by design. The
smaller it is, the faster it will recompile, and it will be compiled
a lot.
2014-05-01 09:46:27 +02:00
ridiculousfish
a475dd15e6 Migrate universal variables to env_var_t structure. Encapsulate
universal variable storage into a class for better testability.
2014-04-25 16:09:26 -07:00
Julian Aron Prenner
cd64a777c3 Set $fish_bind_mode to default on fish startup; set $fish_key_bindings
when sourcing fish_vi_mode.fish
2014-01-19 10:27:39 +01:00
ridiculousfish
b2c78dbd57 Fix for issue where we compute a default USER variable, but never set
its value.
2014-01-12 13:42:26 -08:00
ridiculousfish
b34721b3f4 Miscellaneous optimizations to reduce string copying 2014-01-07 14:57:58 -08:00
ridiculousfish
85ce80d72e Stop insisting on trying to add /usr/bin and /bin to $PATH.
https://github.com/fish-shell/fish-shell/pull/854
2013-08-27 18:23:33 -07:00
David Adam (zanchey)
2a06c72113 Generate version numbers dynamically
This commit hooks the Makefile up to generate a FISH_BUILD_VERSION
symbol and kills off PACKAGE_VERSION in .cpp files.

It also modifies the tarball generation script to add the necessary
version file for releases.
2013-08-11 23:13:38 +08:00
ridiculousfish
c64a86efae Fix some warnings exposed by -Wall 2013-07-16 13:40:11 -07:00
Dag Odenhall
9f0775c873 Fix $LINES = $COLUMNS bug
Fixes #745
2013-05-24 23:23:29 -07:00
ridiculousfish
fe6699f0bf Rely on $PWD instead of getcwd() more often
Fixes https://github.com/fish-shell/fish-shell/issues/696
2013-04-27 00:45:38 -07:00
ridiculousfish
8bbd8ab073 Hack up dcgettext to try to fix CentOS build
https://github.com/fish-shell/fish-shell/issues/645
2013-04-08 12:02:43 -07:00
David Adam (zanchey)
daf5ef1bbd Kill termio.h and sys/termios.h
On FreeBSD, compilation complains that "this file includes
<sys/termios.h> which is deprecated, use <termios.h> instead". On Linux
and FreeBSD, <sys/termios.h> literally just pulls in <termios.h>. On OS
X and Solaris, <termios.h> pulls in <sys/termios.h>.

<termio.h> doesn't exist on FreeBSD or Mac OS X, and on Linux is marked
as deprecated and just includes <termios.h>. It does exist on Solaris,
but no `struct termio` is ever actually used in the codebase.
2013-03-05 12:25:00 -08:00
ridiculousfish
a8e92639af Cleanup and simplify null_terminated_array_t and its clients 2013-02-22 16:22:56 -08:00
ridiculousfish
fbedf020bc Null initialize an ivar (oops) 2013-02-19 23:16:44 -08:00
ridiculousfish
aaa0c25ff7 Large set of changes to how PATH is handled. Changed fish to no longer modify PATH in share/config.fish. Introduced variable fish_user_paths, and a glue function __fish_reconstruct_path that splices together PATH with fish_user_paths. Changed fish to no longer validate changes to PATH unless the paths are new (i.e. don't recheck what's already there). Modified certain sets to store const wchar_t instead of wcstring to save a few allocations.
https://github.com/fish-shell/fish-shell/issues/527
2013-02-19 18:05:20 -08:00
ridiculousfish
6d522e6ed6 First round of fixes based on cppcheck
https://github.com/fish-shell/fish-shell/issues/575
2013-02-16 00:02:40 -08:00
ridiculousfish
8d95d0834d First stab at builtin set_color. Moved set_color.cpp to builtin_set_color.cpp and taught fish about it. 2013-02-14 15:52:24 -08:00
Siteshwar Vashisht
694ab455cd Fixed broken export_func
Fix for https://github.com/fish-shell/fish-shell/issues/573
2013-02-12 13:50:43 +01:00
ridiculousfish
46edc07ae4 Clean up export_func 2013-02-12 00:14:27 -08:00
ridiculousfish
2a7fc9c3a5 Clean up env_var_table_t. Switch from storing var_uni_entry_t* to var_uni_entry_t. Various other cleanups. 2013-02-11 23:16:50 -08:00
Cheer Xiao
274f018494 Remove trailing whitespaces 2013-01-21 10:34:18 +08:00
ridiculousfish
6d61919941 Rearrange some variables for possibly better alignment. int -> bool 2013-01-19 13:32:12 -08:00