Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Would it be impolite to post homework problem...?

0 views
Skip to first unread message

Tony

unread,
Sep 27, 2001, 7:20:14 PM9/27/01
to
Hi, I am taking operating system course in my college. It's a really
tough course and I need to program everything in C. I just got my
second assignment and need to write a real simple shell. I don't have
much clue on how to do it and need some help to get it started...
Would it be impolite to ask questions here regarding my homework?

Joe Halpin

unread,
Sep 27, 2001, 7:35:43 PM9/27/01
to
john...@hotmail.com (Tony) writes:

Well, since you're honest about it being homework, and your question
is not on the order of "please send the code to my email address"
you'll probably get more sympathy here than most.

Did your instructor give you no resources to solve the problem when he
gave you the problem? What are you working with now?

It might be a good thing for him to not give you any resources, but
surely he must have given you some requirements? What does the shell
have to do? Job control? Telepathy?

You could always look at the bash or ksh source. Search engines can
give you lots of places to find not only source, but also
documentation.

Joe


Rich Teer

unread,
Sep 27, 2001, 8:03:44 PM9/27/01
to
On 27 Sep 2001, Joe Halpin wrote:

> It might be a good thing for him to not give you any resources, but
> surely he must have given you some requirements? What does the shell
> have to do? Job control? Telepathy?

The OP should have a look at Sevens' Advanced Programmin in the UNIX
Environment.

And frankly, yes, I do consider homework questions rude (but at
least the OP had the maners to be honest about it).

--
Rich Teer

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net

David Schwartz

unread,
Sep 27, 2001, 9:17:23 PM9/27/01
to
Tony wrote:

If you post the homework question and then ask, "what should I do",
then yes, that would be impolite. If you have a specific problem trying
to solve the problem, then it would be reasonable to ask for help
resolving that specific difficulty, assuming that you had read the FAQ
and made at least some attempt to find help on the web.

Here's an example of bad and an example of good -- bad:

I need to write a program that takes a path as its first argument and
prints out all the files in that path in alphabetical order and their
total size in bytes (kind of like 'ls' and 'du' together, I guess). How
can I do that?

And good:

I need to go through all the files in a directory and I'm a bit
confused about how to use 'readdir'. The documentation talks about the
"memory area pointed to by the 'struct dirent *'" parameter, but how do
I allocate a 'dirent'? Or does the function do it for me?

DS

Andrew Gierth

unread,
Sep 27, 2001, 11:58:46 PM9/27/01
to
>>>>> "Joe" == Joe Halpin <jha...@nortelnetworks.com_.nospam> writes:

Joe> You could always look at the bash or ksh source.

Those are probably a bit hairier than is strictly necessary. A simpler
alternative (but still covering job control and command-line editing)
is the FreeBSD /bin/sh.

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>
or <URL: http://www.whitefang.com/unix/>

péman

unread,
Sep 28, 2001, 4:42:45 AM9/28/01
to
I am sure your teacher has given u example code or something to start with.
But if not there are plenty of resources on the Web about Unix programming
and a good book would be Advanced Programming in Unix Environment by the
late Richard Stevens.
"Tony" <john...@hotmail.com> wrote in message
news:f65bce3b.01092...@posting.google.com...

Lew Pitcher

unread,
Sep 28, 2001, 8:28:04 AM9/28/01
to

Caveat: I haven't read any of the other responses yet, so this reply
may be somewhat redundant.

Posting homework questions with the goal of getting someone else to
provide the answer is usually frowned apon in the technical
newsgroups. Technical homework is frequently (often? always?) assigned
to give you practice in the specific techniques used to solve the
problem, so you will get no benefit from someone else "doing your
homework" for you.

The typical response from the newsgroups will be something like:
"Post what you've done so far, tell us where you are stuck, and ask
questions. We'll answer your questions (using your posted information)
to help you get unstuck, so that you can complete your homework
problem."

Frequently, if phrased right, you can ask a homework problem and get
an answer from the newsgroups. Typically, you have to ask us the same
sort of questions that you'd ask your teacher: "Why does this happen?
How does this work? Where is this used? etc." Many of us here (in
these newsgroups) will happily expound on the theory and practice
behind the technical components (some of us are teachers at heart),
but we still won't do your homework for you. We'll just substitute for
your teacher/lecturer.

Be also aware that many teachers frequent these newsgroups as well.
Sometimes they answer questions, but they also watch for their
students. They _can_ spot a student who has cribbed an answer from the
newsgroup, and that won't be good for the student.

So, if this situation suits you, please feel free to ask away.


Lew Pitcher, Information Technology Consultant, Toronto Dominion Bank Financial Group
(Lew_P...@td.com)

