-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
fish, version 4.0.2
Linux (Debian 12)
Wezterm
Replicated without 3rd-p customizations
Calling a function (hereon referred as x) which contains function -c "y" "z" on a function that was previously saved to disk (y) results in the first-line comment looking like this:
#Defined in /path/to/"y".fish, copied in /path/to/"x".fishThen, calling functions --details "z" incorrectly produces the path of the copying function (/path/to/"x".fish).
This is frustrating given attempting to funced "z" when $EDITOR is set results in the editor opening a tmp file named z (/tmp/fish.0YCzII/z.fish), but with the contents of x.
This happens because of line 75 in funced.fish:
75 else if functions --details -- $funcname | string match --invert --quiet --regex '^(?:-|stdin)$'In case this might be easier to follow, here's a copy of a buffer showcasing what leads to this behavior:
Rise and Shine, Mr. Freeman…
N /m/e/L/S/testing
❱ functions dt-exif2iso
# Defined in /home/g-unix/.config/fish/functions/dt-exif2iso.fish @ line 1
function dt-exif2iso
perl -pe 's/(\d{4}):(\d{2}):(\d{2})[T\s](.+)/$1-$2-$3 $4/gm;' $argv
end
N /m/e/L/S/testing
❱ functions -c dt-exif2iso test_function_copy
N /m/e/L/S/testing
❱ functions test_function_copy
# Defined in /home/g-unix/.config/fish/functions/dt-exif2iso.fish @ line 1, copied interactively
function test_function_copy
perl -pe 's/(\d{4}):(\d{2}):(\d{2})[T\s](.+)/$1-$2-$3 $4/gm;' $argv
end
N /m/e/L/S/testing
❱ funced test_function_copy <<< THIS WORKED AS EXPECTED
Editor exited but the function was not modified
If the editor is still running, check if it waits for completion, maybe a '--wait' option?
N /m/e/L/S/testing 2.3s
❱ functions functions-rename
# Defined in /home/g-unix/.config/fish/functions/functions-rename.fish @ line 1
function functions-rename --wraps=functions --description 'rename function'
set -f old $argv[1]
set -f new $argv[2]
test $old = $new; and return
functions -c $old $new
functions -e $old
# dont write unsaved functions
set -f saved $HOME/.config/fish/functions/$old.fish
if test -f $saved
funcsave $new
rm $saved
end
end
N /m/e/L/S/testing
❱ functions-rename test_function_copy test_renamed_function_copy
N /m/e/L/S/testing
❱ functions test_renamed_function_copy
# Defined in /home/g-unix/.config/fish/functions/dt-exif2iso.fish @ line 1, copied in /home/g-unix/.config/fish/functions/functions-rename.fish @ line 6
function test_renamed_function_copy
perl -pe 's/(\d{4}):(\d{2}):(\d{2})[T\s](.+)/$1-$2-$3 $4/gm;' $argv
end
N /m/e/L/S/testing
❱ funced test_renamed_function_copy <<<< THIS OPENED THE CONTENTS OF functions-rename IN '/tmp/fish.0YCzII/test_renamed_function_copy.fish'
Editor exited but the function was not modified
If the editor is still running, check if it waits for completion, maybe a '--wait' option?
N /m/e/L/S/testing 39.8s
❱ functions --details test_renamed_function_copy #| string match --invert --quiet --regex '^(?:-|stdin)$'
/home/g-unix/.config/fish/functions/functions-rename.fishThis issue doesnt occur when using funced -i "z".
Apologies if the description is hard to follow.