Linux Like Unix with Jim Hall and Jeff Brace

Linux Like Unix with Jim Hall and Jeff Brace

Show Video

uh my name is Jeffrey brace I am the vice president of the Vintage computer Federation this is a vage the VES computer federation's YouTube channel um I'm also showrunner for VCF easts uh today's talk is with Jim Hall Jim Hall uh is an open source software developer and advocate he has authored and contributed to or maintain dozens of open- source projects but folks here may recognize him from free do an open source implementation of the Dos operating system he earned his master of science for the University of Minnesota also teaches university courses on technical writing and on the history of technology and which we'll learn today so today's talk is Linux like Unix um so take it away Jim all right so thank you very much and so uh let me go ahead and share my screen we can talk about uh Linux like original uh Unix and so uh little bit of background here uh as you heard so my my name is Jim Hall and I uh have a a very definite interest in uh in retro technology and kind of how technology got from uh here from there to here uh and as part of that I'd like to explore sort of the history of different parts of Technology including the history of units which I just find uh very fascinating uh so kind of a brief background here on the history of the development of unit and so uh the first version on the pdp1 uh was 1971 so that was obviously a little over 50 years ago if you don't know the story about actually how Unix started let me just take a like 30 seconds here and kind of tell the story is that uh Ken Thompson uh was working on some experiments with a a disc drive and and try to optimize throughput and after he had done a certain amount of work on that at Bell Labs uh he realized he was probably like three weeks away from having a full operating system and he figured that he had like three things he needed to write like an editor uh and an assembler and and a a colonel and you know each one of those would probably take about a week for him to do around that same time his wife uh was uh gonna go and visit all the relatives because they just had a a baby and so she was gonna show the baby off to the to the relatives and he figured he had three full weeks of uninterrupted time and so he was able to create uh the first prototype version uh of Unix and that GRE to uh the Unix that they had at Bell labs and uh they got on the pdp1 uh because they really were trying to negotiate uh you know getting a new system I'll I'll talk about that when when we show a picture of the pdp11 but the first version was on running on the PDP 11 uh unix's Second Edition uh came out in 1972 in June uh and that was the first version that really supported a c compiler because that's that's how old C is C goes back to 1972 uh and in 1973 uh that was the first version of Unix that supported pipes and so you think about it this way trying to run commands from one command to the other right it's a pretty basic function that we think of today but yeah it until then what you had to do if you wanted to run the output of one command through another command is you had to uhh save the output of one command into a file and then you had to uh read that file into the Next program and so it was It was kind of convoluted if you want to get multiple programs to talk to each other and so they had this concept called pipes where they could directly connect the output of one command into the input of the next command and kind of like connecting uh the description was kind of like connecting uh segments of of a of a garden hose together and and so that's where pipes uh came from 1973 in November is when the first public view of Unix came from and it added a couple of extra commands uh and you know I'm going to show the version off that was basically Third Edition but you know you think about when we look at the commands here in a second you'll see there's not much difference between uh at least the commands I'm going to run between uh the the Third Edition and the fourth edition fifth edition was the version that was really available to higher education that was really when it started to get out not saying that it wasn't available before then but that's really when the uh it was made available to higher education uh sixth edition was when you started to see commercial licenses that was in 1975 uh and then looking ahead so it actually took a couple years after that to get to unix's 7th edition and so that was when uh the big Edition there was really the borne the addition of the borne shell uh and so it started to get more sophisticated at the command line uh eth Edition you know a couple years later so it took a little while here to to get the next version uh 1985 and that was really only available for uh education if you wanted to learn about system that's really the only uh release there so so Bell Labs was not able to Market this uh because uh there are various legal reasons I want to go into here but they basically they couldn't uh sell this as a an operating system vendor and so uh you know this was something was only available uh to education uh Unix ninth Edition the next year uh that was really sort of a conceptual version of Unix and so it really wasn't widely distributed uh the last version of research Unix was available in 1989 and that's really when at least in terms of my perspective when I started to get into Computing that's actually when I started to get into uh Unix systems it was actually about a year later in 1990 uh when I was an undergraduate in uh in University and uh and so I started to explore uh Unix uh on for example Sun OS systems on a sun Microsystems Sun 350 workstation uh and then from there kind of some other other systems and so I I that's sort of around my experience was around that 10th edition of of Unix kind of taking a deeper dive though into what these early versions of Unix looked like this is the command list that you had and there are some other things as well but this is really the section one Command right the user based commands uh in first edition again 1971 uh so you got a number of commands in here you know that's you're seeing some familiar commands in there hopefully uh you know Cal to run the calendar cat to display a file right concatenate the output of a file uh Chader to change to a different directory uh chamad to change the mode of a file uh CP to copy files uh DF to show dis free uh dis usage for du Ed Ed's a pretty important command uh and so Ed was the editor at the time right and so if you're going to be editing files on Unix this is long before VI uh you're not going to be running VI or emac that whole VI emx war was well into the future uh and so if you wanted to edit files you're actually editing things using the Ed editor which is what we're going to be doing uh today there's some other commands in there that I'll kind of let you look at that list on your own but I also want to highlight the rth program and so if you don't know what the rth program is uh there was an older program called runoff by Jerry salzer uh it ran on the mits system I think it was and uh that that was a uh text processing program really a Document Preparation system and I actually have interviewed Jerry about that and and he admits this is not the first document processing system uh but it was the one that that he wrote Because it's the one that he needed uh to prepare his uh his thesis uh uh U and so he uh really added the features that he needed uh to do uh Document Preparation that program was called runoff uh and so that name comes from the concept of I'm going to run off a document right that was sort of the term of the time you're going to type up a document you're going to copy a document you're going to run off a document and so he called it runoff to run off a document uh and it used uh these commands uh that would start on their own line that were starting with a DOT and that would allow you to do certain things like you know set the page margins and things like that uh double space and uh and and uh and that was kind of a cool way to uh create documents and this remember at a time when computers had ttes of memory so we're not talking about a lot of uh a lot of memory here so we're not talking about fonts and things like that everything was being outputed actually runoff was generating output for what's called a chain printer which is basically you can imagine that sort of a typewriter like device for output uh the folks at Bell Labs thought that was a cool program and so they wrote a version that used abbreviated commands because runoff could have very very long commands it could also have some short ones but uh it would have these very long commands that always start with the dot and so they made a an abbreviated version of that that used abbreviated commands and so they abbreviated the name and now the name was called rth and so rough really is short for runoff uh and then uh other things in there Fortran compiler basic environment you wanted to program in basic uh and then the Unix uh Second Edition they uh they that's when they wanted to uh upgrade the system right so they wanted uh actually first edition was really when they upgraded the system and so when they when they wanted to buy a new system previous sat there running on a I think it was a PDP 7 and they wanted to buy a newer computer that was faster a little more memory uh so they wanted to buy a pdp1 and they went to management and made the request can we buy a new computer and management was kind of burned by having been involved in this other fail experiment uh called multic which was a cooperation between various organiz a and they said no uh no money to buy a server to keep doing operating system stuff because you know we're just not an operating systems company well around that same time the legal department at Bell Labs wanted to buy a new system that they could use to create documentation actually patent application and patent applications required you know kind of particular formatting the system they were looking at buying didn't actually support uh that didn't have a text processing system that was finished for it at least not something they could use and so uh the operating system guys the Unix team um went to them and said hey tell you what if you buy us a new computer right bias a pdp11 we'll put Unix on it and we'll update the Roth program to support the formatting that you need to do patent applications and they said okay great we'll do that and so that's what they did and so so they created a new version of rth called enroth and so enroth as a name actually stands for new rth uh now Unix second so that version showed up in uh in Unix second edition that was it where enro showed up but you'll also see a reference to rth in the manual as well in a second uh this this is the first version as I said that had a c compiler so C was very early at this time uh and it looks a little different than what we do today or at least uh some of the syntax will be a little bit different um but this was the earliest uh C compiler that we had on a Unix system also invented at Bell Labs of course by Dennis Richie uh and uh Brian kernahan assisted in uh documenting that this is actually what the manual looks like for Unix second edition I'm not going to show you the entire manual but this is the manual that came out June 12 1972 And of course that's how we have the date uh this was entirely printed on a teletype I think it was a teletype 37 uh you basically think of that as a if you don't know what a teletype 37 is I got a photo in a little bit but basically it's a it's a typewriter like device and so you're thinking about everything as being a single uh space for any kind of character right so a lowercase L is the same width as a capital M uh and so that's where your um the first uh manual came from and so just looking at the the first two pages of the table of contents so we can see the uh the section one commands and so again you can see that this one has uh the uh uh this one actually has the NR command in it uh it also has uh another command I want to so NR you can see that on the lower left hand side on uh on page six uh there on the left hand side and that's that's the enroth command you can also see a reference to rth up there at the top uh of page seven and uh you can also see I want to point out on the towards the end of the list in section one there's a command called type now in modern Unix systems modern Linux more specifically the bass shell has a built-in command called type and that'll tell you if you do type like for example LS it'll tell you if that's an alias or if that's an actual command that would run if you were to run that program uh back in this version of Unix type was actually a command that would simulate typing a document because a t type uh printed on a long roll of paper I'll show you a picture in a second but it'll print on a long roll of paper and the type command would actually print out one page at a time and then wait for the user to press a key or actually hit enter before it does the uh the next page and so that uh was a command that you were going to use if you needed to print uh Nic looking documentation uh on on letter sized paper now third addition uh as I mentioned this is the first one that had types and this also of course added the debugger this is also where they split out bin from user bin I won't go into the sort of history about that but again kind of looking at the at the manual right the commands that we have available to us in uh Unix Third Edition you know we've added a couple of commands in here right so again point out that on the left hand side you can see the enroth command uh and towards the bottom on the leftand side you can also of course see the Ed text editor uh there is no VI in here right there's no there's no VI system on this uh the only editor is Ed and of course we have enroth to as I just mentioned to to print documents and type uh to uh to print things out and you know this is what that pdp1 uh looked like and so if uh if you're not uh quite clear if you haven't seen this photo before uh this is Ken Thompson who's seated at the teletype that's a Model 33 uh and that is Dennis Richie who's standing next to him and so behind them is uh those uh circular discs are uh tapes and other parts of that cabinet are the actual parts of the computer system itself and so you can see that teletype that's really what I'm to talk about here the teletype is it's sitting on a stand it's mounted on a metal stand and it's got a roll of paper that comes in from the back and uh that rolls under a basically a print head and then it continues up and ejects out of the top of the uh of the telet Tye now that's an entirely continuous uh roll of paper now uh Ken Thompson has commented before that the the teletype required a pretty significant finger press to uh to actually activate a key press and so uh the that's why the original version of Unix these all these original unix commands tend to have like two character uh command names like CP and LS because you didn't want to do a lot of typing when it required pushing kind of hard on on each one of those keys now uh the actual teletype this is a a better Zoom of a teletype that I picked up at a museum or I I took took a picture of at a museum uh and so you can see the keyboard there uh now the main uh uh attraction on the teletype 33 which is what this is is that it can only print in uppercase uh but you're seeing some things in here that uh that are pretty significant you see that roll that red roll uh that dowel that's that's where you would attach the uh or Mount the the paper that would roll into the back of this uh teletype uh and you can see the knob on the left hand side to advance the roller and you know being able to type in the commands now that uh that that blank space on the right hand side is where you could H um mount an optional uh modem and so there are three different models of the 33 uh teletype the uh I think this is the 3310 of erop corly uh which means it doesn't have a modem and it doesn't have a paper tape unit and so you could get another model that had a paper tape that was mounted on the left hand side and when I was an undergraduate student uh we actually had a a teletype uh 33 uh that we could use to print out Fortran programs and the fact that it could only print uppercase wasn't really an issue for us because for's always uppercase anyway uh and so there was a teletype that was mounted on the left and actually that's what that you can see that on the teletype that is next to Ken there on the pdp11 that that system on the left is where the the paper tape gets mounted on the right hand side that blank spot as I said that's where a modem would get added into the system if you wanted to add a modem to that that was the third model that could do a modem this is what the model 37 teletype looked like and it could do uppercase and lowercase also had sort of a little plastic housing to put in the uh uh the the paper so that way it wasn't quite as noisy uh now you could roll in a an 8 and 1 half by 11 sheet of paper and uh you know basically eject the The Continuous roll and put in an 8 and a half by 11 sheet of paper and that would allow you to print on a US letter uh piece of paper now uh this would print at 10 characters per inch uh going left and right and it would be six lines per inch going up and down so on an 8 and a half by 11 sheet of paper you've actually got 85 columns possible on that sheet of paper and 66 lines now the problem was a teletype actually couldn't do uh 85 columns wide it can only print uh if I recall correctly about 67 columns if that's not the right number it's pretty close uh and so it could only print like at 6768 columns uh and so you can imagine that piece of paper being centered in that uh output of 67 columns out of a possible 85 uh and uh you know around 1969 you started to see video terminals come up and this is a uh a bt52 which actually came out uh I think in 1974 uh and so it's actually a little late for what we're talking about here for 50 years ago but you know since 1969 when we started to have uh you know video terminals around and so that's what we're going to kind of simulate today is we're going to pretend uh to run on a uh on a video terminal uh from around uh 50 years ago 1973 uh and so we'll simulate that I'm going to exit out of the presentation and we can simulate that uh by using cool retro term and so cool retro term is a sort of sim ating different effects you can get on a video terminal and so it's highly pixelated by by Design to kind of simulate that old uh display now here this is set up to be uh 80 columns wide and 24 columns tall uh and that's because uh it's really the font really as I chose but uh terminals would actually be 80 columns wide and they would actually the screen could display 25 lines but the bottom line is usually reserved for uh the terminal itself to display status information so you really got 24 lines uh being displayed back to the user so if you ever wonder when you bring up a terminal window in Linux why it only has 24 lines well that's because it comes back to this uh and so uh having a terminal here that's 80 columns wide by 24 columns tall actually doing a pretty good job of simulating what it looked like to be on an original uh Unix system now I want kind of play around and kind of show what it looked like to do real work on a Unix system from 50 years ago and so here I've got it's just set up as a dumb terminal uh it doesn't do anything like like VI I don't have anything in my current uh directory uh and so let's go ahead and edit a file now again uh there is no way to clear the screen here right this is basically emulating a uh a teletype device but only through a video screen so you're never going to clear the screen and what we're going to see here uh and so let's go ahead and edit a new file now one thing you would do to uh edit a document or create a document uh for print uh on Unix 50 years ago was you would use the enroth uh type setting system Document Preparation system and so let me do a simple document that this that does that and so we'll use the add editor and I'm going to edit a new file now uh you don't actually have to use file extensions back then file extensions pretty meaningless uh and so these days if you're going to write an enroth document or actually gr is the implementation on on Linux systems today uh you could use an extension and a lot of people who write gr documents actually use an extension to indicate what macro package they're using but here we don't have to we don't actually have to do that so we'll do add on a new uh file that we'll just call an magly uh file and there is no file in there right because I did an LS and it was an empty directory and so it's just telling us that there is no such file or directory and it looks like we've hit an error and maybe the system is hung because we're getting no other output on here but actually this is what you'd expect right there is nothing there and Ed is now waiting for us to do something and uh it doesn't display a prompt by default the original Ed did not display a prompt now on Unix systems today or or Linux systems today using G Ed you can actually do a capital P and that will uh generate a star for a prompt but I'm actually going to go really old school I'm not even going to display any kind of a prompt we're just going to do it sort of typing commands I guess I'll describe it into the air uh and so let's insert some new files we're actually because there's no file here we're in a new file and so anything that we insert is going to be right away at the beginning of the file and so let's go ahead and insert some new text using the I command and so I'll just hit return on that and so now I'm in insert mode and so uh Ed is a mode based editor and so you think about you know VI and you read about these different modes that it has edit mode command mode it actually got that from Ed it was a pretty big deal when you had editors later on uh like emac and other ones that were modeless right there was no exiting out of edit mode uh to run a command you could uh you could you could ex execute a command but you're right back into uh edit mode and so you could execute a command by for example an emx with the Escape key and you could meta x uh to run some command like that uh in a modern system using a goey you're probably using a menu uh to activate a command or something but uh here in Ed it's mode based and so we were in command mode and now we've done I now we're in edit mode we're actually inserting some text and so uh we could write uh documents in uh in enro I'm going to do it without uh any kind of macros and we'll add that in in a little bit and so we're going to just add some vertical space on my document so we space down uh let's space down by two Ines and so if you remember that there's six inches per line uh then two inches would be 12 lines and so we're going to add 12 blank lines of space and I want to uh Center some output maybe I want to create a uh a title page here and so we're going to do uh or at least the title of a document so I'm going to Center using doce that will Center uh the next line if I just have doce or I'm going to actually Center in this case the next two lines of output and the first one's going to be uh first line will be Linux uh like uh 50 years ago and then I'm going to add an extra blank line of space that doesn't actually count towards thece doce being two in this case is going to Center the next two output lines uh and a blank line with a dosp doesn't actually count and so now I'm going to do another line will also be centered we'll just put in my name Jim hall now I'm going to uh stop inserting there I'm going to do a period and that tells uh the Ed that we're actually done doing an insert because I just realized of course that Linux like 50 years ago is not uh in let's let's put it in all uppercase uh and so what line is that and so we can actually need to run a command to tell it uh what line we're going to edit uh and so we can figure out what lines we have by asking it to print out all the lines with the number in front and so we'll do one comma and then dollar sign that says start at line one and go until the end of the file dollar sign means the last line of the file and then we're going to do an N command and that will put a number in front of each line and so there it is I've got uh numbers in front of each line uh and so I want to edit line three and so I can actually just remind myself what line three looks like by doing a three that says it's going to execute something on line three I'm going to just print it out without any kind of uh you know tabs or numbers or things like that just to remind myself what the indentation level is like and so let's go ahead and and change line three so we're going to do a three to indicate that we're going to change line three and c will actually change that line and so I hit return and then I'm going to do it on all uppercase uh Linux like 50 years ago and uh I'm done editing that and so now I'm going to do period to get out of the change mode right because if I kept adding more lines it's just going to keep inserting more text but I only wanted to change that one line so there it is I've just edited line three now how do I verify that actually that looks right well I can do one comma dollar to print out all of the lines of my file although actually you could use percent percent is actually shorthand uh for the for for the entire range of the file so percent is the same as doing one comma dollar and we'll print out the contents of my file and so this is one two three four five lines that are in my file and so I've now made a uh capital I all caps uh uh title of my document and so after line five I'm going to pend some information to this and so we're going to pen some lines and then I can just uh type in uh a document and so I might for example do a temporary invent of let's say four spaces and so four spaces uh or sorry five five spaces there new four spaces uh and that will now create a temporary indent and so I'll just describe a little bit uh what it's like to use enro and so I'll say uh this is the uh enro uh Document Preparation system and then I'll I I tend when I writee uh when I write documents in nro or or or t T TR is a more recent version I tend to uh start new sentences on a new line it doesn't matter because enro is actually going to collect these words and fill a paragraph in fact I'll describe that here I'll say uh enro will uh collect words actually let's let's underline that I can actually say actually will underline that word will collect uh uh words and uh and it will and it will uh uh fill we'll underline that. UL will fill paragraphs and so collecting words means it's going to read uh words one at a time from the input and it's going to fill the paragraphs gonna try and put that as on as wide as we uh can now uh enr this only this version uh and that's the enro program uh expects to print to a typewriter like device which means every character has the same width and the original as I said uh teletype Model 37 uh normally printed uh at about I think it was 67 columns but you could load us letter paper single sheet which was actually uh an imaginary uh 85 columns and that's because uh it was printing at uh 10 characters per inch and six Lin lines uh per inch okay so I don't want to spend a whole bunch of time writing my document but as you can see this is now uh a a simple document so I'm do period to get out of my uh insert mode and so now I've been uh adding some uh uh some text to my document uh if I were to want to kind of review where I am I can kind of look at uh the whole file by doing percent and then P that'll print out the entire document and so you can see that uh this the third line on the screen is actually the percent P that I just typed as the command and you can see the rest of my output there is uh is showing uh you know the SSP which is gonna uh space down 12 lines. ce2 will Center the next two lines uh there's a a TI which will do a temporary indent I've got ti4 a little temporary in that you can see some uh lines are being underlined and so this is how you would write documents on Unix uh 50 years ago and so if I were to just write this back to disk and so I'm just gonna write this back to disk here let's go ahead and and quit the editor so it's written 467 bytes back to the system and quit back to the operating system and now there I am back at my Enix shell and I'm going to just do an LS so we can see that my file exists now if I wanted to print this out uh I would just run enroth with the file now that's going to generate one page at a time it's going to print out uh 66 lines and so anything that's blank uh it will basically print out some blank lines to kind of fill out the rest of the 66 Lin so when I when I run this command we'll actually see kind of a blank screen I don't think we'll have any uh any lines at the top yeah and so there we go it looks like it looks like we cleared our screen but actually because our content is sitting way above now let let's imagine what it's like to print on a teletype and so let me skip over to a uh I've got a teletype window that I've got here and so this is a gnome uh terminal and I've got this set up to be uh 80 colums wide and 67 uh lines tall and uh you know as I said the uh 80 columns is pretty common for a uh for a terminal today but as I said teletype for actually uh about 67 lines wide and so I'm going to do 67 and so I've got 67 lines wide or columns wide and 67 lines tall now why do I have 67 lines tall it's because when I uh run this command uh when I when I print out uh the contents of of a single file uh this way we can see 66 lines and then my my my prompt will be at the bottom so we actually won't Roll Off The Top Line uh how do I know that well if I were to go back to my regular uh shell over here and just actually run uh enroth on my file and we'll send it to some output file let's call it out uh now if I bring up my terminal window again if I were to uh let's say edit that F so I want to be able to generate some I want to generate some uh line numbers in front of that well if you go back and look at the slides we we don't have o doesn't exist uh not yet and so we can't actually run a command that will uh put line numbers in front and I know some of you are like well just run the dashn option on cat well that didn't that option didn't exist yet either uh so Unix was uh the intention was every command would focus on doing one thing very well and it would send its output to another program which would then further modify it and so I don't actually have a command in 50 years ago that's going to show me uh line numbers in front of of my uh my file except I actually do we just did that with Ed and so I know that this is kind of small you may not be able to see the output here very well but that's that's actually okay uh the the point here is we just want to see uh the lines on here and see that it starts at one which I think you'll be able to see and then um uh I have a a prompt at the very bottom of the screen so here you can just did an LS and you can see file and then out and out was my output and so let's run the output uh into the Ed command so we're going to run Ed on the file out and so it's red 592 bytes and remember I want to print all the lines with a number in front remember how we did that we did that with percent and then n and so this is sort of the cheap way just to demonstrate from 50 years ago Unix uh that this file really does have uh 66 lines in it and so here we've got 66 lines and actually somehow my terminal has less than uh actually we go it's 67 and so oh it's because my output is uh is too wide and so my output is actually really wide there um and so I can fix that in a second but as you can see the important thing is at the bottom here I've got 66 uh and then the next line is my uh shell let me go and do Q to get out of the uh editor uh and so let's let's go ahead and fix this issue where I have uh you know my output is kind of wide and it's it's wide because uh the current version of enro just has a that you're going to be printing something a little bit wider and so you would actually create uh a uh a document 50 years ago that would actually control output and so we're going to edit a new file we're going to add on a new file it's going to control the page layout so what's called page that file doesn't exist let's go ahead and insert some lines and so here we want to set the line length now the uh uh if I if I'm if my my teletype can only print out uh 60 7 lines well I definitely want to have uh my line length being less than 67 I also have imagine remember that my uh uh my eight and a half by 11 sheet of paper can actually actually has 80 uh if I would imagine 10 characters per inch it has basically 85 columns in theory on it it's not printing all 85 columns but we can imagine there's 85 columns to display on a piece of paper uh and so uh you know 85 minus uh 67 is is getting kind of close to uh 10 so I'm just going to do uh sort of five characters as an offset there and so I want to do uh let's do a line length I think I can do a get away with this if I say it line length. LL is going to set the line length uh and I think if I set this to I'm trying to do some math in my head uh and I think if I were to set this to um 60 characters wide on a line and then I also want to insert a little bit uh of page offset on the left hand side to kind of make an imaginary margin uh and so I can do A.P that's a page offset and so this is how uh documents were written 50 years ago in un we do a page offset let's do like doesn't need to be very many because we've got uh some characters kind of lost on the left hand side because they're we're centering our our uh our piece of paper on the 67 output 67 Columns of output so we'll just go like four column uh on the left hand side I don't need to do anything else than that I can just do period to edit that to end my insert I'm g go ahead and write my file and quit back to the operating system and if I were now run that using enroth on page now Define my page setup and then my file and send that to out and so now I'm overwriting my output file and I were to go back to my terminal window window let's Ed let's do run that through Ed as well so we'll run Ed on the output file and let's go ahe and print all lines with a number in front of it uh and the number is getting in the way so let's go ahead and just do print all lines um on file and so there it is I've got a document that I've now printed uh through uh enroth that I could uh display on my system and so uh now now what does this look like we have an 8 and 1 half by 11 sheet of paper so this is 67 wides uh 67 columns wide and so let's actually add another terminal to this and so this is another terminal that I have it's set up as again 80 columns wide but uh in 67 columns tall let's go ahead and make that 85 columns wide 67 columns tall or 67 lines tall and so this should be roughly the size of a piece of paper uh and if I were to uh actually we'll just make it one row shorter now this 85 by 66 should be the size of a piece of us uh letter paper and so I'm just going to move that on top I'll just move my uh other window so it's more or less centered this is about how you do it by printing a piece of paper on a or printing a document on a piece of paper so you can imagine that uh this terminal window I've just now laid on top of the wider terminal window this is the output uh from a teletype Model 37 and the white uh terminal behind it is representing a USL piece of paper and so as I print out my document you can see on the left hand side there's a margin over there and I've tried to balance this document so that I've got a line length set up and uh a page offset so the length of my line and then a page page offset on the leftand side so I can kind of Center my uh my page my my my document inside uh my 8 and half by 11 sheet of paper it looks like I probably could have uh maybe subtracted something from the um from the layout there on the on the right hand side but we'll leave it as it is and so this is how you would write documents now you actually wouldn't spend a lot of time uh writing your own you know macros to set up the page for example uh you actually would create a bunch of macros that kind of Stack up uh these commands to do different things and so as you were to write a technical document you probably want to uh you know do things like uh temporary indent by default you want to be able to uh you know create section headings you want to be able to italicize uh uh output and things like that oh by the way let me demonstrate uh since we actually had some underlining in there uh so there's my 8 and half by 11 sheet of paper uh and you can notice by the way I just want to highlight that you can actually see uh this is an underlined word and this is an underlined word I didn't really highlight that earlier but that's that's that's the output that you're seeing and of course it's filled out the paragraph So it's completely uh filled out even though my input lines didn't go all the way across the Page by the way I'm add right there I'm g go and quit it so I can get out of it right so as I said you wouldn't actually normally spend uh a lot of time you know typing these enroth commands by hand you actually would stack up a bunch of uh commands together to Define some macros and you can do it on your own for example if I were to uh edit a new file uh called paragraph and all it's called par and I could that's a new file and we'll insert some lines here and we'll Define a new macro called PP this is what you do to add a new paragraph PP is a typical uh abbrevi a for new paragraph I just added some extra character there and so you could for example add a new blank line withp add one line of space uh you could do a temporary invent of four spaces and then we're done right we're done with our macro and so do dot is the end of a macro definition but we're still in the insert mode so we can go ahead and exit out of insert mode and then we can write that back to the operating system and we can quit it now let's go ahead and edit our file to actually use the pp macro and so let's go and added my file and remind ourselves what's in there so let let's do a percent n so we'll see what's what's all in there and I want to replace that ti4 that's on line six with. PP and so I'm going to a six c will allow me to change line six and we'll replace that with PP and let's go ahead and and finish my change with period now I also want to let's let's say I wanted to uh start a new paragraph where it says the original teletype Model 37 normally printed at about 67 columns and so uh that by replacing that one line I shouldn't have changed my lines uh my line numbers and so it should be inserting a new line at at line 17 but just to remind ourselves what's in here let's let's start at line 15 and we'll end at line 18 and we'll print those lines out and so yep definitely true that uh uh 15 is this version line 16 is device uh line 17 is the original teletype a new new sentence which I want to make a new paragraph and then line 18 is 67 column so I want to uh either append to the end of line 16 to make a new line or I want to insert ahead of line 17 to make a new line either one of those will do the job and so I'm going to do a 16 append and so I'm going to append uh new lines after line 16 we'll just insert uh a PP instruction and I'm done adding new lines we'll do a period to stop editing and let's let's see what that looks like so we'll start at line 15 and go to the end of the file we'll print out those lines and sure enough I've got a new paragraph macro in there so I'm using my paragraph macro and so way I would just do uh write that back to disk and uh quit back to the operating system system and let's remind ourselves what that looks like when we now print it and so go back to our there's our 8 and half by 11 sheet of paper and there is our uh teletype output that's coming in and so if I were to run enroth uh on the page definition as well as the paragraph macro that I just defined and then the file itself that now creates a new paragraph where it says the original teletype Model 37 and so uh you're starting to see how you would use these macros You' build up these macros to create more complex documents and in fact I chose P because it's very similar to another macro package uh called uh the me macros written by Eric Alman uh and I think everything in here is okay but let's go ahead and add my file one more time and we'll print it out and just make sure that everything in here is okay everything is uh so I've got which I could keep that way but actually uh uh we could we could replace that uh to be more accurate with the uhme macros and so let's let's see what lines that is for uh for UL now it the interesting thing is I and I've done this by uh playing around with Ed long enough as sort of a running everything on command line uh you're you start to build up a kind of a mental model of where things live in your uh in your document and so you kind of I kind of by doing that I kind of know that I should probably start around line eight go probably around line 17 maybe line 20 uh but I'm going to start at line eight and go to line 15 and I'm going to print out those with an N so that'll be a number in front and so yep you can see that uh nine and 10 uh are the ones that have the underlined with collect uh and so let's instead of doing underline let's use a macro that the me macros would use uh which is Dot I that'll do a Talis sizee if you're G on a typ Setter uh but on a teletype device like this it's going to print out using underline and so I actually want to change uh line uh nine and I need to get rid of line 10 so let's let's Del get rid of line 10 so we're going to do 10 D that will get rid of line 10 so now 10's been deleted and let's go ahe and replace line C so I'm going to change uh I'm sorry change line nine so there's N9 C will allow me to change line nine which isul so we'll do I and then the word collect and I'm done editing so there we go it's our period and let's look at that again so we'll do uh start at line eight go to line 15 and we'll number those lines yep and you can see that I got rid of my ul and replace it with UL or with I and then the word collect and do the same thing for lines 11 and 12 so we're going to get rid of line 12 12d we'll delete it let's change 911 uh and we'll do that oh actually you know what let's do this let's let's uh let's do one other uh thing way that we can edit uh documents we can actually use the swap command and so you're probably used to this if you use said on the command line or maybe you use VI and you probably using this command all the time the S command and so now that I've deleted line 12 I actually want to operate on line 11 and on line 11 I want to swap uh some characters and so I want to swap the UL command or I and then the word fill and so the way that the S command Works in said or in Ed and it works the same way in uh in said and VI is it's going to swap text starting at the first slash and going to the next slash that's the text it's looking for and then between that that second slash and the third slash that's the text that's going to replace it with and if I had more than one instance on the line that I wanted to replace this UL with Ifill I could do G to make it Global but I don't need to do that I'm just going to do uh just one instance and so now I've swapped line uh 11 to change the UL to an I fill so now it's got a Ifill so let's go and look at line 11 we'll just print it out yep there it is Ifill and so now if we're just just going to show you what the entire file looks like we'll just print out the entire file and so this is more like what you would expect to see in a u uh in a in a enroth uh document using the M macros and so let's right back to the back to the operating system and we'll quit and now we can uh go back to our 8 and half by 11 sheet of paper that's our reminder there and we're going to uh now run the nroth command using the M macros I I still need to set up my page the same way but now I don't need to have my parah file which is my my definition for the paragraphs I can just now run the file itself and so there it is I've got a document that I was able to print out uh using the me macros and so that is how you can write documents now uh how what if I wanted to print this out what if I had a multiple page document uh for that you would actually need to write uh we you'd use the type command the type command I mentioned earlier which we actually don't have as I said the type command and so here I'm actually in reality running a A bash shell and if I were to run the type command uh on let's say CP it'll tell you that the CP command is actually been CP but in original Unix type is a command that would uh print out 66 lines and then wait for the user to press enter and then it would uh print the next 66 lines and so that way the by by waiting for you to press enter you could load a piece of 8 and half by 11 sheet of paper and it would print out the 66 lines and then it would wait for you to press enter while it uh while it uh while you could load another eight and half by 11 sheet of paper so I'm going to real quick here write a a c program an original syntax C program uh that will replace the type command and so for that we're going to just remind ourselves what files we have in here I don't actually have a type command and so we're going to do an ed on a file called type.

