Re: Syntax Question...

2011-08-18 Thread Linda Walsh
Greg Wooledge wrote: On Tue, Aug 16, 2011 at 03:41:19PM -0700, Linda Walsh wrote: > Ken Irving wrote: >> Maybe this? today_snaps=( ${snap_prefix} ) > but as you mention, that will put them into an arraysorry > "imprecise terminology" list for me is some number of objects > in a s

Re: Syntax Question...

2011-08-18 Thread Chet Ramey
> On Thu, Aug 18, 2011 at 02:42:03PM -0400, Chet Ramey wrote: > > The expansions are the default set as described in the quoted paragraph, > > without pathname expansion and, since the result is passed to the command > > as a single string, word splitting. > > > > I think the confusion arises over

Re: Syntax Question...

2011-08-18 Thread Greg Wooledge
On Thu, Aug 18, 2011 at 02:42:03PM -0400, Chet Ramey wrote: > The expansions are the default set as described in the quoted paragraph, > without pathname expansion and, since the result is passed to the command > as a single string, word splitting. > > I think the confusion arises over the precise

Re: conditional aliases are broken

2011-08-18 Thread Chet Ramey
On 8/18/11 11:58 AM, Greg Wooledge wrote: > It would appear "declare -g" does NOT allow you to "jump over" a local > variable that is shadowing a global. That's disappointing. That is not its intent. The very narrow purpose of declare -g is to allow you to declare a variable with attributes in

Re: Syntax Question...

2011-08-18 Thread Chet Ramey
On 8/18/11 12:14 PM, Greg Wooledge wrote: > On Thu, Aug 18, 2011 at 10:55:11AM -0400, Chet Ramey wrote: >> The quoted paragraph applies to all redirection operators (and parameter >> and variable expansion are still identical). The description of <<< >> notes that it does not perform pathname expa

Re: conditional aliases are broken

2011-08-18 Thread Eric Blake
On 08/18/2011 08:53 AM, Roman Rakus wrote: On 08/18/2011 04:38 PM, Sam Steingold wrote: how do I write a function that would print the same as $ \ls | cat f3(){ printf "%s\n" "$@"; } "\n" looks funny in shell; even though POSIX requires that "\n" does not treat the \ as an escape but as a li

Re: conditional aliases are broken

