When trying to launch a command starting with a dash, the prompt is throwing multiple errors.
I know that's a strange use case to name a binary/script with a dash as the first letter, but still the theme should handle that.
Steps to reproduce:
Just type anything starting with a dash (e.g. --foo)
Error message:
$ --foo
--footype: Unknown option “--foo”
/usr/share/fish/functions/type.fish (line 7):
argparse -n type --min-args=1 -x t,p,P $options -- $argv
^
in function “type”
called on line 129 of file ~/.config/fish/functions/fish_prompt.fish
with parameter list “-q --foo”
in function “__budspencer_preexec”
called on standard input
typetype - indicate how a command would be interpreted
-
Synopsis
type [OPTIONS] NAME [NAME ...]
type: Type “help type” for related documentation
--foo: command not found
contains: Unknown option “--foo”
~/.config/fish/functions/fish_prompt.fish (line 279):
or contains $cmd $budspencer_nocmdhist
^
in function “__budspencer_create_cmd_hist”
called on standard input
in event handler: handler for generic event “fish_prompt”
containscontains - test if a word is present in a list
-
Synopsis
contains [OPTIONS] KEY [VALUES...]
contains: Type “help contains” for related documentation
contains: Unknown option “--foo”
~/.config/fish/functions/fish_prompt.fish (line 281):
if contains $cmd $$cmd_hist
^
in function “__budspencer_create_cmd_hist”
called on standard input
in event handler: handler for generic event “fish_prompt”
containscontains - test if a word is present in a list
-
Synopsis
contains [OPTIONS] KEY [VALUES...]
contains: Type “help contains” for related documentation
The fix is easy to do (just escape args from being interpreted as options):
diff --git a/fish_prompt.fish b/fish_prompt.fish
index 33d19a5..897f467 100755
--- a/fish_prompt.fish
+++ b/fish_prompt.fish
@@ -126,7 +126,7 @@ function __budspencer_preexec -d 'Execute after hitting <Enter> before doing any
return
end
set -e budspencer_prompt_error[1]
- if not type -q $cmd[1]
+ if not type -q -- $cmd[1]
if [ -d $cmd[1] ]
set budspencer_prompt_error (cd $cmd[1] 2>&1)
and commandline ''
@@ -276,9 +276,9 @@ function __budspencer_create_cmd_hist -e fish_prompt -d 'Create command history
# Create command history
if not begin
expr $cmd : '[cdms] ' > /dev/null
- or contains $cmd $budspencer_nocmdhist
+ or contains -- $cmd $budspencer_nocmdhist
end
- if contains $cmd $$cmd_hist
+ if contains -- $cmd $$cmd_hist
set -e $cmd_hist[1][(contains -i $cmd $$cmd_hist)]
end
set $cmd_hist $$cmd_hist $cmd
I can do the PR if need be, otherwise all needed information are above.
When trying to launch a command starting with a dash, the prompt is throwing multiple errors. I know that's a strange use case to name a binary/script with a dash as the first letter, but still the theme should handle that.
Steps to reproduce: Just type anything starting with a dash (e.g. --foo)
Error message:
The fix is easy to do (just escape args from being interpreted as options):
I can do the PR if need be, otherwise all needed information are above.