forked from mjpost/CachePipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
29 lines (26 loc) · 747 Bytes
/
Copy pathbashrc
File metadata and controls
29 lines (26 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# This allows you to cache commands from the command line.
# Usage:
cachecmd_usage() {
cat <<EOF
Usage: cachecmd ID command [dep1 [dep2 ...]]
where
ID is the command ID (unique within the directory)
command is the command to run (remember to quote multiword commands)
dep1 .. depN are file and environment dependencies
EOF
}
cachecmd() {
if [ -z "$2" ]; then
cachecmd_usage
else
local tmpfile=.cachepipe.$$.$(date +%s)
rm -f $tmpfile
# $@ must be in quotes, or quoted args get split up
# see VonC's answer at http://stackoverflow.com/questions/255898/how-to-iterate-over-arguments-in-bash-script
for arg in "$@"; do
echo $arg >> $tmpfile
done
perl -MCachePipe -e "cache_from_file('$tmpfile')"
rm -f $tmpfile
fi
}