Subversion Repositories stackman

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 daniel-mar 1
#!/bin/bash
2
 
3
# Get the directory of this script (also works with symlinks)
4
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
5
SOURCE="${BASH_SOURCE[0]}"
6
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
7
	DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
8
	SOURCE="$(readlink "$SOURCE")"
9
	[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
10
done
11
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
12
 
13
inputfile="$1"
14
if [ ! -f "$inputfile" ]; then
15
	echo "ERROR: file '$inputfile' does not exist." 1>&2
16
fi
17
shift
18
 
19
category=$( echo $@ )
20
if [[ "$category" == "" ]]; then
21
	echo "Syntax: $0 <inputfile> <category>" 1>&2
22
	exit 2
23
fi
24
shift
25
 
26
# Process
27
cat "$inputfile" | "$DIR"/app "$category"