0
|
1 #!/bin/bash
|
|
2
|
|
3 extify() {
|
|
4 local REQ_EXT=$1
|
|
5 shift
|
|
6
|
|
7 local OUTPUT=""
|
|
8 local FILE
|
|
9 for FILE in $*; do
|
|
10 local BASENAME=$(basename ${FILE})
|
|
11 local EXT=${BASENAME##*.}
|
|
12 if [[ ${EXT} != ${REQ_EXT} ]]; then
|
|
13 local LINK="${BASENAME%%.*}.${REQ_EXT}"
|
|
14 if [[ ! -f ${LINK} ]]; then
|
|
15 ln -s ${FILE} ${LINK}
|
|
16 fi
|
|
17 FILE="${LINK}"
|
|
18 fi
|
|
19 OUTPUT="${OUTPUT} ${FILE}"
|
|
20 done
|
|
21
|
|
22 echo ${OUTPUT}
|
|
23 }
|
|
24
|
|
25 # from http://www.linuxjournal.com/content/use-date-command-measure-elapsed-time
|
|
26 timer() {
|
|
27 if [[ $# -eq 0 ]]; then
|
|
28 echo $(date '+%s')
|
|
29 else
|
|
30 local stime=$1
|
|
31 etime=$(date '+%s')
|
|
32
|
|
33 if [[ -z "$stime" ]]; then stime=$etime; fi
|
|
34
|
|
35 dt=$((etime - stime))
|
|
36 ds=$((dt % 60))
|
|
37 dm=$(((dt / 60) % 60))
|
|
38 dh=$((dt / 3600))
|
|
39 printf '%d:%02d:%02d' $dh $dm $ds
|
|
40 fi
|
|
41 }
|
|
42
|
|
43 on_exit() {
|
|
44 echo "Elapsed time: $(timer ${START_TIME})"
|
|
45 }
|
|
46
|
|
47 set -eux
|
|
48
|
|
49 xargs -n 1 -0 < /proc/self/environ > env.log
|
|
50
|
|
51 START_TIME=$(timer)
|
|
52 trap on_exit EXIT
|