9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Pietro Gagliardi <pietro10@mac.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] bug in echo?
Date: Wed, 26 Mar 2008 14:58:26 -0400	[thread overview]
Message-ID: <F5B1C672-6402-4073-8E19-3D5539ACB95A@mac.com> (raw)
In-Reply-To: <2dccf442569c12a4ba9193abb0392726@quanstro.net>

Is there a valid reason to have echo process the arguments given?
It's a simple mod:

	#include <u.h>
	#include <libc.h>

	/* echo:  echo args */
	void
	main(int argc, char *argv[])
	{
		int nl = 1;

		ARGBEGIN{
		'n':
			nl = 0;
			break;
		default:
			fprint(2, "usage: echo [-n] stuff\n");
			sysfatal("usage");
		}ARGEND;
		for(i = 1; i < argc - 1; i++)
			print("%s ", argv[i]);
		print("%s%s", argv[argc - 1], nl ? "\n" : "");
		exits(0);
	}

However, Plan 9 has gone for years and people have not had this
problem. (Then again, so did TUPE for Unix).

Can we stick with

	echo -n '-n
	'

as Rob (the coauthor of that book, mind you, so he knows EXACTLY what
he is saying) said? It defies the need for handing a single argument.

If we start supporting arguments, we can have other arguments:

	-e		Use escape sequences.
	-E		Use no escape sequences.
	-l (ell)	One per line.
	-t		Separate with tabs.
	-Nn		Use n spaces (default 1).
	-L		If -l is given, use line numbers.
	-o		Output each character in octal.
	-x		Output each character in hex.
	-v		Make non-printing characters visible.
	-r		The first argument is a regular expression. Print each string
given as an argument that matches this regular expression.

and no doubt people will want them. Is this necessary? echo -e is
considered harmful (and when I started /bin/sh programming, I didn't
like that it wasn't default. Oh well).

The lesson?
	echo -n '-n
	'
is the solution.



  reply	other threads:[~2008-03-26 18:58 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-26 11:41 Gorka Guardiola
2008-03-26 12:27 ` Rob Pike
2008-03-26 12:41   ` Gorka Guardiola
2008-03-26 12:52     ` Sape Mullender
2008-03-26 13:19       ` Gorka Guardiola
2008-03-26 20:27   ` Iruata Souza
2008-03-26 12:40 ` Anthony Martin
2008-03-26 13:13   ` Gorka Guardiola
2008-03-26 13:19     ` Joel C. Salomon
2008-03-26 13:40       ` Gorka Guardiola
2008-03-31  8:58         ` Douglas A. Gwyn
2008-03-26 13:55     ` erik quanstrom
2008-03-26 15:52       ` Gorka Guardiola
2008-03-26 17:26         ` roger peppe
2008-03-26 18:10           ` erik quanstrom
2008-03-26 18:58             ` Pietro Gagliardi [this message]
2008-03-26 19:38               ` Joel C. Salomon
2008-03-26 19:43               ` Francisco J Ballesteros
2008-03-26 20:01                 ` Pietro Gagliardi
2008-03-26 20:09                   ` andrey mirtchovski
2008-03-26 20:22                     ` Pietro Gagliardi
2008-03-26 20:30                       ` andrey mirtchovski
2008-03-26 20:56                         ` Pietro Gagliardi
2008-03-26 22:06                           ` Iruata Souza
2008-03-26 22:26                             ` Pietro Gagliardi
2008-03-26 22:54                               ` Iruata Souza
2008-03-27  3:40                                 ` Robert William Fuller
2008-03-27  3:47                                   ` Bruce Ellis
2008-04-01  9:07                                     ` Douglas A. Gwyn
2008-03-27  1:57                 ` Gorka Guardiola
2008-03-27  2:17                   ` Gorka Guardiola
2008-03-27  2:21                   ` Joel C. Salomon
2008-03-27  2:37                     ` Pietro Gagliardi
2008-03-27  3:45                       ` Bruce Ellis
2008-03-27 16:37                       ` john
2008-03-27 17:03                         ` [9fans] databases erik quanstrom
2008-03-27 19:08                           ` Pietro Gagliardi
2008-03-28  4:05                             ` a
2008-03-28  3:46                         ` [9fans] bug in echo? a
2008-03-31 16:26                       ` Russ Cox
2008-04-01  9:07                         ` Douglas A. Gwyn
2008-03-26 20:10             ` roger peppe
2008-04-01  9:06           ` Douglas A. Gwyn
2008-04-01  9:06       ` Douglas A. Gwyn
2008-04-01  9:22         ` Anders Li
2008-04-03  8:54           ` Douglas A. Gwyn
2008-04-03 16:46             ` ron minnich
2008-04-03 18:04               ` Gorka Guardiola
2008-04-03 18:23                 ` Martin Neubauer
2008-04-03 19:11                   ` Pietro Gagliardi
2008-04-03 19:30                     ` Steven D. Vormwald
2008-04-03 19:44                       ` Pietro Gagliardi
2008-04-03 22:16                     ` a
2008-04-03 22:26                       ` Pietro Gagliardi
2008-04-03 22:44                         ` John Floren
2008-04-03 22:53                           ` Pietro Gagliardi
2008-04-03 23:12                       ` Martin Neubauer
2008-04-08 23:51                     ` david parsons
2008-04-09  0:02                       ` Pietro Gagliardi
2008-03-26 13:15   ` Joel C. Salomon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F5B1C672-6402-4073-8E19-3D5539ACB95A@mac.com \
    --to=pietro10@mac.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).