This runs build_tools/style.fish, which runs clang-format on C++, fish_indent on fish and (new) black on python.
If anything is wrong with the formatting, we should fix the tools, but automated formatting is worth it.
For some reason on Solaris the previous code was refusing to compile
with an error (regarding the declaration of stdout in the opts struct)
error: declaration of ‘__iob’ as array of references
The obvious guess that it had something to do with the name of the
variable in question proved true; renaming it from `stdout` to
`opts.stdout` allows the build to go through.
It seems that `parse_cmd_opts` does not correctly handle no arguments,
and so argc was being decremented to -1 causing uninitialized memory
access when argv[0] was dereferenced at a later point.
No longer using `-` to indicate reading to stdout. Use lack of arguments
as stdout indicator. This prevents mixing of variables with stdout
reading and makes it clear that stdout may not be mixed with delimiters
or array mode.
Added an option to read to stdout via `read -`. While it may seem
useless at first blush, it lets you do things like include
mysql -p(read --silent) ...
Without needing to save to a local variable and then echo it back.
Kicks in when `-` is provided as the variable name to read to. This is
in keeping with the de facto syntax for reading/writing from/to
stdin/stdout instead of a file in, e.g., tar, cat, and other standard
unix utilities.
This eliminates the "missing" notion of env_var_t. Instead
env_get returns a maybe_t<env_var_t>, which forces callers to
handle the possibility that the variable is missing.
Internally fish should store vars as a vector of elements. The current
flat string representation is a holdover from when the code was written
in C.
Fixes#4200
It's bugged me forever that the scope is the second arg to `env_get()`
but not `env_set()`. And since I'll be introducing some helper functions
that wrap `env_set()` now is a good time to change the order of its
arguments.
My previous change to eliminate `class var_entry_t` caused me to notice
that `env_get()` turned a set but empty var into a missing var. Which
is wrong. Fixing that brought to light several other pieces of code that
were wrong as a consequence of the aforementioned bug.
Another step to fixing issue #4200.
This is the first step to implementing issue #4200 is to stop subclassing
env_var_t from wcstring. Not too surprisingly doing this identified
several places that were incorrectly treating env_var_t and wcstring as
interchangeable types. I'm not talking about those places that passed
an env_var_t instance to a function that takes a wcstring. I'm talking
about doing things like assigning the former to the latter type, relying
on the implicit conversion, and thus losing information.
We also rename `env_get_string()` to `env_get()` for symmetry with
`env_set()` and to make it clear the function does not return a string.
This takes a string that is then split upon like `string split`.
Unlike $IFS, the string is used as one piece, not a set of characters.
There is still a fallback to IFS if no delimiter is given, that
behaves exactly as before.
Fixes#4156.
The `read` command `-m` and `--mode-name` vars are now deprecated and do
nothing other than result in a warning message. The `read` command now
honors the `FISH_HISTORY` var that is used to control where commands are
read from and written to. You can set that var to the empty string to
suppress the use of both history files. Or you can set it to a history
session ID in which case that will limit the `read` history that is
available.
Fixes#1504
Running the tests on travis revealed that some compilers (or at least
with some options) call the wrong struct constructor if there is more
than one struct with the same name but differing definitions.