Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use INFILEP to get unambiguous path in INTERPRET.REM.CM #1963

Closed

Conversation

MattHeffron
Copy link
Contributor

This is necessary because a path of the form "/home/matt/GREETFILE" is treated as "home>matt>GREETFILE".
OPENSTREAM in INTERPRET.REM.CM tries to open that effectively as relative to (CNDIR T).
This is seen when resuming from a saved lisp.virtualmem.

…/GREETFILE" is treated as "home>matt>GREETFILE".

OPENSTREAM in INTERPRET.REM.CM tries to open that effectively as relative to (CNDIR T).
This is seen when resuming from a saved lisp.virtualmem.
@MattHeffron MattHeffron self-assigned this Jan 9, 2025
@hjellinek
Copy link
Contributor

I tried this using macOS. While connected to {DSK}<Users>hjellinek>Projects>blablabla>, I tried something similar:

(openstream "/tmp/foo.txt" 'input)

The result was a normal input stream on {DSK}<tmp>foo.txt;1.

I don't think OPENSTREAM treats the path in my example differently than the one in your example, so what accounts for the difference in results?

@nbriggs
Copy link
Contributor

nbriggs commented Jan 10, 2025

For background, in the Alto days (Alto Executive from the Alto OS Reference Manual, 1977):

Commands can be separated by semi-colons.
If there is more than one command in a command line, everything following the
first command is saved (after the interpretation described above)
on a file called Rem.Cm, which will be examined the next time the Executive is run.

I think that our current problem got started when we switched from having separate "Rem.Cm" file and site init file to overloading LDEINIT for naming both Rem.Cm and site init files.

Piecing the story together from my fragmentary knowledge - if Lisp wanted to chain to another program (or itself), it could append to (or overwrite) Rem.Cm with "Lisp; (something interesting to Lisp)" with the expectation that the Executive would start "Lisp" and stuff the remaining command line back into Rem.Cm -- Lisp was set up to read an appropriate part of the Rem.Cm contents, and being a good citizen, remove it, and let the Alto executive see the leftovers.

Interpreting Rem.Cm, if it existed and contained anything of interest to Lisp, was completely separate from the site and user greetfiles. I think that interpreting Rem.Cm happens at a different time in the startup than the processing of site and user greeting. Linking the two names together means that you get attempts from both places in the startup to do something with the site init file.

(GREETFILENAME
  [LAMBDA (USER)                                             (* lmm "13-Apr-84 08:42")
                                                             (* Returns name of an existing greeting file, or NIL)
    (DECLARE (GLOBALVARS USERGREETFILES LOGINHOST/DIR COMPILE.EXT))
    (SELECTQ USER
	     [T (OR (INFILEP (QUOTE {DSK}INIT.LISP))
		    (bind FILE while (SETQ FILE (PROMPTFORWORD (QUOTE 
	       "Please enter name of system init file
(e.g. {server}<directory>INIT.extension): ")))
		       until (SETQ FILE (INFILEP (MKATOM FILE))) finally (RETURN FILE]
	     (NIL)
	     (COND
	       ((LISTP USERGREETFILES)
		 (PROG [(POS (STRPOS (QUOTE %.)
				     (SETQ USER (U-CASE USER]
etc. etc.

In the same timeframe, the INTEPRET.REM.CM looked like:

(INTERPRET.REM.CM
  [LAMBDA (RETFLG)                                           (* bvm: "22-Aug-84 14:16")
    (DECLARE (GLOBALVARS STARTUPFORM))

          (* * Looks at REM.CM and evaluates the form there if the first character of the file is open paren or doublequote.
	  If it's a string, it will be unread,, else the form will be evaluated at the next prompt. For use in INIT.LISP, 
	  among others. If RETFLG is true, the expression read is simply returned)


    (PROG ([FILE (CAR (NLSETQ (OPENSTREAM (QUOTE {DSK}REM.CM;1)
					  (QUOTE BOTH]
	   COM AUXFILE)
          (OR FILE (RETURN))
          [COND
	    ([AND (IGREATERP (GETFILEINFO FILE (QUOTE LENGTH))
			     0)
		  (SELCHARQ (\PEEKBIN FILE T)
			    ((%( %")
			      T)
			    NIL)
		  (SETQ COM (PROGN (SETFILEINFO FILE (QUOTE ENDOFSTREAMOP)
						(FUNCTION ERROR!))
				   (CAR (NLSETQ (READ FILE T]
	      (COND
		(RETFLG                                      (* Save it to return))
		((LISTP COM)                                 (* make it happen at next prompt)
		  (SETQ STARTUPFORM (LIST (QUOTE PROGN)
					  (QUOTE (SETQ PROMPTCHARFORMS (DREMOVE STARTUPFORM 
										PROMPTCHARFORMS)))
					  (LIST (QUOTE PRINT)
						(LIST (QUOTE LISPXEVAL)
						      (KWOTE COM))
						T T)))
		  (SETQ PROMPTCHARFORMS (CONS STARTUPFORM PROMPTCHARFORMS)))
		(T                                           (* Unread a string)
		   (BKSYSBUF COM)))
	      (\SETEOFPTR FILE (COND
			    ((NOT (\EOFP FILE))
			      (SELCHARQ (\PEEKBIN FILE)
					((CR ;)              (* Eat up the command terminator)
					  (\BIN FILE))
					NIL)                 (* Need to rewrite REM.CM with remainder of text)
			      (SETQ AUXFILE (OPENSTREAM (QUOTE {NODIRCORE})
							(QUOTE BOTH)
							(QUOTE NEW)))
			      (COPYBYTES FILE AUXFILE)
			      (SETFILEPTR FILE 0)
			      (COPYBYTES AUXFILE FILE 0 (GETFILEPTR AUXFILE))
			      (CLOSEF AUXFILE)
			      (GETFILEPTR FILE))
			    (T 0]
          (CLOSEF FILE)
          (RETURN (COND
		    (RETFLG COM)
		    (COM T])

@MattHeffron
Copy link
Contributor Author

@hjellinek I discovered this when restarting Medley from a .virtualmem file.
I have the -r /home/matt/GREETWRAP in my ~/.medley_config.
This behaves correctly when starting Medley from a sysout (e.g., --full).
But, if in Medley I CD {MEDLEY} then, eventually, (LOGOUT), when I restart/resume from the lisp.virtualmem I get the error:
File not found: /home/matt/GREETWRAP in \OPENFILE.
However, if instead of CD {MEDLEY} I did (CNDIR (MEDLEYDIR)) and then the (LOGOUT), the error doesn't occur.
So, it seems that having used a pseudo-host (any pseudo-host) in the CD, instead of its expansion, is the key.

@MattHeffron
Copy link
Contributor Author

It just occurred to me that this was "familiar".
This is issue #1767!

@nbriggs
Copy link
Contributor

nbriggs commented Jan 10, 2025

This is how it used to work:

// LoadFullFromLisp.cm Edited 5-Sep-85 -- van Melle --

Copy Init.save ← Init.Lisp
Del INIT.LISP!*
FTP/-E ERIS Login/C Dir/C Lisp>koto>basics Ret/<>A Lisp.run DoradoLispMc.eb DolphinLispMc.eb Ret/S Init.nogreet Init.Lisp

Lisp [ERIS]<Lisp>KOTO>BASICS>Lisp.sysout ;"  
SHH(AND (INFILEP '{DSK}INIT.SAVE) (COPYFILE '{DSK}INIT.SAVE '{DSK}INIT.LISP;1) (DELFILE '{DSK}INIT.SAVE))
SHH(LOAD '{ERIS}<LISP>KOTO>CM>LOADFULL.LISP)
SHH(MAKESYS '{ERIS}<LISP>KOTO>BASICS>FULL.SYSOUT]
SHH(LOGOUT T] "

So it saves then replaces your Init.Lisp with Init.nogreet, fires up the Lisp sysout, where the Rem.Cm will contain the "..." commands to do what needs to be done... which is to put back the saved copy of the site init file and then load the Lisp file to load full from lisp, etc.

@masinter masinter marked this pull request as draft January 27, 2025 19:04
@MattHeffron
Copy link
Contributor Author

Superseded by #2027

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants