Closed sweetbbak closed 1 year ago
I dont follow how this is an issue with the kitten? If you pass it paths with newlines at the end, then it will use them, it is not going to second guess the intentions of its invoker.
I don't know where the newline character is coming from, it shouldn't be there at all. There is no way to remove it. If something I was doing was somehow adding a newline character to the end of the string, then I would suspect that it should be able to be removed using sed 's/\n//g' and tr -d '\n' or bash expansion, but it can't.
Here you go
mapfile array < <(find . -type f -iname '*.png')
image=$(printf "%s" "${array[0]}")
kitten icat --scale-up --place 33x33@0x0 "$image"
I suggest you learn a bit more about BASH scripting, or better use a nicer script language Just FYI, you have python available everywhere you have kitty available, with kitty +runpy and kitty +launch.
I probably should just use a better language because its frustrating that this works perfectly well in a vacuum but when I substitute it into my script that is reading the image paths from a pipe like "find . -type f -iname '*.png' | ./myscript | xargs echo " it no longer behaves as expected.
Thank you for your time.
The bug
I'm getting these few errors when using kitty +kitten icat inside of a bash script that say that it cant decode the image, find the path of the image, or cannot use place with "2 images."
Despite these errors, there is only one path. The path is also valid. I think it is reading some kind of character at the end of the string as a separate path, but no matter what I try I haven't been able to fix this issue. It will spit out an error and refuse to show the image, but manually copying the path and using icat works perfectly fine.
/home/sweet/ssd/gallery-dl/twitter/ukasanagi_/1554343762834231296_1.jpg Error: The --place option can only be used with a single image, not 2 Manually copying the path, works however and the image is show without any issue.
/home/sweet/ssd/gallery-dl/twitter/ukasanagi_/15979832952294821.jpg Error: Stat /home/sweet/ssd/gallery-dl/twitter/ukasanagi/15979832952294821.jpg: stat /home/sweet/ssd/gallery-dl/twitter/ukasanagi/1597983295229482_1.jpg: no such file or directory
The Output of running the same string through "od -c" in the same script /home/sweet/ssd/gallery-dl/twitter/ukasanagi_/1653346451647528961_1.jpg
0000000 / h o m e / s w e e t / s s d / 0000020 g a l l e r y - d l / t w i t t 0000040 e r / u k a s a n a g i / 1 6 0000060 5 3 3 4 6 4 5 1 6 4 7 5 2 8 9 6 0000100 1 1 . j p g \n 0000110 Error: The --place option can only be used with a single image, not 2
You may note the '\n' character at the end of the string there
To Reproduce Steps to reproduce the behavior: run: bash -c 'mapfile array < <(find ~ -type f ( -iname *.jpg -o -iname *.png -iname *.gif ) ) && for x in "${array[@]}"; do kitty +kitten icat --scale-up --place 33x33@0x0 "${x}" ; sleep 1 ; done'
and run to see what the shell is "seeing" the string as: copy and pasting this will likely remove the backslashes around (iname ... .gif ) - they need to be there. bash -c 'mapfile array < <(find ~ -type f ( -iname *.jpg -o -iname *.png -iname \.gif ) ) && for x in "${array[@]}"; do echo "${x}" | od -c ; kitty +kitten icat --scale-up --place 33x33@0x0 "${x}" ; sleep 1 ; done'
this also happens with bash builtin readarray.
So far I've tried every suggested way to remove non-printable characters in a variety of different ways to see if this will fix the issue but it hasn't. The output of od -c had me convinced that removing the newline character would fix the issue but no matter what I try it doesn't work.
Environment details
Additional context Any help is appreciated, I think this might be some kind of encoding error, or an error from some obscure null/escape character being read as a path.