rmdir - remove a directory


rmdir FileSpec


Rmdir removes the directory given by FileSpec.  The directory must be empty, i.e., contain no files. 


The program
	kill "/usr/employees/larry"
	kill "/usr/employees/roger"
	kill "/usr/employees/gary"
	rmdir "/usr/employees"
removes the directory "/usr/employees" but only after removing several files known to have been in that directory. 


chdir, mkdir, shell(stmt)


An "Illegal function call" error is generated if anything goes wrong. 


Removing a directory is a privileged operation under the UNIX operating system.  The rmdir statement is implemented for completeness, but requires super-user status; an executable BASIC program must either be run by the super-user or the program must be set-user-id and owned by the super-user.  If the latter condition exists, but not the former, it is assumed that the privileged status was intended to allow operation on the directory but not the ownership of the file.  File (and directory) ownership in BASIC under these conditions is deliberately set to the real user id. 

Note well that enchanting a program with a privileged status is hazardous to the health of a UNIX system, not only can a bug in the program reek havoc but if care is not taken, a set-user-id program can be used by an unauthorized and unscrupulous user to usurp control of the system.  The shell statement is the best way to operate on directories, for example:

	shell "rmdir /usr/employees"
By this method, the privileged status is invoked only when it is necessary and risk of damaging the system with an omnipotent BASIC program is minimized.  At the very least, this technique ought to be used while the program is being developed and replaced with the rmdir statement and privileged status only for the final version. 

The importance of avoiding set-user-id programs owned by the super-user can not be overemphasized. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber