From 5fca2e8ca1775ad5adceb1568508d911d646a01b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sun, 3 Jun 2007 08:06:31 +0000 Subject: [PATCH] =?utf8?q?Fixed=20bug=20#1157:=20yaz-client=20does=20not=20r?= =?utf8?q?ead=20.yazclientrc=20from=20current=20directory.=20yaz-client=20no?= =?utf8?q?w=20reads=20=C2=B7yazclient=20from=20current=20directory;=20failin?= =?utf8?q?g=20that=20~/.yazclientrc=20is=20read.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- client/client.c | 27 ++++++++++++++++++--------- doc/yaz-client-man.xml | 12 +++++++----- 2 files changed, 25 insertions(+), 14 deletions(-) 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. -- 1.7.10.4