/*
 *
 * files  Version 0.8 18JAN84
 *
 * This is the master script for building the `files' subtree.
 *
 */
/*
 * TNIX Version
 * Keyshell Version Number 1
 */


files
{
>
>\klistfiles\e - Lists the files in this directory in long or short format.
>
>\kshowfile\e - Displays a file on the screen or prints it on the lineprinter.
>
>\kfile info\e - Searches, counts, and compares files.
>
>\kfile mgmt\e - Copies, renames, protects, lists, displays, deletes files.  
>
>\kflex disk\e - Moves files to and from a flexible disk archive.
>
>\kdir mgmt\e - Prints the name of this directory, moves to another directory, 
>            creates and deletes directories, and lists directory contents.
>
>\kdone\e - Cancels the command being built or returns to the top set of keys.
>
msg;
f1;listfiles; {
>
>\kshort\e - Lists the files in this directory in short format.
>
>\klong\e - Lists the files in this directory, giving detailed information
>            about access permission, size, ownership, and time of creation.
>
	cmd (^ls ), msg (^Select a listing format: %%);
	f1;short; exec, msg, break;
	f2;long; cmd( -al), exec, msg, break;
	f7;manual; man (ls);
	f8;done; msg, cmd, break;
};
f2;showfile; {
>
>\kon screen\e - Displays a file or files on your terminal screen.
>
>\kprint\e - Prints a file or files on the lineprinter.
> 
	msg(^Select on-screen display or printing: %%) ;
	f1;on screen; {
>
>Name the file or files you want to display.  Separate file names with 
>spaces.
>
		cmd (^more ), msg (^Name the file\(s\) to be shown: %p), msg, exec, msg, break(2);
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (more);
		f8;done; msg, cmd, break(2);
	};
	f2;print; {
>
>Name the file or files to be printed.  Separate file names with
>spaces.
>
		cmd (^lp1r ), msg (^Name the file\(s\) to be printed: %p), msg, exec, break(2);
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (lpr);
		f8;done; msg, cmd, break(2);
	};
	f8;done; msg, cmd, break;
};
f3;file info; {
>
>\ksearch\e - Finds all the occurrences of a given text string in a set of
>            files.
>
>\kcompare\e - Compares two files.  If they differ, it prints the character 
>            number where the difference occurs; otherwise, it prints nothing.
>
>\klinecount\e - Counts the lines, words, and characters in a file.
>
	f1;search; {
>
>Enter the string you want to search for.  
>
		cmd (^fgrep -n "), msg (^Type the string for which you want to search: %p), par (\" ), next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f5;; hist;
		f7;manual; man (grep);
		f8;done; msg, cmd, break;
	}, {
>
>Name the files you want to search for the string you just entered.
>
		msg (^Name the files to be searched \(separate with spaces\): %p), msg, exec, break;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (grep);
		f8;done; msg, cmd, break;
	};
	f2;compare; {
>
> Enter any TNIX filename.
>
> The compare command (\"cmp\") will print nothing if the files compared
> are identical.  If they differ, it will print the number of the first
> character at which they differ.
>
                cmd (^cmp ), msg (^Name the first of the files to be compared: %F), next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (cmp);
		f8;done; msg, cmd, break;
	}, {
>
> Enter a TNIX filename.
>
> The compare command (\"cmp\") will print nothing if the files compared
> are identical.  If they differ, it will print the number of the first
> character at which they differ.
>
>
		msg (^Name the second of the files to be compared: %f), msg, exec, break;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (cmp);
		f8;done; msg, cmd, break;
	};
	f3;linecount; {
>
> Enter a TNIX filename.  
>
> The command \"wc\" will count the lines, words, and characters in the 
> file.
>
		cmd (^wc ), msg (^Name the file in which you want to count: %f), msg, exec, break;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (wc);
		f8;done; msg, cmd, break;
	};
	f6;listfiles; cmd (^ls), msg, exec;
	f8;done; msg, cmd, break;
};
f4;file mgmt; {
>
>\kcopy\e - Makes a copy of a file.
>
>\krename\e - Lets you give a different name to a file. 
>
>\kprotect\e - Lets you determine who has access to a file.
>
>\kdelete\e - Removes (destroys) a file. 
>
>\kshowfile\e - Displays a file on the screen or prints it on the lineprinter.
>
>\klistfiles\e - Lists the files in this directory.
>
>\kdone\e - Cancels the command being built or returns to the previous 
>            set of keys.
>
	f1;copy; {
>
>Enter the name of the file you want to copy.  
>
		cmd (^cp ), msg (^Name the file to be copied: %F), next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (cp);
		f8;done; msg, cmd, break;
	}, {
>
>Enter a name for the copy.
>
		msg (^Enter a name for the copy: %F), msg, exec, next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f5;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (cp);
		f8;done; msg, cmd, break;
	};
	f2;rename; {
>
>Enter the name of the file you want to rename.
>
		cmd (^mv ), msg (^Enter the current name of the file to be renamed: %F), next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (mv);
		f8;done; msg, cmd, break;
	}, {
>
>Enter the new name to be given to the file.
>
		msg (^Type the file's new name: %F), msg, exec, break;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f5;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (mv);
		f8;done; msg, cmd, break;
	};
	f3;protect; {
>
>\kall\e - All users of your system, including you.
>
>\kgroup\e - The members of your group.   
>
>\kothers\e - All system users not in your group.
>
>\kmyself\e - You.
>
		cmd (^chmod ), msg (^To whom do you want to grant/deny access permission? %%), next;
		f1;all; par (a), msg, next;
		f2;group; par (g), msg, next;
		f3;others; par (o), msg, next;
		f4;myself; par (u), msg, next;
		f7;manual; man (chmod);
		f8;done; msg, cmd, break;
	}, {
>
		msg(^Select \"grant\" or \"deny\" permission: %%), next;
		f1;grant; par (+), next;
		f2;deny; par (-), next;
		f7;manual; man (chmod);
		f8;done; msg, cmd, break;
	}, {
>
>\kread\e - Permission to display, print or copy.
>
>\kwrite\e - Permission to delete or change as well as read.
>
>\kexecute\e - Permission to execute if the file is an executable program.
>
>\kread/write\e - A combination of \kread\e and \kwrite\e.
>
>\kread/exec\e - A combination of \kread\e and \kexecute\e. 
>
>\kall\e - A combination of \kread\e, \kwrite\e, and \kexecute\e. 
>
		msg (^Select the permission you want to grant or deny: %%), next;
		f1;read; par (r ), next;
		f2;write; par (w ), next;
		f3;execute; par (x ), next;
		f4;read/write; par(rw ), next;
		f5;read/exec; par(rx ), next;
		f6;all; par (rwx ), next;
		f7;manual; man (chmod);
		f8;done; msg, cmd, break;

	}, {
		msg (^Name the file\(s\) whose permission you\'re changing: %p), exec, msg, break;
>
>Name the file or files whose permission you want to change.  Separate file
>names with spaces. 
>
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ll), msg, exec, return;
		f7;manual; man (chmod);
		f8;done; msg, cmd, break;
	};
	f4;delete; {
>
>Name the file or files to be removed.  Separate file names with spaces.
>
		cmd (^rm ), msg (^Name the file\(s\) to be removed: %p), next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (rm);
		f8;done; msg, cmd, break;
	}, {
>
>\kyes\e - The file or files will be deleted.
>
>\kno\e - The file or files will not be deleted.
>
>\kdone\e - The same as \kno\e.
>
		msg (^Are you sure you want to delete the file\(s\)? %%);
		f1;yes; exec, msg, cmd, break;
		f2;no; msg, cmd, break;
		f8;done; msg, cmd, break;
	};
	f5;showfile; {
>
>\kon screen\e - Displays a file or files on your terminal screen.
>
>\kprint\e - Prints a file or files on the lineprinter.
> 
	msg(^Select on-screen display or printing: %%) ;
	f1;on screen; {
>
>Name the file or files you want to display.  Separate multiple
>file names with spaces.
>
		cmd (^more ), msg (^Name the file\(s\) to be shown: %p), msg, exec, msg, break(2);
			f1;; hist;
			f2;; hist;
		        f3;; hist;
			f4;; hist;
			f6;listfiles; call, cmd (^ls), msg, exec, return;
			f7;manual; man (more);
			f8;done; msg, cmd, break(2);
		};
		f2;print; {
			cmd (^lp1r ), msg (^Name the file\(s\) to be printed: %p), msg, exec, break(2);
>
>Name the file or files you want to print.  Separate file names with spaces. 
>

			f1;; hist;
			f2;; hist;
			f3;; hist;
			f4;; hist;
			f6;listfiles; call, cmd (^ls), msg, exec, return;
			f7;manual; man (lpr);
			f8;done; msg, cmd, break(2);
		};
		f8;done; msg, cmd, break;
        };
	f6;listfiles; cmd (^ls), msg, exec;
	f8;done; msg, cmd, break;
};
f5;flex disk; {
>
>\kformat\e - Prepares a new flexible disk for data storage.  Always format
>            a new disk before using it.  \uWarning: Formatting removes all\n
>            \uof the files on a disk.\n
>
>\karchive\e - Copies files or directories to an archive on a flexible disk.  
>
>\krestore\e - Moves files from a disk archive to your TNIX directory.
>
>\kdone\e - Cancels the command being built or returns to the previous
>            set of key labels.
>
	f1;format; {
>
>\ksingle\e - Formats the disk for single-density recording.
>
>\kdouble\e - Formats the disk for double-density recording.  This is 
>            the default format.
>
		cmd(^format ), msg(^Select single or double density: %%); 
		f1;single; {
>
>\kready\e - Start formatting the flexible disk.
>
>\kdone\e - Cancels the command being built and returns to a previous level.
>
			msg (^Insert disk and press 'ready'. %%);
			f1;ready; par(-s), next(2);
			f8;done;msg, cmd, break(2);
		};
		f2;double; {
>
>\kready\e - Start formatting the flexible disk.
>
>\kdone\e - Cancels the command being built and returns to a previous level.
>
			msg (^Insert disk and press 'ready'. %%);
			f1;ready; next(2);
			f8;done;msg, cmd, break(2);
		};
		f7;manual; man (format);
                f8;done;msg, cmd, break;
		}, {
>
		msg(^Now formatting.  This will take a few minutes.), exec, msg, break;
        }; 
	f2;archive; {
>
>\kready\e - Press ready when you have a formatted flexible disk in the drive.
>
>\kdone\e - Cancels the command being built or returns to the previous set
>            of keys.
>
		msg (^Insert a formatted flexible disk in the drive and press "ready" %%), next;
		f1;ready; msg, next;
		f7;manual; man (fbr);
		f8;done; msg, cmd, break;
	}, {
>
>\knew arch\e - Prepares an empty, formatted disk for file archiving, then
> 	    transfers files or directories to the archive.  \uThis destroys\n
>            \uall files previously present on the archive disk.\n
>
>\kadd file\e - Adds a file or directory to the archive.
>
>\krplc file\e - Replaces an archived file or directory with one from your
>            TNIX directory.
>
>\krmv file\e - Deletes a file or files from the archive disk.
>            \uUse with caution.\n
>
>\klist arch\e - Lists the files on the archive disk.
>
		msg (^Select a task: %%), msg, next;
		f1;new arch; {
>
>Enter the names of the files or directories to be archived.  Separate the
>names with spaces.  
>
                        cmd (^fbr -cv ), msg, next;
		        f7;manual; man (fbr);
		        f8;done; msg, cmd, break;

		}, {
>
>Enter the names of the files or directories to be archived.  Separate the
>names with spaces.  
>
			msg(^Files or directories to be archived: %A), msg(^Archiving files...), exec, msg, break;
			f1;; hist;
			f2;; hist;
			f3;; hist;
			f4;; hist;
			f6;listfiles; call, cmd(^ls), msg, exec, return ;
			f7;manual; man (fbr);
			f8;done; msg, cmd, break;
		};
		f2;add file; {
>
>Enter the names of the files or directories in your TNIX directory that you
>want to add to the archive disk.  Separate the names with spaces.
>
			cmd (^fbr -rv ), msg (^File\(s\) to be added: %p), msg(^Adding files...), exec, msg, break(1);
			f1;; hist;
			f2;; hist;
			f3;; hist;
			f4;; hist;
			f6;listfiles; call, cmd (^ls), msg, exec, return;
			f7;manual; man (fbr);
			f8;done; msg, cmd, break;
		};
		f3;rplc file; {
>
>Enter the names of the files or directories on the archive disk to be replaced
>with new versions from your TNIX directory.  Separate the names with spaces.
>
			cmd (^fbr -rv ), msg (^File\(s\) to be replaced: %p), msg(^Replacing files...), exec, msg, break(1);
			f1;; hist;
			f2;; hist;
			f3;; hist;
			f4;; hist;
			f6;listfiles; call, cmd (^ls), msg, exec, return;
			f7;manual; man (fbr);
			f8;done; msg, cmd, break;
		};
		f4;rmv file; {
>
>Name the files you want to delete from the archive disk.  Separate the names
>with spaces. 
>
>Press \klist arch\e for a list of the files on the archive disk.
>
			cmd(^fbr -dv ), msg (^File\(s\) to be deleted from the archive disk: %p), msg(^Deleting files...), exec, msg, break(1);
			f1;; hist;
			f2;; hist;
			f3;; hist;
			f4;; hist;
			f6;list arch; call, cmd (^fbr -t), msg(^Examining the archive directory...), exec, msg, return;
			f7;manual; man (fbr);
			f8;done; msg, cmd, break;
		};
		f6;list arch.; cmd (^fbr -tv ), msg(^Examining the archive directory...), exec, msg, break(0);
		f7;manual; man (fbr);
		f8;done; msg, cmd, break;
	};
        f3;restore; {
>
>\kready\e - Press ready when you have a formatted flexible disk in the drive.
>
		msg (^Insert flexible disk archive in the drive and press "ready" %%), next;
		f1;ready; msg, next;
		f7;manual; man (fbr);
		f8;done; msg, cmd, break;
	}, {

>
>\kget file\e - Copies a file or directory from the archive disk to your 
>            TNIX directory.
>
>\krmv file\e - Deletes a file or directory from the archive disk.
>            \uUse with caution.\n
>
>\klist arch\e - Lists the files on the archive disk.
>
		msg(^Select a task: %%), msg, next;
		f1;get file; {
>
>Enter the names of the files to be moved from the disk archive to 
>your current TNIX directory.  Separate the names with spaces. 
>
>Press \kall\e to copy all files on the disk archive into your
>current directory.
>
>Press \klist arch\e for a list of the files on the archive disk.
>
			cmd (^fbr -xv ), msg (^File\(s\) to be extracted from the archive: %p), msg(^Getting files from the archive...), exec, msg, break(1);
			f1;all; msg(^Getting files from the archive...), exec, msg, break(1);
			f2;; hist;
			f3;; hist;
			f4;; hist;
			f6;list arch; call, cmd (^fbr -t), msg(^Examining the archive directory...), exec, msg, return;
			f7;manual; man (fbr);
			f8;done; msg, cmd, break;
		};
		f3;rmv file; {
>
>Name the files you want to delete from the archive disk.  Separate the names
>with spaces.
>
>Press \klist arch\e for a list of the files on the archive disk.
>
			cmd(^fbr -dv ), msg (^File\(s\) to be deleted from the archive disk: %p), msg(^Deleting files...), exec, msg, break(1);
			f1;; hist;
			f2;; hist;
			f3;; hist;
			f4;; hist;
			f6;list arch; call, cmd (^fbr -t), msg(^Examining the archive directory...), exec, msg, return;
			f7;manual; man (fbr);
			f8;done; msg, cmd, break;
		};
		f6;list arch.; cmd (^fbr -tv ), msg(^Examining the archive directory...), exec, msg, break(0);
		f7;manual; man (fbr);
		f8;done; msg, cmd, break;
        };
	f8;done; msg, cmd, break;
};
f6;dir mgmt; {
>
>\kthis dir?\e - Displays the name of the directory in which you are working.
>
>\kgoto dir\e - Makes another directory the "working directory" -- the directory
>            to which file manipulation commands automatically refer.
>
>\kcreate\e - Makes a new directory.
>
>\kdelete\e - Removes (destroys) a directory.  
>
>\krename\e - Gives a new name to a directory.
>
>\klistfiles\e - Lists the files in this directory.
>
>\kprotect\e - Lets you decide who will have access to a directory.
>
>\kdone\e - Cancels the command being built or returns to the previous keys.
>
	f1;this dir?; cmd (^pwd), exec, msg;
	f2;goto dir; {
>
>Select a directory.  It will be your new \"working\" directory; the
>directory to which file manipulation commands will automatically refer.
>
>\khome\e - Your login directory.
>
>\kparent\e - The directory above this one in the directory hierarchy.
>
>\kother\e - You will be prompted for the name of another directory.
>
		cmd ( ^cd ), msg (^Select the directory you want to go to: %%), exec, msg, next;
		f1;home; par ( \$HOME), msg;
		f2;parent; par ( ..), msg;
		f3;other; {
>
>Enter the name of the directory you want to go to.
>
		        msg (^Name the directory to go to: %f), msg, exec, break (2);
			f1;; hist;
			f2;; hist;
			f3;; hist;
			f4;; hist;
			f6;listfiles; call, cmd(^ls ), exec, msg, return;
			f7;manual; man(cd);
			f8;done; msg, break(2);
		};	
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (cd);
		f8;done; msg, break;
	};
	f3;create; {
>
>Enter a new directory name.  The new directory will be created as a
>subdirectory of the current directory.  
>
>After the directory has been created, you can make it your working 
>directory by using the \kgoto dir\e key.
>
		cmd (^mkdir ), msg (^Enter a name for the new directory: %F), msg, exec, next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f5;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (mkdir);
		f8;done; msg, cmd, break;
	};
	f4;delete; {
>
>Enter the name of the directory to be deleted.  
>
>You must remove all of the files from a directory before you can
>delete it.
>
		cmd (^rmdir ), msg (^Name the directory to be deleted: %f), next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (rmdir);
		f8;done; msg, cmd, break;
	}, {
>
>\kyes\e - The directory you named will be deleted.
>
>\kno\e - The directory you named will be left unchanged.
>
>\kdone\e - The same as \kno\e.
>
		msg (^Are you sure you want to delete `$$'? %%);
		f1;yes; msg, exec, cmd, break;
		f2;no; msg, cmd, break;
		f8;done; msg, cmd, break;
	};
        f5;rename; {
>
>Enter the name of a directory.
>
		cmd (^mv ), msg (^Enter the directory to rename: %F), next;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (mv);
		f8;done; msg, cmd, break;
	}, {
		msg (^Type the directory's new name: %F), msg, exec, next;
>
>Enter a new name for the directory.
>
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f5;; hist;
		f6;listfiles; call, cmd (^ls), msg, exec, return;
		f7;manual; man (mv);
		f8;done; msg, cmd, break;
	};
	f6;listfiles; cmd (^ls), msg, exec;
	f7;protect; {
>
>\kall\e - All users of your system, including you.
>
>\kgroup\e - The members of your group.   
>
>\kothers\e - All system users not in your group.
>
>\kmyself\e - You.
>	
        	cmd (^chmod ), msg (^To whom do you want to grant/deny access permission? %%), next;
		f1;all; par (a), msg, next;
		f2;group; par (g), msg, next;
		f3;others; par (o), msg, next;
		f4;myself; par (u), msg, next;
		f7;manual; man (chmod);
		f8;done; msg, cmd, break;
	}, {
>
		msg (^Select \"grant\" or \"deny\" permission: %%), next;
		f1;grant; par (+), next;
		f2;deny; par (-), next;
		f7;manual; man (chmod);
		f8;done; msg, cmd, break;
	}, {
>
>\kread\e - Permission to examine or copy the directory contents.
>
>\kwrite\e - Permission to delete or add to the directory as well as
>            to read it.
>
>\kexecute\e - Permission to search the directory (with \uls\n, for example). 
>
>\kread/write\e - A combination of \kread\e and \kwrite\e.
>
>\kread/exec\e - A combination of \kread\e and \kexecute\e.
>
>\kall\e - A combination of \kread\e, \kwrite\e, and \kexecute\e.
>
		msg (^Select the permission you want to grant or deny: %%), next;
		f1;read; par (r ), next;
		f2;write; par (w ), next;
		f3;execute; par (x ), next;
		f4;read/write; par(rw ), next;
		f5;read/exec; par(rx ), next;
		f6;all; par (rwx ), next;
		f7;manual; man (chmod);
		f8;done; msg, cmd, break;
	}, {
>
>Name the directory or directories whose access permission you want to change.
>Separate multiple directory names with spaces.
>
		msg (^Name the directory whose permission you\'re changing: %p), msg, exec, break;
		f1;; hist;
		f2;; hist;
		f3;; hist;
		f4;; hist;
		f6;listfiles; call, cmd (^ll ), msg, exec, return;
		f7;manual; man (chmod);
		f8;done; msg, cmd, break;
	};
	f8;done; msg, cmd, break;
};
f8;done; msg, break;
}
