11 #include "bashgetopt.h"
18 static int printargs ();
22 extern char *ansicstr ();
24 extern char *this_command_name;
26 static char *print_doc[] = {
27 "Output the arguments. The -f option means to use the argument as a",
28 "format string as would be supplied to printf(1). The rest of the",
29 "options are as in ksh.",
33 struct builtin print_struct = {
38 "print [-Rnprs] [-u unit] [-f format] [arguments]",
43 #define ISOPTION(s, c) (s[0] == '-' && s[2] == '\0' && s[1] == c)
50 int c, r, nflag, raw, ofd, sflag;
51 char **v, *pfmt, *arg;
54 nflag = raw = sflag = 0;
58 reset_internal_getopt ();
59 while ((c = internal_getopt (list, "Rnprsu:f:")) != -1)
66 if (loptend && ISOPTION (loptend->word->word, 'n'))
68 loptend = loptend->next;
84 if (all_digits (list_optarg))
85 ofd = atoi (list_optarg);
88 for (l = list; l->next && l->next != lcurrent; l = l->next);
89 lcurrent = loptend = l;
105 ofp = (ofd == 1) ? stdout : fdopen (dup (ofd), "w");
112 w = make_word (pfmt);
113 nlist = make_word_list (w, list);
114 r = printf_builtin (nlist);
115 nlist->next = (WORD_LIST *)NULL;
116 dispose_words (nlist);
122 for (l = list; l; l = l->next)
124 fprintf (ofp, "%s", l->word->word);
134 r = printargs (list, ofp);
143 printargs (list, ofp)
151 for (sawc = 0, l = list; l; l = l->next)
153 ostr = ansicstr (l->word->word, strlen (l->word->word), &sawc, (int *)0);
154 fprintf (ofp, "%s", ostr);