r/linux_programming • u/fazi_d • Jun 15 '23
When exactly EXIT is sent?
I fought - at script exit but:
#!/bin/bash
make_temp() {
t=$(mktemp)
trap "rm $t" EXIT
echo $t
}
tt=$(make_temp)
ls $ttIt gives me 'no such file or directory'
How to catch script exit but not function exit?
0
Upvotes
View all comments
Show parent comment
1
u/fazi_d Jun 15 '23
So - $(something) creates a subshell even it's only a function call? 😱