2018-05-02 12:50:31 -06:00
|
|
|
#!/usr/bin/env bash
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-08-22 13:23:08 -06:00
|
|
|
if [ "$SandboxUtilsVersion" ]; then return 0; fi
|
|
|
|
readonly SandboxUtilsVersion="1.0"
|
2017-08-08 11:40:32 -06:00
|
|
|
|
|
|
|
SandboxWorkspacePath="/tmp/sandbox"
|
|
|
|
SandboxOutputDevice="/dev/stdout"
|
|
|
|
|
|
|
|
# After changing global identifiers in the main script,
|
|
|
|
# I forgot to update the identifiers here, leading to a
|
|
|
|
# horrific accident where the script ended and executed
|
|
|
|
# the command "rm -rf /*" ... yeah, fuck that...
|
|
|
|
# Spent an entire day retreiving all my shit back.
|
|
|
|
function sandbox_remove_workfile() {
|
2017-12-31 09:02:12 -07:00
|
|
|
# Check we've got the environment variables ready.
|
|
|
|
if [[ -z "$SandboxWorkspacePath" || -z "$SandboxOutputDevice" ]]; then
|
|
|
|
echo "The workspace path, or the output device is missing." >$SandboxOutputDevice
|
|
|
|
return 1
|
|
|
|
fi
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
# Check we're actually deleting a workfile.
|
|
|
|
if [[ "$1" != $SandboxWorkspacePath* ]]; then
|
|
|
|
echo "Stopped an attempt to delete non-workfiles." >$SandboxOutputDevice
|
|
|
|
return 2
|
|
|
|
fi
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
# Attempt to remove iff it exists.
|
|
|
|
#if [ ! -e "$1" -a "$1" != *"/"*"*" ]; then
|
|
|
|
# echo "Stopped an attempt to delete non-existent files" > $SandboxOutputDevice
|
|
|
|
# return 3;
|
|
|
|
#fi
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
# Remove the target file (do NOT force it).
|
|
|
|
eval "rm -r $1 &> $SandboxOutputDevice"
|
2017-08-08 11:40:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
# FLUXSCRIPT END
|