Re: Not so useless use of cat

2014-09-18 Thread Chet Ramey
On 9/18/14, 9:26 AM, arn...@skeeve.com wrote: > Chet Ramey wrote: > >> Yes, on this one. There are others; recall the `discussion' about >> whether bash should choose between /dev/fd or FIFOs for process >> substitution at runtime. > > That's a tougher one. It's a question of how far back do yo

Re: Not so useless use of cat

2014-09-18 Thread Greg Wooledge
On Thu, Sep 18, 2014 at 07:26:33AM -0600, arn...@skeeve.com wrote: > I'm finding that modern systems have pretty much the union of things > that I need, and also that the older ones that don't simply aren't > in use anymore. E.g., do you still need to support SunOS 4.1.x? Ultrix? > OSF/1? Irix? W

Re: Not so useless use of cat

2014-09-18 Thread arnold
Chet Ramey wrote: > Yes, on this one. There are others; recall the `discussion' about > whether bash should choose between /dev/fd or FIFOs for process > substitution at runtime. That's a tougher one. It's a question of how far back do you wish to continue supporting systems? I'm finding that

Re: Not so useless use of cat

2014-09-18 Thread Chet Ramey
On 9/18/14, 4:29 AM, Aharon Robbins wrote: >> Sure. It's a choice between internal and external consistency. If I >> emulated /dev/std* (and maybe /dev/fd/*) internally in bash, bash would >> behave the same everywhere, but, as Andreas said, I'd get questions >> about why `foo -o /dev/stdout' an

Re: Not so useless use of cat

2014-09-18 Thread Aharon Robbins
In article , Chet Ramey wrote: >On 9/17/14, 3:07 AM, Aharon Robbins wrote: > >>> I've considered emulating it everywhere, regardless of what the OS >>> provides, but I'd get just as many complaints if I did that. >>> >>> Chet >> >> This is what gawk does. I haven't had any complaints about this,

Re: Not so useless use of cat

2014-09-17 Thread Chet Ramey
On 9/17/14, 3:07 AM, Aharon Robbins wrote: >> I've considered emulating it everywhere, regardless of what the OS >> provides, but I'd get just as many complaints if I did that. >> >> Chet > > This is what gawk does. I haven't had any complaints about this, > and once you do it that way you can cl

Re: Not so useless use of cat

2014-09-17 Thread Ralf Goertz
Am Tue, 16 Sep 2014 14:44:05 -0500 schrieb Dennis Williamson : > Does your program support using a hyphen to represent stdout (some > do)? > > program -i "$i" -o - > It indeed does! Thanks for the tip. Ralf

Re: Not so useless use of cat

2014-09-17 Thread Andreas Schwab
arn...@skeeve.com (Aharon Robbins) writes: > In article , > Chet Ramey wrote: >>On 9/16/14, 3:00 PM, Bob Proulx wrote: >> >>> That is one of the reasons I don't like the /dev/std{err,in,out} >>> things. They are not portable. They do different things on different >>> systems. I avoid them. >>

Re: Not so useless use of cat

2014-09-17 Thread Aharon Robbins
In article , Chet Ramey wrote: >On 9/16/14, 3:00 PM, Bob Proulx wrote: > >> That is one of the reasons I don't like the /dev/std{err,in,out} >> things. They are not portable. They do different things on different >> systems. I avoid them. > >I've considered emulating it everywhere, regardless

Re: Not so useless use of cat

2014-09-16 Thread Bob Proulx
Chet Ramey wrote: > Bob Proulx wrote: > > That is one of the reasons I don't like the /dev/std{err,in,out} > > things. They are not portable. They do different things on different > > systems. I avoid them. > > I've considered emulating it everywhere, regardless of what the OS > provides, but I

Re: Not so useless use of cat

2014-09-16 Thread Chet Ramey
On 9/16/14, 3:00 PM, Bob Proulx wrote: > That is one of the reasons I don't like the /dev/std{err,in,out} > things. They are not portable. They do different things on different > systems. I avoid them. I've considered emulating it everywhere, regardless of what the OS provides, but I'd get jus

Re: Not so useless use of cat

2014-09-16 Thread Dennis Williamson
On Tue, Sep 16, 2014 at 2:03 AM, Ralf Goertz wrote: > Am Sat, 13 Sep 2014 12:53:48 -0600 > schrieb Bob Proulx : > > > > Dennis Williamson wrote: > > > Bob Proulx wrote: > > > > { for i in file[12] ; do cat "$i" ; done ;} > both > > > > There's no need for the curly braces and the last semicolon

Re: Not so useless use of cat

2014-09-16 Thread Bob Proulx
Greg Wooledge wrote: > It's important to note that the following two cases are *not* > equivalent: > >cat "$i" >/dev/stdout >program -i "$i" -o /dev/stdout > > In the first case, the /dev/stdout is part of a redirection. On > platforms that do not have a native /dev/stdout in the file sy

Re: Not so useless use of cat

2014-09-16 Thread Greg Wooledge
On Tue, Sep 16, 2014 at 09:03:20AM +0200, Ralf Goertz wrote: > Actually things are more complicated. I do need the /dev/stdout part. I > obiously don't have the problem with `cat' but with some other program > $ for i in file[12] ; do program -i "$i" -o /dev/stdout ; done > outfile It's important

