#!/bin/bash read -p "Path to be added: " $path set -xv if [ "$path" = "/home/mike/bin" ]; then echo $path >> $PATH echo "new path: $PATH" else echo "did not modify PATH" fi set +xv
使用trap,EXIT模式仅检测退出时状态:
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/bin/bash trap 'echo score is $score, status is $status' EXIT if [ -z $1 ]; then status="default" else status=$1 fi score=0 if [ ${USER} = 'superman' ]; then score=99 elif [ $# -gt 1 ]; then score=$2 fi
DEBUG模式可以检测每步状态:
1
trap 'echo "line ${LINENO}: score is $score"' DEBUG
GDB debug
使用友好的GDB debug会话:
1
gcc -ggdb test.c -o test.out
设置核心转储:
1 2 3 4 5
if ! grep -qi 'kernel.core_pattern' /etc/sysctl.conf; then sudo sh -c 'echo "kernel.core_pattern=core.%p.%u.%s.%e.%t" >> /etc/sysctl.conf' sudo sysctl -p fi ulimit -c unlimited # 使得当前会话解除核心文件大小限制
class Solution { public: void rotate(vector<vector<int>>& matrix) { int n = matrix.size(); int tri = 0; for (int i = 0; i < n; i++) { for (int j = 0+tri; j < n; j++) { int tr=matrix[i][j]; matrix[i][j] = matrix[j][i]; matrix[j][i] = tr; } tri++; } for (int i = 0; i < n; i++) { reverse(matrix[i].begin(),matrix[i].end()); } } };
Edit the html file that just saved, overwrite jQuery reference
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
as
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
or other reference you trust.