Re: [patch] new special variable: test argument

2015-12-21 Thread Piotr Grzybowski
On Mon, Dec 21, 2015 at 2:27 PM, Greg Wooledge wrote: > > If you are trying to advocate for a new feature in bash, it would behoove > you to use an example that ACTUALLY DEMONSTRATES how it would be useful. > Not a bogus example in which the feature is not only unnecessary, but > harmful as well.

Re: [patch] new special variable: test argument

2015-12-21 Thread Piotr Grzybowski
On Mon, Dec 21, 2015 at 2:21 PM, Greg Wooledge wrote: > On Sat, Dec 19, 2015 at 12:58:41AM +0100, Piotr Grzybowski wrote: >> #2 >> touch /tmp/`date +%s`; if [ -f /tmp/`date +%s` ]; then echo "ok: $^"; fi; > > This is both wrong (insecure) and clumsy. You can't create a temp file > this way. [..]

Re: [patch] new special variable: test argument

2015-12-21 Thread Greg Wooledge
On Sat, Dec 19, 2015 at 01:03:35AM +0100, Piotr Grzybowski wrote: > On Wed, Dec 16, 2015 at 7:36 PM, Stephane Chazelas > wrote: > > What's wrong with > > > > f=/tmp/myfile; [ -f "$f" ] && { echo "$f is here"; head -n 1 < "$f"; } > > nothing. sometimes it is just not practical (see my answer to C

Re: [patch] new special variable: test argument

2015-12-21 Thread Greg Wooledge
On Sat, Dec 19, 2015 at 12:58:41AM +0100, Piotr Grzybowski wrote: > #2 > touch /tmp/`date +%s`; if [ -f /tmp/`date +%s` ]; then echo "ok: $^"; fi; This is both wrong (insecure) and clumsy. You can't create a temp file this way. If the file already existed, then you're using someone else's booby

Re: [patch] new special variable: test argument

2015-12-19 Thread Piotr Grzybowski
thanks for the answer Stephane; dont get me wrong, I do understand that using another variable removes the need for some special variables (do you need $REPLY if you can always use "read v" and be happy with it?). Dont you think it makes sense what Konsolebox has written? sincerely, pg El 19/12/20

Re: [patch] new special variable: test argument

2015-12-19 Thread Piotr Grzybowski
El 19/12/2015 03:46, "Stephane Chazelas" escribió: > > 2015-12-19 00:58:41 +0100, Piotr Grzybowski: > > [..] > > Without $^ it begins to look terrible. > > Using a variable is the most obvious thing to do. not always practical. > > Also, what if "new_index" was a function which does call "[ -f"

Re: [patch] new special variable: test argument

2015-12-18 Thread Stephane Chazelas
2015-12-19 00:58:41 +0100, Piotr Grzybowski: > Thanks for taking time to answer. Of course it is the issue of > programming style (isnt it true that most things can be brought down > to the programming style?), two real-life examples (stripped-down of > everything): > > #1 > if [ -f ${output}/${b

Re: [patch] new special variable: test argument

2015-12-18 Thread Piotr Grzybowski
On Wed, Dec 16, 2015 at 8:44 PM, konsolebox wrote: > > Just my quick thoughts: > > Pros: > 1) It could make code smaller. > 2) It could make writing code less prone to typos. > 3) It could make writing code faster. thanks. that was exactly the idea behind it. > Cons: > 1) The constant assignmen

Re: [patch] new special variable: test argument

2015-12-18 Thread Piotr Grzybowski
Dear Stephane, thanks. On Wed, Dec 16, 2015 at 7:36 PM, Stephane Chazelas wrote: > What's wrong with > > f=/tmp/myfile; [ -f "$f" ] && { echo "$f is here"; head -n 1 < "$f"; } nothing. sometimes it is just not practical (see my answer to Chet's comment) and sometimes you just want to get that

Re: [patch] new special variable: test argument

2015-12-18 Thread Piotr Grzybowski
Thanks for taking time to answer. Of course it is the issue of programming style (isnt it true that most things can be brought down to the programming style?), two real-life examples (stripped-down of everything): #1 if [ -f ${output}/${branch}/${index}/${current} ]; then let current--; for((i=

Re: [patch] new special variable: test argument

2015-12-16 Thread konsolebox
On Wed, Dec 16, 2015 at 11:03 PM, Piotr Grzybowski wrote: > 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

Re: [patch] new special variable: test argument

2015-12-16 Thread Chet Ramey
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 t

Re: [patch] new special variable: test argument

2015-12-16 Thread Stephane Chazelas
2015-12-16 16:03:14 +0100, Piotr Grzybowski: > 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 th

[patch] new special variable: test argument

2015-12-16 Thread Piotr Grzybowski
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