Commit Graph

49 Commits

Author SHA1 Message Date
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
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
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
11c1562512 Remove connection_t usage from write_to_fd 2014-06-09 12:57:44 -07:00
ridiculousfish
53814983ff Update style and formatting to conform to fish style guide. 2014-01-15 01:40:40 -08:00
ridiculousfish
89069fdaa4 Miscellaneous minor fixes based on cppcheck static analyzer 2014-01-12 13:33:35 -08:00
Konrad Borowski
ef99a11001 Remove unused values in builtin_set. 2013-10-17 19:01:20 +02:00
ridiculousfish
084542b943 print_variables should use ellipsis_char instead of literal ellipsis 2013-04-19 10:24:33 -07: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
ad8d68dd43 Make subcommands modify $status, and make builtin_set not modify status unless it fails
https://github.com/fish-shell/fish-shell/issues/547
https://github.com/fish-shell/fish-shell/issues/214
2013-01-31 15:57:08 -08:00
ridiculousfish
1879dc4b59 Initial set of changes working to make fish robust against running out of file descriptors 2013-01-30 02:22:38 -08:00
ridiculousfish
bf3e4126b2 Fix for builtin_test crash
https://github.com/fish-shell/fish-shell/issues/497
2013-01-06 14:48:46 -08:00
ridiculousfish
26678682ca Fix indentation of switch statements 2012-11-19 00:31:03 -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
ff124465fd Clean up some warnings and some unused if-related code 2012-09-01 12:29:00 -07: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
2e1b3325c6 Warning cleanup 2012-08-04 11:34:45 -07:00
ridiculousfish
bb4a05032b Merge branch 'index_range' 2012-07-19 10:59:11 -07:00
ridiculousfish
c1a23bf450 Fix for https://github.com/fish-shell/fish-shell/issues/199
Don't hard-fail on setting the PATH or CDPATH just because it contains an invalid entry
2012-07-07 23:04:02 -07:00
maxfl
b25b5bf5f6 restore tabs instead of spaces 2012-07-08 10:55:48 +08:00
maxfl
0a5e7be129 Add index ranges
Builtin 'set' now can set variable index ranges:
  set test[1..3] a b c #works
  set test[-1..-3] a b c #works if variable have enough elements
  set test[2..-2]  a b c #works
  set test[1..3 -1..-2] a b c b b #works

Expand now can parse index ranges. But not handle for now.

TODO:
  * Add variable substitution index ranges: echo $PATH[-1..1]
  * Add command substitution index range: echo (seq 10)[-1..-4]
  * Add process substitution indexes and ranges: echo %vim[-1]
2012-07-07 10:57:28 +08:00
ridiculousfish
19e183f02f Squashed commit of the following:
commit 5b7659ec3d5e67b8dad8d3543d87a0169dc9a9e9
Merge: 57f3df3 22a4cd6
Author: ridiculousfish <corydoras@ridiculousfish.com>
Date:   Thu Jun 21 10:15:41 2012 -0700

    Merge branch 'master' of https://github.com/maxfl/fish-shell into maxfl-master-base

commit 22a4cd686f
Author: maxfl <gmaxfl@gmail.com>
Date:   Tue Jun 19 15:51:43 2012 +0400

    set now expands the variable size, if index is outside it

commit 9b0ffa8315
Author: maxfl <gmaxfl@gmail.com>
Date:   Mon Jun 18 21:30:44 2012 +0400

    fixes #78

commit 78387fb391
Merge: c0e6096 93dc7d4
Author: maxfl <gmaxfl@gmail.com>
Date:   Mon Jun 18 21:27:47 2012 +0400

    Merge remote-tracking branch 'fishfish/master'

commit c0e60963c1
Merge: 32a98e7 1bead8a
Author: maxfl <gmaxfl@gmail.com>
Date:   Mon Jun 18 10:29:42 2012 +0400

    Merge remote-tracking branch 'fishfish/master'

commit 32a98e799e
Merge: 6e71021 f2b5292
Author: maxfl <gmaxfl@gmail.com>
Date:   Sat Jun 16 18:42:07 2012 +0400

    Merge remote-tracking branch 'fishfish/master'

commit 6e710211bc
Author: maxfl <gmaxfl@gmail.com>
Date:   Thu Jun 14 11:01:13 2012 +0400

    revert fish_pager

