Imagine I have a script foo
. It should be run once when the user logs in and isn't needed after a successful run.
My question: Is it safe to remove the script file from within the script?
E.g.:
#!/bin/bash
# do something
...
# if successful
rm /path/to/foo
exit 0
#!/bin/bash -e
to ensure that the script file is removed only if nothing goes wrong.exec rm /path/to/foo
.