code logs -> 2008 -> Sat, 05 Apr 2008< code.20080404.log - code.20080406.log >
--- Log opened Sat Apr 05 00:00:21 2008
01:04 Thaqui [~Thaqui@Nightstar-123.jetstream.xtra.co.nz] has joined #code
01:04 mode/#code [+o Thaqui] by ChanServ
01:25 Shoukanjuu [~Shoukanju@71.48.224.ns-3853] has quit [Client exited]
01:27 Shoukanjuu [~Shoukanju@71.48.224.ns-3853] has joined #code
02:13 Attilla_ [~The.Attil@194.72.70.ns-11849] has joined #code
02:14 Attilla [~The.Attil@194.72.70.ns-11849] has quit [Ping Timeout]
02:14 Attilla_ is now known as Attilla
02:14 * McMartin tests out Fedora 9, streams the UQM soundtrack directly out of the SVN repository.
04:21
<@Vornicus>
cool.
04:34
< Shoukanjuu>
*right shift, left shift, right shift*
04:34
< Shoukanjuu>
>> << >>
04:34
<@Vornicus>
>> << >> ?
04:34
< Shoukanjuu>
:D
04:36
< Shoukanjuu>
I like this place. There are people who actually understand that.
04:36
< Shoukanjuu>
I don't have to explain that >> is a right shift, and they also commonly use it as aface
04:36
< Shoukanjuu>
a face*
05:13
<@Serah>
I was thinking of the buttons.
06:18 JeffL [JPL@Nightstar-12038.dsl.sndg02.pacbell.net] has quit [Ping Timeout]
08:17
<@McMartin>
Hum
08:17
<@McMartin>
Maybe Collect isn't as worthless a behavior as I had presumed.
08:18 * McMartin got a surprising number of medals while maxing it out.
08:18
< Shoukanjuu>
See, most of the problems we have in scoring so high are based on the fact that w- ooh, shiny yellow thing
08:19
<@McMartin>
Yeah. On the Survival levels and such I could completely ignore building up my multiplier because the Collect drone did it for me.
08:19
<@McMartin>
But that was the only point where I was explicitly noticing.
08:20
< Shoukanjuu>
Hehe
08:21
<@McMartin>
But yeah. Only missing medals in Eta and Kappa now.
08:21
<@McMartin>
Well, and Lambda, but I can't unlock it.
08:21 Vornicus is now known as Vornicus-Latens
08:39
< Shoukanjuu>
On another note: FFR hates me.
08:41
<@McMartin>
FFR?
08:41
<@McMartin>
France France Revolution?
08:46
< Shoukanjuu>
Flash flash revolution. >_>
08:46
< Shoukanjuu>
Check the link I so brazenly a href'd
09:05 AnnoDomini [AnnoDomini@83.21.25.ns-2874] has joined #Code
09:05 mode/#code [+o AnnoDomini] by ChanServ
09:05
< Shoukanjuu>
Hey, AD
09:05 * McMartin is too busy UQMing to dance.
09:07
<@AnnoDomini>
Hello.
09:07
< Shoukanjuu>
Bought a TV tuner today. Should be here by Wednesday next week :>
09:13 JeffL [Kaline@Nightstar-12038.dsl.sndg02.pacbell.net] has joined #code
09:26
< AFKSkull>
hey, i've a question. Is it possible to change the offset of an HTML page's background image based on the scroll position of the page? In this case, the page content is larger than the background, but the background is larger than your average display- Letting the background scroll freely with the page would make it repeat in most ugly fashion.
09:28 GeekSoldier [~Rob@91.18.114.ns-12584] has left #code []
09:28 GeekSoldier [~Rob@91.18.114.ns-12584] has joined #code
09:28 mode/#code [+o GeekSoldier] by ChanServ
10:11
<@McMartin>
I believe CSS will let you set it to be fixed, at least.
10:11
<@McMartin>
I don't know about differential scrolling.
10:19 AFKSkull [~none@Nightstar-7066.dyn.optonline.net] has quit [Ping Timeout]
10:33
<@McMartin>
Mwahahaha
10:33
<@McMartin>
GO FORTH, MY ARMY OF ROBOTS
10:36
< Shoukanjuu>
>_>
10:36
< Shoukanjuu>
I distinctly remember something like this happening. Wait. It's coming to me. *EMP*
10:37
<@McMartin>
(I just wrote about four lines of Python to once again restructure big chunks of the UQM resource data)
10:37
<@McMartin>
(Now all ship info outside of AI designators are in the main index)
10:38
<@McMartin>
And soon those will be too, but that part will require actual human work.
10:38
<@McMartin>
The army of robots gets to write out the 70 or so data and header files.
10:38
<@McMartin>
Which will be dropped to 35 or so once I'm through with it, with *one* data file.
10:39
< Shoukanjuu>
Sounds efficient.
10:39
<@McMartin>
Not nearly enough, unless you mean "in programmer time"
10:40
<@McMartin>
This is now the Master File: http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/tools/resmap/resources.csv?revis ion=2927&view=markup
10:41
<@McMartin>
It produces a battery of .ls2 files (resource indices), .h files (C headers to talk about said resources), and one .rmp file (to attach files to the resource names).
10:41
<@McMartin>
The goal is to eventually remove the need for the .ls2 files entirely.
10:42
<@McMartin>
And to do that, first I have to get it down to one.
10:43
<@McMartin>
And with my latest robot assault, all but that main one now are down to a single entry each.
10:43
< Shoukanjuu>
Good. Progress is fun :3
10:46
<@McMartin>
So, if you want to see a Complete Python Application That Is Also A Library...
10:46
<@McMartin>
http://sc2.svn.sourceforge.net/viewvc/sc2/trunk/tools/resmap/gen_resfiles.py?vie w=markup
10:46
<@McMartin>
read_csv() and the two methods inside the ResEntry class are handy for transforming the resource file
10:47
<@McMartin>
And then when run as an application it reads the resource file and generates all the content and header files specified.
10:48
< Shoukanjuu>
!_!
10:48
< JeffL>
Is that a "I don't understand" smiley?
10:48
<@McMartin>
There are at least two aspects of this code that you haven't even been introduced to the syntax for, IIRC.
10:48
<@McMartin>
(to wit, class and try)
10:49
<@McMartin>
Maybe also optional function arguments
10:49
< JeffL>
What the hell, it's 6 AM where Shoukan is. Let's teach him that. I'm down for class.
10:49
< JeffL>
(I remain convinced that try: blocks are the work of the devil/worst thing since goto)
10:49
< Shoukanjuu>
It's 6AM where I am, and I've been up for 14 hours.
10:51
< Shoukanjuu>
May be the best time to code, but not learn to code :3
10:51
<@McMartin>
JeffL: You clearly have never had to deal with code that forgets to check its return value, thus causing a bus error 14 calls later so that the actual bug isn't even in your stack trace.
10:52
<@McMartin>
Now, C++'s version of try, where any value at all including primitives can be thrown and the compiler has to assume that any function can throw anything unless it explicitly declares that it doesn't -- that's pretty heinous.
10:53
<@McMartin>
(Also, C++ destructors even in the absence of exceptions behave in an interesting parallel to try/finally, but that's neither here nor there)
10:54
<@McMartin>
Exceptions don't become Officially Awesome until you get to use a language like OCaml that can get away with stack cutting.
10:54
< JeffL>
(My problem with it is largely that exceptions Don't Trust You. I understand that in some cases you are not to be trusted, but I was trained to always check the null pointers and whatnot. Seeing as how I do so, having to encase my code in a try{} block followed by a catch{} block is just *ugly.)
10:55
<@McMartin>
Yeah, see, in the absence of precise destructors you can also use them to make recursion wtfheinously fast.
10:55
<@McMartin>
And I firmly belong to the school of "an API is not allowed to trust its clients", I suppose.
10:56
< JeffL>
I happen to like precise destructors, but that's just me.
10:56
<@McMartin>
That's what try-finally, or better still, with-blocks are for.
10:56
<@McMartin>
The fact that Java has routines that Really Should Fail Silently instead throw checked exceptions is beyond the point
10:57
< JeffL>
with-blocks?
10:57
<@McMartin>
But I *do* want to track down whoever was responsible for InputStream.close() throwing IOException and beat them severely.
10:57
<@McMartin>
I forget the real name
10:57
<@McMartin>
But Delphi and C# both have it
10:57
<@McMartin>
Basically, it lets you do precise destructors, but with any two methods on an object, instead of specifically constructor and destructor.
10:57
< JeffL>
try-finally blocks don't let me, say, decrement a static-to-class "instances" variable when the garbage collector picks it up, though.
10:58
< JeffL>
Oooooh.
10:58
<@McMartin>
They're Just Better.
10:58
<@McMartin>
And you can turn them off, which is handy because it doesn't remove the "right, backtrack out of the last six function calls in two assembly instructions now, thanks" possibility.
10:59
<@McMartin>
s/turn them off/not use them/, which means basically turning off "precise destruction"
10:59
<@McMartin>
Finding analogues gets a little hairy because OCaml is one of those languages where you rarely actually reassign variables, or, indeed, have them at all
11:01
<@McMartin>
(C#'s version of with blocks require you to implement a magic interface for begin-block and end-block, but that's like four extra lines to make it any two methods)
11:02
<@McMartin>
(Pity C# code doesn't actually run on anything >_>)
11:03
<@McMartin>
But yeah, I've long been of the opinion that Resource Acquisition Is Only Initialization If You Squint Really Hard.
11:05
<@McMartin>
Back to exceptions, one of the reasons they've become unpleasantly pervasive is because of the unending decision that it's the only way constructors can fail.
11:05
< JeffL>
Yes.
11:06
<@McMartin>
And they can't be virtual.
11:06
<@McMartin>
And if you use factory methods you lose precise destruction, mutter, gripe.
11:06
<@McMartin>
Though I guess auto_ptrs could get around that (?)
11:06 * McMartin 's C++ fu is not strong, much as his hand-in-lawnmower fu is not strong.
11:08 * JeffL was trained on C++.
11:08
< JeffL>
Okay, actually, C.
11:08
< JeffL>
And then I learned OO in C++.
11:09
<@McMartin>
Yeah, I should clarify that by "C++" I mean "C++ plus its standard libraries" here.
11:09 * McMartin tends to push C, Java, and Python depending on application scale
11:09
<@McMartin>
And there's really shockingly few applications that hit the Java sweetspot.
11:10
<@McMartin>
("Needs to have a more or less consistent GUI across Windows, Mac, and Linux" or "Needs to be able to go rampant in the presence of wildly varying input loads" are about it.)
11:10
<@McMartin>
Self-re-optimizing JVMs amuse me a lot.
11:12
< JeffL>
Oh?
11:12
<@McMartin>
Basically, most production JVMs will use spare cycles to profile heavily used code and recompile it with optimizations based on what it's seen.
11:12
<@McMartin>
Branch prediction, etc.
11:13
<@McMartin>
So there are some (heavily rigged-input) demos that force it to vacillate back and forth
11:13
<@McMartin>
The punchline is that with sufficiently wild swings in load quality over a long enough time, such a program will eventually outperform any statically compiled executable.
11:14
<@McMartin>
The amusement factor comes in in that in the Marathon games, these sorts of behaviors is what causes AIs to go rampant and thus become villains of shoot-'em-ups.
11:14
< Shoukanjuu>
Hehe
11:14
< Shoukanjuu>
marathon <3
11:15
<@McMartin>
IIRC, they looted that backstory for Teh Haloz, too.
11:15
< Shoukanjuu>
Speaking of AI, why is SSBB's AI an heroes?
11:15
<@McMartin>
Buh?
11:16
< Shoukanjuu>
Well, in Halo, it was more of a misinterpretation of universe slaughtermachines
11:16
< Shoukanjuu>
And to keep the humans from getting to the "Halos" (killers of sentiant kind so the flood can't feed), they killed them, or tried
11:16
<@McMartin>
I don't understand what "SSBB's AI is an heroes" means
11:17
< Shoukanjuu>
Super Smash Brother Brawl, the AI...kills itself. A lot XD
11:17
<@McMartin>
I haven't noticed this particularly. What level are you playing on?
11:17
< Shoukanjuu>
Though it pains me to link to such, encyclopedia dramatica has the closest representation of "an hero" as I could.
11:18
< Shoukanjuu>
I was playing a coin match so I could unlock challenged
11:18
< Shoukanjuu>
challenges* T he coin and hours of brawls ones are the only ones I can't do :/
11:18
<@McMartin>
If your count is low enough it may actually be advantages to do so - your count is halved, but you aren't feeding points to your opponent.
11:18
< Shoukanjuu>
Well, I forgot that the coins don't matter if you quit out of the game ; ;
11:19
< Shoukanjuu>
Well, once you get into the thousands, or so, you lose 100 instead of 50&
11:19
<@McMartin>
That said, I didn't see that happening much in my own coin matches against level 3-6 AIs.
11:19
< Shoukanjuu>
50%
11:19
< Shoukanjuu>
I was palying 9s v_V
11:19
< Shoukanjuu>
It might just be lucas, but every time was and UpB offensive suicide
11:20
<@McMartin>
Maybe some kind of avoidance or aggression code gone horribly wrong when it goes up to 11?
11:20
< Shoukanjuu>
Eh. *shrug*
11:20
< Shoukanjuu>
I need friends over to play Brawl with. I'll never hit this 100 hours BS
11:20
<@McMartin>
My favorite instance of that remains the Amy vs. Sonic fight in Sonic Heroes.
11:20
< Shoukanjuu>
Oh?
11:20
<@McMartin>
You're playing as Amy, corner sonic
11:21
<@McMartin>
Cue cutscene in which Amy does the traditional creepy stalker thing
11:21
<@McMartin>
Close on him and he pitches himself off the building to get away from you
11:21
<@McMartin>
Since that wins the boss fight this is almost certainly an AI bug
11:21
<@McMartin>
But I like to think it isn't.
11:21
< Shoukanjuu>
No, this UP B was an offensive generated to kick some tail
11:22
< Shoukanjuu>
But I think Lucas' AI borrows from Ness
11:22
<@McMartin>
Heh
11:22
< Shoukanjuu>
In that Ness' UP B doesn't go as far
11:22
<@McMartin>
I've noticed Ike will throw an Aether for spite even if it will kill him
11:22
<@McMartin>
But at that point he would have been doomed anyway.
11:22
< Shoukanjuu>
And when Lucas uses the Up B, he usually uses it where Ness wouldn't fall off
11:22
< Shoukanjuu>
Yeah, at least they try
11:22
< Shoukanjuu>
That's what makes them 'an hero'
11:23
< Shoukanjuu>
I like Marth :3
11:23
<@McMartin>
Well, it also gets them back in action sooner.
11:23
<@McMartin>
Important for Timed, not so much for Stock
11:23
< Shoukanjuu>
Yeah
11:23
<@McMartin>
Anyway, 3:30 AM, patch in, sleep times.
11:23
< Shoukanjuu>
Night, man. I'm going to veg and play some Radiant Dawn for a bit before passing out, myself, when it gets light outside
11:50 Thaqui [~Thaqui@Nightstar-123.jetstream.xtra.co.nz] has left #code [Leaving]
11:52 Shoukanjuu [~Shoukanju@71.48.224.ns-3853] has quit [Quit: You're gonna carry that weight.]
13:20 AnnoDomini [AnnoDomini@83.21.25.ns-2874] has quit [Ping Timeout]
13:27 AnnoDomini [AnnoDomini@83.21.51.ns-25885] has joined #Code
13:27 mode/#code [+o AnnoDomini] by ChanServ
13:46 Reiv [~reaverta@Admin.Nightstar.Net] has joined #Code
13:46 Reiver [~reaverta@Admin.Nightstar.Net] has quit [Ping Timeout]
14:17 Reiv is now known as Reiver
18:15 Bobsentme [Bobsentme@Nightstar-4384.dsl.sfldmi.sbcglobal.net] has joined #code
18:19 GeekSoldier [~Rob@91.18.114.ns-12584] has quit [Ping Timeout]
18:35 * Bobsentme sighs.
18:35
< Bobsentme>
Ok, through a series of two for loops and an if statement, have compared and pulled Names from the two text files.
18:36
< Bobsentme>
Now I'm just in need of some vulcan like logic to move forward.
18:38 Netsplit DeepThought.NY.US.Nightstar.Net <-> Blargh.CA.US.Nightstar.Net quits: @MyCatVerbs
18:40 * Vornicus-Latens spocks at Bob.
18:42
< Bobsentme>
Ok.
18:42 MyCatVerbs [~mycatverb@81.174.167.ns-23005] has joined #code
18:42 mode/#code [+o MyCatVerbs] by ChanServ
18:43
< Bobsentme>
Now that I've got a file full of names, and a file full of the same names, followed by phone numbers, I'm trying to work out how to pull out the phone #'s.
18:44
< Bobsentme>
I'm trying to use a while loop...but am getting stuck in a recursive loop.
18:44
< Bobsentme>
Where it continuously prints the first phone # I need.
18:44
<@Vornicus-Latens>
SHow me your code
18:44 MyCatVerbs [~mycatverb@81.174.167.ns-23005] has quit [Nick collision (older nick overruled)]
18:44 MyCatVerbs [~mycatverb@Nightstar-13709.lurkingfox.co.uk] has joined #code
18:44 ServerMode/#code [+o MyCatVerbs] by Blargh.CA.US.Nightstar.Net
18:44 mode/#code [-o MyCatVerbs] by ChanServ
18:44 MyCatVer1s [~mycatverb@Nightstar-13709.lurkingfox.co.uk] has joined #code
18:44
< Bobsentme>
Not without dinner first? (ok, one sec)
18:44 MyCatVerbs [~mycatverb@Nightstar-13709.lurkingfox.co.uk] has quit [Killed (NickServ (GHOST command used by MyCatVer1s))]
18:44 MyCatVer1s is now known as MyCatVerbs
18:48 mode/#code [+ooooo Attilla Bobsentme JeffL MyCatVerbs Reiver] by Vornicus-Latens
18:49
<@Vornicus-Latens>
Don't use while
18:49
<@Vornicus-Latens>
use if
18:49
<@Vornicus-Latens>
Each for iterates over a file in turn; the while does not have any state that it changes.
18:49
<@Bobsentme>
oh
18:51
<@ToxicFrog>
(didn't we solve this yesterday?)
18:51
<@Vornicus-Latens>
I thought we had
18:52
<@Bobsentme>
I apologize. I would up more confused than when I started yesterday.
18:53
<@Bobsentme>
I am a beginner (at best) in bash scripting. If I am annoying anyone, I will gracefully back down.
18:53
<@Bobsentme>
would = wound.
18:58
<@Bobsentme>
Right then. My apologies. I appreciate all the help that you have all offered, and am now off to learn, minus your genius. I'm sorry to have bothered you all.
18:59
<@ToxicFrog>
No, no
18:59 Bobsentme [Bobsentme@Nightstar-4384.dsl.sfldmi.sbcglobal.net] has left #Code [passed_out.exe]
18:59
<@ToxicFrog>
If you were annoying we would have said
18:59
<@ToxicFrog>
Goddamnit
19:18 Bobsentme [Bobsentme@Nightstar-4384.dsl.sfldmi.sbcglobal.net] has joined #Code
19:18 * Bobsentme comes back in, feeling more relaxed and less foolish.
19:22 * jerith plays some Master of Magic.
19:23 * ToxicFrog figures out why the version using read wasn't working. Sort of.
19:24
<@ToxicFrog>
So. the version using awk. Ready for the dissection?
19:24
< Bobsentme>
yes please!
19:25
< Bobsentme>
I know cat...well...cat's the file.
19:25
<@ToxicFrog>
Actually, it dumps the file to stdout.
19:25
< Bobsentme>
ok
19:26
<@ToxicFrog>
"cat" is short for "concatenate", due to the fact that "cat file1 file2 file3" dumps all three concatenated.
19:26
<@jerith>
cat is short for "concatenate". If you give it a bunch of files it'll dump...
19:26
<@jerith>
Yeah, that.
19:26 * Bobsentme nods in understandment
19:26
<@ToxicFrog>
Are you also familiar with |?
19:26
< Bobsentme>
understanding. Dang it.
19:26
< Bobsentme>
Yes, it pipes
19:26 * jerith shall watch and pipe up only when he has something new to add. :-)
19:27
<@ToxicFrog>
Right.
19:27
< Bobsentme>
So, we're piping our first file (of names, and phone #'s), to a while loop
19:27
<@ToxicFrog>
And it works not only on external commands, but also on aliases, user-defined functions, and {...} and (...) code blocks.
19:28
<@ToxicFrog>
So, yes, we are dumping the first file using cat and redirecting the output to a {...} code block.
19:28
< Bobsentme>
ok
19:28
<@ToxicFrog>
This contains a while loop - while read person phone; do .... done
19:28
< Bobsentme>
right...
19:29
< Bobsentme>
The while loop is throwing me just a bit. If we can discuss that for a sec...
19:29
<@ToxicFrog>
That is in fact what I was planning to do.
19:29 Vornicus-Latens is now known as Vornicus
19:29
< Bobsentme>
In my book, I only see examples of While [ test ] do done
19:29
<@ToxicFrog>
The basic structure of a while is: while <command>; do ... done
19:29
< Bobsentme>
Obviously, we're not testing with the while loop, we're just reading each line?
19:29
< Bobsentme>
Ah.
19:29
<@ToxicFrog>
Each time around, it runs <command>, and if it succeeds, the loop continues
19:29
<@ToxicFrog>
If it fails, the loop ends.
19:30
< Bobsentme>
I thought basic while loop was: while [ test ]; do ...done.
19:30
<@ToxicFrog>
[ expression ] is actually a builtin command that succeeds if the expression is true and fails otherwise.
19:30
< Bobsentme>
which explains why mine goes into a loop
19:30
<@ToxicFrog>
(and you should use [[ expression ]] instead, BTW; it's a bash (as opposed to sh) extension that avoids some gotchas with [ ... ])
19:30
<@MyCatVerbs>
*Can* be a builtin, isn't necessarily. See /bin/[ and /bin/test and giggle.
19:31
< Bobsentme>
"Still true! Still true! Still true!"
19:31
<@ToxicFrog>
It's a builtin in bash.
19:31
<@ToxicFrog>
Which is what we're discussing.
19:31
<@ToxicFrog>
You are correct in that it's not a builtin in all shells.
19:31
<@ToxicFrog>
Yeah.
19:31
<@ToxicFrog>
So, here, instead of using a [...] test, we're just using the 'read' command
19:31
< Bobsentme>
Ah
19:32
< Bobsentme>
ok.
19:32
<@ToxicFrog>
Which succeeds if there was something to read, and fails otherwise (error, end of file, etc)
19:32
<@ToxicFrog>
What it actually *does* is read a line, split the line into fields, and assign them to variables
19:32
<@MyCatVerbs>
e.g. while eject; do sleep 3; eject -t; done # excellent way to creep people out by making the disk drives act possessed.
19:33
<@MyCatVerbs>
Goes on forever, 'cuz eject should always succeed.
19:33
< Bobsentme>
So, for every Name and Phone # in file one, While reads them and sets the date from the date "field" in file #2
19:33 * Bobsentme laughs
19:33
<@ToxicFrog>
"read foo bar baz" reads a line, splits it apart (on whitespace, by default), and assigns the first field to $foo, the second to $bar, and everything else to $baz.
19:33
< Bobsentme>
ok
19:33
<@ToxicFrog>
*read* reads them. While is just responsible for repeatedly calling read.
19:34
< Bobsentme>
ok
19:34
< Bobsentme>
err...oh
19:34
<@ToxicFrog>
And when it runs out of lines, read will fail, which causes the while loop to end.
19:34
< Bobsentme>
THAT makes more sense
19:35
<@ToxicFrog>
So, each time around, while calls read; read reads a line, splits it and assigns the two parts to $person and $phone; and then the loop body is executed
19:35
<@ToxicFrog>
And if read failed, the loop ends.
19:35
<@ToxicFrog>
And read is of course getting its input from the pipe, rather than from the terminal.
19:36
<@ToxicFrog>
And if that all makes sense, all that's left is the loop body.
19:36
< Bobsentme>
For the record: My book doesn't even LIST the awk command.
19:36
<@ToxicFrog>
awk isn't a bash builtin, it's a seperate program.
19:36
< Bobsentme>
ah.
19:37
<@ToxicFrog>
Along with some others (grep, sed, etc) it's very heavily used in shell scripts.
19:37
<@ToxicFrog>
So. The loop body consists of two parts:
19:37
<@ToxicFrog>
date=$(awk "/^$person/ { print \$2; } { next; }" < dates)
19:37
<@ToxicFrog>
echo "$person $phone $date"
19:37
<@ToxicFrog>
It should be obvious what the second line does.
19:38 * Bobsentme nods
19:38
<@ToxicFrog>
The first line...this is a variable assignment: date=...
19:38
< Bobsentme>
right
19:38
<@ToxicFrog>
In this case, the ... is actually a $(...) expression
19:39
<@ToxicFrog>
Which is "run the ..., and expand to its output"
19:39
< Bobsentme>
The while loop, and the awk command were the two main parts that were confusing the hell out of me yesterday
19:39
<@ToxicFrog>
$(echo "foo") is "foo", $(true) is "" (as true produces no output, so it becomes nothing), $(cat file) becomes the contents of file
19:40
<@ToxicFrog>
So in this case it is replaced with the output of: awk "/^$person/ { print \$2; }" < dates
19:40
<@ToxicFrog>
You've used > and < redirection, yes?
19:40
< Bobsentme>
yes
19:41
< Bobsentme>
What does the "print \$2" mean though?
19:41
<@ToxicFrog>
In that case we can simply move straight to the awk.
19:41
< Bobsentme>
ah, ok.
19:41
<@ToxicFrog>
The whole "/^$person/ { print \$2; }" is a short awk script.
19:41 * Bobsentme nods.
19:42
<@ToxicFrog>
awk is a text processing language, and the basic structure of a script is a bunch of /pattern/ { code } sequences
19:42
< Bobsentme>
ok
19:42
<@ToxicFrog>
On each line, if the /pattern/ (which is a regular expression) matches the line, the { code } is executed
19:42
<@ToxicFrog>
Code with no pattern is run on every line.
19:42
< Bobsentme>
sou the pattern WE would be searching for is $person
19:43
<@ToxicFrog>
Nooot exactly
19:43
<@ToxicFrog>
We're in "doublequotes" here, so $variables get expanded
19:43
<@ToxicFrog>
Before awk gets called.
19:43
<@ToxicFrog>
And $person is set earlier by read.
19:43
<@ToxicFrog>
So if it's, say, Foo, our pattern is /^Foo/
19:44
< Bobsentme>
o...k....then what does our search pattern expand to?
19:44
<@ToxicFrog>
...what do you mean?
19:45
< Bobsentme>
Ok, awk syntax is /pattern/ { code }
19:45
<@ToxicFrog>
Yes.
19:45
< Bobsentme>
But we've got our /pattern/ in double quotes, so it's expandable
19:46
< Bobsentme>
I guess I don't know what you mean by expandable.
19:46
<@ToxicFrog>
We have -the whole thing- in double quotes
19:46
<@ToxicFrog>
So it is expanded by bash
19:46
<@ToxicFrog>
What I mean by expansion is that, say, $foo is replaced with the value of the variable foo, and $(command) is replaced by the output of the command
19:47
< Bobsentme>
OOOOOOOOHHHHH
19:47
<@ToxicFrog>
In bash, "doublequoted" strings undergo expansion, 'singlequoted' strings do not
19:47 * Bobsentme just got it.
19:47
<@ToxicFrog>
And in doublequotes, you can use \ to escape (remove special properties of) the following character
19:47
< Bobsentme>
right
19:47
<@ToxicFrog>
Try, for example: foo="stuff"; echo "$foo"; echo "\$foo"; echo '$foo'
19:48
<@ToxicFrog>
So, awk "/^$person/ { print \$2; }"
19:48
<@ToxicFrog>
(undergoes bash expansion) => awk '/^Foo/ { print $2; }'
19:48
<@ToxicFrog>
So, when awk sees a line starting with 'Foo', it will execute 'print $2'
19:49
<@ToxicFrog>
Which, in awk, is "print the second field of the line"
19:49
< Bobsentme>
So, to sum up just the awk portion: We're setting the date equal to the line in file 2 that begins with our variable of $person, then grabs the second argument from that line (which happens to be the date)
19:50
<@ToxicFrog>
Pretty much.
19:50
< Bobsentme>
That's the exact procedure I was trying to perform yesterday.
19:50
< Bobsentme>
Wish I had been less confused.
19:51
<@ToxicFrog>
You can also do it with grep (search for lines in file) + read, which is conceptually easier once you get the scope issues sorted out
19:51
< Bobsentme>
really? grep and read are easier than awk?
19:52
<@ToxicFrog>
it becomes: grep "^$person" dates | read person date
19:52
< Bobsentme>
ah. I can see that.
19:52
<@ToxicFrog>
Except in practice everything after the | there needs to be in subshell scope or things break.
19:52
< Bobsentme>
if you were trying to sort someone's code, which would you prefer to see? awk or grep | read ?
19:53
<@ToxicFrog>
I'd prefer grep|read simply because yay small modular components, but it's largely a matter of personal taste; I wouldn't mind the awk approach either.
19:53
<@ToxicFrog>
grep|read is probably more bash-y, though
19:56 * Bobsentme nods.
19:59
<@ToxicFrog>
In which case, due to scope wackiness, the loop body should become:
19:59
<@ToxicFrog>
egrep "^$person" dates | (read _ date; echo "n $person p $phone d $date");
20:09 AFKSkull [~none@Nightstar-7066.dyn.optonline.net] has joined #code
20:11
< Bobsentme>
Thank you!
20:11 * Bobsentme has learned quite a bit
20:12
<@jerith>
And all without annoying us. ;-)
20:12
< Bobsentme>
heh
20:13 GeekSoldier [~Rob@91.18.127.ns-3258] has joined #code
20:13 mode/#code [+o GeekSoldier] by ChanServ
20:15
< Bobsentme>
So, because we haven't covered awk, I've come up with two while loops modeled after your code, TF.
20:15
< Bobsentme>
I've successfully seperated the three items.
20:16
< Bobsentme>
nm, I think what I've just done is silly.
20:33 * GeekSoldier tickles Bob, goes back to drinkin' and playinc poker.
20:33
< Bobsentme>
hehe
20:34 * Bobsentme steals all your spades
20:34
<@C_tiger>
Actually, the black market value of hearts is even higher than that of diamonds and much higher than that of spades.
20:49 mode/#code [+oo AFKSkull Bobsentme] by Vornicus
20:56
<@Bobsentme>
...
20:59 * GeekSoldier does not want to know exactly how C_tiger knows this.
21:37
<@Bobsentme>
"ambiguous redirect"
21:37
<@Bobsentme>
Damn you, Bash, for making me have to look up ambiguous.
21:37
<@Bobsentme>
(just to make sure that the word means what I think it means"
21:37
<@Bobsentme>
)
21:40 Bobsentme [Bobsentme@Nightstar-4384.dsl.sfldmi.sbcglobal.net] has quit [Quit: Now running PassedOut.bat]
23:34 Shoukanjuu [~Shoukanju@71.48.224.ns-3853] has joined #code
--- Log closed Sun Apr 06 00:00:32 2008
code logs -> 2008 -> Sat, 05 Apr 2008< code.20080404.log - code.20080406.log >