[svk-devel] Non-interactive use of "svk info"

David Kaufman david at gigawatt.com
Wed Jun 6 16:28:22 EDT 2007


Adam D. Barratt <lists+svk-devel at adam-barratt.org.uk> wrote:
> Hi,
>
> On Wed, 2007-06-06 at 13:16 -0400, Jesse Vincent wrote:
>> ...Perhaps you want to probe ~/.svk/local to see if it
>> exists. (Also, have a look at the SVKHOME environment variable so you
>> look in the right place ;)
>
> Thanks. I'm assuming you meant SVKROOT ;-)
>
> Will there always be a file called "local" in the relevant location?

Not necessarily.  Sometimes there is just a cache directory in there 
(like when you say no the that prompt, it still creates ~/.svk/cache).

AFAIK calling it "local" is just a convention (for local repositories). 
It could be a mirror of a remote svn repo, in which case you'd see a 
"mirror" directory in there, but again, I think that's only by 
convention...

Either the *presence* of the SVKROOT environment variable (even set to 
an empty string), or the existence of ~/.svk/ is enough to make the "svk 
info" command run non-interactively.

> I've added this (pseudo-coded, obviously :) before trying to run svk:
>
> $root = $SVKROOT
> If $root = "" $root = $HOME/.svk
> $check = $root + "/local"
> if the file $checks exists then...

playing around with this just now I came up with this (if you really 
need to parse the output of svk info)

# if $SVKROOT is set and points to an existing directory
# or user's home directory conatins a .svk/ directory
# then run svk info and capture its output to SVKINFO
# else set SVKINFO="not a checkout path"
SVKINFO=`if [ -d ${SVKROOT-~/.svk} ]; then svk info; else echo "not a 
checkout path"; fi`

but svk info also exits with success if the directory is a checkout 
path, and failure if not, so this may be a simpler "interactive-safe" 
shell test:

# if ($SVKROOT is set and points to an existing directory
# or user's home directory conatins a .svk/ directory)
# AND if svk info succeeds, print Yup
# else print Nope
if [ -d ${SVKROOT-~/.svk} ] && svk info >& /dev/null; then
  echo Yup
else
  echo Nope
fi

Hope this helps!

-dave 



More information about the svk-devel mailing list