-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTEE.PAS
43 lines (39 loc) · 1.04 KB
/
TEE.PAS
1
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
41
42
{ @author: Sylvain Maltais ([email protected])
@created: 2021
@website(https://www.gladir.com/linux-0)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program TEE(Input,Output);
Var
Option:Set Of (Ajouter);
FileWrite:Text;
I:Integer;
CurrLine:String;
FileName:String;
BEGIN
If(ParamStr(1)='/?')or(ParamStr(1)='--help')or(ParamStr(1)='-h')Then Begin
WriteLn('TEE : Cette commande permet d''envoyer l''entr‚e standard vers la sortie standard.');
WriteLn;
WriteLn('Syntaxe : TEE [-a] [nomdufichier]');
End
Else
Begin
Option:=[];
FileName:='';
For I:=1 to ParamCount do Begin
If ParamStr(I)='-a'Then Include(Option,Ajouter)
Else FileName:=ParamStr(I);
End;
If FileName<>''Then Begin
Assign(FileWrite,FileName);
If(Ajouter in Option)Then Append(FileWrite)
Else Rewrite(FileWrite);
End;
While Not EOF do Begin
ReadLn(Input,CurrLine);
WriteLn(Output,CurrLine);
If FileName<>''Then WriteLn(FileWrite,CurrLine);
End;
If FileName<>''Then Close(FileWrite);
End;
END.