[augeas-devel] augeas: master - augtool: add --echo option
David Lutterkort
lutter at fedoraproject.org
Tue Jun 16 18:40:43 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=bad876776fd6c30ea23f07eaea281e91770728c7
Commit: bad876776fd6c30ea23f07eaea281e91770728c7
Parent: 4a21ae6d693ca888deef6aeff912d40083603a66
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Tue Jun 16 11:30:09 2009 -0700
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Tue Jun 16 11:30:09 2009 -0700
augtool: add --echo option
* src/augtool.c: add --echo option to print commands when reading
from a file via stdin
* man/augtool.pod: document --echo option
* man/augtool.1: regenerated
---
man/augtool.1 | 6 +++++-
man/augtool.pod | 5 +++++
src/augtool.c | 16 ++++++++++++----
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/man/augtool.1 b/man/augtool.1
index 138f09f..cd665a0 100644
--- a/man/augtool.1
+++ b/man/augtool.1
@@ -132,7 +132,7 @@
.\" ========================================================================
.\"
.IX Title "AUGTOOL 1"
-.TH AUGTOOL 1 "2009-03-18" "Augeas 0.4.2" "Augeas"
+.TH AUGTOOL 1 "2009-06-16" "Augeas 0.5.1" "Augeas"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -177,6 +177,10 @@ Add \s-1DIR\s0 to the module loadpath. Can be given multiple times. The
directories set here are searched before any directories specified in the
\&\s-1AUGEAS_LENS_LIB\s0 environment variable, and before the default directory
\&\fI/usr/share/augeas/lenses\fR.
+.IP "\fB\-e\fR" 4
+.IX Item "-e"
+When reading commands from a file via stdin, echo the commands before
+printing their output.
.IP "\fB\-\-nostdinc\fR" 4
.IX Item "--nostdinc"
Do not search any of the default directories for modules. When this option
diff --git a/man/augtool.pod b/man/augtool.pod
index a3d7c2d..6894077 100644
--- a/man/augtool.pod
+++ b/man/augtool.pod
@@ -49,6 +49,11 @@ directories set here are searched before any directories specified in the
AUGEAS_LENS_LIB environment variable, and before the default directory
F</usr/share/augeas/lenses>.
+=item B<-e>
+
+When reading commands from a file via stdin, echo the commands before
+printing their output.
+
=item B<--nostdinc>
Do not search any of the default directories for modules. When this option
diff --git a/src/augtool.c b/src/augtool.c
index e4aa973..f7f48c3 100644
--- a/src/augtool.c
+++ b/src/augtool.c
@@ -47,7 +47,7 @@ static const char *const progname = "augtool";
static unsigned int flags = AUG_NONE;
const char *root = NULL;
char *loadpath = NULL;
-
+int echo = 0;
static char *cleanstr(char *path, const char sep) {
if (path == NULL || strlen(path) == 0)
@@ -571,6 +571,7 @@ static void usage(void) {
" leave original unchanged\n");
fprintf(stderr, " -r, --root ROOT use ROOT as the root of the filesystem\n");
fprintf(stderr, " -I, --include DIR search DIR for modules; can be given mutiple times\n");
+ fprintf(stderr, " -e, --echo echo commands when reading from a file\n");
fprintf(stderr, " --nostdinc do not search the builtin default directories for modules\n");
fprintf(stderr, " --noload do not load any files into the tree on startup\n");
fprintf(stderr, " --noautoload do not autoload modules from the search path\n");
@@ -593,6 +594,7 @@ static void parse_opts(int argc, char **argv) {
{ "new", 0, 0, 'n' },
{ "root", 1, 0, 'r' },
{ "include", 1, 0, 'I' },
+ { "echo", 0, 0, 'e' },
{ "nostdinc", 0, 0, VAL_NO_STDINC },
{ "noload", 0, 0, VAL_NO_LOAD },
{ "noautoload", 0, 0, VAL_NO_AUTOLOAD },
@@ -600,7 +602,7 @@ static void parse_opts(int argc, char **argv) {
};
int idx;
- while ((opt = getopt_long(argc, argv, "hnbcr:I:", options, &idx)) != -1) {
+ while ((opt = getopt_long(argc, argv, "hnbcr:I:e", options, &idx)) != -1) {
switch(opt) {
case 'c':
flags |= AUG_TYPE_CHECK;
@@ -620,6 +622,9 @@ static void parse_opts(int argc, char **argv) {
case 'I':
argz_add(&loadpath, &loadpathlen, optarg);
break;
+ case 'e':
+ echo = 1;
+ break;
case VAL_NO_STDINC:
flags |= AUG_NO_STDINC;
break;
@@ -649,8 +654,11 @@ static int main_loop(void) {
if (isatty(fileno(stdin))) {
line = readline("augtool> ");
- } else if (getline(&line, &len, stdin) == -1) {
- return ret;
+ } else {
+ if (getline(&line, &len, stdin) == -1)
+ return ret;
+ if (echo)
+ printf("augtool> %s", line);
}
cleanstr(line, '\n');
if (line == NULL) {
More information about the augeas-devel
mailing list