From: Adam Dickmeiss Date: Sun, 3 Jun 2007 08:06:31 +0000 (+0000) Subject: Fixed bug #1157: yaz-client does not read .yazclientrc from current X-Git-Tag: YAZ.3.0.10~66 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=5fca2e8ca1775ad5adceb1568508d911d646a01b;p=yaz-moved-to-github.git Fixed bug #1157: yaz-client does not read .yazclientrc from current directory. yaz-client now reads ·yazclient from current directory; failing that ~/.yazclientrc is read. --- diff --git a/client/client.c b/client/client.c index 82c78ca..e1b52ed 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: client.c,v 1.342 2007-05-30 21:56:59 adam Exp $ + * $Id: client.c,v 1.343 2007-06-03 08:06:31 adam Exp $ */ /** \file client.c * \brief yaz-client program @@ -3752,17 +3752,26 @@ int cmd_push_command(const char* arg) void source_rcfile(void) { - /* Look for a $HOME/.yazclientrc and source it if it exists */ + /* Look for .yazclientrc and read it if it exists. + If it does not exist, read $HOME/.yazclientrc instead */ struct stat statbuf; char fname[1000]; - char* homedir = getenv("HOME"); - sprintf(fname, "%.500s%s%s", homedir ? homedir : "", - homedir ? "/" : "", - ".yazclientrc"); - - if (stat(fname,&statbuf)==0) - cmd_source(fname, 0 ); + strcpy(fname, ".yazclientrc"); + if (stat(fname, &statbuf)==0) + { + cmd_source(fname, 0); + } + else + { + const char* homedir = getenv("HOME"); + if (homedir) + { + sprintf(fname, "%.800s/%s", homedir, ".yazclientrc"); + if (stat(fname, &statbuf)==0) + cmd_source(fname, 0); + } + } } void add_to_readline_history(void *client_data, const char *line) diff --git a/doc/yaz-client-man.xml b/doc/yaz-client-man.xml index 577d1ef..2fffa3a 100644 --- a/doc/yaz-client-man.xml +++ b/doc/yaz-client-man.xml @@ -8,7 +8,7 @@ %idcommon; ]> - + YAZ @@ -54,10 +54,12 @@ a connection to the Z39.50/SRU target at the address given. - When yaz-client is invoked it attemps to read the - following files: - $HOME/.yazclientrc (home directory, Unix only) and - .yazclientrc (current directory - any platform) + When yaz-client is invoked it attemps to read + .yazclientrc from current working directory. + If .yazclientrc does not exist in current directory + YAZ client reads .yazclientrc from the + home directory, where the home directory is given by environment + variable HOME. For those files that are readable, the YAZ client executes commands in those files. See COMMANDS section for description of commands.