Use correct syntax markup for shell
Approved by: carlavilla
This commit is contained in:
parent
55c95407aa
commit
a9a9e66105
666 changed files with 17924 additions and 17924 deletions
|
|
@ -135,7 +135,7 @@ This convention has a great disadvantage over the UNIX(R) way, at least as far a
|
|||
|
||||
If you do choose the Linux convention, you must let the system know about it. After your program is assembled and linked, you need to brand the executable:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% brandelf -t Linux filename
|
||||
....
|
||||
|
|
@ -501,7 +501,7 @@ Type the code (except the line numbers) in an editor, and save it in a file name
|
|||
|
||||
If you do not have nasm, type:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% su
|
||||
Password:your root password
|
||||
|
|
@ -522,7 +522,7 @@ If your system is not FreeBSD, you need to get nasm from its https://sourceforge
|
|||
|
||||
Now you can assemble, link, and run the code:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% nasm -f elf hello.asm
|
||||
% ld -s -o hello hello.o
|
||||
|
|
@ -600,7 +600,7 @@ Once there is no more input left, we ask the system to exit our program, returni
|
|||
|
||||
Go ahead, and save the code in a file named [.filename]#hex.asm#, then type the following (the `^D` means press the control key and type `D` while holding the control key down):
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% nasm -f elf hex.asm
|
||||
% ld -s -o hex hex.o
|
||||
|
|
@ -675,7 +675,7 @@ That means we only need to set `CL` once. We have, therefore, added a new label
|
|||
|
||||
Once you have changed [.filename]#hex.asm# to reflect these changes, type:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% nasm -f elf hex.asm
|
||||
% ld -s -o hex hex.o
|
||||
|
|
@ -803,7 +803,7 @@ We use `EDI` and `ESI` as pointers to the next byte to be read from or written t
|
|||
|
||||
Let us see how it works now:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% nasm -f elf hex.asm
|
||||
% ld -s -o hex hex.o
|
||||
|
|
@ -919,7 +919,7 @@ write:
|
|||
|
||||
Now, let us see how it works:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% nasm -f elf hex.asm
|
||||
% ld -s -o hex hex.o
|
||||
|
|
@ -1457,7 +1457,7 @@ This code produces a 1,396-byte executable. Most of it is data, i.e., the HTML m
|
|||
|
||||
Assemble and link it as usual:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% nasm -f elf webvars.asm
|
||||
% ld -s -o webvars webvars.o
|
||||
|
|
@ -1478,7 +1478,7 @@ One of the first programs I wrote for UNIX(R) was link:ftp://ftp.int80h.org/unix
|
|||
|
||||
I have used tuc extensively, but always only to convert from some other OS to UNIX(R), never the other way. I have always wished it would just overwrite the file instead of me having to send the output to a different file. Most of the time, I end up using it like this:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% tuc myfile tempfile
|
||||
% mv tempfile myfile
|
||||
|
|
@ -1486,7 +1486,7 @@ I have used tuc extensively, but always only to convert from some other OS to UN
|
|||
|
||||
It would be nice to have a ftuc, i.e., _fast tuc_, and use it like this:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% ftuc myfile
|
||||
....
|
||||
|
|
@ -2034,7 +2034,7 @@ This time I decided to let it do a little more work than a typical tutorial prog
|
|||
|
||||
Here is its usage message:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
Usage: csv [-t<delim>] [-c<comma>] [-p] [-o <outfile>] [-i <infile>]
|
||||
....
|
||||
|
|
@ -2053,7 +2053,7 @@ I made sure that both `-i filename` and `-ifilename` are accepted. I also made s
|
|||
|
||||
To get the 11th field of each record, I can now do:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% csv '-t;' data.csv | awk '-F;' '{print $11}'
|
||||
....
|
||||
|
|
@ -2555,7 +2555,7 @@ But our pinhole program cannot just work with individual characters, it has to d
|
|||
|
||||
For example, if we want the program to calculate the pinhole diameter (and other values we will discuss later) at the focal lengths of `100 mm`, `150 mm`, and `210 mm`, we may want to enter something like this:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
100, 150, 210
|
||||
....
|
||||
|
|
@ -2570,7 +2570,7 @@ Personally, I like to keep it simple. Something either is a number, so I process
|
|||
|
||||
Plus, it allows me to break up the monotony of computing and type in a query instead of just a number:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
What is the best pinhole diameter for the
|
||||
focal length of 150?
|
||||
|
|
@ -2578,7 +2578,7 @@ What is the best pinhole diameter for the
|
|||
|
||||
There is no reason for the computer to spit out a number of complaints:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
Syntax error: What
|
||||
Syntax error: is
|
||||
|
|
@ -2667,7 +2667,7 @@ So, it makes perfect sense to start each line with the focal length as entered b
|
|||
|
||||
No, wait! Not as entered by the user. What if the user types in something like this:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
00000000150
|
||||
....
|
||||
|
|
@ -2680,7 +2680,7 @@ But...
|
|||
|
||||
What if the user types something like this:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
17459765723452353453534535353530530534563507309676764423
|
||||
....
|
||||
|
|
@ -2697,7 +2697,7 @@ What will we do?
|
|||
|
||||
We will slap him in the face, in a manner of speaking:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
17459765723452353453534535353530530534563507309676764423 ??? ??? ??? ??? ???
|
||||
....
|
||||
|
|
@ -2720,7 +2720,7 @@ That still leaves one possibility uncovered: If all the user enters is a zero (o
|
|||
|
||||
We can determine this has happened whenever our counter stays at `0`. In that case we need to send `0` to the output, and perform another "slap in the face":
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
0 ??? ??? ??? ??? ???
|
||||
....
|
||||
|
|
@ -3645,7 +3645,7 @@ Suppose we want to build a pinhole camera to use the 4x5 inch film. The standard
|
|||
|
||||
Our session might look like this:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% pinhole
|
||||
|
||||
|
|
@ -3714,7 +3714,7 @@ Because 120 is a medium size film, we may name this file medium.
|
|||
|
||||
We can set its permissions to execute, and run it as if it were a program:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% chmod 755 medium
|
||||
% ./medium
|
||||
|
|
@ -3722,14 +3722,14 @@ We can set its permissions to execute, and run it as if it were a program:
|
|||
|
||||
UNIX(R) will interpret that last command as:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% /usr/local/bin/pinhole -b -i ./medium
|
||||
....
|
||||
|
||||
It will run that command and display:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
80 358 224 256 1562 11
|
||||
30 219 137 128 586 9
|
||||
|
|
@ -3744,21 +3744,21 @@ It will run that command and display:
|
|||
|
||||
Now, let us enter:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% ./medium -c
|
||||
....
|
||||
|
||||
UNIX(R) will treat that as:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% /usr/local/bin/pinhole -b -i ./medium -c
|
||||
....
|
||||
|
||||
That gives it two conflicting options: `-b` and `-c` (Use Bender's constant and use Connors' constant). We have programmed it so later options override early ones-our program will calculate everything using Connors' constant:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
80 331 242 256 1826 11
|
||||
30 203 148 128 685 9
|
||||
|
|
@ -3773,7 +3773,7 @@ That gives it two conflicting options: `-b` and `-c` (Use Bender's constant and
|
|||
|
||||
We decide we want to go with Bender's constant after all. We want to save its values as a comma-separated file:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% ./medium -b -e > bender
|
||||
% cat bender
|
||||
|
|
@ -3817,7 +3817,7 @@ There is a major difference in the philosophy of design between MS-DOS(R) and UN
|
|||
|
||||
This is NEVER guaranteed under UNIX(R). It is quite common for a UNIX(R) user to pipe and redirect program input and output:
|
||||
|
||||
[source,bash]
|
||||
[source,shell]
|
||||
....
|
||||
% program1 | program2 | program3 > file1
|
||||
....
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue