aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
Commit message (Collapse)AuthorAge
* provide a realpath implementationGravatar Kurtis Rader2016-04-29
| | | | | | | | | Not all distros have a `realpath` command. Provide a function that uses the real command if available else use the fish builtin. Fixes #2932 (cherry picked from commit 6c329e8a839c1b5eeaf2e545b4f4084c3a8830f7)
* Issue a \r in fish_title, except when executing it for the promptGravatar ridiculousfish2016-04-29
| | | | | | | | | | | fish_title currently outputs some escaped text, which can confuse the line driver (#2453). Issue a carriage return so the line driver knows we are at the beginning of the line, unless we are writing the title as part of the prompt. In that case, we may have text from the previous command still on the line and we don't want to move the cursor. Fixes #2453
* Update usage of pcre2_substitute() for pcre2-10.21Gravatar Michael Steed2016-04-27
| | | | | | | | | - Set PCRE2_SUBSTITUTE_OVERFLOW_LENGTH to get the required buffer length from pcre2 instead of guessing - Set PCRE2_SUBSTITUTE_EXTENDED to enable extra goodies in the replacement string (cherry picked from commit c2f9d60eb1f04a3aa0b01d785c1e133cac8ecf1d)
* env_universal_common.cpp: pass correct flag to fcntlGravatar David Adam2016-04-27
| | | | Closes #2955.
* fix off by one errorGravatar Kurtis Rader2016-04-15
| | | | (cherry picked from commit ea3d9c36a52dcf6bcde0ff41af8ca19daca2267e)
* fish handling of readlink()Gravatar Kurtis Rader2016-04-15
| | | | | | | | | | | | | | The readlink() function does not null terminate the path it returns. Remove the OS X code that deals with a path buffer that is too short. For one thing a loop isn't needed since we're told how big of a buffer is required if the first _NSGetExecutablePath() call fails. But more important it is so unlikely that the path will be longer than PATH_MAX that if it is we should just give up. Fixes 2931. (cherry picked from commit 8e103c231e74a3dda40d0a0e5a844ea8b6aa1e4b)
* Fix #2919 by removing the entire block.Gravatar Aaron Gyes2016-04-09
| | | | | | | | | | | | | | This code represents only risk and does nothing useful for anything that can compile fish. In C++ situations where __STDC_VERSION__ is unset (as it should be), fish was assuming we are on < C99 and setting it to __FUNCTION__. Basically always, __PRETTY_FUNCTION__ ends up reaplaced by __FUNCTION__, this hurt error message usefulness and richness. __PRETTY_FUNCTION__: const thing::sub(int) __FUNCTION__: sub
* fix handling of line continuation in keywordsGravatar Jak Wings2016-04-08
| | | | | | | This behavior is more consistent with line continuation in strings other than keywords. Fixes #2897
* add missing special-case for ../Gravatar Kurtis Rader2016-04-08
| | | | | When I reviewed the fix for #952 I noted that "../" wasn't handled but in my haste to merge it forgot to augment the pull-request.
* Migrate PATH-completion logic from complete.cpp to expand.cppGravatar ridiculousfish2016-04-07
| | | | | | | | | | | | | | | | Prior to this fix, when completing a command that doesn't have a /, we would prepend each component of PATH and then expand the whole thing. So any special characters in the PATH would be interpreted when performing tab completion. With this fix, we pull the PATH resolution out of complete.cpp and migrate it to expand.cpp. This unifies nicely with the CDPATH resolution already in that file. This requires introducing a new expand flag EXPAND_SPECIAL_FOR_COMMAND, which is analogous to EXPAND_SPECIAL_CD (which is renamed to EXPAND_SPECIAL_FOR_CD). This flag tells expand to resolve paths against PATH instead of the working directory. Fixes #952
* Implement an --invert/-v for string match, like grep -v.Gravatar Aaron Gyes2016-04-08
| | | | Only lines that do not match the pattern are shown.
* Complain less about "bogus" PATH entriesGravatar ridiculousfish2016-04-07
| | | | | | When determining the old path, get the existing value in any scope, not just the set scope. Also only complain about absolute paths: relative paths are expected to be invalid sometimes.
* Remove a dead function bool_from_env_varGravatar ridiculousfish2016-04-07
|
* fix setting of $argv for `source` w/no argsGravatar Kurtis Rader2016-04-06
| | | | Fixes #139
* change how redirections are formattedGravatar Kurtis Rader2016-04-05
| | | | | | | | Modify `fish_indent` to emit redirections without a space before the target of the redirection; e.g., "2>&1" rather than "2>& 1" as the former is clearer to humans. Fixes #2899
* don't try to use st_gen (inode generation) numberGravatar Aaron Gyes2016-04-04
| | | | | | | | | Per discussion in pull-request #2891, it's not available on Linux (we just fill it with zero), and unless run as root on OS X (or other BSD system) it will be zero. Remove it from file_id_t. Also fix the initialization of the file_id_t structure. Fixes #2891
* remove unused special color "ignore"Gravatar Kurtis Rader2016-04-04
| | | | | | Resolve lint warning about unused method "rgb_color_t::ignore()". Fixes #2893
* fixes for cppcheck lint warningsGravatar Kurtis Rader2016-04-04
| | | | | | Refine the linting behavior. Fix several of the, mostly trivial, lint errors.
* convert atypical env_universal_common loggingGravatar Kurtis Rader2016-04-03
| | | | | | | | | | This is a quick and dirty conversion of the atypical, and undocumented, logging done by env_universal_common.cpp to the usual `debug()` pattern. I didn't want to drop the messages because they could be useful when debugging future issues. So I simply converted them to the lowest debug level using the normal debug() function. Fixes #2887
* lint: remove or comment out unused functionsGravatar Kurtis Rader2016-04-03
| | | | | | Cppcheck has identified a lot of unused functions. This removes funcs that are unlikely to ever be used. Others that might be useful for debugging I've commented out with "#if 0".
* remove unused wgetopt() method found by lintingGravatar Kurtis Rader2016-04-02
|
* Remove an unnecessary c_str()Gravatar ridiculousfish2016-03-27
|
* Fix memory leaks at exit found in testsGravatar Andreas Nordal2016-03-27
| | | | | | | | | | This fixes all memory leaks found by compiling with clang++ -g -fsanitize=address and running the tests. Method: Ensure that memory is freed by the destructor of its respective container, either by storing objects directly instead of by pointer, or implementing the required destructor.
* `fish --version` should write to stdoutGravatar Kurtis Rader2016-03-23
| | | | | | | | | When explicitly asking for the fish version string the information should go to stdout rather than stderr. Also, there is no reason to use exit_without_destructors() rather than exit() in that code path. We actually want the side-effects of exit() such as flushing stdout and there aren't any threads or other things that could cause a normal exit to fail when that function is run.
* Fix memory leak, error message when failing to open input fileGravatar Andreas Nordal2016-03-22
| | | | | | | | | | | | | The early return skipped all cleanup. This problem is a case for the classic "goto fail" paradigm, but this change instead makes a few adjustments to take advantage of a previously unused level of indentation to conditionally execute the success path. The error message now prints the filename instead of "open", which should be more idiomatic. Tip: This patch makes sense if viewed with `git show --ignore-space-change`.
* implement swap-selection-start-stop functionGravatar Federico Ferri2016-03-20
| | | | | | | | | The swap-selection-start-stop function goes to the other end of the highlighted text, the equivalent of `o' for vim visual mode. Add binding to the swap-selection-start-stop function, `o' when in visual mode. Document swap-selection-start-stop, begin-selection, end-selection, kill-selection.
* fix handling of non-ASCII chars in C localeGravatar Kurtis Rader2016-03-20
| | | | | | | | | | | | The relevant standards allow the mbtowc/mbrtowc functions to reject non-ASCII characters (i.e., chars with the high bit set) when the locale is C or POSIX. The BSD libraries (e.g., on OS X) don't do this but the GNU libraries (e.g., on Linux) do. Like most programs we need the C/POSIX locales to allow arbitrary bytes. So explicitly check if we're in a single-byte locale (which would also include ISO-8859 variants) and simply pass-thru the chars without encoding or decoding. Fixes #2802.
* env_universal_common: use uid_t in geteuid checksGravatar David Adam2016-03-18
| | | | | | | | | The u_int typedef fails to compile on all platforms (e.g. Windows). It is part of the code imported from tmux. Update it to the SUS-standard uid_t. Closes #2821.
* parse_execution.cpp: Remove line continuationsGravatar Andreas Nordal2016-03-17
| | | | My IDE (Kdevelop 4.7.3) didn't tackle them.
* Improve error handling around fchownGravatar Jeff Kowalski2016-03-12
| | | | | | | | | Address the feedback from the prior commit: - Change the sense of return value testing to match more common comparison idiom - Test result of fchmod as well as fchown - Change sense of return value testing around wrename as well - Include errno where possible in error message
* Handle return values from fchownGravatar Jeff Kowalski2016-03-12
| | | | | | | | | | | The function fchown is annotated with warn_unused_result. As formerly used in the code, it would emit a compiler warning ```warning: ignoring return value of ‘fchown’, declared with attribute warn_unused_result [-Wunused-result]``` This commit notes the return value and emits appropriate error/logging messages if the call fails, creating more traceable results and satisfying the compiler.
* assume getopt/getopt_long is availableGravatar Kurtis Rader2016-03-08
| | | | | | | | | | | There is no longer a good reason to detect whether or not getopt_long() is available. All UNIX implementations we're likely to run on have it. And if we ever find one that doesn't the right thing to do is not fallback to getopt() but to include the getopt_long() source in our package like we do with the pcre2 library. Since it's licensed under LGPL we can legally do so if it becomes necessary. This partially addresses issue #2790.
* expand_string should not return any results on errorGravatar ridiculousfish2016-03-05
| | | | Fixes #2796
* Save a few string allocations when importing environment variablesGravatar ridiculousfish2016-03-05
|
* Prefer the first, not last, of any env var duplicatesGravatar ridiculousfish2016-03-05
| | | | | If envp contains duplicate environment variables, use the first value, not the last value. Fixes #2784.
* A few fixes suggested by Coverity ScanGravatar ridiculousfish2016-03-03
|
* Tweak UTF8 decoding interfaceGravatar ridiculousfish2016-03-02
| | | | | | | | Previously, when decoding UTF-8, we would first run through the array to compute the correct size, then allocate a buffer of that size, then run through the array again to fill the buffer, and then copy it into a std::wstring. With this fix we can copy it into the string directly, reducing allocations and only requiring a single pass.
* reduce number of Unicode private-use charactersGravatar Kurtis Rader2016-02-28
| | | | | | | | | This narrows the range of Unicode codepoints fish reserves for its own use from U+E000 thru U+F8FE (6399 codepoints) to U+F600 thru U+F73F (320 codepoints). This is still not ideal since fish shouldn't be using any Unicode private-use codepoints but it's a step in the right direction. This partially addresses issue #2684.
* Eliminate narrow_string_rep_tGravatar ridiculousfish2016-02-28
| | | | | | | | | | This was used to cache a narrow string representation of commands, so that if certain system calls returned errors after fork, we could output error messages without allocating memory. But in practice these errors are very uncommon, as are commands that have wide characters. It is simpler to do a best-effort output of the wide string, instead of caching a narrow string unconditionally.
* Re-use the parse tree generated during error detection for executionGravatar ridiculousfish2016-02-28
| | | | | | | Prior to this fix, read_ni would use parse_util_detect_errors to lint the script to run, and then parser_t::eval() to execute it. Both functions would parse the script into a parse tree. This allows us to re-use the parse tree, improving perfomance.
* Allow parse_execution_context to take ownership of a parse treeGravatar ridiculousfish2016-02-28
| | | | | | Introduces a new template moved_ref which is like an rvalue reference. This allows passing around objects while being explicit that the receiver may acquire ownership. This will help reduce some allocations.
* Add missing #include guards in FISH_PAGER_HGravatar ridiculousfish2016-02-27
|
* Remove unused MESS_SIZE defineGravatar ridiculousfish2016-02-27
|
* Remove some unnecessary statics and a silly #define constGravatar ridiculousfish2016-02-27
|
* Mark a bunch of constructors as explicitGravatar ridiculousfish2016-02-27
| | | | This prevents undesired implicit conversions
* Make expand_argument_list a static functionGravatar ridiculousfish2016-02-27
| | | | It doesn't use any properties of parser_t
* Eliminate parser_t::show_errorsGravatar ridiculousfish2016-02-27
| | | | Errors are now unconditionally shown
* Eliminate parser_type_tGravatar ridiculousfish2016-02-27
| | | | It was never fully implemented and wasn't used for anything
* Allow -w option as short for --wraps in define_functionGravatar ridiculousfish2016-02-27
| | | | Fixes #2772
* Allow variable completion from just a $Gravatar ridiculousfish2016-02-27
| | | | | Previously there had to be some variable text, now you can tab complete from just a naked $.