0

Got myself a standard script for passing svn diff output to vimdiff, on my RHEL box:

#!/bin/csh -f
vimdiff ${6} ${7}

added it to the path, and set diff-cmd in ~/.subversion/config

This works great, and I have all the diff-y goodness I need. However, it seems as though the -f flag to csh is being ignored and my .cshrc file is being run: I can see the echo messages spat out by it before vimdiff opens.

My .cshrc connects to a bunch of license servers, so it takes a while, which is less great.

Incidentally, running this script directly (svndiff.sh x x x x x file1 file2) doesn't call .cshrc

Is svn (version 1.6.11) doing this itself? Any ideas why this is happening and what can be done about it?

SamBob
  • 849
  • 6
  • 17

1 Answers1

1

Most likly it's being called as csh svndiff.sh. The hashbang is only executed if it's called as ./svndiff.sh.

It's also recommended to do this in your cshrc:

setenv PATH ~/Local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games
# ...more environment settings

# Only load these for interactive shells
if ( $?prompt ) then
  set autolist
  # ...more settings, keybinds, etc.
endif

But, really, don't use csh scripting for this sort of thing. Use the bourne shell if at all possible. Almost all of the issues raised in "Csh Programming Considered Harmful" from 1995 still apply to tcsh 20 years later.

Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146
  • Prompt check does the job - but it makes something else I do break (running commands through ssh without an interactive shell that needs scripts run that I don't want to run in this case) Renaming `svndiff.sh` to `svndiff` stops svn calling it as `csh svndiff.sh` and then uses the hashbang (which I've naturally replaced with `/bin/bash`). – SamBob Jul 03 '15 at 08:45
  • I was mistaken! Renaming doesn't solve the issue. Changing my default shell won't be an option, in any case I'd need these scripts in my .bashrc and I'd have this problem again. Unhelpful that I can't seemingly force svn diff to call diff-cmd directly and not spawning inside a shell. – SamBob Jul 03 '15 at 08:57
  • Managed to use prompt check and keep my scripts running by checking $HOST as this differentiates the cases for me. Thanks, I'm still interested in knowing more about svn calling (I presume) sh -c 'diff-cmd' rather than diff-cmd itself. – SamBob Jul 03 '15 at 14:32