Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Ian Neal
> > "Utilities other than the special built-ins (see Special Built-In > Utilities) shall be invoked in a separate environment that consists of the > following...[includes redirections specified to the utility]...The > environment of the shell process shall not be changed by the utility" > > > http:

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Chet Ramey
On 4/24/19 10:20 AM, Ian Neal wrote: > "Utilities other than the special built-ins (see Special Built-In > Utilities) shall be invoked in a separate environment that consists of the > following...[includes redirections specified to the utility]...The > environment of the shell proce

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Greg Wooledge
On Wed, Apr 24, 2019 at 09:58:42AM -0400, Chet Ramey wrote: > The SVR4.2 Bourne shell, as another data point, behaves like bash. Since > it doesn't have arithmetic expansion, you have to use something it does > handle internally, like ${n:=2}. I don't know what ksh88, the other POSIX > historical

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Chet Ramey
On 4/24/19 9:49 AM, Ilkka Virta wrote: > On 24.4. 16:37, Chet Ramey wrote: >> "Utilities other than the special built-ins (see Special Built-In >> Utilities) shall be invoked in a separate environment that consists of the >> following...[includes redirections specified to the utility]... > > It do

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Ilkka Virta
On 24.4. 16:37, Chet Ramey wrote: "Utilities other than the special built-ins (see Special Built-In Utilities) shall be invoked in a separate environment that consists of the following...[includes redirections specified to the utility]... It does say "Open files inherited on invocation of the

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Chet Ramey
On 4/24/19 9:07 AM, Andreas Schwab wrote: >> The /bin/true forces the use of an external command, which means a subshell >> is forked. The redirection occurs in the forked subshell. > > But the expansion isn't required to be performed in the subshell. I > don't see POSIX having any wording to r

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Chet Ramey
On 4/24/19 9:22 AM, Ian Neal wrote: > On Wed, Apr 24, 2019, 07:12 Chet Ramey > wrote: > > On 4/24/19 8:47 AM, Ian Neal wrote: > > > At what point is a subshell being invoked? There's no pipeline, command > > substitution, coprocess, background process, or

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Ian Neal
On Wed, Apr 24, 2019, 07:12 Chet Ramey wrote: > On 4/24/19 8:47 AM, Ian Neal wrote: > > > At what point is a subshell being invoked? There's no pipeline, command > > substitution, coprocess, background process, or explicit () subshell > here, > > which are the only cases a subshell should be crea

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Andreas Schwab
On Apr 24 2019, Greg Wooledge wrote: > On Wed, Apr 24, 2019 at 06:47:41AM -0600, Ian Neal wrote: >> At what point is a subshell being invoked? There's no pipeline, command >> substitution, coprocess, background process, or explicit () subshell here, >> which are the only cases a subshell should b

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Chet Ramey
On 4/23/19 5:49 PM, Ian Neal wrote: > Bash Version: 4.2 > Patch Level: 46 > Release Status: release > > Description: > When using arithmetic expansion with variable pre- and > post-increments/decrements in the output redirection file path, > specifically on external e

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Chet Ramey
On 4/24/19 8:47 AM, Ian Neal wrote: > At what point is a subshell being invoked? There's no pipeline, command > substitution, coprocess, background process, or explicit () subshell here, > which are the only cases a subshell should be created. Otherwise, the > entire operation should be evaluated

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Greg Wooledge
On Wed, Apr 24, 2019 at 06:47:41AM -0600, Ian Neal wrote: > At what point is a subshell being invoked? There's no pipeline, command > substitution, coprocess, background process, or explicit () subshell here, > which are the only cases a subshell should be created. Otherwise, the > entire operation

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Ian Neal
> Date:Tue, 23 Apr 2019 15:49:18 -0600 > From:Ian Neal > Message-ID: 1_z7uy+7rv...@mail.gmail.com> > > | When using arithmetic expansion with variable pre- and > | post-increments/decrements in the output redirection file path, > |

Re: Arithmetic expansion with increments and output redirection

2019-04-24 Thread Robert Elz
Date:Tue, 23 Apr 2019 15:49:18 -0600 From:Ian Neal Message-ID: | When using arithmetic expansion with variable pre- and | post-increments/decrements in the output redirection file path, | specifically on external executables (not builtins or functions), the

Arithmetic expansion with increments and output redirection