commit 731a29f35b
Author: maxfl <gmaxfl@gmail.com>
Date:   Thu Jun 14 10:57:41 2012 +0400

    revert fish_pager.cpp

commit 72c1bfc7bf
Merge: ea74ffa 9b781c4
Author: maxfl <gmaxfl@gmail.com>
Date:   Wed Jun 13 17:54:11 2012 +0400

    Merge branch 'master' into maxfl_completions

commit ea74ffa086
Author: maxfl <gmaxfl@gmail.com>
Date:   Wed Jun 13 17:35:20 2012 +0400

    __fish_complete_command now can understand '--arg=option' tokens
    latexmk completion is updated

commit 45b667826f
Author: maxfl <gmaxfl@gmail.com>
Date:   Wed Jun 13 16:46:47 2012 +0400

    . completion

commit 1c9f8ffc9e
Author: maxfl <gmaxfl@gmail.com>
Date:   Wed Jun 13 16:46:13 2012 +0400

    a lot of new completions

commit 8224d9f984
Author: Maxim Gonchar <gonchar@myhost.localdomain>
Date:   Tue Jun 12 20:19:31 2012 +0400

    A lot of new completions.
    Some small updates and fixes of old functions and completions.

commit 234ed8f5da
Author: Maxim Gonchar <gonchar@myhost.localdomain>
Date:   Tue Jun 12 20:03:44 2012 +0400

    step-coloring initial
    set_color correction
2012-06-21 10:24:49 -07:00
Siteshwar Vashisht
93dc7d4cc1 Add support for querying variables with scope options as requested in issue #132 2012-06-18 22:52:33 +05:30
ridiculousfish
eebe126842 Fix for a busted format string 2012-06-17 14:49:45 -07:00
ridiculousfish
39863ce4d7 Fix for longstanding bug where set -e would fail to erase elements from an array.
This was introduced in 7b3377e78c
2012-05-10 01:04:18 -07:00
ridiculousfish
99b51ce6ea Fix to better support CDPATH 2012-05-06 14:53:19 -07:00
ridiculousfish
1a87f44325 Re-implement $history variable
Added -L option to set to mean "don't abbreviate"
2012-03-19 11:52:18 -07:00
ridiculousfish
00764406d7 Fix to preserve errno across certain calls to stop printing EOVERFLOW messages in weird places 2012-03-03 15:28:16 -08:00
ridiculousfish
3ead99b088 Put fish on a diet. Tracked down the biggest memory hogs and fixed them. Total allocations down by a factor of 3 or so, live allocations a few KB. 2012-03-03 15:22:03 -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
376e199ebb Removed a lot of string_buffer_t 2012-02-22 12:00:02 -08:00
ridiculousfish
62bd43f17f Large set of changes to migrate sb_out and sb_err to wcstring 2012-02-22 10:51:06 -08:00
ridiculousfish
d975187433 Removed some al_list functions 2012-02-10 01:37:30 -08:00
Siteshwar Vashisht
bc8a288386 Got rid of multiple cd paths, only current directory will be searched while changing directories, implicit cd (entering directory just by typing it's name) is removed. 2012-02-09 01:18:51 +05:30
ridiculousfish
191eeab589 Cleanup expand_escape_variable 2012-02-08 00:15:06 -08:00
ridiculousfish
3f8621e566 CLeanup the io_stack in builtin.cpp, other changes to migrate away from al_list 2012-02-07 23:53:34 -08:00
ridiculousfish
a0a43046b3 Removed discriminated union from block_t type, allowing us to store wcstrings in it 2012-02-07 17:36:54 -08:00
ridiculousfish
fb63c3908c Minor cleanup of background_highlight_context_t 2012-02-03 18:39:41 -08:00
ridiculousfish
fa796d668f Get some basic function signatures right for new instanced parser 2012-01-16 12:10:08 -08:00
Peter Ammon
f3e2d2f68f Lots of warnings fixes and const correctness 2012-01-14 03:41:50 -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
Siteshwar Vashisht
7b3377e78c Modified builtin_set.cpp to use env_get(), added functions like update_values2(), env_set2() etc. to support wcstring and vector instead of using array_list_t 2012-01-10 01:19:37 +05:30
ridiculousfish
8d2f107d61 Some changes to migrate towards C++ and a multithreaded model 2011-12-26 19:18:46 -08:00
ridiculousfish
3f16ace678 Initial C++ conversion 2011-12-26 19:11:54 -08:00