From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Price Date: Mon, 20 May 2013 12:37:15 +0100 Subject: [Cluster-devel] [PATCH 6/7] gfs2l: Read from stdin by default In-Reply-To: <1369049836-8204-1-git-send-email-anprice@redhat.com> References: <1369049836-8204-1-git-send-email-anprice@redhat.com> Message-ID: <1369049836-8204-6-git-send-email-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Instead of requiring -f - in order to read from stdin, do that by default. Signed-off-by: Andrew Price --- gfs2/libgfs2/gfs2l.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c index 9fc647a..e58c827 100644 --- a/gfs2/libgfs2/gfs2l.c +++ b/gfs2/libgfs2/gfs2l.c @@ -9,7 +9,7 @@ static void usage(const char *cmd) printf("Usage: %s [options] \n", cmd); printf("Available options:\n"); printf(" -h Print this help message and exit\n"); - printf(" -f Path to script file or '-' for stdin\n"); + printf(" -f Path to script file or '-' for stdin (the default)\n"); printf(" -T Print a list of gfs2 structure types and exit\n"); printf(" -F Print a list of fields belonging to a type and exit\n"); } @@ -55,12 +55,11 @@ static void print_fields(const char *name) static int getopts(int argc, char *argv[], struct cmdopts *opts) { int opt; + opts->src = stdin; while ((opt = getopt(argc, argv, "F:f:hT")) != -1) { switch (opt) { case 'f': - if (!strcmp("-", optarg)) { - opts->src = stdin; - } else { + if (strcmp("-", optarg)) { opts->src = fopen(optarg, "r"); if (opts->src == NULL) { perror("Failed to open source file"); -- 1.8.1.4