2019-04-23 Thread Ian Neal
output: Linux s1028505 3.10.0-957.10.1.el7.x86_64 #1 SMP Thu Feb 7 07:12:53 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-redhat-linux-gnu Bash Version: 4.2 Patch Level: 46 Release Status: release Description: When using arithmetic expansion with variable pre- and post-incr

Re: Output redirection to sockets possible within rbash

2018-02-03 Thread Blake Burkhart
On Sat, Feb 3, 2018 at 4:55 PM, Chet Ramey wrote: > On 2/3/18 12:20 PM, Blake Burkhart wrote: > > Within rbash, attempting to open a socket using /dev/tcp with <> fails as > > expected due to output redirection being disabled: > > > > rbash-4.4$ exec 3<>

Re: Output redirection to sockets possible within rbash

2018-02-03 Thread Chet Ramey
On 2/3/18 12:20 PM, Blake Burkhart wrote: > Within rbash, attempting to open a socket using /dev/tcp with <> fails as > expected due to output redirection being disabled: > > rbash-4.4$ exec 3<>/dev/tcp/www.gnu.org/80 > rbash: /dev/tcp/www.gnu.org/80: restric

Output redirection to sockets possible within rbash

2018-02-03 Thread Blake Burkhart
Within rbash, attempting to open a socket using /dev/tcp with <> fails as expected due to output redirection being disabled: rbash-4.4$ exec 3<>/dev/tcp/www.gnu.org/80 rbash: /dev/tcp/www.gnu.org/80: restricted: cannot redirect output However, I noticed that output redirection is not

argument precedence, output redirection

2010-12-03 Thread Payam Poursaied
Hi all, I'm not sure this is a bug or please let me know the concept: What is the difference between: ls -R /etc/ 2>&1 1>/dev/null and ls -R /etc/ 1>/dev/null 2>&1 the second one redirect everything to /dev/null but the first one, still prints errors (run as a non root user would unveil the prob

Re: argument precedence, output redirection

2010-12-03 Thread Marc Herbert
Le 03/12/2010 14:46, Payam Poursaied a écrit : > > Hi all, > I'm not sure this is a bug or please let me know the concept: > What is the difference between: > ls -R /etc/ 2>&1 1>/dev/null > and > ls -R /etc/ 1>/dev/null 2>&1 > > the second one redirect everything to /dev/null but the first one,

Re: argument precedence, output redirection

2010-12-03 Thread Chet Ramey
> I'm not sure this is a bug or please let me know the concept: > What is the difference between: > ls -R /etc/ 2>&1 1>/dev/null > and > ls -R /etc/ 1>/dev/null 2>&1 > > the second one redirect everything to /dev/null but the first one, still > prints errors (run as a non root user would unveil

Re: argument precedence, output redirection

2010-12-03 Thread Eric Blake
On 12/03/2010 07:46 AM, Payam Poursaied wrote: > > Hi all, > I'm not sure this is a bug or please let me know the concept: > What is the difference between: > ls -R /etc/ 2>&1 1>/dev/null > and > ls -R /etc/ 1>/dev/null 2>&1 POSIX requires that redirections are evaluated from left to right. The

Re: argument precedence, output redirection

2010-12-03 Thread Greg Wooledge
On Fri, Dec 03, 2010 at 06:16:06PM +0330, Payam Poursaied wrote: > What is the difference between: > ls -R /etc/ 2>&1 1>/dev/null > and > ls -R /etc/ 1>/dev/null 2>&1 http://mywiki.wooledge.org/BashFAQ/055 In a sentence, redirections are done in order, from left to right.

argument precedence, output redirection

2010-12-03 Thread Payam Poursaied
Hi all, I'm not sure this is a bug or please let me know the concept: What is the difference between: ls -R /etc/ 2>&1 1>/dev/null and ls -R /etc/ 1>/dev/null 2>&1 the second one redirect everything to /dev/null but the first one, still prints errors (run as a non root user would unveil the pro

Re: output redirection with process substitution asynchronous?

2009-12-12 Thread pjodrr
Hello again, I have to reply to my own post to correct it: On Dec 8, 2:00 pm, pjodrr wrote: > coproc prefix_timestamp > seq 10>&${COPROC[1]} > eval "exec ${COPROC[1]}>&-" > cat <&${COPROC[0]} > wait $COPROC_PID replace this with: { coproc prefix_timestamp >&3 ; } 3>&1 seq 10>&${COPROC[1]} eval

