DealWithGaus.sh
Go to the documentation of this file.
1 #!/bin/bash
2 # Program name
3 prog=${0##*/}
4 # ======================================================================
5 function usage() {
6  cat 1>&2 <<EOF
7 usage: $prog <top-dir>
8 EOF
9 }
10 
11 get_this_dir()
12 {
13  ( cd / ; /bin/pwd -P ) >/dev/null 2>&1
14  if (( $? == 0 )); then
15  pwd_P_arg="-P"
16  fi
17  reldir=`dirname ${0}`
18  thisdir=`cd ${reldir} && /bin/pwd ${pwd_P_arg}`
19 }
20 
21 ## perl -wapi\~ -f fix-header-locs.pl "${F}" >/dev/null 2>&1 && rm -f "${F}~"
22 
23 function fcl_file() {
24  local F=$1
25  printf "$F ... "
26  # Optionally fix whitespace
27  (( ${fix_whitespace:-0} )) && ed "$F" < fix-whitespace.ed > /dev/null 2>&1
28  # Fix CMakeLists.txt
29  perl -wapi\~ -f ${thisdir}/fix_fcl.pl "${F}" >/dev/null 2>&1 && rm -f "${F}~"
30 }
31 
32 # ======================================================================
33 # Prepare:
34 getopt -T >/dev/null 2>&1
35 if (( $? != 4 )); then
36  echo "ERROR: GNU getopt required! Check SETUP_GETOPT and PATH." 1>&2
37  exit 1
38 fi
39 
40 TEMP=`getopt -n "$prog" -o a --long fix-whitespace -- "${@}"`
41 eval set -- "$TEMP"
42 while true; do
43  case $1 in
44  --fix-whitespace)
45  fix_whitespace=1
46  shift
47  ;;
48  --)
49  shift
50  break
51  ;;
52  *)
53  echo "Bad argument \"$OPT\"" 1>&2
54  usage
55  exit 1
56  esac
57 done
58 
59 TOP=${1}
60 
61 get_this_dir
62 
63 # ======================================================================
64 # Run scripts to update
65 
66 TMP=`mktemp -t DealWithGaus.sh.XXXXXX`
67 trap "rm $TMP* 2>/dev/null" EXIT
68 
69  echo
70  for F in `find $TOP -name "*.fcl" -print`; do
71  fcl_file "$F"
72  done
73  echo