Skip to content

Commit

Permalink
Merge pull request #28 from mgafner/fix-keep
Browse files Browse the repository at this point in the history
fix reading command line parameters
  • Loading branch information
BrettSheleski authored Feb 20, 2019
2 parents 0db73f1 + 91dfdb5 commit 2f5fefe
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions comchap
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ verbose=false
lockfile=""
workdir=""

while [[ $# -gt 1 ]]
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
Expand Down Expand Up @@ -68,8 +68,26 @@ case $key in
workdir="${key#*=}"
shift
;;
-*)
echo "Option $1 doesn't exist, please check the documentation"
exit 1
;;
*)
break
if [ -z $infile ]; then
infile=$1
if [ ! -f "$infile" ]; then
echo "Inputfile '$infile' doesn't exist. Please check."
exit 1
fi
else
if [ -z $outfile ]; then
outfile=$1
else
echo "Error: too many parameters. Inputfile and Outputfile already defined. Please check your command."
exit 1
fi
fi
shift
;;
esac
done
Expand Down Expand Up @@ -100,12 +118,8 @@ elif ! grep -q "output_edl=1" "$comskipini"; then
echo "output_edl=1" >> "$comskipini"
fi

infile=$1

if [[ -z "$2" ]]; then
if [[ -z "$outfile" ]]; then
outfile="$infile"
else
outfile="$2"
fi

outdir=$(dirname "$outfile")
Expand Down

0 comments on commit 2f5fefe

Please sign in to comment.