Re: output redirection with process substitution asynchronous?

2009-12-08 Thread pjodrr
On Dec 8, 10:55 am, Marc Herbert wrote: > DennisW wrote : > > > Would you care to comment on the coproc command in Bash 4? > > I wish I could, but I know nothing about it. Anyone else? yeah, I tried that: prefix_timestamp() { while read line; do echo "$(date): $line" done } copr

Re: output redirection with process substitution asynchronous?

2009-12-08 Thread pjodrr
On Dec 8, 11:05 am, Marc Herbert wrote: > pk a écrit : > > > > > I disagree. All the further changes in the requirements because creating a > > subshell or being asynchronous is not acceptable etc. are not a goal in > > themselves, but rather the indicators that he's trying to accomplish > > somet

Re: output redirection with process substitution asynchronous?

2009-12-08 Thread Marc Herbert
pk a écrit : > > I disagree. All the further changes in the requirements because creating a > subshell or being asynchronous is not acceptable etc. are not a goal in > themselves, but rather the indicators that he's trying to accomplish > something else. > I think he just want side-effects li

Re: output redirection with process substitution asynchronous?

2009-12-08 Thread Marc Herbert
DennisW wrote : > Would you care to comment on the coproc command in Bash 4? I wish I could, but I know nothing about it. Anyone else? pjodrr wrote : > But at least it became clear that the builtin process substitution is > not the solution for me. Wait! Maybe it is. I found a much nicer way to

Re: output redirection with process substitution asynchronous?

2009-12-07 Thread pjodrr
Hi Marc, On Dec 7, 5:25 pm, Marc Herbert wrote: > Marc Herbert wrote: > > What is wrong with the following: > > > prefix_with_date () > > { > >     while read; do > >         printf '%s: %s\n' "$(date)" "$REPLY"; > >     done > > } > > > seq 4 | prefix_with_date > > ls | prefix_with_date > > Sorr

Re: output redirection with process substitution asynchronous?

2009-12-07 Thread pk
Marc Herbert wrote: >> pjodrr wrote: >> It would be nice if you explained what it is you're attempting to do, >> rather than ask for a solution for what you're thinking would do that. > > To be honest that is the first thing he (tried to) do: > > pjodrr wrote: >> how can I prefix every line of o

Re: output redirection with process substitution asynchronous?

2009-12-07 Thread DennisW
On Dec 7, 10:25 am, Marc Herbert wrote: > Marc Herbert wrote: > > What is wrong with the following: > > > prefix_with_date () > > { > >     while read; do > >         printf '%s: %s\n' "$(date)" "$REPLY"; > >     done > > } > > > seq 4 | prefix_with_date > > ls | prefix_with_date > > Sorry I misse

Re: output redirection with process substitution asynchronous?

2009-12-07 Thread Marc Herbert
Marc Herbert wrote: > What is wrong with the following: > > prefix_with_date () > { > while read; do > printf '%s: %s\n' "$(date)" "$REPLY"; > done > } > > seq 4 | prefix_with_date > ls | prefix_with_date Sorry I missed the fact that you want to run your commands in the current

Re: output redirection with process substitution asynchronous?

2009-12-07 Thread Greg Wooledge
> pjodrr wrote: > > how can I prefix every line of output of some command with a > > timestamp? Mark Herbert wrote: > What is wrong with the following: > > prefix_with_date () > { > while read; do > printf '%s: %s\n' "$(date)" "$REPLY"; > done > } > > seq 4 | prefix_with_date

Re: output redirection with process substitution asynchronous?

2009-12-07 Thread Marc Herbert
> pjodrr wrote: > It would be nice if you explained what it is you're attempting to do, rather > than ask for a solution for what you're thinking would do that. To be honest that is the first thing he (tried to) do: pjodrr wrote: > how can I prefix every line of output of some command with a > t

Re: output redirection with process substitution asynchronous?

2009-12-06 Thread pk
pjodrr wrote: > in my original example the "seq 4" runs in the current shell > while here the command runs in a subshell. It would be nice if you explained what it is you're attempting to do, rather than ask for a solution for what you're thinking would do that.

Re: output redirection with process substitution asynchronous?

2009-12-06 Thread pjodrr
On Dec 5, 3:51 pm, DennisW wrote: > On Dec 5, 3:14 am, pjodrr wrote: > > > > > Hello, > > > On Dec 4, 8:18 pm, DennisW wrote: > > > > It works for me. Does it not for you? If you're asking why not do it, > > > then the answer is "why call an external program unnecessarily?". > > > > Sorry, by th

