mkdir - make a directory


mkdir FileSpec


Mkdir creates the directory given by FileSpec.  Any directories leading to the directory to be created must already exist. 


The program
	mkdir "/usr/employees"
	open "/usr/employees/larry" for output as file 1
	print #1, "6/15/87 reprimanded for flaky behavior"
	print #1, "8/12/87 cruised in late after liquid lunch"
	print #1, "8/31/87 terminated"
	close #1
creates and writes the file "/usr/employees/larry." Assuming that the directory "/usr/employees" did not exist previously, this program first makes the directory. 


chdir, rmdir, shell(stmt)


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


Making a directory is a privileged operation under the UNIX operating system.  The mkdir 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 "mkdir /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 mkdir 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