      SUBROUTINE MAIN
      LOGICAL*1 BUF(512)
      INTEGER I, NARG
      INTEGER GETARG, GETLIN, ISATTY, INDEXC
      INTEGER OPEN
      COMMON / CRM / FORCE, INTER, VERBOS, TTYIN
      INTEGER FORCE
      INTEGER INTER
      INTEGER VERBOS
      INTEGER TTYIN
      LOGICAL*1 TTY(4)
      DATA TTY(1)/84/,TTY(2)/73/,TTY(3)/58/,TTY(4)/0/
      CALL QUERY( 28Husage:  rm [-fiv] [file] ...)
      FORCE = 0
      VERBOS = 0
      INTER = 0
      TTYIN = OPEN(TTY, 1)
      I = 1 
23000 IF (.NOT.(GETARG( I, BUF, 40) .NE. -1 ))GOTO 23002
      IF (.NOT.( BUF(1) .EQ. 45 ))GOTO 23003
      CALL FOLD(BUF)
      IF (.NOT.(INDEXC(BUF, 102) .GT. 0))GOTO 23005
      FORCE = 1
23005 CONTINUE
      IF (.NOT.(INDEXC(BUF, 105) .GT. 0))GOTO 23007
      INTER = 1
23007 CONTINUE
      IF (.NOT.(INDEXC(BUF, 118) .GT. 0))GOTO 23009
      VERBOS = 1
23009 CONTINUE
      CALL DELARG(I)
      I = I - 1
23003 CONTINUE
23001 I = I + 1 
      GOTO 23000
23002 CONTINUE
      IF (.NOT.( I .GT. 1 ))GOTO 23011
      I = 1 
23013 IF (.NOT.(GETARG( I, BUF, 40) .NE. -1 ))GOTO 23015
      CALL RMFILE(BUF)
23014 I = I + 1 
      GOTO 23013
23015 CONTINUE
      GOTO 23012
23011 CONTINUE
      IF (.NOT.( ISATTY(1) .EQ. 0 ))GOTO 23016
      I = GETLIN( BUF, 1) 
23018 IF (.NOT.(I .NE. -1 ))GOTO 23020
      BUF(I) = 0
      CALL RMFILE(BUF)
23019 I = GETLIN( BUF, 1) 
      GOTO 23018
23020 CONTINUE
23016 CONTINUE
23012 CONTINUE
      RETURN
      END
      SUBROUTINE RMFILE(FILE)
      LOGICAL*1 FILE(40), PSTR(512), YESNO(512)
      LOGICAL*1 CLOWER
      INTEGER JUNK
      INTEGER CHMOD, PROMPT, REMOVE
      COMMON / CRM / FORCE, INTER, VERBOS, TTYIN
      INTEGER FORCE
      INTEGER INTER
      INTEGER VERBOS
      INTEGER TTYIN
      LOGICAL*1 SUFF1(17)
      LOGICAL*1 SUFF2(31)
      LOGICAL*1 ERRST(23)
      DATA SUFF1(1)/58/,SUFF1(2)/32/,SUFF1(3)/100/,SUFF1(4)/101/,SUFF1(5
     *)/108/,SUFF1(6)/101/,SUFF1(7)/116/,SUFF1(8)/101/,SUFF1(9)/63/,SUFF
     *1(10)/32/,SUFF1(11)/40/,SUFF1(12)/121/,SUFF1(13)/47/,SUFF1(14)/110
     */,SUFF1(15)/41/,SUFF1(16)/32/,SUFF1(17)/0/
      DATA SUFF2(1)/58/,SUFF2(2)/32/,SUFF2(3)/105/,SUFF2(4)/115/,SUFF2(5
     *)/32/,SUFF2(6)/112/,SUFF2(7)/114/,SUFF2(8)/111/,SUFF2(9)/116/,SUFF
     *2(10)/101/,SUFF2(11)/99/,SUFF2(12)/116/,SUFF2(13)/101/,SUFF2(14)/1
     *00/,SUFF2(15)/59/,SUFF2(16)/32/,SUFF2(17)/100/,SUFF2(18)/101/,SUFF
     *2(19)/108/,SUFF2(20)/101/,SUFF2(21)/116/,SUFF2(22)/101/,SUFF2(23)/
     *63/,SUFF2(24)/32/,SUFF2(25)/40/,SUFF2(26)/121/,SUFF2(27)/47/,SUFF2
     *(28)/110/,SUFF2(29)/41/,SUFF2(30)/32/,SUFF2(31)/0/
      DATA ERRST(1)/63/,ERRST(2)/32/,ERRST(3)/67/,ERRST(4)/97/,ERRST(5)/
     *110/,ERRST(6)/39/,ERRST(7)/116/,ERRST(8)/32/,ERRST(9)/114/,ERRST(1
     *0)/101/,ERRST(11)/109/,ERRST(12)/111/,ERRST(13)/118/,ERRST(14)/101
     */,ERRST(15)/32/,ERRST(16)/102/,ERRST(17)/105/,ERRST(18)/108/,ERRST
     *(19)/101/,ERRST(20)/32/,ERRST(21)/96/,ERRST(22)/96/,ERRST(23)/0/
      IF (.NOT.(INTER .EQ. 1 .AND. FORCE .EQ. 0 .AND. TTYIN .NE. -3))GOT
     *O 23021
      CALL CONCAT(FILE, SUFF1, PSTR)
      JUNK = PROMPT( PSTR, YESNO, TTYIN)
      IF (.NOT.( CLOWER(YESNO(1)) .NE. 121 ))GOTO 23023
      RETURN
23023 CONTINUE
23021 CONTINUE
      IF (.NOT.( REMOVE(FILE) .NE. -3 ))GOTO 23025
      IF (.NOT.( VERBOS .EQ. 1 ))GOTO 23027
      CALL REMARK(FILE)
23027 CONTINUE
      RETURN
23025 CONTINUE
      IF (.NOT.( FORCE .EQ. 0 .AND. TTYIN .NE. -3))GOTO 23029
      CALL CONCAT(FILE, SUFF2, PSTR)
      JUNK = PROMPT( PSTR, YESNO, TTYIN)
      IF (.NOT.( CLOWER(YESNO(1)) .NE. 121 ))GOTO 23031
      RETURN
23031 CONTINUE
23029 CONTINUE
      IF (.NOT.( CHMOD( FILE, -1) .NE. -3 ))GOTO 23033
      IF (.NOT.( REMOVE(FILE) .NE. -3 ))GOTO 23035
      IF (.NOT.( VERBOS .EQ. 1 ))GOTO 23037
      CALL REMARK(FILE)
23037 CONTINUE
      RETURN
23035 CONTINUE
23033 CONTINUE
      CALL PUTLIN( ERRST, 3)
      CALL PUTLIN( FILE, 3)
      CALL REMARK( 3H''.)
      RETURN
      END
