Prev: Converting a relative path to an absolute path
Next: Simple Hack To Get $2500 To Your PayPal Account.
From: Thomas 'PointedEars' Lahn on 21 Jul 2010 20:31 Kenny McCormack wrote: > Thomas 'PointedEars' Lahn wrote: >> Kenny McCormack wrote: >>> Chris F.A. Johnson <cfajohnson(a)gmail.com> wrote: >>>> On 2010-07-21, Kenny McCormack wrote: >>>>> What's the difference between enclosing the cmds in {} vs. ()? >>>> Commands in ( ) are executed in a subshell. >>> That's what I thought. So, the answer to the original question, despite >>> all the other flurry, is simply: Yes, you should use {} rather than (). >> No, the answer simply is, again, "it depends." That is the part of >> software development that you do not seem to understand. > > You funny. It was not my intention to amuse you, but to make you think twice. BTW, in responding like this you are also making a fool of yourself with regard to grammar. > (And I've not even seen any pix of you and you funny ears!) I have not seen a photo of you either. So what? -- PointedEars
From: Thomas 'PointedEars' Lahn on 22 Jul 2010 05:44 Seebs wrote: > Thomas 'PointedEars' Lahn wrote: >> No, the foregone assumption (FGA is not a common Usenet acronym > > "Frequently Given Answer", used by some guy whose name I've forgotten > to refer to things he maintains in a format chosen to prevent people from > rebutting the idiocy therein. Thanks. In ten years of regular Usenet participation, in and outside of the Big 8, I had never come across that acronym. It is not in the Jargon File either. So I doubt it is more than his original research. -- PointedEars
From: John DuBois on 22 Jul 2010 11:03 In article <8ap77sFvcrU3(a)mid.individual.net>, Chris F.A. Johnson <cfajohnson(a)gmail.com> wrote: >On 2010-07-21, John DuBois wrote: >> In article <i243tu$l8g$1(a)news.xmission.com>, >> Kenny McCormack <gazelle(a)shell.xmission.com> wrote: >>>Workarounds: >>> 1) append "< /dev/tty" to each command >>> 2) enclose the commands in parens and redirect that. I.e.: >>> >>> commandThatGeneratesTheFilenames | while read x;do >>> (cmd1;cmd2;cmd3;...) < /dev/tty >>> done >>> >>>Method 2 is nice and seems to work fine, but I am wondering if there is >>>any hidden cost to it and if there is any more elegant/effcient way to >>>do this. >> >> Unless you specifically want to read from the controlling tty rather than >> the standard input, it's always better to save the standard input to >> another fd and then read from it. > > Why? Because the standard input may not be the controlling tty (if the program is piped or redirected into, or started from an environment with no controlling tty, etc). John -- John DuBois spcecdt(a)armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/
From: Stephane CHAZELAS on 26 Jul 2010 12:57 2010-07-20, 12:13(+00), Kenny McCormack: > In this group, it is an FGA that one should so: > > commandThatGeneratesTheFilenames | while read x ... > > instead of the more common: > > for i in ... > > because of the problems of filenames that spaces and other weird characters. After IFS=' ' # NL set -f for i in $(commandThatGeneratesTheFilenames); do... shouldn't be a problem (except that the loop only starts when commandThatGeneratesTheFilenames finishes). Other solution (not any better either than the ones that have already been given): while IFS= read <&3 -r i; do ... done 3<<EOF $(commandThatGeneratesTheFilenames) EOF { commandThatGeneratesTheFilenames | while IFS= read <&3 -r i; do ... done 3<&0 <&4 4<&- } 4<&0 as already given would be the best one. If you're picky, you may write it: { commandThatGeneratesTheFilenames 4<&- | while IFS= read <&3 -r i; do { ... } 3<&- done 3<&0 <&4 4<&- } 4<&0 or: { commandThatGeneratesTheFilenames 4<&- | while IFS= read -r i 4<&-; do { ... } <&4 4<&- done } 4<&0 -- Stephane
First
|
Prev
|
Pages: 1 2 3 4 Prev: Converting a relative path to an absolute path Next: Simple Hack To Get $2500 To Your PayPal Account. |