[net.bugs.4bsd] Ioctl Errors

steve@tellab3.UUCP (Steve Harpster) (06/11/84)

Quite often someone here will execute a C-shell script and will get the
error

	ioctl: Operation not supported on socket

This appears to come from the csh spawned to execute the script. The
scripts which cause it simply copy files, change modes and the like; 
nothing that would involve sockets. Anyone out there know where this
message is coming from? I've been searching with no luck so far. Many
thanks.....

ihnp4!tellab1!steve
Steve Harpster

crp@ccivax.UUCP (Chuck Privitera) (06/12/84)

I have seen some very bizarre things happen in C-shell scripts due
to a bug in parsing if statements.  In the manual it outlines the
syntax of if to be:

	if(expr) command

	or

	if(expr) then
	   ...
	else if(expr2) then
	   ...
	else
	   ...
	endif

Notice that the example shows no space between the if and the
opening paren.  Now, in C, bc, awk, etc., a space between if
and the opening paren is optional, in the C-shell, if you don't
have a space there nested ifs break.  Here is an example that shows
the problem:

#!/bin/csh -f

if ( $?a ) then
	echo the variable a is set
	if( $?b ) then
		echo the variable b is set
	else if ( $?c ) then
		echo the variable c is set
	else
		echo a is set but b nor c are.
	endif
else
	echo a is not even set
endif

If you run this without setting a variable a or b or c, the
output will be "a is set but b nor c are." . The first if is
matching the first else!  The problem is that the second if,
i.e. if( $?b ), needs a space between if and the left paren.
Obvious isn't it!!!  I haven't bothered to chase the problem
down I don't usually write shell scripts in C-shell. I think
I first ran into this in my .cshrc file.  Anyways, C-shell
programmers beware this one.

		Chuck Privitera,  Computer Consoles Inc.
		{allegra,seismo}!rochester!ritcv!ccivax!crp