The default behaviour of the GNU rm command when asked to delete write-protected files is to interactively ask whether the user wants to delete each of the files. This is quite inconvenient in many situations.
A crude general way to supply an interactive command invocation with no meaningful input is to use a here-string. I expected that in this case,
touch wpf && chmod -w wpf rm wpf <<< "" would result in the command being aborted, i.e. the file still being there afterwards, much like when I try rm wpf and just hit enter or ctrl+d upon the prompt.
To my surprise however, it actually results in the file being deleted.
(Ubuntu 18.04, GNU Bash 4.4.20, coreutils 8.28)
What's going on here, and does it also have ramifications for similar situations?
echo "" | rm filewill also delete it. Looks likermdetects whether its input is linked to a terminal or not.