我试图将一个文件复制到其他目录,并在调用中断时收到错误消息.
剧本 :
#!/bin/bash
PATH=~/MkFile/
exitfn () {
trap SIGINT # Resore signal handling for SIGINT
echo ; echo 'Called ctrl + c ' # Growl at user,cp ./BKP/temp.txt $PATH/backup.txt
exit # then exit script.
}
trap "exitfn" INT # Set up SIGINT trap to call function.ii
read -p "What? "
echo "You said: $REPLY"
# reset all traps##
trap - 0 SIGINT
输出:
./signal.sh
What? ^C
Called ctrl + c
./signal.sh: line 9: cp: command not found
你知道这个剧本有什么问题吗?
最佳答案
原文链接:https://www.f2er.com/linux/440671.html