From togo at of.net Tue Aug 2 08:22:08 2011 From: togo at of.net (Tony Godshall) Date: Tue, 2 Aug 2011 08:22:08 -0700 Subject: [buug] Y2K and Related Papers? In-Reply-To: References: <20110728152712.GZ29324@primate.net> <20110729183445.GR27273@linuxmafia.com> Message-ID: >>> Our Computer Science department has been dominated by Communism and >>> Russian Socialism since Pearl Harbor was attacked in 1941. They >>> wouldn't teach us what we need to know after they attacked us, >>> especially after re-attacking us on 9/11 instead of checking their own >>> nuclear reactors and weapons for Y2K problems. >> And protecting our precious bodily fluids! > Nice Rick, but I don't quite follow you on that one. ?... Turn of your CRM114 discriminator! From togo at of.net Tue Aug 2 08:22:27 2011 From: togo at of.net (Tony Godshall) Date: Tue, 2 Aug 2011 08:22:27 -0700 Subject: [buug] Y2K and Related Papers? In-Reply-To: References: <20110728152712.GZ29324@primate.net> <20110729183445.GR27273@linuxmafia.com> Message-ID: On Tue, Aug 2, 2011 at 8:22 AM, Tony Godshall wrote: >>>> Our Computer Science department has been dominated by Communism and >>>> Russian Socialism since Pearl Harbor was attacked in 1941. ?They >>>> wouldn't teach us what we need to know after they attacked us, >>>> especially after re-attacking us on 9/11 instead of checking their own >>>> nuclear reactors and weapons for Y2K problems. > >>> And protecting our precious bodily fluids! > >> Nice Rick, but I don't quite follow you on that one. ?... > > Turn of your CRM114 discriminator! Doh, I meant off. From itz at buug.org Wed Aug 3 12:52:38 2011 From: itz at buug.org (Ian Zimmerman) Date: Wed, 03 Aug 2011 12:52:38 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh Message-ID: <87r5525l2x.fsf@matica.localdomain> After all these years with Unix I still don't know how to deal with this annoying misfeature of the shell, without going into ridiculous contortions: [30]matica:~$ foo=1 ; for a ; do foo=bar ; done [31]matica:~$ echo $foo 1 or [32]matica:~$ foo=1 ; echo bar | read foo [33]matica:~$ echo $foo 1 or finally, somewhat closer to my real application: [34]matica:~$ echo bar > baz [35]matica:~$ foo=1 [36]matica:~$ cat baz | while read line ; do foo=$line ; done [37]matica:~$ echo $foo 1 Help? I understand _why_ this is happening (see Subject), I want a solution. And a pony too! -- Ian Zimmerman gpg public key: 1024D/C6FF61AD fingerprint: 66DC D68F 5C1B 4D71 2EE5 BD03 8A00 786C C6FF 61AD Rule 420: All persons more than eight miles high to leave the court. From itz at buug.org Wed Aug 3 15:26:45 2011 From: itz at buug.org (Ian Zimmerman) Date: Wed, 03 Aug 2011 15:26:45 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh In-Reply-To: <87r5525l2x.fsf@matica.localdomain> (Ian Zimmerman's message of "Wed, 03 Aug 2011 12:52:38 -0700") References: <87r5525l2x.fsf@matica.localdomain> Message-ID: <87mxfq5dy2.fsf@matica.localdomain> Ian> After all these years with Unix I still don't know how to deal with Ian> this annoying misfeature of the shell, without going into Ian> ridiculous contortions: Ian> [30]matica:~$ foo=1 ; for a ; do foo=bar ; done [31]matica:~$ echo Ian> $foo 1 This example is bogus - the loop doesn't get executed. This works: [40]matica:~$ foo=1 ; for a in baz ; do foo=bar ; done [41]matica:~$ echo $foo bar So, it's the pipe that is the sole culprit, not the loop. Still looking for answers in the pipe case ... -- Ian Zimmerman gpg public key: 1024D/C6FF61AD fingerprint: 66DC D68F 5C1B 4D71 2EE5 BD03 8A00 786C C6FF 61AD Rule 420: All persons more than eight miles high to leave the court. From togo at of.net Thu Aug 4 12:55:31 2011 From: togo at of.net (Tony Godshall) Date: Thu, 4 Aug 2011 12:55:31 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh In-Reply-To: <87r5525l2x.fsf@matica.localdomain> References: <87r5525l2x.fsf@matica.localdomain> Message-ID: > ?[34]matica:~$ echo bar > baz > ?[35]matica:~$ foo=1 > ?[36]matica:~$ cat baz | while read line ; do foo=$line ; done > ?[37]matica:~$ echo $foo > 1 > > Help? ?I understand _why_ this is happening (see Subject), I want a > solution. ?And a pony too! Well, a pipe does need two processes so you can have concurrent execution, otherwise you'd have a MSDOS-style pipe T From itz at buug.org Thu Aug 4 14:07:14 2011 From: itz at buug.org (Ian Zimmerman) Date: Thu, 04 Aug 2011 14:07:14 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh In-Reply-To: (Tony Godshall's message of "Thu, 4 Aug 2011 12:55:31 -0700") References: <87r5525l2x.fsf@matica.localdomain> Message-ID: <87wresnawt.fsf@matica.localdomain> > [34]matica:~$ echo bar > baz > [35]matica:~$ foo=1 > [36]matica:~$ cat baz | while read line ; do foo=$line ; done > [37]matica:~$ echo $foo > 1 Tony> Well, a pipe does need two processes so you can have concurrent Tony> execution, otherwise you'd have a MSDOS-style pipe But bash creates 3 processes in this case. There is a subshell where the while .. done executes. And I'm sure this is mandated by POSIX. Anyway, as I wrote I'm just interested in solutions :-P Right now I use temporary files which is ugly as sin. -- Ian Zimmerman gpg public key: 1024D/C6FF61AD fingerprint: 66DC D68F 5C1B 4D71 2EE5 BD03 8A00 786C C6FF 61AD Rule 420: All persons more than eight miles high to leave the court. From itz at buug.org Thu Aug 4 15:21:04 2011 From: itz at buug.org (Ian Zimmerman) Date: Thu, 04 Aug 2011 15:21:04 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh In-Reply-To: <87r5525l2x.fsf@matica.localdomain> (Ian Zimmerman's message of "Wed, 03 Aug 2011 12:52:38 -0700") References: <87r5525l2x.fsf@matica.localdomain> Message-ID: <87sjpgn7hr.fsf@matica.localdomain> Sigh. When I wrote my post I assumed the problem I described would be instantly recognized by any Unix veteran who (I kept assuming) had run into it themselves many times before, and who would be able to suggest a neat way around it. I was wrong. So let's start again. Here's a hypothetical but reasonably practical example, unlike the schematic examples I posted before. You have a program output_foo that spews lines line these: foo 1 bar 23 baz 4 foo 53 foobar 6 ... Note there are repetitions. Now let's say you want a script that sums up all of "foo" lines, and for some reason you want to use sh (and not perl or python etc.) How would you do it? Well, the obvious way: total=0 output_foo | while read item count ; do if [ $item = foo ] ; then total=`expr $total+ $count` fi done echo $total won't work, for precisely the reasons my schematic scripts before failed. (It will echo 0). Your turn. -- Ian Zimmerman gpg public key: 1024D/C6FF61AD fingerprint: 66DC D68F 5C1B 4D71 2EE5 BD03 8A00 786C C6FF 61AD Rule 420: All persons more than eight miles high to leave the court. From Michael.Paoli at cal.berkeley.edu Thu Aug 4 15:52:58 2011 From: Michael.Paoli at cal.berkeley.edu (Michael Paoli) Date: Thu, 04 Aug 2011 15:52:58 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh In-Reply-To: <87sjpgn7hr.fsf@matica.localdomain> References: <87r5525l2x.fsf@matica.localdomain> <87sjpgn7hr.fsf@matica.localdomain> Message-ID: <20110804155258.153105lun6lb424o@webmail.rawbw.com> > From: "Ian Zimmerman" > Subject: Re: [buug] loops and pipe sinks are subshells, aaaargh > Date: Thu, 04 Aug 2011 15:21:04 -0700 > Sigh. When I wrote my post I assumed the problem I described would be > instantly recognized by any Unix veteran who (I kept assuming) had run Yes, instantly recognized. I believe it's also well covered in shell FAQ(s) ... somewhere - and I think maybe even including suggested work-around(s) ... but I wasn't able to super easily find such FAQ, though it likely (still) exists ... somewhere. > into it themselves many times before, and who would be able to suggest a > neat way around it. I was wrong. Feasible way(s) around it, ... "neat" is debatable. > So let's start again. Here's a hypothetical but reasonably practical > example, unlike the schematic examples I posted before. Helps to have a better idea of exactly what one's trying to solve (some of the earlier examples could be trivially reduced to something where the problem was totally moot - so I didn't think there was much "value" I could add there). > You have a program output_foo that spews lines line these: > > foo 1 > bar 23 > baz 4 > foo 53 > foobar 6 > ... > > Note there are repetitions. Now let's say you want a script that sums > up all of "foo" lines, and for some reason you want to use sh (and not > perl or python etc.) How would you do it? Well, the obvious way: > > total=0 > > output_foo | > while read item count ; do > if [ $item = foo ] ; then > total=`expr $total+ $count` > fi > done > > echo $total > > won't work, for precisely the reasons my schematic scripts before > failed. (It will echo 0). Among possible approaches: #!/bin/sh output_foo(){ echo 'foo 1 bar 23 baz 4 foo 53 foobar 6 ...' } total=0 output_foo | echo $( while read item count ; do if [ $item = foo ] ; then total=`expr $total + $count` fi done echo $total) And executing that gives us output of: 54 Typically ways of handling the - I want my subshell to change my environment or parent shell - issues are: capture and use the results via: stdout and/or stderr return value And in turn those might be directly output or written to stdout or stderr, or use them to set shell variable(s)/parameter(s). Alternatively (but generally not as elegant), write them to a file (and if a temporary file, to so securely - and there isn't a fully standard POSIX/SUS way to do that directly just with shell, but with POSIS/SUS utilities and creating a (temporary) directory, it can be achieved, or temporary file can be directly and securely created with certain other utilities (I think one of which is likely in LSB)) - file can then be used by ancestor shell - or can be final output. Bonus points/extra credit: Find the FAQ(s) (or a FAQ) that not only explains the whole shell pipe (|) subshell environment/variable/parameter "issue", but also shows (semi?-)elegant work-arounds. Hint: news:comp.unix.shell From Michael.Paoli at cal.berkeley.edu Thu Aug 4 17:40:08 2011 From: Michael.Paoli at cal.berkeley.edu (Michael Paoli) Date: Thu, 04 Aug 2011 17:40:08 -0700 Subject: [buug] (SF) Fwd: Computer work this Sunday @ KIPP school 10 to 5 Message-ID: <20110804174008.26391i3q5bhgrfno@webmail.rawbw.com> ----- Forwarded message from einfeldt at gmail.com ----- Date: Wed, 3 Aug 2011 19:50:28 -0700 From: "Christian Einfeldt" Subject: Computer work this Sunday @ KIPP school 10 to 5 To: "discussion at lists.partimus.org" , "Jack Deslippe" , "board at partimus.org" Hi, The school year is starting again in a big way, and we have teachers who need GNU-Linux computers! If you can come to the KIPP school this Sunday 8/7/11, you will get free pizza and drinks! Pls come to the back of the school @ O'Farrell and Pierce as the school is undergoing heavy construction. Pls call me @ 415.351.1300 when you arrive so that I can get you into the building! We will probably have lunch @ about 12:30 or so. Please bring blank CDs, screw drivers, needle nose pliers, cat 5 cables, hubs, switches, and surge protectors if you have them. Jack, cd u pls repost this announcement to Berkeley LUG's list? Could someone pls mention this to whomever is left @ Noisebridge tonight? Could someone pls post this on SV-LUG? Thx everyone! ----- End forwarded message ----- From togo at of.net Fri Aug 5 11:47:12 2011 From: togo at of.net (Tony Godshall) Date: Fri, 5 Aug 2011 11:47:12 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh In-Reply-To: <20110804155258.153105lun6lb424o@webmail.rawbw.com> References: <87r5525l2x.fsf@matica.localdomain> <87sjpgn7hr.fsf@matica.localdomain> <20110804155258.153105lun6lb424o@webmail.rawbw.com> Message-ID: [IZ] >> Sigh. When I wrote my post I assumed the problem I described would be >> instantly recognized by any Unix veteran who (I kept assuming) ... Ian: Well, color us whooshed. By the way, you'll get better answers faster if you provide complete working code in your questions. It's not always about skill: it can also be about time. [MP] > Yes, instantly recognized. I believe it's also well covered in shell > FAQ(s) ... ... > Among possible approaches: > > #!/bin/sh > output_foo(){ > echo 'foo 1 ... Michael: Well, you still don't get the variable to the outside of the subshell, the point of the original question. This does: start script #!/bin/bash # note I changed Michael's shebang because of the bashisms) output_foo(){ echo 'foo 1 bar 23 baz 4 foo 53 foobar 6' } total=$( output_foo | ( total=0 while read item count do let total=total+count done echo $total ) ) echo $total end script end message From togo at of.net Fri Aug 5 12:48:36 2011 From: togo at of.net (Tony Godshall) Date: Fri, 5 Aug 2011 12:48:36 -0700 Subject: [buug] "we have teachers who need GNU-Linux computers!" + some kind of school wiring thing Message-ID: Cool Related to this, I gather... http://partimus.org/ksfba.php On Thu, Aug 4, 2011 at 5:40 PM, Michael Paoli wrote: > > > ----- Forwarded message from einfeldt at gmail.com ----- > ? ?Date: Wed, 3 Aug 2011 19:50:28 -0700 > ? ?From: "Christian Einfeldt" > ?Subject: Computer work this Sunday @ KIPP school 10 to 5 > ? ? ?To: "discussion at lists.partimus.org" , > "Jack Deslippe" , "board at partimus.org" > > > Hi, > > The school year is starting again in a big way, and we have teachers who > need GNU-Linux computers! ?If you can come to the KIPP school this Sunday > 8/7/11, you will get free pizza and drinks! ?Pls come to the back of the > school @ O'Farrell and Pierce as the school is undergoing heavy > construction. ?Pls call me @ 415.351.1300 when you arrive so that I can get > you into the building! ?We will probably have lunch @ about 12:30 or so. > Please bring blank CDs, screw drivers, needle nose pliers, cat 5 cables, > hubs, switches, and surge protectors if you have them. > > Jack, cd u pls repost this announcement to Berkeley LUG's list? > > Could someone pls mention this to whomever is left @ Noisebridge tonight? > > Could someone pls post this on SV-LUG? > > Thx everyone! > > > ----- End forwarded message ----- > > _______________________________________________ > Buug mailing list > Buug at weak.org > http://www.weak.org/mailman/listinfo/buug > -- Best Regards. This is unedited. P-) From Michael.Paoli at cal.berkeley.edu Fri Aug 5 14:30:08 2011 From: Michael.Paoli at cal.berkeley.edu (Michael Paoli) Date: Fri, 05 Aug 2011 14:30:08 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh In-Reply-To: References: <87r5525l2x.fsf@matica.localdomain> <87sjpgn7hr.fsf@matica.localdomain> <20110804155258.153105lun6lb424o@webmail.rawbw.com> Message-ID: <20110805143008.51377e5bptxm844c@webmail.rawbw.com> > From: "Tony Godshall" > Subject: Re: [buug] loops and pipe sinks are subshells, aaaargh > Date: Fri, 5 Aug 2011 11:47:12 -0700 > [IZ] >>> Sigh. When I wrote my post I assumed the problem I described would be >>> instantly recognized by any Unix veteran who (I kept assuming) ... > > Ian: > > Well, color us whooshed. By the way, you'll get better answers > faster if you provide complete working code in your questions. > It's not always about skill: it can also be about time. Yes, (relatively) true ... doesn't have to be "complete working code" - that can be, and often is overkill, ... but reduce it down to what's essentially required and/or needs to be done/solved or at least sufficiently illustrative example of that, but not (much) more. "Everything should be made as simple as possible, but no simpler." - Albert Einstein > [MP] >> Yes, instantly recognized. I believe it's also well covered in shell >> FAQ(s) ... > ... >> Among possible approaches: >> >> #!/bin/sh >> output_foo(){ >> echo 'foo 1 ... > > Michael: > > Well, you still don't get the variable to the outside of the subshell, > the point of the original question. Well, yes, but ... easy/trivial enough to (also) do that (or at least I thought that would likely be sufficiently obvious once the command substitution was shown - may or may not have been as obvious to all, but likely quite so to at least the original poster), ... and I have a tendency to optimize things - in the example the shell variable wasn't used beyond once as a single argument to an echo command, and the variable would be an integer - I optimized it down to simply outputting it, rather than assigning it, echoing it, and then never referring to that variable/parameter again. At least one of the earlier examples in the thread I'd optimized in my head down to a tail -n 1, making the "problem"/"solution" relatively moot for what I thought was the "meat" of the question, so I waited for a more complete example problem (and I still optimized it some reasonable bit). > This does: ... yes, ... and there are also additional approaches (maybe I'll write up at least one more, or maybe someone else will beat me to it - or better yet find URL(s) to FAQ(s) or the like that have already better illustrated the matter and "best" (of class, for POSIX) shell solutions for that "problem"/issue). Ian also mentioned case/example at meeting yesterday, that's less trivial, e.g. one wants to count for not just one string/item, but say several items. I may write up an example solution for that (have it in my head ... just have to type, test, post ... all that requires is ... time - of which I usually seem to have too little). I'll drop a hint on how that might be approached (and without temporary files): eval Other note (generally applies) - these are mostly illustrative examples, and for simplicity/clarity of illustration, are generally lacking in the error checking and robustness that would typically be appropriate (if not required) for actual production code, e.g. see also: http://www.rawbw.com/~mp/unix/sh/#Good_Programming_Practices From khogoboom at gmail.com Fri Aug 5 19:38:11 2011 From: khogoboom at gmail.com (Karen Hogoboom) Date: Fri, 5 Aug 2011 19:38:11 -0700 Subject: [buug] Y2K and Related Papers? In-Reply-To: References: <20110728152712.GZ29324@primate.net> <20110729183445.GR27273@linuxmafia.com> Message-ID: >>>>> Our Computer Science department has been dominated by Communism and >>>>> Russian Socialism since Pearl Harbor was attacked in 1941. ?They >>>>> wouldn't teach us what we need to know after they attacked us, >>>>> especially after re-attacking us on 9/11 instead of checking their own >>>>> nuclear reactors and weapons for Y2K problems. >> >>>> And protecting our precious bodily fluids! >> >>> Nice Rick, but I don't quite follow you on that one. ?... >> >> Turn of your CRM114 discriminator! > > Doh, I meant off. > Unfortunately, I grew up in a poor family with no father as a result of the bombing of Pearl Harbor and the Korean and Viet Nam wars, so I didn't have one of those when I was growing up. Nor did I have a TRS-80 or a Cromemco or even a TI calculator. I didn't encounter a computer that I could work on until I was about 20 years old. It's different being a girl from a poor family who grows up on the west coast than guys who suckled on MIT electronics like a lot of east coast people apparently did. I was encouraged to learn how to type and to balance a checkbook. My first job was babysitting when I was 11 years old, not building a computer in a garage. From itz at buug.org Fri Aug 5 20:38:45 2011 From: itz at buug.org (Ian Zimmerman) Date: Fri, 05 Aug 2011 20:38:45 -0700 Subject: [buug] Y2K and Related Papers? In-Reply-To: (Karen Hogoboom's message of "Fri, 5 Aug 2011 19:38:11 -0700") References: <20110728152712.GZ29324@primate.net> <20110729183445.GR27273@linuxmafia.com> Message-ID: <87bow3mcoq.fsf@matica.localdomain> Karen> My first job was babysitting when I was 11 years old, not Karen> building a computer in a garage. But you _did_ have a garage, right? -- Ian Zimmerman gpg public key: 1024D/C6FF61AD fingerprint: 66DC D68F 5C1B 4D71 2EE5 BD03 8A00 786C C6FF 61AD Rule 420: All persons more than eight miles high to leave the court. From Michael.Paoli at cal.berkeley.edu Fri Aug 5 23:28:04 2011 From: Michael.Paoli at cal.berkeley.edu (Michael Paoli) Date: Fri, 05 Aug 2011 23:28:04 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh In-Reply-To: <20110805143008.51377e5bptxm844c@webmail.rawbw.com> References: <87r5525l2x.fsf@matica.localdomain> <87sjpgn7hr.fsf@matica.localdomain> <20110804155258.153105lun6lb424o@webmail.rawbw.com> <20110805143008.51377e5bptxm844c@webmail.rawbw.com> Message-ID: <20110805232804.1974435zeyemiskk@webmail.rawbw.com> > From: "Michael Paoli" > Subject: Re: [buug] loops and pipe sinks are subshells, aaaargh > Date: Fri, 05 Aug 2011 14:30:08 -0700 > Ian also mentioned case/example at meeting yesterday, that's less > trivial, e.g. one wants to count for not just one string/item, but say > several items. I may write up an example solution for that (have it in > my head ... just have to type, test, post ... all that requires is ... > time - of which I usually seem to have too little). I'll drop a hint > on how that might be approached (and without temporary files): eval A few more examples. First a wee bit of a note - bash manages to screw this up and not work - I wasted probably about 20 minutes trying to figure out what "I" did wrong, ... when I had not done anything wrong as far as I'm aware. Seems to be a bug even in relatively current version of bash, and also significantly older version - and probably many other versions (present in at least versions: 2.05b.0(1)-release and: 3.00.15(1)-release ... likely also those between and probably before, and at least somewhat after ) and bash messes it up even when invoked with arg0 of sh or /bin/sh or the like, in which case it should behave in POSIXly correct manner. The ash and dash shells seem to handle it just fine, ... and - with minor adjustments for historical backwards compatibility, even ye old Bourne shell from Unix 7th edition (circa 1979) handles it just fine. So, first, we have: $ expand -t 4 < eval #!/bin/sh output_foo(){ cat <<- \__EOT__ foo 1 bar 23 baz 4 foo 53 foobar 6 whatever 99 ... __EOT__ } eval $( foo=0 bar=0 baz=0 foobar=0 output_foo | ( while read item count; do case "$item" in foo|bar|baz|foobar) eval $item=\$\(expr \$$item + \$count\) ;; esac done echo foo=$foo bar=$bar baz=$baz foobar=$foobar ) ) for item in foo bar baz foobar do eval echo count for \$item is \$$item done For ye olde ancient Unix 7th edition circa 1979 Bourne shell (run under emulation), we additionally have: $ diff eval eval.old | expand -t 4 1c1 < #!/bin/sh --- > : 3,15c3 < output_foo(){ < cat <<- \__EOT__ < foo 1 < bar 23 < baz 4 < foo 53 < foobar 6 < whatever 99 < ... < __EOT__ < } < < eval $( --- > eval ` 20c8 < output_foo | --- > ./output_foo | 25c13 < eval $item=\$\(expr \$$item + \$count\) --- > eval $item=\\\`expr \\\$$item + $count\\\` 31c19 < ) --- > ` $ cat output_foo : cat << \__EOT__ foo 1 bar 23 baz 4 foo 53 foobar 6 whatever 99 ... __EOT__ (Ye olde shell doesn't support #!notation, shell functions, and doesn't support $( command substitution syntax.) And the various test runs (fails miserably under bash shell - I won't bother showing that - it apparently can't properly parse case statement with pattern(s) in that context) ... $ cat /etc/debian_version && ls -l /bin/sh 6.0.2 lrwxrwxrwx 1 root root 4 Apr 13 12:16 /bin/sh -> dash $ ./eval count for foo is 54 count for bar is 23 count for baz is 4 count for foobar is 6 $ ./eval.old count for foo is 54 count for bar is 23 count for baz is 4 count for foobar is 6 $ And under ye olde Bourne shell from Unix 7th edition circa 1979: $ ./eval.old count for foo is 54 count for bar is 23 count for baz is 4 count for foobar is 6 $ I'll leave analyzing/explaining/commenting the code as an exercise. Standard caveats/disclaimers apply. references/excerpts: sh(1) expr(1) cat(1) http://www.rawbw.com/~mp/unix/sh/ http://www.rawbw.com/~mp/unix/sh/#Good_Programming_Practices http://www.weak.org/pipermail/buug/2011-August/003884.html et. seq. From itz at buug.org Sat Aug 6 02:38:31 2011 From: itz at buug.org (Ian Zimmerman) Date: Sat, 06 Aug 2011 02:38:31 -0700 Subject: [buug] loops and pipe sinks are subshells, aaaargh In-Reply-To: <20110805232804.1974435zeyemiskk@webmail.rawbw.com> (Michael Paoli's message of "Fri, 05 Aug 2011 23:28:04 -0700") References: <87r5525l2x.fsf@matica.localdomain> <87sjpgn7hr.fsf@matica.localdomain> <20110804155258.153105lun6lb424o@webmail.rawbw.com> <20110805143008.51377e5bptxm844c@webmail.rawbw.com> <20110805232804.1974435zeyemiskk@webmail.rawbw.com> Message-ID: <877h6qnalk.fsf@matica.localdomain> Did you report the bash bug? Sounds scary. -- Ian Zimmerman gpg public key: 1024D/C6FF61AD fingerprint: 66DC D68F 5C1B 4D71 2EE5 BD03 8A00 786C C6FF 61AD Rule 420: All persons more than eight miles high to leave the court. From Michael.Paoli at cal.berkeley.edu Sat Aug 6 08:32:26 2011 From: Michael.Paoli at cal.berkeley.edu (Michael Paoli) Date: Sat, 06 Aug 2011 08:32:26 -0700 Subject: [buug] bash bug (bug also apparently in, and not in, some other shells) In-Reply-To: <877h6qnalk.fsf@matica.localdomain> References: <87r5525l2x.fsf@matica.localdomain> <87sjpgn7hr.fsf@matica.localdomain> <20110804155258.153105lun6lb424o@webmail.rawbw.com> <20110805143008.51377e5bptxm844c@webmail.rawbw.com> <20110805232804.1974435zeyemiskk@webmail.rawbw.com> <877h6qnalk.fsf@matica.localdomain> Message-ID: <20110806083226.207777esehclno4c@webmail.rawbw.com> > From: "Ian Zimmerman" > Subject: Re: [buug] loops and pipe sinks are subshells, aaaargh > Date: Sat, 06 Aug 2011 02:38:31 -0700 > Did you report the bash bug? Sounds scary. I don't know about "scary", but stupid and annoying bug. Looks like it's known bug, and also apparently known upstream (GNU): http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=86397 Looks the bug is also present in some non-bash shells, but not in some others. There's also apparently some alternate case syntax that can be used as work-around. Current stable Debian uses dash for /bin/sh :-) and dash doesn't have that bug. I was gathering information to report it, but looks like that would've been quite redundant, as it's apparently already known, reported, and currently open bug (though unfortunately doesn't sound likely to be fixed anytime soon). Some of what I'd put together: Subject: fails to parse pattern in case in loop in $() Description: fails to parse pattern in case in loop in $() command substitution Repeat-By: rather minimalist example demonstrations found thus far: $ expand -t 4 bug #!/bin/sh if [ x"${BASH_VERSION+bash}" = xbash ]; then set -o posix echo $BASH_VERSION fi $( for x in x; do case "$x" in x) : ;; esac done ) $ expand -t 4 bug2 #!/bin/sh if [ x"${BASH_VERSION+bash}" = xbash ]; then set -o posix echo $BASH_VERSION fi $( < /dev/null while read x; do case "$x" in x) : ;; esac done ) Example runs: $ ./bash-4.2/bash bug 4.2.0(1)-release bug: command substitution: line 16: syntax error: unexpected end of file bug: line 13: syntax error near unexpected token `;;' bug: line 13: ` ;;' $ ./bash-4.2/bash bug2 4.2.0(1)-release bug2: command substitution: line 13: syntax error near unexpected token `do' bug2: command substitution: line 13: ` < /dev/null while read x; do' bug2: line 13: syntax error near unexpected token `;;' bug2: line 13: ` ;;' $ problem occurs under at least these bash versions: 4.2.0(1)-release 3.00.15(1)-release 2.05b.0(1)-release problem does not occur under dash or ash shells. problem does not occur: if `` command substitution syntax is used instead of $() if the while or for loop (but not its contents) is removed if the case statement contains no pattern section(s) Fix: inelegant workarounds: use `` instead of $(), or dash or ash or other POSIX/SUS compliant shells instead of bash From nick at zork.net Sat Aug 6 11:26:07 2011 From: nick at zork.net (Nick Moffitt) Date: Sat, 6 Aug 2011 18:26:07 +0000 Subject: [buug] Y2K and Related Papers? In-Reply-To: References: <20110728152712.GZ29324@primate.net> <20110729183445.GR27273@linuxmafia.com> Message-ID: <20110806182607.GI26789@zork.net> Karen Hogoboom: > >>>> Our Computer Science department has been dominated by Communism and > >>>> Russian Socialism since Pearl Harbor was attacked in 1941. ?They > >>>> wouldn't teach us what we need to know after they attacked us, > >>>> especially after re-attacking us on 9/11 instead of checking their own > >>>> nuclear reactors and weapons for Y2K problems. > >>> And protecting our precious bodily fluids! > >> Nice Rick, but I don't quite follow you on that one. ?... > > Turn off your CRM114 discriminator! > > Unfortunately, I grew up in a poor family with no father as a result > of the bombing of Pearl Harbor and the Korean and Viet Nam wars, so I > didn't have one of those when I was growing up. Exhibit A: http://www.imdb.com/title/tt0057012/quotes?qt0454454 http://www.imdb.com/title/tt0057012/quotes?qt0454480 Exhibit B: http://www.imdb.com/title/tt0079367/quotes?qt0271096 -- 01234567 <- The amazing* Indent-O-Meter! ^ *: Indent-O-Meter may not actually amaze. From khogoboom at gmail.com Sun Aug 7 11:39:40 2011 From: khogoboom at gmail.com (Karen Hogoboom) Date: Sun, 7 Aug 2011 11:39:40 -0700 Subject: [buug] Y2K and Related Papers? In-Reply-To: <87bow3mcoq.fsf@matica.localdomain> References: <20110728152712.GZ29324@primate.net> <20110729183445.GR27273@linuxmafia.com> <87bow3mcoq.fsf@matica.localdomain> Message-ID: On Fri, Aug 5, 2011 at 8:38 PM, Ian Zimmerman wrote: > > Karen> My first job was babysitting when I was 11 years old, not > Karen> building a computer in a garage. > > But you _did_ have a garage, right? > Nope. Right after we pulled out of the Viet Nam war, my mother couldn't afford to feed me, so her friend allowed me to stay with her in Denver. I shared a small two bedroom apartment with her and her daughter. I didn't have access to a computer until I was 19 years old. Make no assumptions about female programmers who have worked as hard as I have to attempt to overcome sexism and discrimination in computer science education and employment. If you are not worth my attention, I won't give it to you. Women are NOT free software. > -- > Ian Zimmerman > gpg public key: 1024D/C6FF61AD > fingerprint: 66DC D68F 5C1B 4D71 2EE5 ?BD03 8A00 786C C6FF 61AD > Rule 420: All persons more than eight miles high to leave the court. > _______________________________________________ > Buug mailing list > Buug at weak.org > http://www.weak.org/mailman/listinfo/buug > -- Karen Lee Hogoboom Computer Programmer Phone:? (510)?666-8298 Mobile:? (510) 407-4363 khogoboom at gmail.com http://www.linkedin.com/in/karenlhogoboom From itz at buug.org Sun Aug 7 17:54:52 2011 From: itz at buug.org (Ian Zimmerman) Date: Sun, 07 Aug 2011 17:54:52 -0700 Subject: [buug] apropos maths vs. physics Message-ID: <878vr4bu3n.fsf@matica.localdomain> http://concretenonsense.wordpress.com/2011/08/03/on-physical-units/ -- Ian Zimmerman gpg public key: 1024D/C6FF61AD fingerprint: 66DC D68F 5C1B 4D71 2EE5 BD03 8A00 786C C6FF 61AD Rule 420: All persons more than eight miles high to leave the court. From Michael.Paoli at cal.berkeley.edu Mon Aug 15 19:25:18 2011 From: Michael.Paoli at cal.berkeley.edu (Michael Paoli) Date: Mon, 15 Aug 2011 19:25:18 -0700 Subject: [buug] BALUG TOMORROW! Tu 2011-08-16 BALUG meeting; & other BALUG "news" Message-ID: <20110815192518.126724mxjpe5uias@webmail.rawbw.com> BALUG TOMORROW! Tu 2011-08-16 BALUG meeting; & other BALUG "news" Bay Area Linux User Group (BALUG) meeting Tuesday 6:30 P.M. 2011-08-16 Please RSVP if you're planning to come (see further below). For our 2011-08-16 BALUG meeting, at least presently we don't have a specific speaker/presentation lined up and confirmed for this meeting (but we may have one on a security topic, or possibly something else - if you're directly subscribed to our "announce" list: http://lists.balug.org/listinfo.cgi/balug-announce-balug.org watch it and/or: http://www.balug.org/#Meetings-upcoming for announcements and potentially late-breaking updates. ). In any case, speaker/presentation or not, that doesn't prevent us from having interesting and exciting meetings. Sometimes we also manage to secure/confirm a speaker too late for us to announce or fully publicize the speaker (that's happened at least twice in the past five or so years). Got questions, answers, and/or opinions? We typically have some expert(s) and/or relative expert(s) present to cover LINUX and related topic areas. Want to hear some interesting discussions on LINUX and other topics? Show up at the meeting, and feel free to bring an agenda if you wish. Want to help ensure BALUG has speakers/presentations lined up for future meetings? Help refer speakers to us and/or volunteer to be one of the speaker coordinators. Good food, good people, and interesting conversations to be had. So, if you'd like to join us please RSVP to: rsvp at balug.org **Why RSVP??** Well, don't worry we won't turn you away, but the RSVPs really help BALUG and the Four Seas Restaurant plan the meal and meeting, and with sufficient attendance, they also help ensure that we'll be able to eat upstairs in the private banquet room. Meeting Details... 6:30pm Tuesday, August 16th, 2011 2011-08-16 Four Seas Restaurant http://www.fourseasr.com/ 731 Grant Ave. San Francisco, CA 94108 Easy PARKING: Portsmouth Square Garage at 733 Kearny: http://www.sfpsg.com/ Cost: The meetings are always free, but for dinner, for your gift of $13 cash, we give you a gift of dinner - joining us for a yummy family-style Chinese dinner - tax and tip included (your gift also helps in our patronizing the restaurant venue and helping to defray BALUG costs such treating our speakers to dinner). ------------------------------ CDs, etc.: Additional goodies we'll have at the meeting (at least the following): CDs, etc. - have a peek here: http://www.wiki.balug.org/wiki/doku.php?id=balug:cds_and_images_etc We do also have some additional give-away items, and may have "door prizes". ------------------------------ Picn*x 20 - The Linux 20th Anniversary Picnic 2011-08-27, Sunnyvale http://www.linuxpicnic.org/ ------------------------------ Want to volunteer to help out BALUG? (quite a variety of opportunities exist) Drop us a note at: balug-contact at balug.org Or come talk to us at a BALUG meeting. ------------------------------ Feedback on our publicity/announcements (e.g. contacts or lists where we should get our information out that we're not presently reaching, or things we should do differently): publicity-feedback at balug.org ------------------------------ http://www.balug.org/ From Michael.Paoli at cal.berkeley.edu Wed Aug 31 23:40:32 2011 From: Michael.Paoli at cal.berkeley.edu (Michael Paoli) Date: Wed, 31 Aug 2011 23:40:32 -0700 Subject: [buug] BALUG Tu 2011-09-20: Travis H on Encrypted Storage Message-ID: <20110831234032.14571dghgu7dv940@webmail.rawbw.com> BALUG Tu 2011-09-20: Travis H on Encrypted Storage Bay Area Linux User Group (BALUG) meeting Tuesday 6:30 P.M. 2011-09-20 Please RSVP if you're planning to come (see further below). For our Tuesday 6:30 P.M. 2011-09-20 meeting, we're proud to present: Travis H on Encrypted Storage This is a talk covering the three types of encrypted storage technologies (application-level, filesystem, block device) in Linux (and BSD, unless we want to skip those slides). We will start off a little abstract, and end up very practical, with LUKS/dm-crypt and TrueCrypt, and end up with some important discussion about thumb drives and the limits of what we can achieve. Travis H is the founder of Bay Area Hacker's Association (BAHA)[1], a former member of Austin Hacker's Association (AHA), and has been employed doing security or cryptography for financial institutions, web client software, top 50 web sites, e-commerce hosting companies, and other organizations. He has been part of the largest security monitoring operation in the world, security consulting startups, helped design an intrusion detection system, and has taught code-making and breaking at Stanford. He also has written a book on security which is free online. He is a fan of the Ghost in the Shell franchise, and collects Matrix-inspired fashion accessories. 1. http://baha.bitrot.info/ See also a bit further below for some additional goodies we'll have at this meeting (CDs, etc.) So, if you'd like to join us please RSVP to: rsvp at balug.org **Why RSVP??** Well, don't worry we won't turn you away, but the RSVPs really help the Four Seas Restaurant plan the meal and dining arrangements and such. We've also tweaked our "door prize" / giveaway practices a bit - so RSVPing and arriving sufficiently on time increases one's odds of winning door prize(s) and/or getting first or earlier pick of giveaway items. Meeting Details... 6:30pm Tuesday, September 20th, 2011 2011-09-20 Four Seas Restaurant http://www.fourseasr.com/ 731 Grant Ave. San Francisco, CA 94108 Easy PARKING: Portsmouth Square Garage at 733 Kearny: http://www.sfpsg.com/ Cost: The meetings are always free, but for dinner, for your gift of $13 cash, we give you a gift of dinner - joining us for a yummy family-style Chinese dinner - tax and tip included (your gift also helps in our patronizing the restaurant venue and helping to defray BALUG costs such treating our speakers to dinner). Additional goodies we'll have at this meeting (at least the following): CDs, etc. - have a peek here: http://www.wiki.balug.org/wiki/doku.php?id=balug:cds_and_images_etc We do also have some additional give-away items, and may have "door prizes". ------------------------------ Feedback on our publicity/announcements (e.g. contacts or lists where we should get our information out that we're not presently reaching, or things we should do differently): publicity-feedback at balug.org ------------------------------ http://www.balug.org/