All pastes #395260 Raw Edit

blah

public shellscript v1 · immutable
·published 2007-03-14 22:07 UTC
rendered paste body
#! /bin/tcsh#test du nombre d'argumentsif (($#argv != 2) && ($#argv != 3)) then		echo "usage $0 <option> <repertoire>"		exit(1)endif#code pour le test sur le repertoire pour les options -tous et -videif ($1 == 1 ) then    if  ($#argv != 2) then 	 echo "usage: $0 -tous <repertoire>"	 echo "ça test pour nombre argument dans -tous"	  exit(1)    endif    if ((! -d $2)&& (! -r $2) || (! -d ~/$2) && (! -r ~/$2))then	echo "$0 n'est pas un repertoire ou n'est pas accessible"	echo "s$ usage: <option>  <repertoire>"	exit(1)    endif    if (-r $2) then    echo "ça marche"    set a = r    cd $2    endif    if (-r ~/$2) then    echo "ça marche aussi"    set a = ab    cd ~/$2    endif   endif#code pour l'option -tousif ($1 == 1 ) then    if  ($#argv != 2) then 	 echo "usage: $0 -tous <repertoire>"	 echo "ça test pour nombre argument dans -tous"	  exit(1)    endif 	foreach file (`ls *.txt`)	set t = Test	set t1 = $file	set t2 = $t$t1	set gh = $t2	set class_name = $t2:r	set nom_p = $3:h	set nom_package = $nom_p:t	set nom_fich = gh$$.txt	set nom_fichier = $file:r				if (($nom_fichier != Test*) && (! -e $t2)) then	       	    echo "package $nom_package;" > $t2		    echo "import outils.Console;" >> $t2		    echo "public class $class_name  {" >> $t2		    echo "     public static void main (String [] args) {" >> $t2	            echo "" >> $t2	                                echo "            Console es = new Console ();" >> $t2 		    echo "	       es.println("Resultats des tests");" >> $t2                    echo "" >> $t2		    echo "     } // main(Strings[])" >> $t2    		    echo " } // class $class_name " >> $t2				    echo "la on arrive"		    	        endif          			end	exit(1)endif#code pour l'option -videif ($1 == 4) then	foreach file (`ls *.txt`)	set t = Test	set t1 = $file	set t2 = $t$t1	set class_name = $t2:r	set nom_p = $3:h	set nom_package = $nom_p:t        set nom_fichier = gh$$.txt	set compar = comp$$.txt	set nom_fich = $file:r			if ($nom_fich == Test*) then		    echo "package $nom_package;" > $nom_fichier		    echo "import outils.Console;" >> $nom_fichier		    echo "public class $class_name  {" >> $nom_fichier		    echo "     public static void main (String [] args) {" >> $nom_fichier	            echo "" >> $nom_fichier	                                echo "            Console es = new Console ();" >> $nom_fichier 		    echo "	       es.println("Resultats des tests");" >> $nom_fichier                    echo "" >> $nom_fichier		    echo "     } // main(Strings[])" >> $nom_fichier    		    echo " } // class $class_name " >> $nom_fichier			    		   diff -q $nom_fichier $t1 > $compar		   if ( ! -z $compar) then			echo "$t2"	           endif		   		   # rm $nom_fichier		  		 					    endif          			end	exit(1)endif    #code test si repertoire valide, fichier  ou accessible pour l'option -nom -saufif (($1 == 2) && ($1 == 3)) then    if  ($#argv != 3) then 	 echo "usage: $0 <option> <repertoire> <repertoire>"	  exit(1)    endif    if ((! -d $3) && (! -r $3) || (! -d ~/$3) && (! -r ~/$3))then	echo "$0 n'est pas un repertoire ou n'est pas accessible"	echo "s$ usage: <option>  <repertoire>"	exit(1)    endif     if ( $2:e != txt) then	echo "work pour le test d'extension"	echo "usage: $0 -sauf <class java> <repertoire>"	exit(1)    endif    if (-r $3) then	echo "ça marche"	echo "$2:e"	set a = r	cd $3    endif    if (-r ~/$3) then	echo "ça marche aussi"	set a = ab	cd ~/$3    endif    endif#code pour l'opion -saufif ($1 == 3) then    if  ($#argv != 3) then 	 echo "usage: $0 -sauf <repertoire>"	  exit(1)    endif 	foreach file (`ls *.txt`)	    set t = Test	    set t1 = $file	    set t2 = $t$t1		    set class_name = $t2:r	    set nom_p = $3:h	    set nom_package = $nom_p:t			if (($t1 != $2) && (! -e $t2) && (! -e $t2)) then		    echo "package $nom_package;" > $t2		    echo "import outils.Console;" >> $t2		    echo "public class $class_name  {" >> $t2		    echo "     public static void main (String [] args) {" >> $t2	            echo "" >> $t2	                                echo "            Console es = new Console ();" >> $t2 		    echo "	       es.println("Resultats des tests");" >> $t2                    echo "" >> $t2		    echo "     } // main(Strings[])" >> $t2    		    echo " } // class $class_name " >> $t2								    endif          			end	exit(1)endif#code pour l'option -nomif ($1 == 2) then    if  ($#argv != 3) then 	 echo "usage: $0 -nom <repertoire>"	  exit(1)    endif 	    set t1 = Test	    set file_test = $2	    	    set t2 = $t1$file_test		    set class_name = $t2:r	    set nom_p = $3:h	    set nom_package = $nom_p:t			if ((-e $file_test) && (! -e $t2)) then		    echo "package $nom_package;" > $t2		    echo "import outils.Console;" >> $t2		    echo "public class $class_name  {" >> $t2		    echo "     public static void main (String [] args) {" >> $t2	            echo "" >> $t2	                                echo "            Console es = new Console ();" >> $t2 		    echo "	       es.println("Resultats des tests");" >> $t2                    echo "" >> $t2		    echo "     } // main(Strings[])" >> $t2    		    echo " } // class $class_name " >> $t2								    endif						if (! -e $2) then			    echo "ERREUR: la classe point n'existe pas dans le repertoire $nom_package"			    echo "usage: $0 <option> <repertoire>"			    exit(1)			endifendif