Commit Graph

281 Commits

Author SHA1 Message Date
Kurtis Rader
51468b7646 add function --shadow-builtin flag
It's currently too easy for someone to bork their shell by doing something
like `function test; return 0; end`. That's obviously a silly, contrived,
example but the point is that novice users who learn about functions are
prone to do something like that without realizing it will bork the shell. Even
expert users who know about the `test` builtin might forget that, say, `pwd`
is a builtin.

This change adds a `--shadow-builtin` flag that must be specified to
indicate you know what you're doing.

Fixes #3000
2016-05-14 20:38:32 -07:00
Kurtis Rader
ff1d651415 rename get_is_interactive and remove stupid test
I'm doing this as part of fixing issue #2980. The code for managing tty modes
and job control is a horrible mess. This is a very tiny step towards improving
the situation.
2016-05-14 20:35:54 -07:00
Kurtis Rader
b055b8440c enhance the key_reader program
The original `key_reader` program was useful but didn't do much that `xxd`
or `od -tx1z` didn't do. Furthermore, it wasn't built and installed by
default. This change adds features that make it superior to those programs
for decoding interactive key presses and makes it a first-class citizen
like the `fish_indent` program that is always available.

Fixes #2991
2016-05-10 14:11:30 -07:00
Kurtis Rader
14d7b1a0fa restyle the key_reader source 2016-05-10 14:11:30 -07:00
Kurtis Rader
bc6cc4c105 fix fork debug printf() calls
The fork (create new process) related debugging messages rely on an
undocumented env var and use `printf()` rather than `debug()`. There are
also errors in how the fork count is tracked that this fixes.

Fixes #2995
2016-05-05 20:22:20 -07:00
Kurtis Rader
4481692037 lint: low hanging fruit in history.cpp 2016-05-05 15:09:31 -07:00
Kurtis Rader
1cdf386822 lint: screen.cpp low hanging fruit
The remaining lint work to be done on screen.cpp will require refactoring
several functions that are way too large and complex.
2016-05-04 18:14:04 -07:00
Kurtis Rader
79f342b954 lint cleanup: eliminate "redundant" errors
This removes some pointless parentheses but the primary focus is removing
redundancies like unnecessary "else" clauses.
2016-05-04 15:32:04 -07:00
Kurtis Rader
42068931c7 eliminate "useless parentheses" lint errors
Some `oclint` errors regarding "useless parentheses" are meaningfull. But
the vast majority are bogus in as much as removing the parentheses reduces
readability. So fix a few of the egregious uses and otherwise suppress
that error.
2016-05-03 21:31:32 -07:00
Kurtis Rader
3ad5c7c289 add missing fallback declarations
Fixes #2993
2016-05-03 19:15:27 -07:00
Kurtis Rader
fc44cffac5 restyle switch blocks to match project style
I missed restyling a few "switch" blocks to make them consistent with the rest
of the code base. This fixes that oversight. This should be the final step in
restyling the C++ code to have a consistent style. This also includes a few
trivial cleanups elsewhere.

I also missed restyling the "complete" module when working my way from a to z
so this final change includes restyling that module.

Total lint errors decreased 36%. Cppcheck errors went from 47 to 24. Oclint P2
errors went from 819 to 778. Oclint P3 errors went from 3252 to 1842.

Resolves #2902.
2016-05-03 17:14:56 -07:00
Kurtis Rader
5c8763be0e restyle remaining modules to match project style
For this change I decided to bundle the remaining modules that need to be
resytyled because only two were large enough to warrant doing on their own.

Reduces lint errors from 225 to 162 (-28%). Line count from 3073 to 2465 (-20%).

Another step in resolving issue #2902.
2016-05-03 16:09:45 -07:00
Kurtis Rader
ee44879d4d restyle utf8 module to match project style
Reduces lint errors from 63 to 57 (-10%). Line count from 518 to 418 (-19%).

Another step in resolving issue #2902.
2016-05-03 15:12:19 -07:00
Kurtis Rader
c14bac4284 restyle tokenizer module to match project style
Reduces lint errors from 70 to 46 (-34%). Line count from 1158 to 936 (-19%).

Another step in resolving issue #2902.
2016-05-03 15:00:44 -07:00
Kurtis Rader
0aa7fd95b8 restyle signal module to match project style
Reduces lint errors from 15 to 15 (-0%). Line count from 754 to 438 (-42%).

