0

I want my Cshell script to process through my $argv list, but to cherry-pick through that list. For example:

@ i = 1
while ( $i <= $#argv )
  if ($argv[$i] == "--ignore-externals") then
    set svnargs = ( $svnargs $argv[$i] )
    shift $argv[1]
  else
    @ i = $i + 1
  endif
end

... but "shift" doesn't work like that. What's the best approach?

macetw
  • 1,640
  • 1
  • 17
  • 26
  • 1
    did you have a look at getopt? – subsub Sep 11 '13 at 12:37
  • I am a nube to getopt. It looks like it wouldn't work because it's not directly part of the shell, but then again, there was a good example I found. I'm not sure how to use it for my case. – macetw Sep 11 '13 at 12:46
  • 1
    `shift n`, where n is an integer, right? to get rid of a specific argument in your list, just assign it the `""` null(ish) string, i.e. `argv[1]=""` or `argv[$i]=""`. I don't have a csh to play with anymore, so can't confirm that this will work, but `shift $argv[1]` won't work. Keep playing with it, or better yet, switch to `ksh` or `bash` or `zsh` or ... ? Having worked at a place where `csh` was the default shell for 1000+ users, I know that switching may not be as practical as it sounds to us converts. Good luck. – shellter Sep 12 '13 at 08:24

0 Answers0