I have created a script of a recycle bin on minix. I move a file that will deleted to a folder instead of deleting it. I have used the alias command on rm command to use the script instead of rm. The problem now is that I have to empty the recycle bin. I wrote this script:
#!/bin/sh
unalias rm
rm -r "/home/recyclebin/*"
alias rm='/home/scriptrm.sh'
#
In this script I unalias rm command so I can use it again then I empty the recycle bin and then alias rm again with the script that moves files to recycle bin. When I run this script it does nothing. I tried only running the script to unalias rm but rm continues with the alias. Does anyone know what's happening?
Thank you.
A couple things to fix.
You’re (double-)quoting your glob (*
), so it won’t actually expand to anything (except if you have a file actually named *
there).
Your script is going to run in a sub-process, so setting/resetting aliases and such will not have any effect in the parent shell that invokes your script. IOW, you don’t need to alias it back to an original form at the end. And it won’t inherit your existing parent shell’s aliases. They’re not exported from the parent.