In bash, what are my options with respect to handling system requests for inputs?
I have a script that contains rm "$STDLOG" &>/dev/null
开发者_运维知识库In the case of the file not existing, I want to proceed, which is why I'm tossing the results.
But I'm not accounting for the case of insufficient permissions, in which case the system asks a question and the script locks up.
Is there a general method for trapping on requests for input?
No. It is your job to instruct the command to either skip (e.g. --interactive=never
) or force (e.g. -f
) the operation beforehand.
精彩评论