Re: output redirection with process substitution asynchronous?

2009-12-06 Thread pjodrr
On Dec 5, 4:45 pm, pk wrote: > pjodrr wrote: > > Hi > > > On Dec 4, 7:58 pm, pk wrote: > >> What's wrong with > > >> seq 4 | while read line; do echo "$(date): $line"; done > > > it creates a subshell > > uh...where do you think your original > > >(while read line; do echo "$(date): $line"; done)

Re: output redirection with process substitution asynchronous?

2009-12-05 Thread pjodrr
Hello, On Dec 4, 8:18 pm, DennisW wrote: > It works for me. Does it not for you? If you're asking why not do it, > then the answer is "why call an external program unnecessarily?". > > Sorry, by the way, I missed what you were doing with the file > descriptor on my first read. What is it that you

Re: output redirection with process substitution asynchronous?

2009-12-05 Thread pjodrr
Hi On Dec 4, 7:58 pm, pk wrote: > What's wrong with > > seq 4 | while read line; do echo "$(date): $line"; done it creates a subshell, "seq" was just an example, sorry for the confusion, it could be any other command, and it should run in the current shell. thanks, Peter

Re: output redirection with process substitution asynchronous?

2009-12-05 Thread pjodrr
On Dec 4, 7:46 pm, DennisW wrote: > > This should be in gnu.bash rather than gnu.bash.bug oh, you are right, it's not a bug yet > Would this work for you? > > while read line; do echo "$(date): $line $((num++))"; done ah sorry, I used the command "seq" just as an example, it could be any other

Re: output redirection with process substitution asynchronous?

2009-12-05 Thread pk
pjodrr wrote: > Hi > > On Dec 4, 7:58 pm, pk wrote: >> What's wrong with >> >> seq 4 | while read line; do echo "$(date): $line"; done > > it creates a subshell uh...where do you think your original >(while read line; do echo "$(date): $line"; done) runs?

Re: output redirection with process substitution asynchronous?

2009-12-05 Thread DennisW
On Dec 5, 3:14 am, pjodrr wrote: > Hello, > > On Dec 4, 8:18 pm, DennisW wrote: > > > It works for me. Does it not for you? If you're asking why not do it, > > then the answer is "why call an external program unnecessarily?". > > > Sorry, by the way, I missed what you were doing with the file > >

output redirection with process substitution asynchronous?

2009-12-04 Thread pjodrr
Hello, how can I prefix every line of output of some command with a timestamp? I thought like this: $ exec 3> >(while read line; do echo "$(date): $line"; done) $ seq 4 >&3 Friday, December 4, 2009 4:20:29 PM MET: 1 $ Friday, December 4, 2009 4:20:29 PM MET: 2 Friday, December 4, 2009 4:20

Re: output redirection with process substitution asynchronous?

2009-12-04 Thread DennisW
On Dec 4, 12:58 pm, pk wrote: > pjodrr wrote: > > Hello, > > > how can I prefix every line of output of some command with a > > timestamp?  I thought like this: > > > $ exec 3> >(while read line; do echo "$(date): $line"; done) > > $ seq 4 >&3 > > Friday, December  4, 2009  4:20:29 PM MET: 1 > > $

Re: output redirection with process substitution asynchronous?

2009-12-04 Thread pk
pjodrr wrote: > Hello, > > how can I prefix every line of output of some command with a > timestamp? I thought like this: > > $ exec 3> >(while read line; do echo "$(date): $line"; done) > $ seq 4 >&3 > Friday, December 4, 2009 4:20:29 PM MET: 1 > $ Friday, December 4, 2009 4:20:29 PM MET:

Re: output redirection with process substitution asynchronous?

2009-12-04 Thread DennisW
On Dec 4, 9:28 am, pjodrr wrote: > Hello, > > how can I prefix every line of output of some command with a > timestamp?  I thought like this: > > $ exec 3> >(while read line; do echo "$(date): $line"; done) > $ seq 4 >&3 > Friday, December  4, 2009  4:20:29 PM MET: 1 > $ Friday, December  4, 2009

Re: the context of expansion for output redirection

