#!/bin/bash 


while  test "$commande" != "exit" 
do
    echo -n "[Interpreteur]$ "
    read commande;

    com=`echo $commande | cut -d " " -f 1`	
    parametre=`echo $commande | cut -sd " " -f 2`
    
    ap=`echo $commande | cut -sd " " -f 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,30,31,32,33,34,35,36,37,38,39,40`    


    if test "$com" == alias -a -z "$parametre"
    then
    cat aliasfile 

    elif test "$com" == "alias"
    then
	echo "Ajout d un alias"
	echo "$ap" >> aliasfile

    elif test "$com" == "unalias" -a -n "$parametre"
    then
    	echo "Supression d un alias"
	grep -Ev "^$parametre=" aliasfile > temp
	cat temp > aliasfile

	
    elif test "$com"  != "exit"
    then
    
        aalias=`grep "^$com=" aliasfile | cut -d '"' -sf 2`
	if test -n "$aalias"
	then
	    $aalias $ap1
	else
	    $commande
	fi
    
    
    fi
    








done