(Opinions expressed are my own, not my employer's.)

Cameron Kerr

unread,
Sep 28, 2001, 8:22:10 AM9/28/01
to
"péman" <major...@hotmail.com> wrote:
| I am sure your teacher has given u example code or something to start with.
| But if not there are plenty of resources on the Web about Unix programming
| and a good book would be Advanced Programming in Unix Environment by the
| late Richard Stevens.

I'm sure you'll also find some very useful material about shells in the
GNU libc manual ftp://ftp.gnu.org/gnu/Manuals/glibc/

If you want a small shell as an example, you might like to look at ash,
which is a really small shell. (Not sure how it compares to the Unix
/bin/sh though)

Cameron Kerr
--
camero...@paradise.net.nz
http://homepages.paradise.net.nz/~cameronk/

Joe Halpin

unread,
Sep 28, 2001, 9:27:09 AM9/28/01
to
john...@hotmail.com (Tony) writes:

There was a thread about this on comp.unix.shell a while back, and
someone posted what's probably the smallest shell around. You can find
it on Google at

http://groups.google.com/groups?hl=en&threadm=3b56f535_3%40news.iglou.com&rnum=1&prev=/groups%3Fq%3D%2B%2522shell%2Bwritten%2Bin%2B%2522%2Bgroup:comp.unix.shell%26hl%3Den%26scoring%3Dr%26rnum%3D1%26selm%3D3b56f535_3%2540news.iglou.com

I don't think this will make things overly easy for you :-).

Joe

Phil Edwards

unread,
Oct 3, 2001, 2:44:52 PM10/3/01
to

Joe Halpin <jha...@nortelnetworks.com_.nospam> wrote:
> There was a thread about this on comp.unix.shell a while back, and
> someone posted what's probably the smallest shell around. You can find
> it on Google at
>
> http://groups.google.com/groups?hl=en&threadm=3b56f535_3%40news.iglou.com&rnum=1&prev=/groups%3Fq%3D%2B%2522shell%2Bwritten%2Bin%2B%2522%2Bgroup:comp.unix.shell%26hl%3Den%26scoring%3Dr%26rnum%3D1%26selm%3D3b56f535_3%2540news.iglou.com
>

Two comments.

First, the shell I see posted in that thread (the one that starts with
"#define D ,close(" isn't the smallest shell. How about this one, which
I first saw in '96:

a,b[99],*c,d[99];main(){while(printf(">"),c=d,*c=a=gets(b)){
for(;*++c=strtok(a," ");a=0);fork()?wait(0):execvp(*d,d+1);}}

Second, the version of the shell in that thread obscured three of its most
pertainent features: it won an award (can't recall what), it has a builtin
"cd" command, and when posted properly, it makes cool designs:

-------- cut here ------------------------- no not here back there ------
#define D ,close(

char *c,q [512 ],m[ 256
],*v[ 99], **u, *i[3];int f[2],p;main (){for
(m[m [60]= m[62 ]=32 ]=m[* m=124 [m]= 9]=6;
e(-8) ,gets (1+( c=q) )|| exit (0); r(0,0)
)for( ;*++ c;); }r(t, o){ *i=i [2]= 0;for
(u=v +98 ;m[*--c] ^9;m [*c] &32 ?i[*c
&2]= *u,u- v^98 &&++u:

3 )if(!m[*c]){for(*++c=0;!m[*--c];);
* --u= ++c;}u-v^98?strcmp(*u,"cd")?*c?pipe(f),o=f[
1 ]:
4 ,(p=fork())?e(p),o?r(o,0)D o)D*f):
1 ,wait(0):(o?dup2(*f,0)D*f)D o):*i?
5 D 0),e(open(*i,0)):
9 ,t?dup2(t,1)D t):i[
2 ]?
6 D 1),e(creat(i[2],438)):
5 ,e(execvp(*u,u))):e(chdir(u[1])*2):
3 ;}e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||exit(1):
5 ;}
-------- cut here ------------------------- ouch ------------------------

Personally, I like the vertical digit listing of pi. Others see elements
of Dali or Escher.

No, I don't recall who wrote either of those, unfortunately.


Luck++;
Phil

--
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace. We seek
not your counsel, nor your arms. Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen. - Samuel Adams

Rich Teer

unread,
Oct 3, 2001, 5:28:44 PM10/3/01
to
On 3 Oct 2001, Phil Edwards wrote:

> Second, the version of the shell in that thread obscured three of its most
> pertainent features: it won an award (can't recall what), it has a builtin

Looking at the code (very pretty!), my guess would be that it won the
obfuscated C contest one year.

Andrew Gierth

unread,
Oct 6, 2001, 1:52:44 AM10/6/01
to
>>>>> "Phil" == Phil Edwards <pedw...@dmapub.dma.org> writes:

Phil> Second, the version of the shell in that thread obscured three
Phil> of its most pertainent features: it won an award (can't recall
Phil> what), it has a builtin "cd" command, and when posted properly,
Phil> it makes cool designs:
[snip pretty shell]

That won "Best Utility" in the 1990 International Obfuscated C Code
Contest, authors were Byron Rakitzis and Sean Dorward.

See http://www.ioccc.org for more....

0 new messages