2 * Copyright (C) 1984-2000 Mark Nudelman
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
7 * For more information about less, or for information on how to
8 * contact the author, see the README file.
13 * lessecho [-ox] [-cx] [-pn] [-dn] [-a] file ...
14 * Simply echos its filename arguments on standard output.
15 * But any argument containing spaces is enclosed in quotes.
17 * -ox Specifies "x" to be the open quote character.
18 * -cx Specifies "x" to be the close quote character.
19 * -pn Specifies "n" to be the open quote character, as an integer.
20 * -dn Specifies "n" to be the close quote character, as an integer.
21 * -a Specifies that all arguments are to be quoted.
22 * The default is that only arguments containing spaces are quoted.
27 static char *version = "$Revision: 1.6 $";
29 static int quote_all = 0;
30 static char openquote = '"';
31 static char closequote = '"';
37 "usage: lessecho [-ox] [-cx] [-pn] [-dn] [-a] file ...\n");
47 for (p = version; *p != ' '; p++)
50 for (p++; *p != '$' && *p != ' ' && *p != '\0'; p++)
60 fprintf(stderr, "%s\n", s);
65 lstrtol(s, radix, pend)
74 /* Skip leading white space. */
75 while (*s == ' ' || *s == '\t')
78 /* Check for a leading + or -. */
88 /* Determine radix if caller does not specify. */
107 /* Parse the digits of the number. */
110 if (*s >= '0' && *s <= '9')
112 else if (*s >= 'a' && *s <= 'f')
114 else if (*s >= 'A' && *s <= 'F')
126 /* Skip trailing white space. */
127 while (*s == ' ' || *s == '\t')
143 for ( ; *s != '\0'; s++)
165 if (*arg != '-' || no_more_options)
179 openquote = lstrtol(++arg, 0, &s);
181 pr_error("Missing number after -O");
184 closequote = lstrtol(++arg, 0, &s);
186 pr_error("Missing number after -C");
197 if (strcmp(arg, "version") == 0)
202 if (strcmp(arg, "help") == 0)
207 pr_error("Invalid option after --");
209 pr_error("Invalid option letter");
216 if (quote_all || strchr(arg, ' ') != NULL)
217 printf("%c%s%c", openquote, arg, closequote);