Make 1990/tbr alt version that uses fgets not gets
This is so that the warning about gets() is not interspersed with the
initial output of the program (see below). I do want to note that if one
sends EOF it will segfault so to exit one should do ctrl-c (for
instance) (exit never worked). I will look at fixing that fault later on
to match the original code but this is good for now. When fixed (low
priority though) I will consider making the gets() version the alt but
probably not (I guess time will tell).
As for the interspersed output it looks like:
$ warning: this program uses gets(), which is unsafe.
# cursor is here
At the cursor I can either hit enter to get another prompt or I can
input a command but this is not immediately obvious.
Updated .gitignore to have tbr.alt.
This commit is contained in:
1 parent
e6d578660b
commit
6a6807e587
4 files changed
+45
-4
No files matched your search
@@ -0,0 +1,23 @@
|
||||
|
||||
#define D ,close(
|
||||
|
||||
char *c,q [512 ],m[ 256
|
||||
],*v[ 99], **u, *i[3];int f[2],p;main (){for
|
||||
(m[m [60]= m[62 ]=32 ]=m[* m=124 [m]= 9]=6;
|
||||
e(-8) ,(c=fgets (q,512,stdin),c[strlen(c)-1]='\0',1)||(exit (0),0);r(0,0)
|
||||
)for( ;*++ c;); }r(t, o){ *i=i [2]= 0;for
|
||||
(u=v +98 ;m[*--c] ^9;m [*c] &32 ?i[*c
|
||||
&2]= *u,u- v^98 &&++u:
|
||||
|
||||
3 )if(!m[*c]){for(*++c=0;!m[*--c];);
|
||||
* --u= ++c;}u-v^98?strcmp(*u,"cd")?*c?pipe(f),o=f[
|
||||
1 ]:
|
||||
4 ,(p=fork())?e(p),o?r(o,0)D o)D*f):
|
||||
1 ,wait(0):(o?dup2(*f,0)D*f)D o):*i?
|
||||
5 D 0),e(open(*i,0)):
|
||||
9 ,t?dup2(t,1)D t):i[
|
||||
2 ]?
|
||||
6 D 1),e(creat(i[2],438)):
|
||||
5 ,e(execvp(*u,u))):e(chdir(u[1])*2):
|
||||
3 ;}e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||(exit(1),0):
|
||||
5 ;}
|
||||
Reference in new issue
Block a user