[Gllug] csh shell scripting woes

Tom Gilbert tom at linuxbrit.co.uk
Wed Mar 13 23:31:13 UTC 2002


* Stig Brautaset (stigbrau at start.no) wrote:
> Hi there, 
> 
> Actually, this time it is my housemate that needs help. He needs to
> write a shell script in csh for one of his courseworks. The script
> should take either of the optional arguments -i or -f. The problem he is
> facing is that the shell has its own interpretation of e.g. -f, so the
> script fails.
> 
> He has, as a temporarily measure, written the script to function
> correctly if the arguments are either i or f (no - if front), but surely
> there must be a way to turn off this "feature"? 
> 
> Both he and I have tried every combination of --, -f, -b, -c etc we
> could think of at the end of #!/bin/csh which obviously is the first
> line. We *have* read the manpage, but if it contains a clear explanation
> of the problem, then I for one can't find it. 

Er. Why are you putting arguments there?
I assume you mean he's writing a program that needs to take an -f
parameter and putting it in the hashbang, e.g:
#!/bin/csh -f

Why? That's not how you write a script that takes arguments, under any
shell.

#!/bin/csh
Is all you need. You handle the arguments in the script ($1, $2, $*,
etc)

Tom.
-- 
   .^.    .-------------------------------------------------------.
   /V\    | Tom Gilbert, London, England | http://linuxbrit.co.uk |
 /(   )\  | Open Source/UNIX consultant  | tom at linuxbrit.co.uk    |
  ^^-^^   `-------------------------------------------------------'

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list