Skip to content

funced dosn't like backslash escapes in function names #8289

@IsaacOscar

Description

@IsaacOscar

I'm probably abusing fish here,
but funced dosn't work if I have a function name with a \ escape in it.

E.g.

function \\
   status function
end
\\ # prints '\' as expected
funcsave \\ # creates a file `~/.config/fish/functions/\.fish`
functions \\ # prints the function definition
funced \\ # opens vim in a new blank file called "/tmp/fish.MeJ0Vw/.fish"

But funced \\ breaks, it opens a new blank vim window, the status bar says "/tmp/fish.MeJ0Vw/.fish [New]", and then saving this files gives an error:

Editor exited but the function was not modified
rmdir: failed to remove '/tmp/fish.MeJ0Vw': Directory not empty

Wierder things happen with other escape sequences:

$ funced \'  #  funced \"  is similar
/usr/share/fish/functions/funced.fish (line 1): Unexpected end of string, quotes are not balanced
vim /tmp/fish.Yef3x9/'.fish
    ^
in function 'funced' with arguments '\''

Editing failed or was cancelled

funced \n for some reason opens vim with "/tmp/fish.GLuG8w/" is a directory:

" ============================================================================
" Netrw Directory Listing                                        (netrw v170)
"   /tmp/fish.GLuG8w
"   Sorted by      name
"   Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
"   Quick Help: <F1>:help  -:go up dir  D:delete  R:rename  s:sort-by  x:special
" ==============================================================================
../                                                                                                                                  
./
.fish

Closing vim then gives:

 .fish: command not found                      
/usr/share/fish/functions/funced.fish (line 2): 
.fish
^
in function 'funced' with arguments '\n'
Editing failed or was cancelled

Using \r, \t, or \v behaves similarly.
Also \x00 dosn't work, but that makes sense as you can't have a filename with that in it.
Otherwise, funced seems to work on other \ escape sequences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that's not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions