aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_config_interactive.fish
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-05-08 15:57:56 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-05-14 20:38:32 -0700
commit51468b764689e7d724a87e6c2b8cdb4e599a3604 (patch)
tree75fe13dbad791e0d143a3610bfe7ed7d0136ad38 /share/functions/__fish_config_interactive.fish
parentff1d651415a2752e82ec417294f9bdf8c234c10f (diff)
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
Diffstat (limited to 'share/functions/__fish_config_interactive.fish')
-rw-r--r--share/functions/__fish_config_interactive.fish18
1 files changed, 5 insertions, 13 deletions
diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish
index 7b306e3d..ec891ddd 100644
--- a/share/functions/__fish_config_interactive.fish
+++ b/share/functions/__fish_config_interactive.fish
@@ -4,9 +4,7 @@
# This function is called by the __fish_on_interactive function, which is defined in config.fish.
#
function __fish_config_interactive -d "Initializations that should be performed when entering interactive mode"
-
-
- # Make sure this function is only run once
+ # Make sure this function is only run once.
if set -q __fish_config_interactive_done
return
end
@@ -27,7 +25,6 @@ function __fish_config_interactive -d "Initializations that should be performed
#
# If we are starting up for the first time, set various defaults
#
-
if not set -q __fish_init_1_50_0
if not set -q fish_greeting
set -l line1 (printf (_ 'Welcome to fish, the friendly interactive shell') )
@@ -97,25 +94,22 @@ function __fish_config_interactive -d "Initializations that should be performed
#
# Directory history colors
#
-
set -q fish_color_history_current
or set -U fish_color_history_current cyan
end
#
- # Generate man page completions if not present
+ # Generate man page completions if not present.
#
-
if not test -d $userdatadir/fish/generated_completions
#fish_update_completions is a function, so it can not be directly run in background.
eval "$__fish_bin_dir/fish -c 'fish_update_completions > /dev/null ^/dev/null' &"
end
#
- # Print a greeting
- # fish_greeting can be a function (preferred) or a variable
+ # Print a greeting.
+ # fish_greeting can be a function (preferred) or a variable.
#
-
if functions -q fish_greeting
fish_greeting
else
@@ -130,7 +124,6 @@ function __fish_config_interactive -d "Initializations that should be performed
# fish_color_cwd changes value. Like all event handlers, it can't be
# autoloaded.
#
-
function __fish_repaint --on-variable fish_color_cwd --description "Event handler, repaints the prompt when fish_color_cwd changes"
if status --is-interactive
set -e __fish_prompt_cwd
@@ -149,7 +142,6 @@ function __fish_config_interactive -d "Initializations that should be performed
# Completions for SysV startup scripts. These aren't bound to any
# specific command, so they can't be autoloaded.
#
-
complete -x -p "/etc/init.d/*" -a start --description 'Start service'
complete -x -p "/etc/init.d/*" -a stop --description 'Stop service'
complete -x -p "/etc/init.d/*" -a status --description 'Print service status'
@@ -293,7 +285,7 @@ function __fish_config_interactive -d "Initializations that should be performed
# Don't allow setting color other than what linux offers (see #2001)
functions -e set_color
- function set_color
+ function set_color --shadow-builtin
set -l term_colors black red green yellow blue magenta cyan white normal
for a in $argv
if not contains -- $a $term_colors