#!/bin/bash

file_index=1
args_index=1
carry=

for i in "$@"
do
	if [ "$carry" != "yes" ]
	then
		case $i in
			"-n" | -a | "-s" | "-w" | "-o" | "-2" | "--help" )
				args[$args_index]=$i
				args_index=`expr $args_index + 1`
				;;
			"-p" | "-q" | "-A" | "-f" | "-b" | "-fbs" )
				args[$args_index]=$i
				args_index=`expr $args_index + 1`
				carry=yes
				;;
			*)
				files[$file_index]=$i
				file_index=`expr $file_index + 1`
				;;
		esac
	else
		args[$args_index]=$i
		args_index=`expr $args_index + 1`
		carry=
	fi
done

for i in "${files[@]}"
do
	tgatoppm "$i"
done |
ppm2raw ${args[@]}

