<> <> DIRECTORY AMBridge USING [TVForReferent], Atom USING [GetPName, Gensym], CedarVersion USING [major, minor, patch], CIFS USING [Error, GetFC, Open, read], Commander USING [Register, CommandProc, Handle], CommandProcOps USING [CheckForAbort, EventFailed, GetTheFile], ConvertUnsafe USING [AppendRope], Directory USING [DeleteFile, Error, GetProperty, GetProps, Lookup, PutProperty, Rename, ignore], File USING [Capability, GetSize], FileStream USING [SetLeaderPropertiesForCapability], FileIO USING [Open, OpenFailed, CapabilityFromStream, StreamFromCapability], IO USING [AppendStreams, card, Close, CR, CreateEditedStream, CreateProcsStream, CreateRefStreamProcs, DeliverWhenProc, EndOf, EraseChar, ESC, GetBlock, GetLength, GetOutputStreamRope, GetRefAny, GetToken, GreenwichMeanTime, IDProc, int, LookupData, PeekChar, Put, PutBlock, PutChar, PutF, PutRope, RIS, ROPE, rope, ROS, SetEcho, SetLength, Signal, SkipOver, SP, StoreData, STREAM, time, TokenProc, UserAborted, WhiteSpace], List USING [DReverse, Sort, CompareProc, Compare], PropertyTypes USING [tCreateDate], Rope USING [Cat, Concat, Equal, Fetch, Find, FromChar, IsEmpty, Length, Replace, Substr, ToRefText], Runtime USING [GetBuildTime], System USING [GreenwichMeanTime, GetGreenwichMeanTime, SecondsSinceEpoch], Time USING [Current], UserExec USING [CheckForAbort, CheckForFile, CommandProc, ExecHandle, GetNameAndPassword, GetStreams, GetTheFile, HistoryEvent, RegisterCommand, RegisterTransformation, RopeSubst, SetNameAndPassword, TransformProc, UserAbort, UserAborted], UserExecPrivate USING [EventFailed, CallRegisteredProc, FileNotFound, GetRestOfStream, HistoryEventPrivateRecord, LookupCommand, ProcessProfile, RopeFromCMFile, StoreInSymTab, RunBCDFile] ; UserExecOpsImpl: CEDAR PROGRAM IMPORTS AMBridge, Atom, CedarVersion, CIFS, Commander, CommandProcOps, ConvertUnsafe, Directory, File, FileIO, FileStream, IO, List, Rope, Runtime, System, Time, UserExec, UserExecPrivate EXPORTS UserExec, UserExecPrivate = BEGIN OPEN IO; <> HistoryEventPrivateRecord: PUBLIC TYPE = UserExecPrivate.HistoryEventPrivateRecord; <> correct: ROPE; -- to be used in resume <> Run: Commander.CommandProc = { commandLineStream: STREAM = IO.RIS[cmd.commandLine]; anythingRun: BOOL _ FALSE; file, error: ROPE; DO next: ROPE; callDebuggerFirst: BOOL _ FALSE; IF file = NIL THEN file _ IO.GetToken[commandLineStream]; next _ IO.GetToken[commandLineStream]; IF Rope.IsEmpty[file] THEN EXIT; CommandProcOps.CheckForAbort[cmd]; IF Rope.Equal[next, "/"] THEN { switches: ROPE _ IO.GetToken[commandLineStream, IO.IDProc]; FOR i: INT IN [0..Rope.Length[switches]) DO char: CHAR = switches.Fetch[i]; SELECT char FROM 'd, 'D => callDebuggerFirst _ TRUE; ENDCASE => CommandProcOps.EventFailed[cmd, Rope.Concat["Unrecognized switch: ", Rope.FromChar[char]]]; ENDLOOP; next _ NIL; }; [, error] _ UserExecPrivate.RunBCDFile[fileName: file, callDebuggerFirst: callDebuggerFirst, out: cmd.out ! UserExecPrivate.FileNotFound => { correct _ CommandProcOps.GetTheFile[file: name, defaultExt: defaultExt, handle: cmd]; RESUME[correct]; } ]; IF error # NIL THEN EXIT; anythingRun _ TRUE; file _ next; ENDLOOP; IF NOT anythingRun AND error = NIL THEN error _ "run what?"; IF error # NIL THEN CommandProcOps.EventFailed[cmd, error, file]; }; RunAndCall: PUBLIC UserExec.CommandProc = { commandLineStream: STREAM = event.commandLineStream; fileName, command, name, error: ROPE; fileName _ IO.GetToken[commandLineStream, IO.IDProc]; [name, error] _ UserExecPrivate.RunBCDFile[fileName: fileName, out: UserExec.GetStreams[exec].out ! UserExecPrivate.FileNotFound => {correct _ UserExec.GetTheFile[file: name, defaultExt: defaultExt, event: event, exec: exec]; RESUME[correct]; } ]; IF error # NIL THEN UserExecPrivate.EventFailed[event, error, fileName]; fileName _ Rope.Substr[base: name, len: Rope.Length[name] - 4]; -- strip off the bcd command _ UserExecPrivate.LookupCommand[fileName]; -- running the bcd may have registered a command. IF command # NIL THEN { UserExec.GetStreams[exec].out.PutChar['\n]; event.commandLine _ UserExecPrivate.GetRestOfStream[commandLineStream]; [] _ IO.RIS[event.commandLine, event.commandLineStream]; [] _ UserExecPrivate.CallRegisteredProc[command, event, exec]; }; }; <> AliasRecord: TYPE = RECORD [def: ROPE, args: LIST OF ROPE]; Alias: UserExec.CommandProc = { commandLineStream: STREAM = event.commandLineStream; name, def: ROPE; args: LIST OF ROPE _ NIL; name _ IO.GetToken[commandLineStream, IO.TokenProc]; IO.SkipOver[commandLineStream, IO.WhiteSpace]; IF NOT commandLineStream.EndOf[] AND commandLineStream.PeekChar[] = '( THEN { FOR l: LIST OF REF ANY _ NARROW[commandLineStream.GetRefAny[]], l.rest UNTIL l = NIL DO WITH l.first SELECT FROM r: ROPE => args _ CONS[r, args]; a: ATOM => args _ CONS[Atom.GetPName[a], args]; ENDCASE => ERROR; ENDLOOP; TRUSTED {args _ LOOPHOLE[List.DReverse[LOOPHOLE[args]]]}; }; def _ UserExecPrivate.GetRestOfStream[in: commandLineStream, includeLast: FALSE]; RegisterAlias[name, args, def]; }; RegisterAlias: PROCEDURE [name: ROPE, args: LIST OF ROPE, def: ROPE] = { PrintAlias: PROC RETURNS [doc: ROPE] = { out: STREAM = IO.ROS[]; out.PutRope["Alias "]; IF args # NIL THEN { out.PutChar['[]; FOR l: LIST OF ROPE _ args, l.rest UNTIL l = NIL DO out.PutRope[l.first]; IF l.rest # NIL THEN out.PutRope[", "]; ENDLOOP; out.PutRope["]: "]; }; out.Put[rope[def]]; RETURN[IO.GetOutputStreamRope[out]]; }; UserExec.RegisterTransformation[name: name, proc: ExpandAlias, doc: PrintAlias[], clientData: NEW[AliasRecord _ [def: def, args: args]]]; }; ExpandAlias: UserExec.TransformProc = { alias: REF AliasRecord _ NARROW[clientData]; synonyms: LIST OF REF SynonymRecord; SynonymRecord: TYPE = RECORD[key, val: ROPE]; RopeMemb: PROC [rope: ROPE, lst: LIST OF ROPE] RETURNS[BOOLEAN] = { FOR l: LIST OF ROPE _ lst, l.rest UNTIL l = NIL DO IF Rope.Equal[rope, l.first, FALSE] THEN RETURN[TRUE]; ENDLOOP; RETURN[FALSE] }; result _ alias.def; FOR l: LIST OF ROPE _ alias.args, l.rest UNTIL l = NIL DO new: ROPE _ IO.GetToken[event.commandLineStream, IO.IDProc]; IF RopeMemb[new, l.rest] THEN { -- e.g. args are (x y) and substituting y gorp. dummy: ROPE = Atom.GetPName[Atom.Gensym[]]; synonyms _ CONS[NEW[SynonymRecord _ [new, dummy]], synonyms]; new _ dummy; }; result _ UserExec.RopeSubst[old: l.first, new: new, base: result, case: FALSE]; ENDLOOP; FOR l: LIST OF REF SynonymRecord _ synonyms, l.rest UNTIL l = NIL DO result _ UserExec.RopeSubst[old: l.first.val, new: l.first.key, base: result, case: FALSE]; ENDLOOP; result _ Rope.Cat[result, UserExecPrivate.GetRestOfStream[in: event.commandLineStream, includeLast: TRUE]]; -- used to be FALSE. changed to TRUE because was not getting CR at end of event. }; <> DeleteFiles: UserExec.CommandProc = { commandLineStream: STREAM = event.commandLineStream; out: STREAM = UserExec.GetStreams[exec].out; file: ROPE; someMissing: BOOL _ FALSE; n: INT _ 0; numPages: INT _ 0; Delete: PROC [file: ROPE] RETURNS[deleted: BOOLEAN _ FALSE] = TRUSTED { found: BOOL _ TRUE; ls: LONG STRING = LOOPHOLE[Rope.ToRefText[file]]; cap: File.Capability; cap _ Directory.Lookup[fileName: ls, permissions: Directory.ignore ! Directory.Error => {found _ FALSE; CONTINUE}]; IF found THEN { numPages _ File.GetSize[cap] + numPages; deleted _ TRUE; Directory.DeleteFile[ls ! Directory.Error => {deleted _ FALSE; CONTINUE} ]; }; IF deleted THEN out.PutF["*nDeleted: %g\n", rope[file]] ELSE { out.PutF["*n*m%g not found.*s\n", rope[file]]; UserExecPrivate.EventFailed[event: event, offender: file]; -- and go on. }; }; DO UserExec.CheckForAbort[exec]; file _ IO.GetToken[commandLineStream, IO.IDProc]; IF Rope.Length[file] = 0 THEN EXIT; IF Delete[file] THEN n _ n + 1 ELSE someMissing _ TRUE; ENDLOOP; IF someMissing OR n > 1 THEN out.PutF["*nDeleted %d files, %d pages.", int[n], int[numPages]]; }; GetCreateDate: PROC [file: File.Capability] RETURNS [System.GreenwichMeanTime] = TRUSTED { createDate: System.GreenwichMeanTime; Directory.GetProperty[file: file, property: PropertyTypes.tCreateDate, propertyValue: DESCRIPTOR[@createDate, SIZE[System.GreenwichMeanTime]]]; RETURN [createDate]; }; SetCreateDate: PROC [file: File.Capability, createDate: System.GreenwichMeanTime] = TRUSTED { Directory.PutProperty[file: file, property: PropertyTypes.tCreateDate, propertyValue: DESCRIPTOR[@createDate, SIZE[System.GreenwichMeanTime]]]; }; CopyFiles: UserExec.CommandProc = { commandLineStream: STREAM = event.commandLineStream; out: STREAM = UserExec.GetStreams[exec].out; buffer: REF TEXT; bufferSize: CARDINAL = 512; bytes, totalBytes, numberOfFiles: INT _ 0; newF: STREAM; newN, oldN, arrow: ROPE; createDate: System.GreenwichMeanTime; capability: File.Capability; CopyOneFile: PROC = { r: ROPE; oldCap: File.Capability; oldF: STREAM; oldLen: INT; r _ UserExec.GetTheFile[file: oldN, event: event, exec: exec]; IF r = NIL THEN { ENABLE CIFS.Error => GOTO NotFound; oldCap _ CIFS.GetFC[CIFS.Open[name: oldN, mode: CIFS.read]]; oldF _ FileIO.StreamFromCapability[capability: oldCap, accessOptions: read, raw: TRUE]; EXITS NotFound => { out.PutF["*n*m%g not found.*s\n", rope[oldN]]; UserExecPrivate.EventFailed[event: event, offender: oldN]; GOTO Error; }; }; numberOfFiles _ numberOfFiles + 1; IF oldF = NIL THEN { oldF _ FileIO.Open[fileName: r, accessOptions: read, createOptions: oldOnly, raw: TRUE]; oldCap _ FileIO.CapabilityFromStream[oldF]; }; createDate _ GetCreateDate[oldCap]; oldLen _ oldF.GetLength[]; IF newF = NIL THEN -- first time -- newF _ FileIO.Open[fileName: newN, accessOptions: overwrite, createLength: oldLen ! FileIO.OpenFailed => IF why = notImplementedYet THEN { out.PutF["*n*m%g not implemented yet.*s\n", rope[newN]]; UserExecPrivate.EventFailed[event: event]; GOTO Error; }; ] ELSE newF.SetLength[totalBytes + oldLen]; DO bytes _ oldF.GetBlock[buffer]; IF bytes=0 THEN EXIT; totalBytes _ totalBytes + bytes; newF.PutBlock[buffer]; ENDLOOP; oldF.Close[]; EXITS Error => RETURN }; newN _ IO.GetToken[commandLineStream, IO.IDProc]; arrow _ IO.GetToken[commandLineStream, IO.IDProc]; IF Rope.Length[newN] = 0 OR NOT Rope.Equal[arrow, "_"] THEN { out.PutF["*eArgument missing or syntax error for copy!*s"]; RETURN; }; buffer _ NEW[TEXT[bufferSize]]; WHILE Rope.Length[oldN _ IO.GetToken[commandLineStream, IO.IDProc]] # 0 DO CopyOneFile[]; ENDLOOP; IF newF = NIL THEN RETURN; capability _ FileIO.CapabilityFromStream[newF]; newF.Close[]; out.PutF["*n*sCopied %d bytes", card[totalBytes]]; IF numberOfFiles = 1 THEN SetCreateDate[capability, createDate] ELSE out.PutF[" from %g files", card[numberOfFiles]]; out.PutF[" to %g", rope[newN]]; }; ListFiles: UserExec.CommandProc = { [] _ DoList[event, exec]; }; ListByDates: UserExec.CommandProc = { compare: List.CompareProc = TRUSTED { x, y: REF FileRec; x _ NARROW[ref1]; y _ NARROW[ref2]; RETURN[IF System.SecondsSinceEpoch[x.createDate] < System.SecondsSinceEpoch[y.createDate] THEN greater ELSE less]; -- more recently created files come first }; [] _ DoList[event, exec, compare]; }; FileRec: TYPE = RECORD[name: ROPE, createDate: System.GreenwichMeanTime, byteLength, numPages: LONG CARDINAL]; DoList: PROC [event: UserExec.HistoryEvent, exec: UserExec.ExecHandle, compare: List.CompareProc _ NIL] = { commandLine: ROPE _ event.commandLine; out: STREAM = UserExec.GetStreams[exec].out; len: INT; numFiles, numPages: INT _ 0; stream: IO.STREAM; spellingCorrect: BOOL _ FALSE; files: LIST OF REF FileRec; file: ROPE; Lookup: PROC [file: ROPE] = TRUSTED -- Directory -- { txt: REF TEXT; name: LONG STRING; cap: File.Capability; failed: BOOLEAN _ FALSE; IF spellingCorrect THEN { r: ROPE = UserExec.GetTheFile[file: file, event: event, exec: exec]; IF r = NIL THEN GOTO NotFound; txt _ Rope.ToRefText[r]; } ELSE IF UserExec.CheckForFile[file] THEN txt _ Rope.ToRefText[file] ELSE GOTO NotFound; name _ LOOPHOLE[txt];-- Directory.GetProps may write into name, e.g. to change lower case to capitals. cap _ Directory.Lookup[fileName: name, permissions: Directory.ignore ! Directory.Error => {failed _ TRUE; CONTINUE}]; IF failed THEN ERROR ELSE { createDate: IO.GreenwichMeanTime; byteLength: LONG CARDINAL; [, , createDate,byteLength,] _ Directory.GetProps[file: cap, name: name ! Directory.Error => IF type = invalidProperty THEN { out.PutF["*n*e%g has bad leader page*s", rope[file]]; GOTO Error; }]; IF compare = NIL THEN Print[file, createDate, byteLength, File.GetSize[cap]] -- so user gets to see them as they are processed ELSE files _ CONS[NEW[FileRec _ [name: file, createDate: createDate, byteLength: byteLength, numPages: File.GetSize[cap]]], files]; -- will be sorted first }; EXITS Error => {}; NotFound => { out.PutF["*n*m%g not found*s", rope[file]]; UserExecPrivate.EventFailed[event: event, offender: file]; }; }; -- of Lookup Print: PROC [name: ROPE, createDate: IO.GreenwichMeanTime, byteLength, nPages: LONG CARDINAL] = { out.PutF["*s*n%-30g %6d %g\n", rope[name], card[byteLength], time[createDate]]; numPages _ numPages + nPages; numFiles _ numFiles + 1; }; -- of Print len _ Rope.Length[commandLine]; IF len > 1 AND Rope.Fetch[commandLine, len - 2] = '! THEN { -- special case check for ! here and in eval. If this occurs in several places, probably should handle it by filtering out at a higher point and setting the tryHarder field of the event to TRUE. spellingCorrect _ TRUE; commandLine _ Rope.Replace[base: commandLine, start: len - 2, len: 1]; }; stream _ IO.RIS[commandLine]; DO file _ IO.GetToken[stream, IO.IDProc]; IF Rope.Length[file] = 0 THEN EXIT; UserExec.CheckForAbort[exec]; Lookup[file]; ENDLOOP; IF compare # NIL THEN TRUSTED { files _ LOOPHOLE[List.Sort[LOOPHOLE[files], compare]]; FOR lst: LIST OF REF FileRec _ files, lst.rest UNTIL lst = NIL DO UserExec.CheckForAbort[exec]; Print[lst.first.name, lst.first.createDate, lst.first.byteLength, lst.first.numPages] ENDLOOP; }; out.PutF["*n*sTotal of %d files, %d pages", int[numFiles], int[numPages]]; }; Rename: UserExec.CommandProc = { commandLineStream: STREAM = event.commandLineStream; out: STREAM = UserExec.GetStreams[exec].out; oldName, newName, r: ROPE; oldName _ IO.GetToken[commandLineStream, IO.IDProc]; newName _ IO.GetToken[commandLineStream, IO.IDProc]; IF Rope.Equal[newName, "_"] THEN { newName _ oldName; oldName _ IO.GetToken[commandLineStream, IO.IDProc]; }; IF Rope.Length[oldName] = 0 OR Rope.Length[newName] = 0 THEN UserExecPrivate.EventFailed[event: event, msg: "Empty file name"]; r _ UserExec.GetTheFile[file: oldName, event: event, exec: exec]; IF r = NIL THEN UserExecPrivate.EventFailed[event: event, msg: Rope.Concat[oldName, " Not Found"], offender: oldName]; oldName _ r; RETURN[RenameFile[oldName, newName, out]]; }; RenameFile: PUBLIC PROC [oldName, newName: ROPE, out: STREAM] RETURNS[success: BOOL] = { msg, r: ROPE; { Rename1: PROC [old, new: ROPE] = TRUSTED { olds: LONG STRING _ [60]; news: LONG STRING _ [60]; ConvertUnsafe.AppendRope[to: olds, from: old]; ConvertUnsafe.AppendRope[to: news, from: new]; Directory.Rename[olds, news]; FileStream.SetLeaderPropertiesForCapability[cap: Directory.Lookup[news], write: Time.Current[]]; }; Delete1: PROC [file: ROPE] = TRUSTED { Directory.DeleteFile[LOOPHOLE[Rope.ToRefText[file]] ! Directory.Error => CONTINUE]; }; Rename1[oldName, newName ! Directory.Error => { SELECT type FROM fileAlreadyExists => {IF Rope.Equal[oldName, newName, FALSE] THEN TRUSTED {Delete1["$$scratch" ! Directory.Error => CONTINUE]; Rename1[oldName, "$$scratch"]; Rename1["$$scratch", newName]; CONTINUE; }; r _ Rope.Concat[newName, "$$"]; IF Rope.Equal[r, oldName, FALSE] THEN -- e.g. user is in fact performing rename foo.mumble _ foo.mumble$$ {Delete1[newName]; RETRY; }; Delete1[r ! Directory.Error => CONTINUE]; Rename1[newName, r]; out.PutF["*s%g already existed, now renamed to %g\n", rope[newName], rope[r]]; RETRY; }; fileNotFound => msg _ "File Not Found"; invalidFileName => msg _ "Invalid File Name"; ENDCASE => msg _ "Directory Error"; out.PutF["*e%g, ", rope[msg]]; GOTO fail; }; ]; out.PutF["%g renamed to %g", rope[oldName], rope[newName]]; RETURN[TRUE]; EXITS fail => {out.PutRope["Unable to complete rename."]; RETURN[FALSE]}; }; }; <> LoginProc: Commander.CommandProc = { LoginFromStreams[cmd.in, cmd.out]; UserExecPrivate.ProcessProfile[]; }; Login: PUBLIC PROC [in, out: STREAM] RETURNS[name, password: ROPE] = { LoginFromStreams[in, out]; [name, password] _ UserExec.GetNameAndPassword[]; UserExecPrivate.ProcessProfile[]; }; LoginFromStreams: PROC [in, out: STREAM] = { name, password: ROPE; UNTIL in.backingStream = NIL DO in _ in.backingStream; ENDLOOP; in _ IO.CreateEditedStream[in: in, echoTo: out, deliverWhen: IODeliverWhen]; name _ UserExec.GetNameAndPassword[].name; out.PutF["*sUser Name: " ! IO.Signal => IF ec = NotImplementedForThisStream THEN RESUME]; in.StoreData[key: $Count, data: NEW[INT _ Rope.Length[name]]]; IO.AppendStreams[in, RIS[name]]; name _ IO.GetToken[in, IO.IDProc ! IO.Signal => SELECT ec FROM Rubout => ERROR IO.UserAborted; EmptyBuffer => RESUME; ENDCASE; ]; out.PutRope["Password: "]; [] _ in.SetEcho[IO.CreateProcsStream[ streamProcs: IO.CreateRefStreamProcs[putChar: PutStar, eraseChar: EraseStar], backingStream: out, streamData: NIL]]; password _ IO.GetToken[in, IO.IDProc ! IO.Signal => SELECT ec FROM Rubout => ERROR IO.UserAborted; EmptyBuffer => RESUME; ENDCASE; ]; UserExec.SetNameAndPassword[name, password]; }; IODeliverWhen: IO.DeliverWhenProc = { count: REF INT = NARROW[stream.LookupData[$Count]]; count^ _ count^ - 1; IF count^ > 0 THEN RETURN[FALSE] -- the idea is that if there are illegal characters, e.g. space, cr, etc. in user name, then don't want to have these terminate, or else could never change this again! ELSE RETURN[SELECT char FROM CR, SP, ESC => TRUE, ENDCASE => FALSE]; }; PutStar: PROC [self: STREAM, char: CHARACTER] = { SELECT char FROM CR, SP, ESC => NULL; ENDCASE => self.backingStream.PutChar['*] }; EraseStar: PROC [self: STREAM, char: CHARACTER] = { self.backingStream.EraseChar['*]; }; -- if default it, would print \ and char, causing two *'s. <> TypeVersion: UserExec.CommandProc = TRUSTED { out: STREAM = UserExec.GetStreams[exec].out; out.PutF[ "You are running Cedar %g.%g", IO.int[CedarVersion.major], IO.int[CedarVersion.minor]]; IF CedarVersion.patch # 0 THEN out.PutF[".%g", IO.int[CedarVersion.patch]]; out.PutF[" of %t\n", IO.time[Runtime.GetBuildTime[]]]; RETURN [TRUE] ; }; TypeDaytime: UserExec.CommandProc = TRUSTED { out: STREAM = UserExec.GetStreams[exec].out; time: System.GreenwichMeanTime = System.GetGreenwichMeanTime[]; out.PutF["The time is %g\n", IO.time[time]]; UserExecPrivate.StoreInSymTab[value: AMBridge.TVForReferent[NEW[System.GreenwichMeanTime _ time]], event: event, exec: exec]; RETURN [TRUE]; }; TypeUser: UserExec.CommandProc = TRUSTED { out: STREAM = UserExec.GetStreams[exec].out; user: ROPE = UserExec.GetNameAndPassword[].name; out.PutF["The logged-in user is %g\n", IO.rope[user]]; UserExecPrivate.StoreInSymTab[value: AMBridge.TVForReferent[NEW[ROPE _ user]], event: event, exec: exec]; RETURN [TRUE]; }; <> CommandsFrom: UserExec.TransformProc = { commandLineStream: STREAM = event.commandLineStream; fileName: ROPE; contents, name: ROPE; fileName _ IO.GetToken[commandLineStream, IO.IDProc]; [contents, name] _ UserExecPrivate.RopeFromCMFile[file: fileName, event: event, exec: exec]; IF event # NIL THEN {private: REF UserExecPrivate.HistoryEventPrivateRecord = event.privateStuff; event.dontCorrect _ TRUE; private.inCommandFile _ TRUE; private.inCMFile _ (Rope.Find[s1: name, s2: ".cm", case: FALSE] # -1); }; result _ Rope.Concat[contents, UserExecPrivate.GetRestOfStream[commandLineStream]]; }; -- of CommandsFrom <> Commander.Register["Login", LoginProc, "Supply user name and password."]; UserExec.RegisterCommand["Delete", DeleteFiles, "Delete a list of files."]; UserExec.RegisterCommand["Rename", Rename, "Renames a file", "Renames a file. Syntax is Rename old new, or Rename new _ old."]; UserExec.RegisterCommand["Copy", CopyFiles, "Copy contents of one or more files to another (new _ old1 old2 ...)."]; UserExec.RegisterCommand["List", ListFiles, "Prints size, creation date for the indicated files."]; UserExec.RegisterCommand["ListByDates", ListByDates, "Prints size, creation date for the indicated files, sorted by create date."]; Commander.Register["Run", Run, "Load and Start the named programs.\n/d following a file name means just load the corresponding program, but do not start it. Instead, call the debugger, e.g. so that you can plant breakpoints. Proceeding from the corresponding action area will then start the program."]; UserExec.RegisterCommand["RunAndCall", RunAndCall, "Load and Start the named program. Then call the registered procedure, if any."]; UserExec.RegisterCommand["Alias", Alias, "Defines an Alias, Form is Alias (args) rest-of-line.", "Defines an Alias. Aliases provide a substitution macro facility for the first token on a line, e.g. Alias br bringover /o /a would cause 'br file df' to be transformed to 'bringover /o /a file df'. An optional argument list is permitted following the alias name, in which case tokens from the input line are substituted for the arguments, e.g. Alias both (file) compile file '; bind file would cause 'both foo' to be transformed to 'compile foo; bind foo'."]; UserExec.RegisterCommand["Version", TypeVersion, "Types the version number and build time of the Cedar boot file you are running."]; UserExec.RegisterCommand[ "Date", TypeDaytime, "Types today's date and time."]; UserExec.RegisterCommand["User", TypeUser, "Types the name of the logged-in user."]; UserExec.RegisterTransformation["@", CommandsFrom, "Treat the contents of the named file as a command file.", "If {file} ends in .cm (or {file} has no extension and there is a {file}.cm), treat the {file} as an old-style command file, i.e. when interpreting the contents, treat {fileName} by itself on a line as Run {fileName}. Similarly, treat @{fileName} by itself the same as CommandsFrom {fileName}. Interpreted {command}.~ to mean invoke the indicated registered command. \nOtherwise, if {file} ends in .commands (or the {file} has no extension and there is a {file}.commands), treat the file as a new-style command file, i.e. treat the contents of the {file} the same as though they had been typed."]; RegisterAlias[name: "Compiler", args: NIL, def: "Compile"]; RegisterAlias[name: "Binder", args: NIL, def: "Bind"]; END. August 12, 1982 4:15 pm fixed login to call userprofile.profilechanged September 9, 1982 11:03 am fixed listfiles to catch Directory.Error[type: invalidProperty] <> <> <> <<>>