fix(plugins/copyfile): don't fail with empty filename

clipcopy interprets empty filename as stdin, but the current "error
handling" breaks its behavior.

This bug was introduced in ohmyzsh/ohmyzsh#13248.
This commit is contained in:
Nuri Jung 2025-09-19 21:14:34 +09:00
commit d47df7208a
No known key found for this signature in database
GPG key ID: D5BDFF67E90BACBE

View file

@ -4,16 +4,10 @@
function copyfile {
emulate -L zsh
if [[ -z "$1" ]]; then
clipcopy "${1-}" || {
echo "Usage: copyfile <file>"
return 1
fi
}
if [[ ! -f "$1" ]]; then
echo "Error: '$1' is not a valid file."
return 1
fi
clipcopy $1
echo ${(%):-"%B$1%b copied to clipboard."}
echo ${(%):-"%B${1:-/dev/stdin}%b copied to clipboard."}
}