#!/usr/bin/tttt -fc I!:{oooooooo_________________ ___oo_____ooooo___ooooo__ ___oo____oo____o_oo___oo_ ___oo____ooooooo_oo___oo_ ___oo____oo______oo___oo_ ___oo_____ooooo___oooo_o_ _________________________} x!:{ TEA OS v1.0.9 is Ready...} v:vBanner | #i: ###| The above is the "original" bootscreen ###| The rest of the story follows.. *:{==| PREAMBLE |==} L:lPREAMBLE_START Y:vBanner #| V@:dvLOG V@:dvLOG_start #Of course, this is TEA programming We can write verbatim documentation and comments in the most natural of ways without worry or concern. We sometimes shall do just that. V@:dvABOUT_TOS:{ #---[ABOUT TEA OS] NAME: TEA Operating System (also "TEA OS" or just "TOS") ARCHITECT: J. Willrich Lutalo SINCE: 9th APRIL, 2026 INTENT: To manifest a true general purpose, lightweight, minimal but powerful operating system that can essentially just fit inside a single string; to see what the limits of the mathematics of TRANSFORMATICS might be, and what we surely could accomplish with its proper use via modern portable computers. ABOUT: TEA OS is implemented using the Transforming Executable Alphabet (TEA) programming language. It is based on a specification first laid out in the TEA TAZ. It is a project originating from UGANDA. PROJECT HOME: Nuchwezi Research | https://tea.nuchwezi.com} #--[GLOBAL CONSTANTS] V@:dvOSName:{TEA OS} V@:dvOSName_short:{TOS} V@:dvOSVersion:{1.0.9} V:vSLOGAN:{TEA OS! T can fit in a string!} I!:{___________________}|V:vDELIM|V@:dvDELIM I!:{ =o==o==o==o==o==o==o= }|V:vDELIM2|V@:dvDELIM2 #--[GLOBAL VARIABLES] V:vUSERNAME:{user} # not used that much! #--[DATABASE VARIABLES] #Y@:dvLOG|i:{}|V@:dvLOG #all activity V@:dvLastPS:{} V@:dvLastCommand:{} V@:dvLastOutput:{} #TEA-DATABASE powered FILE-SYSTEM register #{F1|F2|...|FN} s.t NAME(Fi)=ID(Fi) Y@:dvFileList|I:{.}|V@:dvFileList ####| INTERFACE CONFIG VARIABLE # 0 forces original terminal mode: fit for TEA mobile IDE # 1 is mini-terminal mode: fit for CLI and other WEB # user can change this via commands: # uimini -> 1 # uilog -> 0 # will default to mini if not already set Y@:dvUIMODE_MINI|I:{1}|V@:dvUIMODE_MINI #--[SOME FUNCTIONS] #for presenting pretty message prompt.. # in vUIMODE_MINI=0 V:fPROMPT_DEFAULT:" # FIRST: IMPORTANTLY... v:vMSG #stores AI at invocation y@:dvDELIM|v:vD2 y:vMSG|x!:{ }|v:vMSG #affix space at prompt end i!:{} | g*:{ }:vD2:vMSG v:vMSG Y@:dfLogAI|v:f # a stealth import :) y:vMSG|e*:f #then show log+latest prompt Y@:dvLOG i: #returns input.. " Y:fPROMPT_DEFAULT|V@:dfPROMPT_DEFAULT #for presenting pretty message prompt.. # in vUIMODE_MINI=1 V:fPROMPT:" # FIRST: IMPORTANTLY... v:vMSG #stores AI at invocation #check if we should instead be using default ui y@:dvUIMODE_MINI | f!:^0$:lN_UIMODE_MINI y@:dfPROMPT_DEFAULT|v:fPROMPT_DEFAULT y:vMSG | E*:fPROMPT_DEFAULT q!: # no need to proceed.. l:lN_UIMODE_MINI #THEN imports... y@:dfLastIO|v:fLastIO y@:dfMakePS|v:fMakePS y@:dvDELIM|v:vD2 y:vMSG|x!:{ }|v:vMSG #affix space at prompt end i!:{} | g*:{ }:vD2:vMSG v:vMSG Y@:dfLogAI|v:f # a stealth import :) y:vMSG|e*:f #then show log+latest prompt #Y@:dvLOG E*:fMakePS|v:vNEXTPS E*:fLastIO #fetch last I/O x!:{ > }|#x*!:vNEXTPS i: #returns input.. " Y:fPROMPT|V@:dfPROMPT #login function V:fLogin:" #import some functions from database... y@:dfPROMPT_DEFAULT|v:fPROMPT y@:dfLogAI|v:fLogAI y@:dfLogO|v:fLogO y@:dfGreetUser|v:fGreetUser # show OS banner y@:dvLOG_start | v:vSCREEN e*:fLogAI #greet user via stored name.. y!@:dvUSERNAME | f!:^0$:lGREET_USER #Username not yet set, prompt and store l:lSET_USERNAME I!:{ Please set a Username:}|v:vPromptMSG e*:fLogAI y:vSCREEN | x*!:vPromptMSG | i: t!.:|v:|v!:|f:^0$:lSET_USERNAME y:|V@:dvUSERNAME # store in database e*:fLogAI l:lGREET_USER e*:fGreetUser|v:vGreetings e*:fLogO | e*:fPROMPT " #load username and greet V:fGreetUser:" y@:dvUSERNAME x:{ Hello, }|x!:{. Welcome to TOS!} " Y:fGreetUser|V@:dfGreetUser #for os name.. V:fOSHandle:" y@:dvOSName | v:vN y@:dvOSVersion | v:vV g*:{ v}:vN:vV " Y:fOSHandle|V@:dfOSHandle #for default prompt.. V:fMakePS:" z.:TIME |v:vT y@:dvOSName_short | v:vPWD v:vD:{>} g*:{/}:vPWD:vT:vD " Y:fMakePS|V@:dfMakePS #log last cmd+O V:fLogIO:" #load+execute function from database! y@:dfLastIO|e: v:vLastIO y@:dvLOG | v:vLOG g*:{ }:vLOG:vLastIO | v@:dvLOG " #suffix AI to log V:fLogAI:" v:vAI y@:dvLOG | v:vLOG g*:{ }:vLOG:vAI | v@:dvLOG #return AI y:vAI " #also make it a db function Y:fLogAI|v@:dfLogAI #store AI as last-O.. V:fLogO:" v@:dvLastOutput v@:dvDATABUFFER #also stash into special data buffer Y@:dvLastOutput " #fetch last I/O.. V:fLastIO:" y@:dvLastPS | v:vPS y@:dvLastCommand | v:vC y@:dvLastOutput | v:vO g*:{}:vPS:vC|v:vCC g*:{ }:vCC:vO " #store that function in the database too (so we can later use it in context-unaware functions). y:fLastIO|v@:dfLastIO L:lPREAMBLE_END #:{=================} *:{==|UTILITY SYSTEM |==} L:lSYS_UTILITY_START #--[UTILITY Functions] #fix URL V:fFixURL:" v:vURL|z: f:{^https?://}:lFINE y:vURL|x:{https://} v:vURL l:lFINE y:vURL " #reset+clear log V:fResetLog:" y@:dvLastOutput | v@:dvLastOutput_backup c!@:dvLOG c*:vLOG C!@:dvLastOutput y@:dfGreetUser|E:|v:vGreetings y@:dvLOG_start x*!:vGreetings " # make available for [db] import.. Y:fResetLog|V@:dfResetLog V:fGetLatestOutputBuffer:" y@:dvLastOutput_backup f!:^$:lN_USED_BACKUP y@:dvLastOutput l:lN_USED_BACKUP c@:dvLastOutput_backup " Y:fGetLatestOutputBuffer|V@:dfGetLatestOutputBuffer L:lSYS_UTILITY_END #:{=================} *:{==|HELP SYSTEM |==} L:lSYS_HELP_START #--[HELP/DOC Functions] #present USER INTERFACE help-category commands V:fGetUIMenu:" y@:dfOSHandle|e:|x!:{ INTERFACE System Commands: uimini uilog} v:vMSG y@:dvDELIM2|v:vD g*:{}:vD:vMSG:vD " #present FILE help-category commands V:fGetFileCMDMenu:" y@:dfOSHandle|e:|x!:{ FILE System Commands: create FILENAME init FILENAME write FILENAME (rename | rn | mv | move) FILENAME NEWNAME (copy|clone) FILE1 FILE2 exists FILENAME find PATTERN (show | cat | read) FILENAME export FILENAME (del | delete | rm) FILENAME (ls | dir | files) PATTERN} v:vMSG y@:dvDELIM2|v:vD g*:{}:vD:vMSG:vD " #present UTILITIES help-category commands V:fGetUtilityMenu:" y@:dfOSHandle|e:|x!:{ UTILITY System Commands: clear date echo MESSAGE exit export (fetch | web) [URL] [FILENAME] logout math EXPRESSION print tea CODE time timestamp username NAME whoami | name} v:vMSG y@:dvDELIM2|v:vD g*:{}:vD:vMSG:vD " #present main help-category commands V:fGetHelpMenu:" y@:dfOSHandle|e:|x!:{ HELP System Commands: about (help | man | whatis | info) [NAME] help-file help-help help-prog help-ui help-util} v:vMSG y@:dvDELIM2|v:vD g*:{}:vD:vMSG:vD " #present main about os info V:fGetAboutTOS:" y@:dfOSHandle|e:|x:{ABOUT: } v:vMSG y@:dvABOUT_TOS|x*:vMSG|v:vMSG y@:dvDELIM2|v:vD g*:{}:vD:vMSG:vD " #present help-on a given topic V:fGetHelpOn:" #asumes topic is passed via AI v:vHelpTOPIC #some imports... y@:dfGetFilenameProtocolMSG|v:fGetFilenameProtocolMSG E*:fGetFilenameProtocolMSG | v:vFILENAME_PROTOCOL #set default.. r@:{That help topic [#vHelpTOPIC#] is not understood or supported. Try the 'help' command to see what help commands there are. For example 'help whatis'}|v:vMSG y:vHelpTOPIC #> help about f!:^about$:lN_h0 v:vMSG:{about <~ Displays basic info about the currently running version of the TEA Operating System.} j:lh1_present l:lN_h0 #> help whatis f!:^whatis$:lN_h1 v:vMSG:{whatis NAME <~ Displays help info about a given system command or user program.} j:lh1_present l:lN_h1 #> help man f!:^man$:lN_h1b v:vMSG:{man NAME <~ Displays help info about a given system command or user program. It is just another alias for 'whatis' or 'help'} j:lh1_present l:lN_h1b #> help help f!:^help$:lN_h2 v:vMSG:{Present menu for user to access help about all available [essential] commands based on category.} j:lh1_present l:lN_h2 f!:^help-file$:lN_h3 v:vMSG:{Display all available commands in the FILE I/O category or sub-system.} j:lh1_present l:lN_h3 f!:^help-prog$:lN_h4 v:vMSG:{Display all available commands in the PROGRAMMING category or sub-system.} j:lh1_present l:lN_h4 f!:^help-util$:lN_h5 v:vMSG:{Display all available commands in the UTILITIES category or sub-system.} j:lh1_present l:lN_h5 f!:^help-help$:lN_h6 v:vMSG:{Display help on how to use the HELP facility or sub-system.} j:lh1_present l:lN_h6 f!:^clear$:lN_hu0 v:vMSG:{clear <~ Resets and clears the current TEA OS session log since login.} j:lh1_present l:lN_hu0 f!:{^(fetch|web)$}:lN_hu1 v:vCMD r@:{#vCMD# URL <~ fetch and output contents of the specified [online/network] resource. #vCMD# URL FILENAME <~ fetch and save contents at URL into file record named FILENAME. #vFILENAME_PROTOCOL#} | v:vMSG j:lh1_present l:lN_hu1 f!:^tea$:lN_hu2 v:vMSG:{tea CODE.. <~ take everything following the keyword 'tea' as a TEA program, run and output the result: It's a simple way to write and run basic TEA programs (TEA-one-liners) in TOS.} j:lh1_present l:lN_hu2 f!:^math$:lN_hu3 v:vMSG:{math EXPRESSION <~ execute basic mathematics on the command-line as specified in EXPRESSION.} j:lh1_present l:lN_hu3 f!:^date$:lN_hu4 v:vMSG:{date <~ Show the current date.} j:lh1_present l:lN_hu4 f!:^time$:lN_hu5 v:vMSG:{time <~ Show the current time.} j:lh1_present l:lN_hu5 f!:^timestamp$:lN_hu6 v:vMSG:{timestamp <~ Show the current timestamp.} j:lh1_present l:lN_hu6 f!:^print$:lN_hu7 v:vMSG:{print <~ Show or preview current output buffer contents (usually, output of last command). After clearing log, but also after exit/system shutdown/login also shows final output before the log was reset.} j:lh1_present l:lN_hu7 f!:^export$:lN_hu8 r@:{export <~ Take the output of the last command or rather, current contents of the output buffer and export that outside the operating system (also terminates the operating system session). export FILENAME <~ Exit the system, outputting the contents of given file. #vFILENAME_PROTOCOL#} | v:vMSG j:lh1_present l:lN_hu8 f!:^exit$:lN_hu9 v:vMSG:{exit <~ Ends the TOS session returning nothing.} j:lh1_present l:lN_hu9 f!:^logout$:lN_hu10 v:vMSG:{logout <~ Resets username and system logs and ends the TOS session returning nothing.} j:lh1_present l:lN_hu10 f!:^username$:lN_hu11 v:vMSG:{username NAME <~ Overrides current username with specified value.} j:lh1_present l:lN_hu11 f!:^help-ui$:lN_h12 v:vMSG:{Display all available commands in the USER INTERFACE category or sub-system.} j:lh1_present l:lN_h12 f!:^uimini$:lN_h13 v:vMSG:{uimini <~ Configure TEA OS interface to render using mini-terminal mode. Setting persists across logins until changed. This mode is suitable for environments such as using TOS on some Desktop Computer Systems.} j:lh1_present l:lN_h13 f!:^uilog$:lN_h14 v:vMSG:{uilog <~ Configure TEA OS interface to render using long/log-terminal mode. Setting persists across logins until changed. This mode is suitable for environments such as using TOS on the TEA MOBILE IDE.} j:lh1_present l:lN_h14 f!:^whoami$:lN_h15 v:vCMD r@:{#vCMD# <~ Display the NAME of currently active USER.} | v:vMSG j:lh1_present l:lN_h15 f!:^create$:lN_h16 r@:{create FILENAME <~ Creates blank file with name FILENAME. #vFILENAME_PROTOCOL#}|v:vMSG j:lh1_present l:lN_h16 f!:{^(ls|dir|files)$}:lN_h17 v:vCMD r@:{#vCMD# <~ Display list of ALL available files. #vCMD# PATTERN <~ Display list of ONLY files matching regular expression PATTERN.} | v:vMSG j:lh1_present l:lN_h17 f!:^init$:lN_h18 r@:{init FILENAME <~ Create a file using the given name and the currently available input/last-output (or the PRINT buffer) or blank if none. #vFILENAME_PROTOCOL#}|v:vMSG j:lh1_present l:lN_h18 f!:^write$:lN_h19 r@:{write FILENAME <~ Write the contents of the current available input/last-output (or the PRINT buffer) or blank if none, to a file with the specified name. If the file already exists, essentially overwrites its contents. #vFILENAME_PROTOCOL#} | v:vMSG j:lh1_present l:lN_h19 f!:{^(show|cat|read)$}:lN_h20 v:vCMD r@:{#vCMD# FILENAME <~ Preview the contents of given file. #vFILENAME_PROTOCOL#} | v:vMSG j:lh1_present l:lN_h20 f!:^echo$:lN_h21 v:vMSG:{echo MESSAGE <~ Simply print MESSAGE as is.} j:lh1_present l:lN_h21 f!:{^(find)$}:lN_h22 v:vCMD r@:{#vCMD# PATTERN <~ Display list of ONLY files matching regular expression PATTERN.} | v:vMSG j:lh1_present l:lN_h22 f!:{^(del|delete|rm)$}:lN_h23 v:vCMD r@:{#vCMD# PATTERN <~ Remove from storage, any and all files whose name matches PATTERN.} | v:vMSG j:lh1_present l:lN_h23 f!:{^(rename|rn|mv|move)$}:lN_h24 v:vCMD r@:{#vCMD# FILENAME NEWNAME <~ Change the name of an existing file from FILENAME to NEWNAME. #vFILENAME_PROTOCOL#} | v:vMSG j:lh1_present l:lN_h24 f!:{^(exists)$}:lN_h25 v:vCMD r@:{#vCMD# FILENAME <~ Show whether or not a file named FILENAME exists. #vFILENAME_PROTOCOL#} | v:vMSG j:lh1_present l:lN_h25 f!:{^(copy|clone)$}:lN_h26 v:vCMD r@:{#vCMD# FILENAME FILE2 <~ Copies contents of FILENAME to FILE2 creating the destination if it doesn't exist. #vFILENAME_PROTOCOL#} | v:vMSG j:lh1_present l:lN_h26 l:lh1_present y@:dvDELIM2|v:vD g*:{}:vD:vMSG:vD " L:lSYS_HELP_END #:{=================} *:{==|FILE SYSTEM |==} L:lSYS_FILE_START #--[FILE SYSTEM Functions] #f(N)->DFS_N V:fGetFilenameProtocolMSG:"i!:{Valid FILENAME should consist of ONLY letters a-zA-Z, numbers 0-9, underscore _ and/or a dot .}" Y:fGetFilenameProtocolMSG|V@:dfGetFilenameProtocolMSG #f(N)->DFS_N V:fGenDBFilename:"x:{DFS_}" Y:fGenDBFilename|V@:dfGenDBFilename #f(DFS_N)->N V:fDecodeDBFilename:"d:^DFS_" Y:fDecodeDBFilename|V@:dfDecodeDBFilename #f(N)->0|1 V:fIsFileNameValid:" f!:^[a-z0-9_]+(\.[a-z0-9]+)?$:lBAD_FILE_NAME i!:1|q!: l:lBAD_FILE_NAME i!:0 " Y:fIsFileNameValid|V@:dfIsFileNameValid #create FILENAME V:fCreateFile:" # first, grab incoming function argument... v:vFILENAME|t!.:|v:vFNAME #then import functions.. y@:dfGenDBFilename|v:fGenDBFilename y@:dfGetLatestOutputBuffer|v:fGetLatestOutputBuffer y@:dfIsFileNameValid|v:fIsFileNameValid y:vFNAME | f:^$:lNFINE # filename shouldn't be blank # file name should conform to accepted patterns y:vFNAME | E*:fIsFileNameValid | f!:0:lGOOD_FILENAME r@:{Invalid File Name [#vFNAME#]! FILE NOT CREATED.}|q!: l:lGOOD_FILENAME # fetch current file name list.. y@:dvFileList | v:vFileList # ensure file name doesn't yet exist in records #e.g v:vFileList:{F1|F2|F33|File|File} #v:vFNAME:{f1} # check if file name is unique r@:{(^#vFNAME#\|)|(\|#vFNAME#\|)|(\|#vFNAME#$)}|v:vFNAME_REGEX y:vFileList | f*!:vFNAME_REGEX:lFNAME_UNIQUE:lFNAME_DUPLICATE l:lFNAME_UNIQUE # add name to file list g*:{|}:vFileList:vFNAME | v:vFileList | v@:dvFileList #also create blank file record in db filesystem y:vFNAME|E*:fGenDBFilename|v:vdFNAME v@:dvDATA:{} # we'll write empty file r@:{y@:dvDATA|v@:#vdFNAME#}|E: i!:{CREATED NEW BLANK FILE: }|x*!:vFNAME q!: l:lFNAME_DUPLICATE i!:{File Already Exists! NOT DUPLICATING FILE: }|x*!:vFNAME q!: l:lNFINE i!:{Invalid [blank] File Name! FILE NOT CREATED.} " Y:fCreateFile|V@:dfCreateFile #delete FILENAME V:fDeleteFile:" # first, grab incoming function argument... v:vFILENAME|t!.:|v:vFNAME #then import functions.. y@:dfGenDBFilename|v:fGenDBFilename y@:dfIsFileNameValid|v:fIsFileNameValid y:vFNAME | f:^$:lNFINE # filename shouldn't be blank # file name should conform to accepted patterns y:vFNAME | E*:fIsFileNameValid | f!:0:lGOOD_FILENAME r@:{Invalid File Name [#vFNAME#]! FILE NOT DELETED.}|q!: l:lGOOD_FILENAME # fetch current file name list.. y@:dvFileList | v:vFileList # remove file name from records #v:vFileList:{F1|F2|F33|F3|File|File} #v:vFNAME:{File} # get filename pattern # create delete filename patterns + apply them.. r@:{(^#vFNAME#\|)|(\|#vFNAME#$)}|v:vFNAME_REGEX_ENDS r@:{(\|#vFNAME#\|)}|v:vFNAME_REGEX_MID r@:{^#vFNAME#$}|v:vFNAME_REGEX_ALL # use it to del y:vFileList | d*:vFNAME_REGEX_ENDS | v:vFileList y:vFileList | d*:vFNAME_REGEX_ALL | v:vFileList v:vDIV:{|} r*:vFileList:vFNAME_REGEX_MID:vDIV | v:vFileList # update file list y:vFileList | v@:dvFileList #also delete file record from db filesystem y:vFNAME|E*:fGenDBFilename|v:vdFNAME r@:{c!@:#vdFNAME#}|E: i!:{DELETED FILE: }|x*!:vFNAME q!: l:lFNAME_DUPLICATE i!:{Found Duplicate Files! NOT DELETING FILE: }|x*!:vFNAME q!: l:lNFINE i!:{Invalid [blank] File Name! FILE NOT DELETED.} " Y:fDeleteFile|V@:dfDeleteFile #ls | dir | files V:fShowFilesList:" # takes no parameters ;) # fetch current file name list.. y@:dvFileList #process and present.. h!:{\|}|d:{\|} " #(ls | dir | files | find) PATTERN V:fSearchFilesList:" # takes file regex pattern parameter v:vREGEX_PATTERN # fetch current file name list.. y@:dvFileList #process and present.. h!:{\|}|d:{\|} # only keep what matches... k*:vREGEX_PATTERN " #(del | delete | rm) PATTERN V:fDeleteFilesList:" # takes file regex pattern parameter v:vREGEX_PATTERN #imports.. y@:dfDeleteFile | v:fDeleteFile # fetch current file name list.. y@:dvFileList #process and present.. h!:{\|}|d:{\|} # only keep what matches... k*:vREGEX_PATTERN g:{|} | v:vDelFileList | v:vDelFileListORIG f:^$:NO_FILES_TO_DELETE # to track files we couldn't delete v:vNOTDelFileList:{} # go through files and delete.. v:vNCOUNTER:0 v:vNCOUNTER_DEL:0 l:lSTART_DEL y:vDelFileList f:^$:lDONE_DEL #fetch.. y:vDelFileList | d!:{^[^\|]+\|?} d:{\|} | v:vDelFileNAME #if actually blank.. go pop f:^$:lPOPDEL_LIST # delete file.. E*:fDeleteFile #q!: # check... f!:{DELETED FILE}:lDELETE_FAILED:lDELETED_OK l:lDELETE_FAILED # add name to NOT deleted file list g*:{|}:vNOTDelFileList:vDelFileNAME | v:vNOTDelFileList j:lDONE_DELETED_OK l:lDELETED_OK y:vNCOUNTER_DEL | x!:+1 | r.: | v:vNCOUNTER_DEL l:lDONE_DELETED_OK y:vNCOUNTER | x!:+1 | r.: | v:vNCOUNTER #pop.. l:lPOPDEL_LIST y:vDelFileList | d:{^[^\|]+\|?} | v:vDelFileList #x:{Remaining: } | q!: j:lSTART_DEL # iterate l:lDONE_DEL r@:{#vNCOUNTER# - #vNCOUNTER_DEL#}|r.:|v:vNCOUNTER_NDEL y:vNCOUNTER_DEL | f:^1$:lDEL_REP_1 r@:{DELETED #vNCOUNTER_DEL# file[s] from list: #vDelFileListORIG# EXCEPT #vNCOUNTER_NDEL#: #vNOTDelFileList#}|q!: l:lDEL_REP_1 y:vNCOUNTER | f!:^1$:lDEL_REP_2 r@:{DELETED ONLY #vNCOUNTER_DEL# file: #vDelFileListORIG# }|q!: l:lDEL_REP_2 r@:{DELETED ONLY #vNCOUNTER_DEL# file from list: #vDelFileListORIG# EXCEPT #vNCOUNTER_NDEL#: #vNOTDelFileList#}|q!: l:NO_FILES_TO_DELETE r@:{#vREGEX_PATTERN# matched no FILES! NO FILE WAS DELETED} " #init FILENAME V:fInitFile:" v:vFILENAME|t!.:|v:vFNAME #imports... y@:dfCreateFile|v:fCreateFile y@:dfGenDBFilename|v:fGenDBFilename y@:dfGetLatestOutputBuffer|v:fGetLatestOutputBuffer y@:dfIsFileNameValid|v:fIsFileNameValid y:vFNAME | E*:fIsFileNameValid | f!:0:lGOOD_FILENAME r@:{Invalid File Name [#vFNAME#]! FILE NOT CREATED.}|q!: l:lGOOD_FILENAME # then, try to create the file... y:vFNAME | E*:fCreateFile # check if it was created... f!:{CREATED NEW BLANK FILE}:lFILE_NOT_CREATED # get name of that newly created file... y:vFNAME|E*:fGenDBFilename|v:vdFNAME # get current output buffer y@:dvDATABUFFER | v@:dvDATA # only if it was empty then... f!:^$:lFINE_DATA_BUFFER # use print buffer... e*:fGetLatestOutputBuffer | v@:dvDATA l:lFINE_DATA_BUFFER # store it into file system record... r@:{y@:dvDATA|v@:#vdFNAME#}|E: #a test... #r@:{y@:#vdFNAME#}|E: #x:{File now contains: #}|q!: i!:{CREATED and INITIALIZED NEW File: }|x*!:vFNAME q!: l:lFILE_NOT_CREATED i!:{FAILED TO CREATE FILE: } | x*!:vFNAME " #write FILENAME V:fWriteFile:" v:vFILENAME|t!.:|v:vFNAME #imports... y@:dfCreateFile|v:fCreateFile y@:dfGenDBFilename|v:fGenDBFilename y@:dfGetLatestOutputBuffer|v:fGetLatestOutputBuffer y@:dfIsFileNameValid|v:fIsFileNameValid y:vFNAME | E*:fIsFileNameValid | f!:0:lGOOD_FILENAME r@:{Invalid File Name [#vFNAME#]! FILE NOT WRITTEN.}|q!: l:lGOOD_FILENAME # then, try to create the file... y:vFNAME | E*:fCreateFile # check if it was created... f!:{(CREATED NEW BLANK FILE)|(NOT DUPLICATING FILE)}:lFILE_NOT_CREATED # get name of that file... y:vFNAME|E*:fGenDBFilename|v:vdFNAME # get current output buffer y@:dvDATABUFFER | v@:dvDATA # only if it was empty then... f!:^$:lFINE_DATA_BUFFER # use print buffer... e*:fGetLatestOutputBuffer | v@:dvDATA l:lFINE_DATA_BUFFER # store it into file system record... r@:{y@:dvDATA|v@:#vdFNAME#}|E: i!:{DATA WRITTEN to File: }|x*!:vFNAME q!: l:lFILE_NOT_CREATED i!:{FAILED TO WRITE FILE: } | x*!:vFNAME " #savedata FILENAME #reads special buffer v@:dvDATABUFFER V:fSaveDataToFile:" v:vFILENAME|t!.:|v:vFNAME #imports... y@:dfCreateFile|v:fCreateFile y@:dfGenDBFilename|v:fGenDBFilename y@:dfGetLatestOutputBuffer|v:fGetLatestOutputBuffer y@:dfIsFileNameValid|v:fIsFileNameValid y:vFNAME | E*:fIsFileNameValid | f!:0:lGOOD_FILENAME r@:{Invalid File Name [#vFNAME#]! FILE NOT WRITTEN.}|q!: l:lGOOD_FILENAME # then, try to create the file... y:vFNAME | E*:fCreateFile # check if it was created... f!:{(CREATED NEW BLANK FILE)|(NOT DUPLICATING FILE)}:lFILE_NOT_CREATED # get name of that file... y:vFNAME|E*:fGenDBFilename|v:vdFNAME # get current data buffer # and store it into file system record... r@:{y@:dvDATABUFFER|v@:#vdFNAME#}|E: i!:{DATA WRITTEN to File: }|x*!:vFNAME q!: l:lFILE_NOT_CREATED i!:{FAILED TO WRITE FILE: } | x*!:vFNAME " #read FILENAME V:fReadFile:" v:vFILENAME|t!.:|v:vFNAME #imports... y@:dfGenDBFilename|v:fGenDBFilename y@:dfIsFileNameValid|v:fIsFileNameValid y:vFNAME | E*:fIsFileNameValid | f!:0:lGOOD_FILENAME r@:{Invalid File Name [#vFNAME#]! FILE NOT READ.}|q!: l:lGOOD_FILENAME # then, try to read the file... y:vFNAME|E*:fGenDBFilename|v:vdFNAME r@:{y@:#vdFNAME#}|E: " y:fReadFile | v@:dfReadFile #exists FILENAME V:fFileExists:" # first, grab incoming function argument... v:vFILENAME|t!.:|v:vFNAME #then import functions.. y@:dfGenDBFilename|v:fGenDBFilename y@:dfIsFileNameValid|v:fIsFileNameValid y:vFNAME | f:^$:lNFINE y:vFNAME | E*:fIsFileNameValid | f!:0:lGOOD_FILENAME r@:{Invalid File Name [#vFNAME#]! FILE MAY NOT EXIST.}|q!: l:lGOOD_FILENAME # fetch current file name list.. y@:dvFileList | v:vFileList #v:vFileList:{F1|F2|F33|F3|File|File} #v:vFNAME:{f1} # create delete filename patterns + apply them.. r@:{(^#vFNAME#\|)|(\|#vFNAME#$)}|v:vFNAME_REGEX_ENDS r@:{(\|#vFNAME#\|)}|v:vFNAME_REGEX_MID r@:{^#vFNAME#$}|v:vFNAME_REGEX_ALL # use it test for existence y:vFileList | f*:vFNAME_REGEX_ENDS:lFILE_EXISTS f*:vFNAME_REGEX_ALL:lFILE_EXISTS f*:vFNAME_REGEX_MID:lFILE_EXISTS i!:{FILE DOES NOT EXIST}|q!: l:lFILE_EXISTS i!:{FILE EXISTS} q!: l:lNFINE i!:{Invalid [blank] File Name! FILE DOES NOT EXIST.} " L:lSYS_FILE_END #:{=================} *:{==|SYSTEM SHELL |==} L:lSYS_SHELL_START E*:fLogin #---[ Main LOOP ] L:lSTART_Main # present default prompt.. E*:fMakePS V@:dvLastPS E*:fPROMPT E*:fLogAI #clean+process input.. V:vIN_raw t!.:| v:vIN_clean Z:|v:vIN_clean_lc #what did we get? y:vIN_clean_lc #preliminary processing... # a subsystem.. ###((FILE System)) #> create FILENAME F!:^create\s+.*$:lN_CRT_FILE Y:vIN_raw|t!.: V@:dvLastCommand d:^\S+\s+|V:vFileName E*:fCreateFile | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_CRT_FILE #> ls | dir | files F!:{^(ls|dir|files)$}:lN_LIST_FILES V@:dvLastCommand E*:fShowFilesList | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_LIST_FILES #> (ls | dir | files | find) PATTERN F!:{^(ls|dir|files|find)\s+(\S+\s*)+$}:lN_SEARCH_FILES Y:vIN_raw|t!.: V@:dvLastCommand d:^\S+\s+|V:vFilePattern E*:fSearchFilesList | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_SEARCH_FILES #> (del | delete | rm) PATTERN F!:{^(del|delete|rm)\s+(\S+\s*)+$}:lN_DEL_FILES Y:vIN_raw|t!.: V@:dvLastCommand d:^\S+\s+|V:vFilePattern E*:fDeleteFilesList | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_DEL_FILES #> init FILENAME F!:^init\s+.*$:lN_INIT_FILE Y:vIN_raw|t!.: V@:dvLastCommand d:^\S+\s+|V:vFileName E*:fInitFile | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_INIT_FILE #> write FILENAME F!:^write\s+.*$:lN_WRITE_FILE Y:vIN_raw|t!.: V@:dvLastCommand d:^\S+\s+|V:vFileName E*:fWriteFile | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_WRITE_FILE #> (show|cat|read) FILENAME F!:{^(show|cat|read)\s+.*$}:lN_READ_FILE Y:vIN_raw|t!.: V@:dvLastCommand d:^\S+\s+|V:vFileName E*:fReadFile | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_READ_FILE #> exists FILENAME F!:{^(exists)\s+.*$}:lN_EXISTS_FILE Y:vIN_raw|t!.: V@:dvLastCommand d:^\S+\s+|V:vFileName E*:fFileExists | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_EXISTS_FILE #> (rename|rn|mv|move) FILENAME NEWNAME F!:{^(rename|rn|mv|move)\s+([a-z0-9_]+(\.[a-z0-9]+)?)\s+([a-z0-9_]+(\.[a-z0-9]+)?)$}:lN_RENAME_FILE Y:vIN_raw|t!.: V@:dvLastCommand d:^\S+\s+|V:vFileNames Y:vFileNames | D:\s+.*$ | V:vFileName Y:vFileNames | D!:\s+.*$ | V:vNewName #check.. #R@:{Renaming #vFileName# to #vNewName#} | q!: # ensure source file exists... Y:vFileName | E*:fFileExists F!:{^FILE EXISTS$}:lCANNOT_RENAME # read src into data buffer Y:vFileName | E*:fReadFile | v@:dvDATABUFFER # write data buffer into new file Y:vNewName | E*:fSaveDataToFile | v:vWRITELOG # delete old file Y:vFileName | E*:fDeleteFile R@:{File #vFileName# RENAMED #vNewName# With status: #vWRITELOG#} E*:fLogO J:lFIN_CMD_PROCESSING l:lCANNOT_RENAME R@:{File #vFileName# does NOT EXIST! RENAME Operation ABANDONED} E*:fLogO J:lFIN_CMD_PROCESSING L:lN_RENAME_FILE #> (copy|clone) FILE1 FILE2 F!:{^(copy|clone)\s+([a-z0-9_]+(\.[a-z0-9]+)?)\s+([a-z0-9_]+(\.[a-z0-9]+)?)$}:lN_CLONE_FILE Y:vIN_raw|t!.: V@:dvLastCommand d:^\S+\s+|V:vFileNames Y:vFileNames | D:\s+.*$ | V:vFileName Y:vFileNames | D!:\s+.*$ | V:vFileName2 #check.. #R@:{Cloning #vFileName# to #vFileName2#} | q!: # ensure source file exists... Y:vFileName | E*:fFileExists F!:{^FILE EXISTS$}:lCANNOT_CLONE # read src into data buffer Y:vFileName | E*:fReadFile | v@:dvDATABUFFER # write data buffer into new file Y:vFileName2 | E*:fSaveDataToFile | v:vWRITELOG R@:{File #vFileName# CLONED TO #vFileName2# With status: #vWRITELOG#} E*:fLogO J:lFIN_CMD_PROCESSING l:lCANNOT_CLONE R@:{File #vFileName# does NOT EXIST! CLONE Operation ABANDONED} E*:fLogO J:lFIN_CMD_PROCESSING L:lN_CLONE_FILE #> export FILENAME F!:^export\s+.*$:lN_EXPORT_FILE Y:vIN_raw|t!.: V@:dvLastCommand #exit via file export.. d:^\S+\s+|V:vFileName E*:fReadFile | v:vLOG # read file E*:fResetLog # reset log # Gracefully quit... E*:fOSHandle | X:{Thanks for Using } V:vMSG G*!:vDELIM2:vFileName:vLOG:vMSG J:lEXIT_Main L:lN_EXPORT_FILE ###((END FILE System)) # a subsystem.. ###((INTERFACE System)) #> uimini F!:^uimini$:lN_UIMINI V@:dvLastCommand V@:dvUIMODE_MINI:{1} I!:{TOS Mini-Interface Mode Activated} | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_UIMINI #> uilog F!:^uilog$:lN_UILOG V@:dvLastCommand V@:dvUIMODE_MINI:{0} I!:{TOS Log-Interface Mode Activated} | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_UILOG ###((END INTERFACE System)) # a subsystem.. ###((HELP System)) #> about F!:^about$:lN_ABOUT V@:dvLastCommand E*:fGetAboutTOS | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_ABOUT #> help | man | whatis | info F!:{^(help|man|whatis|info)$}:lN_HELP V@:dvLastCommand E*:fGetHelpMenu | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_HELP #> (help|man|whatis|info) NAME F!:{^(help|man|whatis|info)\s+(\S+\s*)+$}:lN_HELP_TOPIC Y:vIN_raw|t!.: V@:dvLastCommand #extract+process topic.. d:{^\S+\s+} | E*:fGetHelpOn | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_HELP_TOPIC #> help-file[s]? F!:^help-file[s]?$:lN_HELP_FILE |V@:dvLastCommand E*:fGetFileCMDMenu | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_HELP_FILE #> help-util[s]? F!:^help-util[s]?$:lN_HELP_UT V@:dvLastCommand E*:fGetUtilityMenu | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_HELP_UT #> help-ui[s]? F!:^help-ui[s]?$:lN_HELP_UI V@:dvLastCommand E*:fGetUIMenu | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_HELP_UI #> help-help[s]? F!:^help-help[s]?$:lN_HELP_HELP V@:dvLastCommand E*:fGetHelpMenu X:{ To use or access help on any topic in the system, use any of the commands presented in the following Menu. } X!:{ Each of those commands leads you to further information about help on other commands. For example > help help-util Will explain what the help-util command is all about.} E*:fLogO J:lFIN_CMD_PROCESSING L:lN_HELP_HELP ###((END HELP System)) # a subsystem.. ###((UTILITY System)) #> echo MESSAGE F!:^echo.*$:lN_ECHO Y:vIN_raw|t!.: d:^\S+\s*|V:vMESSAGE X:{echo } |V@:dvLastCommand Y:vMESSAGE E*:fLogO J:lFIN_CMD_PROCESSING L:lN_ECHO #> (fetch|web) URL F!:{^(fetch|web)\s+\S*$}:lN_FETCH Y:vIN_raw|t!.: V@:dvLastCommand #extract url.. d:{^\S+\s+} E*:fFixURL W: #do the web.. E*:fLogO J:lFIN_CMD_PROCESSING L:lN_FETCH #> tea CODE F!:^tea\s+[\S]+.*$:lN_TEA Y:vIN_raw|t!.: #extract code.. d:^\S+\s+|V:vTEACode X:{tea } |V@:dvLastCommand Y:vTEACode E: #do the tea.. E*:fLogO J:lFIN_CMD_PROCESSING L:lN_TEA #> math EXPRESSION F!:^math\s+[\S]+.*$:lN_MATH Y:vIN_raw|t!.: #extract expression.. d:^\S+\s+|V:vMathExp X:{math } |V@:dvLastCommand Y:vMathExp R.: #do the math.. E*:fLogO J:lFIN_CMD_PROCESSING L:lN_MATH #> username NAME F!:^username\s+[\S]+.*$:lN_SETUSER V@:dvLastCommand #extract expression.. Y:vIN_raw|t!.: d:^\S+\s+ V@:dvUSERNAME #update db E*:fLogO J:lFIN_CMD_PROCESSING L:lN_SETUSER #> (whoami|name) F!:{^(whoami|name)$}:lN_WHOAMI V@:dvLastCommand Y@:dvUSERNAME E*:fLogO J:lFIN_CMD_PROCESSING L:lN_WHOAMI #> time F!:^time$:lN_TIME v@:dvLastCommand #show cur.time.. Z.:TIME | E*:fLogO #present+log I/O J:lFIN_CMD_PROCESSING L:lN_TIME #> date F!:^date$:lN_DATE v@:dvLastCommand Z.:DATE | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_DATE #> timestamp F!:^timestamp$:lN_TSTAMP v@:dvLastCommand Z.:TIMESTAMP | E*:fLogO J:lFIN_CMD_PROCESSING L:lN_TSTAMP #> clear F!:^clear$:lN_CLEAR v@:dvLastCommand E*:fResetLog E*:fLogO J:lFIN_CMD_PROCESSING L:lN_CLEAR #> print F!:^print$:lN_PRINT V@:dvLastCommand E*:fGetLatestOutputBuffer E*:fLogO J:lFIN_CMD_PROCESSING L:lN_PRINT #> logout F!:^logout$:lN_LOGOUT C!@:dvUSERNAME # delete username C*:vUSERNAME # also clear vault E*:fResetLog # reset log # ensure to clear log backup too! C@:dvLastOutput_backup # Gracefully quit... E*:fOSHandle | X:{You have SIGNED OUT! Thanks for Using } J:lEXIT_Main L:lN_LOGOUT #> exit F!:^exit$:lN_EXIT #don't log input cmd. E*:fResetLog # reset log #prepare for immediate exit.. # Gracefully quit... E*:fOSHandle | X:{Thanks for Using } J:lEXIT_Main L:lN_EXIT #> export F!:^export$:lN_EXPORT #don't log input cmd. #exit via export.. Y@:dvLOG|V:vLOG E*:fResetLog # reset log # Gracefully quit... E*:fOSHandle | X:{Thanks for Using } V:vMSG G*!:vDELIM2:vLOG:vMSG J:lEXIT_Main L:lN_EXPORT ###((END UTILITY System)) ###((CATCH-ALL)) #if we came this far #then it's CNF! F:^$:lFIN_CMD_PROCESSING Y:vIN_raw | V@:dvLastCommand # log unknown command I!:{--COMMAND NOT FOUND | INVALID COMMAND--} E*:fLogO J:lFIN_CMD_PROCESSING ###((END CATCH-ALL)) #we only naturally get here for properly #processed commands.. L:lFIN_CMD_PROCESSING #for non-exit commands, we want to ensure #we log user response from latest command.. E*:fLogAI J:lSTART_Main ####[End Main LOOP] #outside shell.. quitting L:lEXIT_Main #delete session log from db C!@:dvLOG Q!: #quit+return AI L:lSYS_SHELL_END #:{=================}