Open name-snrl opened 1 month ago
I'm writing a script that creates a temporary directory, and I'd like the script to delete it when it terminates(no matter how). If try block terminates with an error, the directory is deleted, but if I interrupt it, nothing happens.
try
run the script below, then interrupt it.
#!/usr/bin/env nu let tmp = mktemp --directory print $tmp try { sleep 10sec } catch { rm -rf $tmp } rm -rf $tmp
check the printed path directory still exists :(
the directory is deleted when the script is interrupted
No response
Would that be a form of a finally block?
finally
Describe the bug
I'm writing a script that creates a temporary directory, and I'd like the script to delete it when it terminates(no matter how). If
try
block terminates with an error, the directory is deleted, but if I interrupt it, nothing happens.How to reproduce
run the script below, then interrupt it.
check the printed path directory still exists :(
Expected behavior
the directory is deleted when the script is interrupted
Screenshots
No response
Configuration
Additional context
No response