Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #12034
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: [patch] new special variable: test argument |
| Date | 2015-12-16 14:12 -0500 |
| Message-ID | <mailman.35.1450293144.843.bug-bash@gnu.org> (permalink) |
| References | <CAP=cN8kxxnxRiJ7xz9hJUHVkLGQFJKxLE7Kz0fUpEFtSmcL9YQ@mail.gmail.com> |
On 12/16/15 10:03 AM, Piotr Grzybowski wrote:
> Dear All,
>
> one thing I missed for some time now, is the ability to access the
> argument passed to test, or any argument on the right hand side.
> I needed it so I made a quick hack, which I attach as a reference.
> It allows to access arg in the the -f $arg easily, e.g.:
>
> [ -f /tmp/myfile ] && { echo "$^ is here"; head -1 "$^"; }
This seems like an issue of programming style more than anything else.
If you have a string or similar that you would like to refer to more
than once, use a variable for it. It would take perhaps half a dozen
more characters to use an explicit variable here.
If you want something that is similar to perl's `$_', I'd be interested
in your thoughts, but this is of limited usefulness as it stands.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: [patch] new special variable: test argument Chet Ramey <chet.ramey@case.edu> - 2015-12-16 14:12 -0500
csiph-web