It is currently Tue, 07 Dec 2021 02:18:48 GMT



 
Author Message
 #!/bin/tcsh vs. #! /bin/tcsh
Is there anything wrong in starting a shell script with the line

#! /bin/tcsh

To avoid heaps of smileys in the replies - I'm interested in
answers regarding the space after the exclamation mark, not
the fact that I'm a tcsh user :-)

A read a number of articles where people posted that one should
avoid the space - could somebody fill me in on whether that's
correct and why ?

Thanks a lot,
patsch

--
Patrick Dockhorn \ Uni-Bibliothek \ Kaiserstrasse 12 \ 76131 Karlsruhe \
\ e-mail: pat...@ubka.uni-karlsruhe.de                \ Germany  __o    \
 \  There are two rules for success in life:           \       _`\<,_    \
  \   Rule 1: Don't tell people everything you know.    \     (_)/ (_)    \

--
Patrick Dockhorn \ Uni-Bibliothek \ Kaiserstrasse 12 \ 76131 Karlsruhe \
\ e-mail: pat...@ubka.uni-karlsruhe.de                \ Germany  __o    \
 \  There are two rules for success in life:           \       _`\<,_    \
  \   Rule 1: Don't tell people everything you know.    \     (_)/ (_)    \



 Sat, 27 Jan 1996 15:00:03 GMT   
 #!/bin/tcsh vs. #! /bin/tcsh
In article <247h1j$...@nz12.rz.uni-karlsruhe.de>, pat...@ubka.uni-karlsruhe.de (Patrick Dockhorn) writes:
|> Is there anything wrong in starting a shell script with the line
|>
|> #! /bin/tcsh
|>
|> To avoid heaps of smileys in the replies - I'm interested in
|> answers regarding the space after the exclamation mark, not
|> the fact that I'm a tcsh user :-)
|>
|> A read a number of articles where people posted that one should
|> avoid the space - could somebody fill me in on whether that's
|> correct and why ?

        Hmm... I've always used the space...

-----
Greg Thoman:  The opinions expressed herein are mine alone, and I am
              solely irresponsible for them.



 Sat, 27 Jan 1996 23:29:22 GMT   
 #!/bin/tcsh vs. #! /bin/tcsh
In article b...@nz12.rz.uni-karlsruhe.de,  pat...@ubka.uni-karlsruhe.de (Patrick Dockhorn) writes:

Yes, do NOT have a space. Why is because then it does not work! It
will ignore the "/bin/tcsh" and use /bin/sh instead.

                                                                Z

--
-------------------------------------------------------------------------
| Syed Zaeem Hosain          P. O. Box 610097            (408) 441-7021 |
| Z Consulting Group        San Jose, CA 95161             s...@zcon.com |
-------------------------------------------------------------------------



 Sun, 28 Jan 1996 02:16:52 GMT   
 #!/bin/tcsh vs. #! /bin/tcsh
s...@zcon.com (Syed Zaeem Hosain) writes:

Well, then it should be reported as a bug. However, version 6.00.01 of tcsh
that we have here properly handles scripts that have and do not have
the space. For that matter, sh, ksh and csh also handle the space/no-space
difference.

But now that I think of it, I recall that an OS bug was reported in the past
several months concerning just such a problem; I don't remember details, only
that scripts would work one way, but not the other; the problem was not
with the shell, but in the OS.

Fester



 Sun, 28 Jan 1996 23:12:33 GMT   
 #!/bin/tcsh vs. #! /bin/tcsh
In article <1993Aug10.181652.8...@zcon.com>, s...@zcon.com (Syed Zaeem Hosain) writes:
|> In article b...@nz12.rz.uni-karlsruhe.de,  pat...@ubka.uni-karlsruhe.de (Patrick Dockhorn) writes:
|> >Is there anything wrong in starting a shell script with the line
|> >
|> >#! /bin/tcsh
|> >
|> >To avoid heaps of smileys in the replies - I'm interested in
|> >answers regarding the space after the exclamation mark, not
|> >the fact that I'm a tcsh user :-)
|> >
|> >A read a number of articles where people posted that one should
|> >avoid the space - could somebody fill me in on whether that's
|> >correct and why ?
|>
|> Yes, do NOT have a space. Why is because then it does not work! It
|> will ignore the "/bin/tcsh" and use /bin/sh instead.

        I just double-checked on the Sun I'm using and it works
