bug-bash
[Top][All Lists]
Advanced

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

Re: [patch] new special variable: test argument


From: Chet Ramey
Subject: Re: [patch] new special variable: test argument
Date: Wed, 16 Dec 2015 14:12:15 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.4.0

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/



reply via email to

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