我正在尝试将一个文件复制到另一个目录并在调用中断时收到错误消息。
剧本 :
#!/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
你知道这个脚本有什么问题吗?