Sponsored Content
Top Forums Programming Some questions regarding old if.c Post 302930459 by Don Cragun on Sunday 4th of January 2015 12:43:35 PM
Old 01-04-2015
Quote:
Originally Posted by achenle
Without any comments from the programmer stating the intent of the code, it's impossible to tell.


Depending on your command shell, it's usually something like this:
Code:
-bash-4.1$ command arg1 arg2 ...
-bash-4.1$ echo $?

"$?" is usually the value returned from the last command run in a shell. csh is probably different, but I don't remember exactly.
One thing Bourne based shells and csh based shells share is that $? is the exit code of the previous command. But, we're talking about a UNIX Version 6 shell here; not a modern shell. I never used V6 much (although I worked on developing PWB UNIX and MERT both of which were derived from V6). I used the Mashey shell for a while and early versions of the Bourne shell (both of which were developed as replacements for the V6 shell). (As you can probably guess from current shells, the Mashey shell lost out to the Bourne shell; but some Mashey shell features were adopted by the Bourne shell.)

The V6 shell was VERY simple. (You can check out V6 utility man pages here.) Although there is no mention of shell variables or special parameters (e.g., $#, $?, and $!) on the V6 sh(1) man page and it is clear from the description of command execution that there was no $PATH variable, I think the special parameters listed above were provided with their current meanings. Positional parameters aren't even mentioned on the sh(1) man page, but $1 is mentioned on the goto(1) and shift(1) man pages. There were no loops (for, while, or until), but the the goto command could be used with the if command to produce loops. The only file descriptors you could redirect were standard input and standard output. (The BUGS section of the man page says it is a bug that diagnostic messages couldn't be redirected.) The Synopsis for the if command was:
Code:
if expr command [args...]

Note that there is no then, else, or fi here. And, as has been noted in this thread, if was a standalone utility; not a shell built-in. If I remember correctly, the only built-ins in V6 sh were chdir (there was no cd then), login, newgrp, shift, and probably exit.
These 2 Users Gave Thanks to Don Cragun For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

i got some questions :)

Hi! Im new to all this but the computer club im in has unix i think. now my questions. 1.is it NTFS i need to partion the harddrive with to be able to use unix? 2.Unix and Linux whats the diffrense?yes im a noob got no idea been using crap windows for ages and hate it. 3.I got a win98... (2 Replies)
Discussion started by: Pierre
2 Replies

2. Programming

C questions

What does "extern" do? ex. extern int x; and another question, what about using static in functions? like: static void foo(), why? (2 Replies)
Discussion started by: Esaia
2 Replies

3. Solaris

2 Questions

Hello Everbody I hope you can give me a hand, I have some questions The first one itīs about some message that I donīt know what means, I was looking about it. but nothing. This is the message rsh: connection from bad port bsd-gw: Error reading from connection: Bad file number And my... (4 Replies)
Discussion started by: lo-lp-kl
4 Replies

4. UNIX for Dummies Questions & Answers

Just a few questions.

Hi everyone im new to this forums, i just wanted to get started by asking a few question(Im a Unix newbie) 1. How do i sort a file called "dirr" in a ascending order on the 3rd column 2. what does alias on=who do Thanks in advance!!! (1 Reply)
Discussion started by: Da Paper
1 Replies

5. Programming

two questions

hey all, I have question when am writing simple shell... in the child am calling execvp, i want the parent to know when execvp returns - 1. how can i let the parent know the result of execvp thanks in advance (9 Replies)
Discussion started by: joey
9 Replies

6. Homework & Coursework Questions

Print questions from a questions folder in a sequential order

1.) I am to write scripts that will be phasetest folder in the home directory. 2.) The folder should have a set-up,phase and display files I have written a small script which i used to check for the existing users and their password. What I need help with: I have a set of questions in a... (19 Replies)
Discussion started by: moraks007
19 Replies

7. UNIX for Dummies Questions & Answers

Just had a few questions

1) The lpr and sort utilities accept input either from a file named on the command line or from standard input. a)Name two other utilities that function in a similar manner. b)Name a utility that accepts its input only from standard input. 2) Explain the following error message. What... (10 Replies)
Discussion started by: youngyou
10 Replies

8. UNIX for Dummies Questions & Answers

Vi questions

Hello, I would like to know how we can highlight/select a section of a file in vi and delete that section if we don't want to use the dd command to delete one line at at time. There is one where we don't want to delete the whole line , but up to a certain word. (2 Replies)
Discussion started by: Pouchie1
2 Replies
All times are GMT -4. The time now is 01:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy