Shell-parsing test program (was Re: coreutils-5.1.3 released: bug-fix-only, candidate for stable 5.2.0)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 11, 2004 at 11:48:09AM +0100, Jim Meyering wrote:
>   $ echo / // /// //// .// //.
>   $ echo abc| tr -t ab //

Here's a trivial little debugging aid I can't live without, for
testing and isolating just such things without driving oneself
crazy, or resorting to painful contortions like that "tr"
pipeline.  Unlike echo:
  - because it's not a shell builtin, you can be sure that
    whatever effects you see are caused by the shell's generic
    command-line parsing, rather than by any special-case code
    for the particular command itself (well, you could get that
    by saying "/bin/echo", but see below)

  - it does *no* parsing or interpretation of the command-line
    arguments; it just spits out what it sees -- benefit as above

  - (irrelevent to your current problem) it shows you the
    argument boundaries, so you can quickly see whether your
    evals and variable substitutions expanded to:
        prargs a b c
    or:
        prargs "a b c"
    or:
        prargs a "b " c

The blurb's twice the size of the program itself :-/

--

|  | /\
|-_|/  >   Eric Siegerman, Toronto, Ont.        erics@xxxxxxxxxxxx
|  |  /
It must be said that they would have sounded better if the singer
wouldn't throw his fellow band members to the ground and toss the
drum kit around during songs.
	- Patrick Lenneau
/*
 * Copyright (C) 1998, by Eric Siegerman
 * You can do whatever you want with this thing -- commercial or otherwise.
 * No restrictions.
 */
#include <stdio.h>

main(int argc, char *argv[])
{
	int i;

	for (i=0; i<argc; ++i)
		printf("%d: <%s>\n", i, argv[i]);
}

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux