This reverts commit cdce8511a1.
This change was unsafe. The prior version (now restored) took the lock and
then copied the data. By returning a reference, the caller holds a
reference to data outside of the lock.
This function isn't worth optimizing. Hardly any functions use this
facility, and for those that do, they typically just capture one or two
variables.
* Convert `function_get_inherit_vars()` to return a reference to the
(possibly) existing map, rather than a copy;
* Preallocate and reuse a static (read-only) map for the (very) common
case of no inherited vars;
* Pass references to the inherit vars map around thereafter, never
triggering the map copy (or even move) constructor.
NB: If it turns out the reference is unsafe, we can switch the inherit vars
to be a shared_ptr and return that instead.
Universal newlines behaves differently between Python 2.7 and 3.x,
leading to problems when running Sphinx with Python 2.7.
fish_indent always uses \n, so there's no need to use universal newline
detection.
This also allows full UTF-8 in documentation sources.
Closes#5808.
I did not realize builtins could safely call into the parser and inject
jobs during execution. This is much cleaner than hacking around the
required shape of a plain_statement.
* Honour `dirprev` scope
Honour the scope of the `dirprev` variable if it is universal
and avoid to shadow it with a global. This enables to share
the `cd` history between sessions.
* Honor dirnext and __fish_cd_direction scope
If these variables exist in the universal scope, do not shadow them
- fix the carat position expanding e.g. `command $,`
- improve the error reporting for not-allowed command subtitutions
by figuring out where the expansion failed instead of using
SOURCE_LOCATION_UNKNOWN
- allow nullptr for parse_util_licate_brackets_range() out_string
argument if we don't need it to do any work.
Fixes#5812
`eval` has always been implemented as a function, which was always a bit
of a hack that caused some issues such as triggering the creation of a
new scope. This turns `eval` into a decorator.
The scoping issues with eval prevented it from being usable to actually
implement other shell components in fish script, such as the problems
described in #4442, which should now no longer be the case.
Closes#4443.
While `eval` is still a function, this paves the way for changing that
in the future, and lets the proc/exec functions detect when an eval is
used to allow/disallow certain behaviors and optimizations.
This adds an option --print-rusage-self to the fish executable. When set,
this option prints some getrusage stats to the console in a human-readable
way. This will be used by upcoming benchmarking support.
Followup to 394623b.
Doing it in the parser meant only top-level jobs would be reaped after
being `disown`ed, as subjobs aren't directly handled by the parser.
This is also much cleaner, as now job removal is centralized in
`process_clean_after_marking()`.
Closes#5803.
This prevents the `disown` builtin from directly removing jobs out of
the jobs list to prevent sanity issues, as `disown` may be called within
the context of a subjob (e.g. in a function or block) in which case the
parent job might not yet be done with the reference to the child job.
Instead, a flag is set and the parser removes the job from the list only
after the entire execution chain has completed.
Closes#5720.
This lets non-developers simply `cd` into the fish source directory and
execute `make` to build the project. The Makefile searches for CMake and
hands over the build to it if it is available, otherwise an error
message is emitted. All dependency checking is left to CMake.
Non-fish-devs shouldn't have to concern themselves with what build
system fish developers have chosen, and building a random C++ project
should not be a chore in familiarizing one's self with all the various
build platforms out there.
CMake is instructed to use `ninja` if it is available, otherwise the
standard Unix Makefiles generator option is used.
(This has already been the behavior on BSDs since CMake was adopted.)