Another step in resolving issue #2902.
2016-05-03 13:06:45 -07:00
Kurtis Rader
fa53563733 restyle sanity & screen module to match project style
Reduces lint errors from 163 to 112 (-31%). Line count from 1866 to 1493 (-20%).

Another step in resolving issue #2902.
2016-05-03 12:53:54 -07:00
Kurtis Rader
835176ef32 restyle reader module to match project style
Reduces lint errors from 338 to 205 (-39%). Line count from 4650 to 3654 (-21%).

Another step in resolving issue #2902.
2016-05-03 12:14:41 -07:00
Kurtis Rader
c76d866317 Suppress another pointless IWYU warning 2016-05-02 22:20:53 -07:00
Kurtis Rader
9d742a4fa1 restyle proc module to match project style
Reduces lint errors from 134 to 101 (-25%). Line count from 1994 to 1466 (-26%).

Another step in resolving issue #2902.
2016-05-02 22:07:58 -07:00
Kurtis Rader
dc8d31a12a restyle postfork module to match project style
Reduces lint errors from 37 to 20 (-46%). Line count from 670 to 566 (-15%).

Another step in resolving issue #2902.
2016-05-02 21:34:26 -07:00
Kurtis Rader
8d6b88eb5d restyle path module to match project style
Reduces lint errors from 30 to 21 (-30%). Line count from 597 to 481 (-19%).

Another step in resolving issue #2902.
2016-05-02 21:23:33 -07:00
Kurtis Rader
80250c0729 restyle parser module to match project style
Reduces lint errors from 72 to 44 (-43%). Line count from 1698 to 1313 (-23%).

Another step in resolving issue #2902.
2016-05-02 19:24:52 -07:00
Kurtis Rader
ca912f157e restyle parse_util module to match project style
Reduces lint errors from 187 to 91 (-51%). Line count from 1754 to 1477 (-16%).

Another step in resolving issue #2902.
2016-05-02 17:11:02 -07:00
Kurtis Rader
716706bd9f restyle parse_tree module to match project style
Reduces lint errors from 163 to 52 (-68%). Line count from 2012 to 1904 (-5%).

Another step in resolving issue #2902.
2016-05-02 16:44:27 -07:00
Kurtis Rader
61a614b612 restyle parse_productions module to match project style
Reduces lint errors from 33 to 9 (-73%). Line count from 551 to 534 (-3%).

Another step in resolving issue #2902.
2016-05-02 16:03:37 -07:00
Kurtis Rader
ea945cc437 restyle parse_execution module to match project style
Reduces lint errors from 184 to 84 (-54%). Line count from 2139 to 1943 (-9%).

Another step in resolving issue #2902.
2016-05-02 13:00:03 -07:00
Kurtis Rader
13d7432368 restyle pager & lru module to match project style
Reduces lint errors from 65 to 25 (-63%). Line count from 1439 to 1218 (-15%).

Another step in resolving issue #2902.
2016-05-02 12:11:57 -07:00
Kurtis Rader
ed8d1040ba restyle output module to match project style
Reduces lint errors from 34 to 31 (-9%). Line count from 712 to 535 (-25%).

Another step in resolving issue #2902.
2016-05-01 22:36:29 -07:00
Kurtis Rader
4f619c966b restyle kill module to match project style
Reduces lint errors from 10 to 9 (-10%). Line count from 242 to 175 (-28%).

Another step in resolving issue #2902.
2016-05-01 22:18:59 -07:00
Kurtis Rader
483b798863 restyle iothread module to match project style
Reduces lint errors from 41 to 26 (-37%). Line count from 444 to 423 (-5%).

Another step in resolving issue #2902.
2016-05-01 21:54:54 -07:00
Kurtis Rader
b19bfc0dd3 restyle io module to match project style
Reduces lint errors from 15 to 10 (-33%). Line count from 637 to 489 (-23%).

Another step in resolving issue #2902.
2016-05-01 20:38:19 -07:00
Kurtis Rader
8b2cf81f17 restyle intern module to match project style
Reduces lint errors from 8 to 6 (-25%). Line count from 112 to 83 (-26%).

Another step in resolving issue #2902.
2016-05-01 20:28:46 -07:00
Kurtis Rader
da17420cdf restyle input_common module to match project style
Reduces lint errors from 27 to 24 (-11%). Line count from 466 to 378 (-19%).