Re: Not so useless use of cat

2014-09-16 Thread Bob Proulx
Ralf Goertz wrote: > Actually things are more complicated. I do need the /dev/stdout part. I > obiously don't have the problem with `cat' but with some other program > that doesn't write to stdout per se and expects a -o parameter for the > output file. And this program just accepts one input file.

Re: Not so useless use of cat

2014-09-16 Thread Ralf Goertz
Am Sat, 13 Sep 2014 12:53:48 -0600 schrieb Bob Proulx : > Dennis Williamson wrote: > > Bob Proulx wrote: > > > { for i in file[12] ; do cat "$i" ; done ;} > both > > There's no need for the curly braces and the last semicolon. > > Of course you are totally right. I was distracted by the subs

Re: Not so useless use of cat

2014-09-15 Thread Chet Ramey
On 9/15/14, 8:14 AM, Greg Wooledge wrote: > On HP-UX, /dev/stdout is NOT an actual file in the file system, so it > is implemented by duplicating FD 1 within Bash. > > arc3:~$ uname -a > Linux arc3 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u1 i686 GNU/Linux > arc3:~$ for i in file[12]; do cat "$

Re: Not so useless use of cat

2014-09-15 Thread Greg Wooledge
On Fri, Sep 12, 2014 at 06:12:13PM -0600, Bob Proulx wrote: > (for i in file[12] ; do cat "$i" > /dev/stdout ; done) > both > > > $ cat both > > second > > Because the >/dev/stdout truncates the output. It writes the first. > Then the second one truncates the file and then writes the second.

Re: Not so useless use of cat

2014-09-13 Thread Bob Proulx
Dennis Williamson wrote: > Bob Proulx wrote: > > And the subshell isn't needed either. Use a list. > > > > { for i in file[12] ; do cat "$i" ; done ;} > both > > There's no need for the curly braces and the last semicolon. Of course you are totally right. I was distracted by the subshell as a

Re: Not so useless use of cat

2014-09-12 Thread Dennis Williamson
On Sep 12, 2014 7:12 PM, "Bob Proulx" wrote: > > Ralf Goertz wrote: > > Since you have used an invalid address I assume you are reading the > mailing list via a web archive or other means and did not CC you. > > > Why do I need cat (the second on) here? > > You don't. > > > $ echo first >file1 >

Re: Not so useless use of cat

2014-09-12 Thread Bob Proulx
Ralf Goertz wrote: Since you have used an invalid address I assume you are reading the mailing list via a web archive or other means and did not CC you. > Why do I need cat (the second on) here? You don't. > $ echo first >file1 > $ echo second >file2 > $ (for i in file[12] ; do cat "$i" > /dev

Re: Not so useless use of cat

2014-09-12 Thread Dennis Williamson
On Sep 12, 2014 6:42 PM, "Ralf Goertz" wrote: > > Hi, > > Why do I need cat (the second on) here? > > $ echo first >file1 > $ echo second >file2 > $ (for i in file[12] ; do cat "$i" > /dev/stdout ; done) | cat > both > > $ cat both > first > second > > > > If I omit the "| cat" after the loop