2011-08-18 Thread Eric Blake
On 08/18/2011 11:38 AM, Stefano Lattarini wrote: Hi Eric. On Thursday 18 August 2011, Eric Blake wrote: On 08/18/2011 08:44 AM, Eric Blake wrote: how do I write a function that would print the same as $ \ls | cat Useless use of cat. This can be done with \ls -1. f(){ for a in "$@"; do ech

Re: conditional aliases are broken

2011-08-18 Thread Stefano Lattarini
On Thursday 18 August 2011, Stefano Lattarini wrote: > Hi Eric. > > On Thursday 18 August 2011, Eric Blake wrote: > > On 08/18/2011 08:44 AM, Eric Blake wrote: > > >> how do I write a function that would print the same as > > >> $ \ls | cat > > > > Useless use of cat. This can be done with \ls -

Re: conditional aliases are broken

2011-08-18 Thread Stefano Lattarini
Hi Eric. On Thursday 18 August 2011, Eric Blake wrote: > On 08/18/2011 08:44 AM, Eric Blake wrote: > >> how do I write a function that would print the same as > >> $ \ls | cat > > Useless use of cat. This can be done with \ls -1. > > > f(){ for a in "$@"; do echo "$a"; done; } > > Or skip the

Re: Syntax Question...

2011-08-18 Thread Ken Irving
On Thu, Aug 18, 2011 at 10:13:45AM -0700, Linda Walsh wrote: >Um...the description from "<<<", above indicates it is...subject > to pathname expansion...If I had matching filesin my dir, it > expanded and returned them, > so I'm pretty sure it does PN expansion. As noted, you're being fooled

general bash oddities and discussion (was Re: Syntax Question...)

2011-08-18 Thread Linda Walsh
` Greg Wooledge wrote: Now that one is suprising, as it's supposed to take the output of the ... hmmm.yup!... that's exactly what it does. takes the work and executes it and returns the results on stdin as a single quoted blob of output: > read a <<< *.txt > echo $a apc_c

Re: Syntax Question...

2011-08-18 Thread Linda Walsh
` Chet Ramey wrote: On 8/18/11 9:37 AM, Greg Wooledge wrote: The word following the redirection operator in the following descrip- tions, unless otherwise noted, is subjected to brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expan???

Re: conditional aliases are broken

2011-08-18 Thread Linda Walsh
` Greg Wooledge wrote: On Thu, Aug 18, 2011 at 08:03:41AM -0700, Linda Walsh wrote: 4.2 introduce a new -g to declare a global variable inside a function. Which doesn't say what it would do in situations like the above. Then let's test: imadev:~$ echo $BASH_VERSION

Re: Is this a bug in [[ -f ]]?

2011-08-18 Thread Greg Wooledge
On Thu, Aug 18, 2011 at 12:35:37PM -0400, Steven W. Orr wrote: > lrwxrwxrwx. 1 sorr fc5 Aug 18 08:48 err -> errio > -rw-rw-r--. 1 sorr fc 3816 Aug 18 08:48 errio > *836 > [[ -f err ]] > 837 > echo $? # BAD answer > 0 Sounds like you want this: http://mywiki.wooledge.org/BashFAQ/097 -

Re: Syntax Question...

2011-08-18 Thread Greg Wooledge
On Thu, Aug 18, 2011 at 09:26:42AM -0700, Linda Walsh wrote: > It's like "-e" was very using in bash 3.0-4.0, but you didn't know it so > thought it worthless. I certainly knew about -e. It was bad back then, too. It's arguably worse now, because there are even more variants in implementation th

Re: Is this a bug in [[ -f ]]?

2011-08-18 Thread Eric Blake
On 08/18/2011 10:35 AM, Steven W. Orr wrote: I have a symlink file and if if I test it I get success status with -f. 831 > ls -l errio err lrwxrwxrwx. 1 sorr fc 5 Aug 18 08:48 err -> errio -rw-rw-r--. 1 sorr fc 3816 Aug 18 08:48 errio 832 > [[ -f errio ]] 833 > echo $? # Good answer 0 *834 > [[

Is this a bug in [[ -f ]]?

2011-08-18 Thread Steven W. Orr
I have a symlink file and if if I test it I get success status with -f. 831 > ls -l errio err lrwxrwxrwx. 1 sorr fc5 Aug 18 08:48 err -> errio -rw-rw-r--. 1 sorr fc 3816 Aug 18 08:48 errio 832 > [[ -f errio ]] 833 > echo $?# Good answer 0 *834 > [[ -h errio ]] 835 > echo $?

Re: Syntax Question...

2011-08-18 Thread Linda Walsh
Pierre Gaston wrote: l understood a while ago, now I'll just stop feeding the troll. --- You obviously feel there needs to be a right and wrong, and if you haven't made me wrong, you've lost -- indicated by your resorting to name calling rather than discussing issues. Sigh.

Re: Syntax Question...

2011-08-18 Thread Linda Walsh
` Greg Wooledge wrote: On Thu, Aug 18, 2011 at 06:02:14AM -0700, Linda Walsh wrote: The "shopt -s expand_aliases" feature has been in bash since I first encountered it in ~1999. Fine. You know more bash bad practices than I do. You win. Just because you didn't know about it do

Re: Syntax Question...

2011-08-18 Thread Greg Wooledge
On Thu, Aug 18, 2011 at 10:55:11AM -0400, Chet Ramey wrote: > The quoted paragraph applies to all redirection operators (and parameter > and variable expansion are still identical). The description of <<< > notes that it does not perform pathname expansion at all. The word following the red

Re: conditional aliases are broken

2011-08-18 Thread Greg Wooledge
On Thu, Aug 18, 2011 at 08:03:41AM -0700, Linda Walsh wrote: > >4.2 introduce a new -g to declare a global variable inside a function. > >Which doesn't say what it would do in situations like the above. Then let's test: imadev:~$ echo $BASH_VERSION 4.2.10(7)-release imadev:~$ unset a b;

Re: conditional aliases are broken

2011-08-18 Thread Linda Walsh
Pierre Gaston wrote: Is this a question? or are you trying to make a point? It is both -- a chance to find answer to a question, or make the point that aliases in scripts have a useful purposes that can't be replaced by function clls. For the question (If I understand correctly): 1) Most

Re: Syntax Question...

2011-08-18 Thread Chet Ramey
On 8/18/11 9:37 AM, Greg Wooledge wrote: >>The word following the redirection operator in the following descrip- >>tions, unless otherwise noted, is subjected to brace expansion, tilde >>expansion, parameter expansion, command substitution, arithmetic expan??? >>sion, quote rem

Re: conditional aliases are broken

2011-08-18 Thread Roman Rakus
On 08/18/2011 04:38 PM, Sam Steingold wrote: how do I write a function that would print the same as $ \ls | cat f3(){ printf "%s\n" "$@"; } But please move your question like "HOW TO..." somewhere else; comp.unix.shell usenet group or the #bash IRC channel on freenode or... This mailing list

Re: Syntax Question...

2011-08-18 Thread Chet Ramey
On 8/18/11 9:02 AM, Linda Walsh wrote: >The word following the redirection operator in the following descrip- >tions, unless otherwise noted, is subjected to brace expansion, tilde >expansion, parameter expansion, command substitution, arithmetic expan‐ >sion, quote removal, pa

Re: conditional aliases are broken

2011-08-18 Thread Eric Blake
On 08/18/2011 08:44 AM, Eric Blake wrote: how do I write a function that would print the same as $ \ls | cat Useless use of cat. This can be done with \ls -1. f(){ for a in "$@"; do echo "$a"; done; } Or skip the loop altogether: f(){ printf %s\\n "%@"; } -- Eric Blake ebl...@redhat.co

Re: conditional aliases are broken

2011-08-18 Thread Eric Blake
On 08/18/2011 08:38 AM, Sam Steingold wrote: mkdir z cd z touch a b 'c d' When doing exercises like this, I like to: touch a b 'c d' Notice the double spacing - it proves whether I used enough quoting throughout the exercise - if 'c d' with one space shows up anywhere, then I missed quotin

Re: conditional aliases are broken

2011-08-18 Thread Sam Steingold
> * Eric Blake [2011-08-15 16:59:29 -0600]: > > On 08/15/2011 04:40 PM, Sam Steingold wrote: >>> * Andreas Schwab [2011-08-15 22:04:04 +0200]: >>> >>> Sam Steingold writes: >>> Cool. Now, what does this imply? >>> >>> "For almost every purpose, shell functions are preferred over aliase

Re: Syntax Question...

2011-08-18 Thread Pierre Gaston
On Thu, Aug 18, 2011 at 5:13 PM, Linda Walsh wrote: > > > > Pierre Gaston wrote: >> >> On Mon, Aug 15, 2011 at 2:31 AM, Linda Walsh wrote: >> >>> >>> Re:   BashFAQ/006: http://mywiki.wooledge.org/BashFAQ/006 >>> Pierre Gaston wrote: >>> Linda: > > please show quote the sect

Re: Syntax Question...

2011-08-18 Thread Linda Walsh
Pierre Gaston wrote: On Mon, Aug 15, 2011 at 2:31 AM, Linda Walsh wrote: Re: BashFAQ/006: http://mywiki.wooledge.org/BashFAQ/006 Pierre Gaston wrote: Linda: please show quote the section that shows using an variable that holds the name of an array to be used (and assigned

Re: Syntax Question...

2011-08-18 Thread Greg Wooledge
On Thu, Aug 18, 2011 at 06:02:14AM -0700, Linda Walsh wrote: > The "shopt -s expand_aliases" feature has been in bash since I first > encountered it in ~1999. Fine. You know more bash bad practices than I do. You win. > > b="one two three" > > read a <<<$b > > echo $a > one two three >The

Re: Syntax Question...

2011-08-18 Thread Linda Walsh
Greg Wooledge wrote: [[[ yeah, am running a bit behind]... On Mon, Aug 15, 2011 at 12:45:58AM -0700, Linda Walsh wrote: > #!/bin/bash -exu > +[shopt -s expand_aliases extglob] > > alias sub=function > alias unless='if !' Aliases don't even *work* in scripts. Hopefully you someon

Re: conditional aliases are broken

2011-08-18 Thread Greg Wooledge
On Wed, Aug 17, 2011 at 08:46:34PM -0700, Linda Walsh wrote: > how do you declare a variable for storage in the context of the caller? > (using a function)... > ??? The *caller* declares it. > I found it very troublesome > inside a function, to store a value into a local variable in the caller.

Re: conditional aliases are broken

2011-08-18 Thread Pierre Gaston
On Thu, Aug 18, 2011 at 6:46 AM, Linda Walsh wrote: > > > > ` Eric Blake wrote: >> >> On 08/15/2011 04:40 PM, Sam Steingold wrote: * Andreas Schwab  [2011-08-15 22:04:04 +0200]: Sam Steingold  writes: > > Cool.  Now, what does this imply?    "For almost every purpo