From 1c4cc7bc2bd65deb8ff2f075c8edc11dc20e1f34 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Wed, 4 Sep 2013 18:43:39 -0400 Subject: [PATCH] Read config from stdin if config is specified as '-' --- doc/imapfilter.1 | 2 +- src/lua.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/imapfilter.1 b/doc/imapfilter.1 index ff66c37..f6e3f73 100644 --- a/doc/imapfilter.1 +++ b/doc/imapfilter.1 @@ -24,7 +24,7 @@ The command line options of are as follows: .Bl -tag -width Ds .It Fl c Ar configfile -Path to the configuration file. The default is +Path to the configuration file, or - to read from stdin. The default is .Pa $HOME/.imapfilter/config.lua . .It Fl d Ar debugfile File that contains debugging information about the full communication with the diff --git a/src/lua.c b/src/lua.c index 795be55..e97ee1d 100644 --- a/src/lua.c +++ b/src/lua.c @@ -78,7 +78,7 @@ start_lua() "=") || lua_pcall(lua, 0, LUA_MULTRET, 0)) fatal(ERROR_CONFIG, "%s\n", lua_tostring(lua, -1)); } else { - if (luaL_loadfile(lua, opts.config)) + if (luaL_loadfile(lua, strcmp(opts.config, "-") == 0 ? NULL : opts.config)) fatal(ERROR_CONFIG, "%s\n", lua_tostring(lua, -1)); lua_pushcfunction(lua, traceback_handler); lua_insert(lua, 1);