MacOS - odd behaviour - BBEdit and (load) - a UTF8 issue?

Started by cormullion, March 30, 2007, 09:09:51 AM

Previous topic - Next topic

cormullion

Something weird was going on when I used (load) in a Terminal to load a file that I'd created using BBEdit. newLISP was executing the statements at the top of the file (i hadn't included the #!/usr/bin/newlisp line - I didn't think files to be loaded needed it), even though I'd preceded them with a semicolon. It took a long time for me to discover this - it was after I'd commented out a (context ...) command and noticed the errors relating to that context were still appearing.



I investigated further, and I got the problem to go away if I changed the document encoding from 'UTF8' to 'UF8 - no BOM', or if I added the #!/usr/bin/newlisp line at the top.



The reason I didn't put #!/usr/bin/newlisp at the top is because when i loaded a file with that in it I also got a new symbol created, called '#!/usr/bin/newlisp'... Which didn't seem right...

Lutz

#1
I used Textwrangler for a while (the free version of BBEdit) but did not have this problem.



I sounds to me, as if BBEdit is encoding the # sign with something else, because newLISP will always take it as beginning of a comment, not a symbol.



Try the following to find out what really is in that first line:


(map char (explode (read-file "problemfile.lsp")))

This should start with the numbers 35 33 47 for #!/



Lutz

cormullion

#2
A UTF8 file gives the following for that code:


(65279 35 33 47 117 115 114 47 98  ..

whereas a 'UTF8 - no BOM' gives:


(35 33 47 117 115 114 47

That's the problem, obviously. Perhaps this is a general Unix thing...