2009-09-29 Thread Chet Ramey
Lewis Hyatt wrote: > Hello- > > I was somewhat surprised to see the following behavior (this is 3.1.17): > > $ x=0; /bin/echo > /tmp/$((++x)); echo $x > 0 > $ x=0; echo > /tmp/$((++x)); echo $x > 1 > > I guess in the first case the expansion of $((++x)) is taking place after > forking, whereas i

the context of expansion for output redirection

2009-09-28 Thread Lewis Hyatt
Hello- I was somewhat surprised to see the following behavior (this is 3.1.17): $ x=0; /bin/echo > /tmp/$((++x)); echo $x 0 $ x=0; echo > /tmp/$((++x)); echo $x 1 I guess in the first case the expansion of $((++x)) is taking place after forking, whereas in the second case there is no forked proc

Re: problems with output redirection

2008-04-03 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bob Proulx on 4/3/2008 12:18 AM: |> ~ echo "" >> $OUTPUT |> done | | Why are there '~' chars in the above lines? Because recent versions of the Enigmail plugin to Thunderbird insist on ~-escaping lines that start with whitespace, to gua

Re: problems with output redirection

2008-04-02 Thread Bob Proulx
Verena Alishahi wrote: > last week I've updated my workstation cluster client (amd 64 bit) from > SuSE 10.0 to openSUSE 10.3. My bash-version is 3.2.25(1)-release. > ... > Both the bash-scripts and the output file are stored on an > NFS-Filesystem (on the workstation cluster server), so every clien

Re: problems with output redirection

2008-04-02 Thread Verena Alishahi
10.0 to openSUSE 10.3. My bash-version is 3.2.25(1)-release. | | Now I've problems with a bash script, which I used (with bash 3.1) for | years without any problems. I really don't understand what's going on. | | I've reduced my original script to a minimal script which reproduces t

Re: problems with output redirection

2008-04-02 Thread Bert Barbe
bash script, which I used (with bash 3.1) for years without any problems. I really don't understand what's going on. I've reduced my original script to a minimal script which reproduces the output redirection error. The script works as follows: My first script (local.sh) reads

Re: problems with output redirection

2008-04-02 Thread Bert Barbe
E 10.3. My bash-version is 3.2.25(1)-release. Now I've problems with a bash script, which I used (with bash 3.1) for years without any problems. I really don't understand what's going on. I've reduced my original script to a minimal script which reproduces the output redirection

Re: problems with output redirection

2008-04-02 Thread Jan Schampera
Verena Alishahi wrote: > My first script (local.sh) reads a list of worksation cluster clients > from hosts.inp in a loop and prints some output to output.txt. In the > loop a second script (remote.sh) is called in a ssh instruction. > remote.sh then writes some output to the same output.txt file,

problems with output redirection

2008-04-02 Thread Verena Alishahi
ithout any problems. I really don't understand what's going on. I've reduced my original script to a minimal script which reproduces the output redirection error. The script works as follows: My first script (local.sh) reads a list of worksation cluster clients from hosts.inp in a loop

Re: Output redirection?

2006-01-29 Thread Chet Ramey
Yuri Karlsbrun wrote: > Hello, > > I, probably, need bash-help mailing list, but I could not find it. > > Here is the bash script fragment: > LOG_FILE="./logfile" > ... >> $LOG_FILE > > I supposed that the statement above redirects stdout to the logfile. > But the following 'echo' statement prin

Re: Output redirection?

2006-01-29 Thread Chris F.A. Johnson
On Fri, 27 Jan 2006, Yuri Karlsbrun wrote: Hello, I, probably, need bash-help mailing list, but I could not find it. The best place is the Usenet news group, comp.unix.shell. Here is the bash script fragment: LOG_FILE="./logfile" ... > $LOG_FILE That statement will create an empty

Re: Output redirection?

2006-01-29 Thread Bob Proulx
Yuri Karlsbrun wrote: > I, probably, need bash-help mailing list, but I could not find it. > > Here is the bash script fragment: > LOG_FILE="./logfile" > ... > >$LOG_FILE > > I supposed that the statement above redirects stdout to the logfile. > But the following 'echo' statement prints on the sc

Output redirection?

2006-01-28 Thread Yuri Karlsbrun
Hello, I, probably, need bash-help mailing list, but I could not find it. Here is the bash script fragment: LOG_FILE="./logfile" ... >$LOG_FILE I supposed that the statement above redirects stdout to the logfile. But the following 'echo' statement prints on the screen. The logfile is opened. Wha