跳到主内容

bash 笔记

bash notes

  • set -e 有错误即退出
  • set -u 如有未赋值的变量即退出
  • set -x

  • trap command signal [INT, TERM and EXIT ...]

    if [ ! -e $lockfile ]; then
    trap "rm -f $lockfile; exit" INT TERM EXIT
    touch $lockfile
    critical-section
    rm $lockfile
    trap - INT TERM EXIT
    else
    echo "critical-section is already running"
    fi
    

评论

Comments powered by Disqus