Another step in resolving issue #2902.
2016-05-01 20:02:16 -07:00
Kurtis Rader
45c6ac0208 restyle input module to match project style
Reduces lint errors from 69 to 48 (-30%). Line count from 1270 to 1044 (-18%).

Another step in resolving issue #2902.
2016-04-30 21:46:56 -07:00
Kurtis Rader
7378871768 restyle highlight module to match project style
Reduces lint errors from 176 to 69 (-61%). Line count from 1627 to 1426 (-12%).

Another step in resolving issue #2902.
2016-04-30 21:10:23 -07:00
Kurtis Rader
d3f155d895 restyle function module to match project style
Reduces lint errors from 39 to 27 (-31%). Line count from 619 to 498 (-20%).

Another step in resolving issue #2902.
2016-04-30 20:37:46 -07:00
Kurtis Rader
075811e588 restyle fish modules to match project style
Reduces lint errors from 60 to 60 (-0%). Line count from 5599 to 4925 (-12%).

Another step in resolving issue #2902.
2016-04-30 19:52:13 -07:00
Kurtis Rader
aa8840b423 restyle fallback module to match project style
Reduces lint errors from 36 to 33 (-8%). Line count from 1910 to 1476 (-23%).

Another step in resolving issue #2902.

This also fixes a stupid mistake from an earlier commit where I didn't realize
that osx/config.h was meant to be included as a semi-static file in the
repository.
2016-04-30 18:20:18 -07:00
ridiculousfish
58d7c4b388 Remove use of __environ
It has apparently never worked. Fixes #2988
2016-04-30 17:46:14 -07:00
ridiculousfish
bd2b107d37 Remove some unused macros from builtin_set_color.cpp 2016-04-29 14:54:21 -07:00
ridiculousfish
74d3aa582b Issue a \r in fish_title, except when executing it for the prompt
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
2016-04-29 12:14:10 -07:00
Kurtis Rader
ffad7b0b29 restyle expand module to match project style
Reduces lint errors from 183 to 126 (-31%). Line count from 2231 to 1787 (-20%).

Another step in resolving issue #2902.
2016-04-28 20:33:27 -07:00
Kurtis Rader
d93bbfd486 restyle exec module to match project style
Reduces lint errors from 121 to 59 (-51%). Line count from 1578 to 1290 (-18%).

Another step in resolving issue #2902.
2016-04-28 20:07:00 -07:00
Kurtis Rader
32c241f51b retyle event module to match project style
Reduces lint errors from 39 to 30 (-23%). Line count from 915 to 670 (-27%).

Another step in resolving issue #2902.
2016-04-28 19:39:41 -07:00
Kurtis Rader
690ceeeaa7 restyle env_universal module to match project style
Reduces lint errors from 121 to 52 (-57%). Line count from 1916 to 1671 (-13%).

Another step in resolving issue #2902.
2016-04-28 19:17:28 -07:00
Kurtis Rader
ea02da35d4 restyle env module to match project style
Reduces lint errors from 90 to 72 (-20%). Line count from 1719 to 1298 (-24%).

Another step in resolving issue #2902.
2016-04-28 18:48:01 -07:00
Kurtis Rader
6c329e8a83 provide a realpath implementation
Not all distros have a `realpath` command. Provide a function that uses the
real command if available else use the fish builtin.

Fixes #2932
2016-04-28 16:03:27 -07:00
Kurtis Rader
e08039a2bd restyle common module to match project style
Reduces lint errors from 194 to 142 (-27%). Line count from 3352 to 2645 (-21%).

Another step in resolving issue #2902.
2016-04-27 17:08:25 -07:00
Kurtis Rader
108d66211f restyle color module to match project style
Reduces lint errors from 16 to 14 (-13%). Line count from 558 to 463 (-17%).

Another step in resolving issue #2902.
2016-04-27 16:06:03 -07:00
Kurtis Rader
87d5fa054d compile fallback.cpp and util.cpp seperately
Don't `#include "*.cpp"` modules in other cpp modules. I already took care
of all the builtin_*.cpp modules in my previous change where I restyled
the builtin code. This change fixes the two remaining instances of this
anti-pattern.
2016-04-27 14:56:46 -07:00