fine either way; at least on this system, it does not use the wrong
shell.  I'm reasonably sure it's fine on the RTIX box I used to use
too, since I used the space all the time.
        The idea of a space causing the line to be ignored sounds
like a bug...

-----
Greg Thoman:  The opinions expressed herein are mine alone, and I am
              solely irresponsible for them.



 Mon, 29 Jan 1996 04:44:17 GMT   
 #!/bin/tcsh vs. #! /bin/tcsh
In article <murphyn.745081953@galena15> murp...@rtsg.mot.com (Neal P. Murphy) writes:

At the risk of getting my head blown off here, it's not necessarily
down to the shell is it? It's the kernel that decides whether a script
has a valid interpreter. If the execve of the script fails it's not
technically a valid executable but most shells will have a last resort
option of feeding it to a shell. So is the kernel recognizing '#!
/bin/foo' and '#!/bin/foo' or are shells clever enough to do it when
it's wrong?  Just about every shell I know will feed a script starting
with a bare '#' to itself.

FWIW 'file' on SunOS4.1.x will recognize '#! (200 spaces) /bin/csh' as
a c-shell script but not #!  (1200 spaces) /bin/csh'.

Several posters have said that scripts with the space don't work.
Does anyone have any facts to support this or is it just the usual BS?
All the man pages for execve I can find (ConvexOS, Irix, SunOS, AIX)
*DO* have the space in '#! /bin/foo'. Sun's (4.1.x) shell scripts
mostly have the space, ConvexOS and AIX mainly don't although some do.
Irix 4 and Irix 5 are a mixture.

None of the above OSs seems to notice the difference and certainly
their vendors don't worry about it.

John



 Tue, 30 Jan 1996 05:53:05 GMT   
 #!/bin/tcsh vs. #! /bin/tcsh
In article 5...@bigguy.eng.ufl.edu,  tho...@helios.tcad.ee.ufl.edu (Greg Thoman) writes:

May have been. It was either in SunOS 4.0.3 or 4.1.1 that I first
saw it happen to me - I misremember. I just checked and it seems
to be okay in SunOS 4.1.3 anyway.

                                                        Z

--
-------------------------------------------------------------------------
| Syed Zaeem Hosain          P. O. Box 610097            (408) 441-7021 |
| Z Consulting Group        San Jose, CA 95161             s...@zcon.com |
-------------------------------------------------------------------------



 Tue, 30 Jan 1996 14:29:40 GMT   
 #!/bin/tcsh vs. #! /bin/tcsh

Exactly the impression I've been under; and maintained by R. Stevens in
'Advanced Programming in the Unix Environment' (pp 217-221). Even if the
shell would check the first line for #!, it would still have to call
exec(), because sourcing the file is out of question whether the
interpreter is the shell itself or not. The sh (1) manual page further
encourages this view.

Indeed. If exec() fails to execute the (executable) file, it is assumed
to contain shell commands, and it is fed to a subshell. At this stage the
subshell considers the #! line to be a comment, and simply ignores it.

On a SunOS 4.1.3 the following will work expectedly:

---------------
#!                   /bin/awk -f
BEGIN   { print "worx" }
---------------

However, the following won't:

---------------
#!                    /bin/awk -f
BEGIN   { print "worx" }
---------------

On the first script above the #! line is magically 32 characters long
(33 on the second one).

I would be very interested in hearing this too. In my very limited
experience the only thing to assume that there is no space on the #!
line has been gopher (v. 1.12). The 32 character limitation could be
strategic if you keep interpreters in some weird directory with a
25-character name.

--
rw



 Tue, 30 Jan 1996 08:47:14 GMT   
 
   [ 8 post ] 

Similar Threads

1. /bin/tcsh vs /usr/local/bin/tcsh

2. #!/bin/tcsh vs. #! /bin/tcsh

3. Can /bin/csh be replaced with /bin/tcsh?

4. /etc/shells - getusershell - /bin/tcsh ????

5. /bin/tcsh is not a valid shell

6. Only root can login! /bin/tcsh: permission denied

7. tcsh ~/bin add to path how

8. bin tcsh for sun 386i (request)

9. /bin/tcsh

10. pwd not in csh/tcsh, coding /bin/pwd ?


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software