Commit graph

48 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
a8e92639af Cleanup and simplify null_terminated_array_t and its clients 2013-02-22 16:22:56 -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
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
ridiculousfish
6d61919941 Rearrange some variables for possibly better alignment. int -> bool 2013-01-19 13:32:12 -08:00
ridiculousfish
e07de09460 Big cleanup of env_set. Changed var_table_t to use direct var_entry_t instead of pointers. Changed some ints to bools. 2013-01-19 13:32:06 -08:00
ridiculousfish
9992b8eb0e Apply new indentation, brace, and whitespace style 2012-11-18 16:30:30 -08:00
Łukasz Niemier
47df1ae40a Remove trailing whitespaces and change tabs to spaces 2012-11-18 11:23:22 +01:00
ridiculousfish
61686aff34 Adopt posix_spawn (!)
Rewrite IO chains to be a vector of pointers, instead of a linked list
Removed io_transmogrify
2012-08-15 00:57:56 -07:00
ridiculousfish
261bf12c91 Lots of miscellaneous cleanup. Unified the path_get_cd_path, path_allocate_cd_path, etc. functions 2012-07-20 22:11:05 -07:00
ridiculousfish
b08fb86637 Renamed env_vars to env_vars_snapshot_t
Cleanup of non-wcstring version of path_get_path
2012-07-20 20:39:31 -07:00
ridiculousfish
e9f43f1097 Changes to make fish use the relocated fishd instead of the installed one, if it exists 2012-07-18 10:50:56 -07:00
ridiculousfish
175249b455 Adopt wcstring in env_set 2012-05-09 03:06:10 -07:00
ridiculousfish
0e3eb38f11 Improved fork reporting
Made autosuggestion work properly for tilde expansion
2012-04-21 20:08:44 -07:00
ridiculousfish
68b93c624f Move special handling of DISPLAY environment variable from etc/config.fish to fish itself to reduce number of fork calls made at launch 2012-03-06 15:52:16 -08:00
ridiculousfish
f35d2629d4 Notice when fish_term256 changes and react to it 2012-03-05 14:18:16 -08:00
ridiculousfish
909d24cde6 More work on improving interaction between fork and pthreads. Added null_terminated_array_t class. 2012-02-29 16:14:51 -08:00
ridiculousfish
94a764d6ea Fix for error messages when loading completions 2012-02-26 01:15:53 -08:00
ridiculousfish
38e40862fe More work towards autosuggesting completions 2012-02-25 18:54:49 -08:00
Siteshwar Vashisht
8232857d07 Modified env_get_string() to accept wcstring instead of wchar_t*. 2012-02-24 00:58:01 +05:30
ridiculousfish
029c8c06c2 Remove old env_get_names implementation 2012-02-08 00:59:46 -08:00
ridiculousfish
5ad6849d4e Work on new history implementation 2012-02-05 16:42:24 -08:00
Peter Ammon
a359f45df2 Redesign new environment variables to use env_var_t instead of wcstring
Migrate uses of empty() to missing() to distinguish between empty variable and unset variable
2012-01-14 02:42:17 -08:00
Peter Ammon
e8b6d48ad0 Introduce env_var_t to replace empty string as missing environment variable 2012-01-14 01:06:47 -08:00
ridiculousfish
c18d177b8c Additional migration to STL data structures 2012-01-10 12:55:22 -08:00
ridiculousfish
8d2f107d61 Some changes to migrate towards C++ and a multithreaded model 2011-12-26 19:18:46 -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
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
axel
e98a604a21 Minor edits, remove unneeded code, add a few commants, correct spelling, tweak the todo list, etc.
darcs-hash:20061026102253-ac50b-eb42fdab9a9211d68386a563134856a96b870d90.gz
2006-10-26 20:22:53 +10:00
axel
2d05b1c1b4 Add compiler warnings for some common incorrect usage of functions, such as forgetting to cast null pointers to variadic functions
darcs-hash:20061019151947-ac50b-4043638a7a830fa80fd918f92365f5afe3ff208a.gz
2006-10-20 01:19:47 +10:00
axel
53ea5d60b7 Minor code tweaks, mostly things like indentation, but also a ferw code reorderings
darcs-hash:20060828120244-ac50b-ad4be149ff245b6f799452f9eeff7bcc60af1526.gz
2006-08-28 22:02:44 +10:00
axel
f7118e769f Add more function input validation checks
darcs-hash:20060608235212-ac50b-25fd55f96356af65d4da1eec100cc954b4a9f81e.gz
2006-06-09 09:52:12 +10:00
axel
04b142208d Make it possible to specify scope of a variable to be erased or tested. Also make sure set exits with a non-zero exit status when erasing fails.
darcs-hash:20060604201451-ac50b-4ea0212c513b33be40559dfe8d65c1446c53f682.gz
2006-06-05 06:14:51 +10:00
axel
bd9c843fd1 Add warning when trying to change read-only variable
darcs-hash:20060410153626-ac50b-700ff7687647b8aab47ba79d759d1739cbe60425.gz
2006-04-11 01:36:26 +10:00
axel
0ebf6db4b9 Increase fish robustness by improving signal handling when forking jobs and minor signal handling improvements
darcs-hash:20051014114033-ac50b-8d0f6274ac590f1b6dbe82c55366f44ed7debf20.gz
2005-10-14 21:40:33 +10:00
James Vega
e27664b13b Add header guards to the header files.
darcs-hash:20051004151139-35ec8-7af69b9d7647d145dc621f7eaea726e729cff554.gz
2005-10-05 01:11:39 +10:00
axel
0ef22a5577 Add support for zero element arrays
darcs-hash:20050926144703-ac50b-3ed14d14b02908862d69aec08aab35b6d0188bba.gz
2005-09-27 00:47:03 +10:00
axel
f971e02256 Exportable universal variables
darcs-hash:20050922201652-ac50b-f70e7607b4ace24da4020f2d432718dc335e5bdd.gz
2005-09-23 06:16:52 +10:00
axel
149594f974 Initial revision
darcs-hash:20050920132639-ac50b-fa3b476891e1f5f67207cf4cc7bf623834cc5edc.gz
2005-09-20 23:26:39 +10:00