3 ms·
All the comments here about how awful my script is were true! In Bash that didn't work on files with spaces or funky characters. But, I never noticed because i
by mmh0000 4y ago
All the comments here about how awful my script is were true!
In Bash that didn't work on files with spaces or funky characters. But, I never noticed because in Zsh, my primary shell, it works fine with all filenames.
Here's an updated one which incorperates the advice from several posts to also work in Bash:
function rm {
for file; do
mv -t ~/.local/share/Trash/files/ -- "${file}"
cat << FROG > ~/.local/share/Trash/info/"$(basename
"${file}")".trashinfo
[Trash Info]
Path=$(realpath "${file}")
DeletionDate=$(date "+%FT%T")
FROG
done
}
- LinuxBender 4y agoThis gets even more quirky in busybox/ash especially if using `rm -Rf some_dir`. I think the function needs a more distinct name to protect rm use cases and avoid having to prefix wth \rm. maybe something like "function trash"