C now type do. c doesn't exist and uh it's really just waiting for us to enter a command it's not actually an error per se and so I can start inserting some lines and so I'm going to go ahead and insert and start typing a new a new uh program now this is something that's interesting and I would challenge you to do it on your own uh run a full screen terminal for like a week and write documents using enroth and edit files using Ed you'll find that your your brain kind of uh starts to work a little bit differently than uh than we do today with the guey uh and so it sort of becomes second nature so I'm going to try this a little bit slower but to me it is kind of at this point second nature uh but I'm inserting uh lines here I'm going to do my include standard i.h and you know to define a new function in modern C you would say well I'm G to define a new function it's an integer function uh called pause and that's a void function doesn't actually take any input uh but that's not original style C so let's let's actually back up a second we'll stop editing my current line is the last one I was just editing so if I do p you can see it's actually just the line that was on and so let's go ahead and and change that line so we're going to change that line to actually be original style C and so original style C 50 years ago uh every function was really integer if you didn't ask for some to be something else and so we can just type pause and then an parameter list because there it doesn't take any options uh and then we'll do our uh open curly brace by the way you'll notice I'm still doing C from that last line so actually we're inserting new lines as we go we changed that line and now we're adding new lines to our file and so here we're going to uh read a key and so we'll do in a variable called key and that's like meant to be the key press and then I'm just going to do a loop that's going to wait it's going to read every key from standard input because that is the terminal right 50 years ago that's a terminal uh and so it's going to read from standard in and it's going toh just look for a a new line character and so it's going to do a while that key being uh equal to the get uh care function and as long as that is not equal to a new line then it's going to just do the while loop right semicolon I don't have to have a there's nothing that it does otherwise I don't I I'm not processing anything and then once it it's done it's going to just go ahead and return back to whoever called it and we'll give it zero because I don't really care all right and so that is a uh a function in original style C uh now I actually need a fi a function that's going to type out the contents of a file one line at a time time uh and it'll do only 66 of them now in modern programming you actually would Define a parameter uh called page length or something and you define that to be 66 because you know that's good programming you parameterize that stuff um but we're doing this on a on a teletype Model 37 and we know it's going to be 66 lines six lines per inch 11 uh inches long and so that's 66 uh lines and so we actually need to define a parameter here we can just do the actual number so here we go we're going to define a function here called type file and type file uh takes uh a file argument uh that we're going to call in oh wait a second that's actually modern SE style right so Pro I know some people out there that are like oh no no no that's that's that's modern sea style and it is and so we're going and we're going to we're going to remind ourselves here what we've entered in so I've done P to get or dot to get back to the edit mode and we're going to go ahead and and print out the entire contents of our file and remind ourselves what what line we're on right now so let do p for the current line and that's the type file so we'll go ahead and change that and it'll make it look like original style C and that is type file uh on uh with a variable called in and in is a file pointer and that's what that looks like and now I can start my function and so if you haven't seen original style C before that's that's original LC uh and so here we need to read uh A A Single Character at a time from our file and so I need a an in ch which will be a single character that we're reading from our input file um this is not the most performant program um but you know because like you would probably today write this by reading buffers or something like that but um on a original style Unix system we're we're measuring memory in kilobytes and so we want to save as much as we can if we don't need to uh you know read everything uh into a into a buffer then why bother we're going to just read one character at a time and in any case printing the output on the uh on the teletype is actually going to be slower than reading data from a file so it it turns out performance isn't really an issue for reading files because the output's going to be slow anyway uh so we're going to just uh read one character at a time uh and I need to have a variable in here called lines that will count number of lines that I've read I'll just initialize that to be zero and then I'm going to do a loop just going to do a loop here so while uh the character is read from actually it's an F get C uh read from that input file and as long as that isn't the end of the file then we're going to keep doing our Loop and all right so what do I do inside there so once I've read the character I can actually print it back out to the uh to the output and so in theory if I'm typing this out on 8 and half by 11 sheet of paper this is just printing one character at a time so I'll just do a put care uh of CH and I I want this to go to standard output I don't I don't want this to go to uh like parameterize this and have it go possibly to a file or something we know we're printing this to standard output let's just print right the standard output with the put care function uh and then once we've done that we we should probably double check if that was a a new line and so we're going to say uh if that character was a new line character then uh we want to uh add one to the to the line count and then check if our our line count is now reached 66 and so we could do that a couple different ways we could say uh lines equals lines plus one um and then we could check uh if lines is 66 and we're going to do something but that's actually not how C program is right that and so I'm going to do period there to get back into uh into my command mode by the way let's save before we do anything else because it's always good to save early save often uh and so where was I I left off here I'll just number that so that's that's line 22 and so let's back up to line 18 uh and go to the end of the file and we'll we'll print those lines out uh and so I want to replace those last two lines and so let's go ahead and get rid of the last line uh so if I count on screen I can see put care is line 18 the blank is line 19 uh 20 is the if uh 21 is the lines equals and 22 is the if and so I'm going to go ahead and delete uh line 22 and then we're going to swap out line 21 so 21 C and so the more efficient way to write that as a c programmer uh is to uh just say uh if uh and then we'll increment lines first if lines uh is lines equals uh 66 then we're going to call the pause function which we'll read from standard in until it uh hits a a return key and then it will then reset the lines back to zero I think I'm keeping track of this I think that's my if over there and then this one should be the other if that I had and then reminding ourselves what we have so I'm going to start at line 15 and go to the end of the file just number them out and so there we go so my next one needs to be the while and so let's do remind ourselves here 25 gr just so I know where my invent level is we'll do 25 append and then that should be the while loop right there and then we can return back the whoever called us return zero and there's our function there and so we're almost done we're actually almost done with the type uh command and so now we can write our our main functions so normally we do an INT main with uh ARG c k arv uh but remember original style C it's gonna look like this we're gonna say Main and then argc and then arv that's going to be an INT argument count and a character array of arv and there's my main function and we're going to have a file pointer here let's call P file and then we're going to uh be able to parse the command line we're going read each command on the command or file on the command line so we'll do an integer I to sort of loop through and then we can do a loop that says 4 I equals 1 that's the one after the the command itself and then I is less than r c and then i++ and then we're going to open that file P file will be uh using F open of rvi so if you haven't done C programing before we just now opened a file from whatever is the I entry starting at one uh where one is the first command line option uh and we're going to open that for reading and then if we actually have a valid uh file pointer and I know there's people out there that do program and see and they're like you're not comparing that to if it's not null this is this is fine original style C this is totally acceptable uh and then I'm going to uh if that is true let's let's give the operator a moment to actually uh now swap in a piece of paper and so we'll call the pause function there and then we will type out the file that is pointed to by P file and then once I'm done with that I probably should close my file so do an F close on P file and once I've done that that's all I need to do I'm going to just silently ignore any uh here let's do this I'll I'll silent ly ignore um any missing files or any files I can't open um because we're we're typing this out to an 8 and half by 11 sheet of paper and that's probably expensive so we don't want to be printing out error messages we'll just silently ignore that and then there's my for Loop and then I can return back the operating system and then there's my closi

2023-11-12 00:24

Show Video

Other news