let's set the positional parameters with a simple 'read'
From:
jidanni
Subject:
let's set the positional parameters with a simple 'read'
Date:
Wed, 04 Jan 2012 01:16:27 +0800
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, nothing as easy as
$ read 1
sds
bash: read: `1': not a valid identifier
$ read @
sdss
bash: read: `@': not a valid identifier
Regretful.
How about just
$ set -- sds
you say. Well that won't work as good as
$ read x
http://www.youtube.com/watch?v=PLTOc2TVAs8&list=PL54881C422E6B58FC
$
When one is pasting URLs with the mouse, and they contain special
characters.
Yes one could do
$ set '<PASTE>'
but that is a little more fuss.
So I propose we 'wreck the language' to allow me to do
$ read @
to set $@, same with 1, 2,.. * (almost the same as @).