bug-bash
[Top][All Lists]
Advanced

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

Re: let's set the positional parameters with a simple 'read'


From: Eric Blake
Subject: Re: let's set the positional parameters with a simple 'read'
Date: Tue, 03 Jan 2012 10:36:27 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

On 01/03/2012 10:16 AM, jidanni@jidanni.org wrote:
> One can do
> $ read p
> to set $p
> but no just as easy method to set $@, $1, etc.
> One must do
> $ set -- `cat` #which involves ^D, "too much trouble"
> Or set -- `read x; echo "$x"` etc.

No need for a subshell to do what you want.  Just do:

read p
set -- "$p"

to set $1, or

read p
set -- $p

to set all of $@ according to the IFS splitting of $p.

> 
> So I propose we 'wreck the language' to allow me to do
> $ read @
> to set $@, same with 1, 2,.. * (almost the same as @).

Sorry, I don't think this is worth doing.

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]