[augeas-devel] [PATCH] Add --interactive, -i option to run an interactive shell after evaluating STDIN and inputfile
David Lutterkort
lutter at redhat.com
Tue Feb 15 01:48:00 UTC 2011
On Thu, 2011-02-10 at 12:20 +0100, Raphael Pinson wrote:
> From: Raphaël Pinson <raphink at gmail.com>
>
> ---
> src/augtool.c | 18 +++++++++++++++++-
> 1 files changed, 17 insertions(+), 1 deletions(-)
ACK. That's a very useful option. I committed a slight variation of your
patch:
> diff --git a/src/augtool.c b/src/augtool.c
> index 7de8e9d..4042618 100644
> --- a/src/augtool.c
> +++ b/src/augtool.c
> @@ -1193,6 +1200,15 @@ static int main_loop(void) {
> }
>
> if (line == NULL) {
> + if (!isatty(fileno(stdin)) && interactive && !in_interactive) {
> + in_interactive = true;
> + echo = true;
> + // reopen in and out streams
> + rl_instream = fopen("/dev/tty", "r");
> + rl_outstream = fopen("/dev/stdout", "w");
> + continue;
> + }
> +
There's two problems with the above: (1) we might end up leaking
rl_outstream (not that big a deal here, but still) and (2) there's zero
error checking for the fopen. I addressed both in the patch I committed.
David
More information about the augeas-devel
mailing list