tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Du command does not work on my system

Fun with shell ▻

How to "set" current arguments preserving whitespace?

In article <37767C29.4FDA0F13@odn.de>,
Heiner Steven  <heiner.steven@odn.de> wrote:
>If I enter
>
>   "one two"
>
>after running the script, it will print
>
>   2 arguments

Yes.  The first argument is

    "one

and the second is

    two"

>How can I make the "set" command recognize "one two" as *one* argument?

If you want Bourne shell quoting to apply to input, you'll need to use
eval.  This does the trick.

    eval set -- `read line; echo "$line"`

This still collapses multiple spaces into a single space; this appears
to be a "feature" of the `set' builtin.

Tim.
--
Tim Goodwin   | "You don't need to do drugs in order to
University of | think that the government's policies are
Leicester, UK | stupid and dangerous." -- David Bancroft

Original headers:

From: tjg@ltpcg.star.le.ac.uk (Tim J Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: How to "set" current arguments preserving whitespace?
Date: 28 Jun 1999 11:51:22 +0100
Organization: University of Leicester, UK
Message-ID: <7l7k3a$qbk$1@ltpcg.star.le.ac.uk>
References: <37767C29.4FDA0F13@odn.de>

△ comp.unix.shell △

◅ Du command does not work on my system

Fun with shell ▻