1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-01-26 04:02:27 +00:00

pbsh.s: detect if stdin is a regular file using seek

seek doesn't fail on special devices, but it always returns zero
This commit is contained in:
Phil Budne
2016-03-28 02:07:21 -04:00
parent 5cab912d88
commit d3ccf536c4

View File

@@ -36,7 +36,17 @@ maxargs=10
lac d1
sys intrp " make shell uninterruptable
sys getuid
" see if reading from a special file
cla; sys seek; 1; 0 " try seeking stdin forward
sna " new offset non-zero?
jmp 1f " no: input is a special file (ttyin,keyboard)
dzm prompt " yes: regular file, kill prompt
cla; sys seek; 0; 0 " seek file back to start
jmp newline
" stdin is a special file, see if superuser
1: sys getuid
sma " <0?
jmp newline " no
lac hash " yes: superuser