ReimuNotMoe / ydotool

Generic command-line automation tool (no X!)
GNU Affero General Public License v3.0
1.52k stars 81 forks source link

Implicit Enter Press When Reading From File #256

Open g-h-97 opened 2 weeks ago

g-h-97 commented 2 weeks ago

Hello,

I have noticed that ydotool always adds an implicit \n at the end when reading from a file using -f flag. For example, let's say I have a file with the following

cd /home/user/
ls
rm file.txt

I would assume that ydotool will type and execute the first and second commands (cd and ls) but only type the last one (rm) and I should press the final enter to execute it. However, this is not the case and ydotool behaves as if the file is like this (with a trailing new line after the rm

cd /home/user/
ls
rm file.txt

Another point worth mentioning is that passing the text I want to type via CLI does not show the same behavior, as in, new lines are types only if they're explicitly there,

Regards,

g-h-97 commented 2 weeks ago

I also want to mention that the below command works correctly but unfortunately it completely omits newlines, so it cannot be used for multiline files,

echo -n "ls" | ydotool type -f - && sleep 5

Edit: The sleep 5 is to observer ydotool behavior and not confuse it with program exit,