welcome to to hell that is 35l.
this first assignment has you do things with emacs and bash, so we're off to a great start
i'm gonna assume you took 31 or 32 and have one of those seasnet accounts to login with
nothing much, just first make sure emacs is doing its thing by typing ```bash emacs --version ``` it should be 29.1
then actually start it up by running emacs without that version flag
start the tutorial by pressing `Ctrl+h` and `t`- notice that you have to do two sets of keypresses!
disclaimer: you don't have to go through all of it, just enough to give you a general idea of how crap works
run this command:
```bash
wget2 https://web.cs.ucla.edu/classes/winter24/cs35L/assign/assign1.html
```
this downloads a copy of winter 24's assignment 1 webpage to your file system
change the quarter to yours i suppose
next, copy the file (it should be DL'ed as `assign1.html`) to 3 new names:
`exer1.html`, `exer2.html`, and `exer3.html`
you can do this with the `cp` command like so:
```bash
cp assign1.html exer1.html # and ditto for exer2/exer3
```
we'll mess around with the other 2 files later, but first open `exer1.html` with this command:
```bash
emacs exer1.html # or whatever path you've copied it to
```
run the emacs command `M-x open-dribble-file` to create a dribble file `lab1.drib` that will log all your keypresses
for the current session
later, you'll do the same for labs 1.2, 1.3, and 1.4- make `lab[x].drib` files for those as well
perform the following actions with cool emacs commands- don't just use the arrow keys for everything
the TAs won't like check if you've done the actions exactly- they'll just check if the commands you used are efficient enough, like using `C-s` for forward searching and `C-a` for going to the beginning of a line
open emacs on `exer2.html` this time and create the appropriate dribble file
do these tasks, which should eventually remove all html comments on the page
again, be sure to use cool emacs commands instead of backspacing everything
to check your work, run this command: ```bash diff -u exer1.html exer2.html >exer2.diff ``` it should contain only the text you wanna remove, smth like this: ```diff --- exer1.html 2024-03-26 08:11:17.370737753 -0700 +++ exer2.html 2024-03-26 08:11:17.370737753 -0700 @@ -68,7 +68,6 @@ and you are not expected to read it all.</li> </ul> -<!-- diff,在UNIX系統上的一個工具程式,它可以比較兩個檔案之間的不同。通常它被用來比較同一個檔案,在不同版本間的差異。它可以產生一個擴展名為.diff或.patch的檔案,這個檔案可以被另一個工具程式patch來使用。--> </section> <section> ``` don't stress if your file doesn't match this exactly- again, the TAs just look to see which commands you used for deletion or whatever
open emacs on `exer3.html`, yada yada
this one actually doesn't start with opening an exer file, wow!
check by running the shell command `diff -u exer1.html exer4.html`
the only differences should be changes from `<ol>` to `<oL>` and a giant html comment at the end
but don't stress if your output is ever so slightly different!
again, the TAs will just look if you used cool emacs commands
put all the answers here along with the commands you used to get them in `notes.txt`
most of the questions here are suffixed by a cool command that can be used for it because
there's no goddamn way people are supposed to figure this out by themselves
the spec says to do this in emacs, but it doesn't matter
the TAs literally don't check if you did it so
create this file named `hello.c` or whatever you want with the following content: ```c #include <stdio.h> int main (void) { for (;;) { int c = getchar (); if (c < 0) { if (ferror (stdin)) perror ("stdin"); else fprintf (stderr, "EOF on input\n"); return 1; } if (putchar (c) < 0 || (c == '\n' && fclose (stdout) != 0)) { perror ("stdout"); return 1; } if (c == '\n') return 0; } } ```
i really recommend you understand these commands first before doing this assignment
if you don't, you can use `man` or `tldr` to figure that out
use the `sort` command and some funny redirection to make a file named `sorted.words` that contains all the words of `/usr/share/dict/linux.words` in alphabetical order
now, take this lil bash script: ```bash tr -cs 'A-Za-z' '[\n*]' | sort -u | comm -23 - sorted.words ``` it tries to be a rudimentary spellchecker, but it kinda sucks
to see why, run this command, which runs the script with the very dictionary we generated `sorted.words` from: ```bash tr -cs 'A-Za-z' '[\n*]' </usr/share/dict/linux.words | sort -u | comm -23 - sorted.words ``` a bunch of weird words come out! try to figure out why first before moving on
write a shellscript named `myspell` that looks at `linux.words` and spellchecks some text given from stdin
by that, i mean it should take in text from stdin and output misspelled words to stdout
for this assignment, a "word" can be defined as just any consecutive string of uppercase or lowercase alphabets
so don't worry, the given `tr` command:
```bash
tr -cs 'A-Za-z' '[\n*]'
```
will work just fine for separating out all the "words" of a file
if you want to, you can make a helper script `makedict` to preprocess `linux.words` first
but beware- the TAs won't call it for you! you have to run it yourself in `myspell`
you can expect the TAs to call it like so: ```bash ./myspell <file_with_words_idk.txt ```
```bash ./myspell </usr/share/dict/linux.words ``` should output nothing because the dictionary by definition should only contain correctly spelled words
say we have the following file named `lol.txt`: ``` I love Software Construction I love software Construction? Professor Eggert is the best I am "enjoying" the class Am_I_enjoying_the_class? we-all love sushi. whitefish-taste-bad ``` when we run the following command: ```bash ./myspell <lol.txt >output.xt ``` a new file `output.txt` should appear with the following text: ``` Construction Eggert Professor Software ```
if the TAs say the output should be otherwise, believe them!
alright i won't be ambiguous, here's a list of all files that should be in your thing
submit these files as a `.tgz` file- you can generate this by doing the following command: ```bash tar -cvzf assign1.tgz lab1.drib lab2.drib # .. i'm not gonna list all the files here ``` you can check that all the files are in there by doing this: ```bash tar -tvf assign1.tgz ```