• h (unregistered) in reply to dextron
    dextron:
    For searching I would do something like

    find . -exec grep -iH disconnect {} ;

    YMMV

    Old school, uh? xargs is so much more flexible and has less clutter ;) And you might not want to search binary files, so here. And you might want to remove the find completely...

    grep -iHIr disconnect *

  • Dirk (unregistered)

    What's with the $cientology adds?

  • Bobbo (unregistered) in reply to Dirk
    Dirk:
    What's with the $cientology adds?

    Dunno - sounds like you need to get yourself Adblock!

  • woohoo (unregistered) in reply to NaN
    NaN:
    Matt:
    NaN:
    Also seen while at was at university, one of my tutors provided the following "Infinite Loop":

    System.out.println("I am going to loop."); for(int counter = 0; counter => 0; counter ++) { //This will happen forever } System.out.println("You have now entered the twilight zone."); // This will never happen

    I had to point that one out.

    Was the intention to show what happens when ints overflow, or was he just being dumb?

    while(TRUE){ // loop forever }

    Unfortunately, that was one of about 10 examples (Including the one you just gave) that were supposed to be infinite loops. I did have to explain why it wasn't, although he did seem to understand the overflow thing, meaning that it was just an oversight, however, he did try and bluff his way out of it with "Well, it will last a very long time, it might as well be an infinite loop".

    Hehe, that's a scream... I'm willing to bet that this loop does not take longer than in the magnitude of 10 seconds on any standard PC hardware that was built in this millenium ;o)

    It all depends on one's definition of "infinite", of course...

  • woohoo (unregistered) in reply to Andy Goth
    Andy Goth:
    xtremezone:
    I keep my infinite loops simple though. :)
    I like this one:
    while (2) {...}
    while (42) {...}
    :o)
  • A. Nonny Moose (unregistered) in reply to NaN
    NaN:
    boolean paul = true, brilliant = true;

    while(paula == brilliant) {

    }

    no, how about:

    while(paulaBean.getPaula().equals("Brillant")) {
            //loop indefinitely
    }

    captcha: commoveo ... WTF is "commoveo"???

  • (cs)
    SlyEcho:
    I got stumped on this one some time ago:

    for (byte b = 0; b <= 255; b++) { // stuff }

    For me it was:

    for(unsigned int i=42; i>=0; i--)

    If you think the loop process goes something like "if i==0, exit the loop, else i = i - 1" you're wrong. And with unsigned int, 0 - 1 > 0.

  • immibis (unregistered) in reply to NaN
    NaN:
    boolean paul = true, brilliant = true;

    while(paula == brilliant) {

    }

    Error on line 3: Undefined variable 'paula'

  • Goggles Do Nothing (unregistered) in reply to scottl
    scottl:
    Ummm... you can run grep recursively on a top level directory... Or is that sound I hear a joke going over my head?

    Two words: recursive symlinks.

    Wait, you don't get them on windows server.

    Oh, but you don't have grep on windows server either!

  • John (unregistered) in reply to woohoo
    woohoo:
    Andy Goth:
    I like this one:
    while (2) {...}
    while (42) {...}
    :o)

    Or how about (in C):

    while(EXIT_FAILURE) {...}

  • Sharmila (unregistered) in reply to NaN

    Oops:

    It should have been

    boolean paul = true, brillant = true;

    while(paula == brillant) {

    }

  • (cs) in reply to Goggles Do Nothing
    Goggles Do Nothing:
    Oh, but you don't have grep on windows server either!
    Well, not unless you install it. (I have a copy of grep on all my Windows machines.)
  • (cs) in reply to NaN
    NaN:
    Eventually, bad things will happen in the following pieces of code:

    //this is definitely [anything]

    if(exp1) { //DO } else if(exp2) { //Do Something Else } else { //This condition will never be true //Do nothing }

    I actually had an if else block almost exactly like that once in a program, with the comment something like // This will never happen.

    And one time I was debugging the code through the debugger and it went down into that block. Which allowed me to quickly find the error and fix it.

    But then I tend to try to bullet proof code, testing for errors that will "never" happen. So much in fact that one program I wrote for a software house the owner PUT a bug in so he could sell maintenance on the program (needless to say I quit very soon after).

  • matt (unregistered) in reply to Serpardum

    //this is definitely [anything]

    Doesn't that mean it's assertion time?

  • Jake (unregistered) in reply to mallard
    Or, more generally, MAX_INT + 1 = MIN_INT. Not all systems have 32-bit integers.

    Its Java. Isn't its int always 32-bit?

  • m0ffx (unregistered) in reply to Goggles Do Nothing
    Goggles Do Nothing:
    Two words: recursive symlinks.

    One word: Don't.

    As for the original comment - it seems to me like it might be sarcastic. I reckon whomever wrote it was probably told to do it like that by some kind of formal specification, and was in a shop where it had to be followed to the letter. Maybe. It's just bad code I understand, but bad comments...hmmm...

  • Havstein (unregistered) in reply to dextron
    dextron:
    find . -exec grep -iH disconnect {} \;
    Save the world and go

    grep -R disconnect *

    ?

  • John (unregistered) in reply to Jay
    Jay:
    Besides, the latest chip from Intel is so fast that it can execute an infinite loop in 12 seconds.

    Hahaha. Nice one

  • Loren Pechtel (unregistered) in reply to Dave
    Dave:
    S:
    Ok, not the best way of saying what an invalid session is, but at least the code was commented and it was clear what it did.

    Perhaps this site needs a sister "Daily Hmmm" for bugs which take a few mins to fix.

    This would occasionally lead to ‘really bad things’ that could take all day to fix.

    It could do, I guess. But a repeatable bug, caused by code accurately commented with text which should be amongst the first thing you'd grep for shouldn't take more than a few mins to fix. This wouldn't make a bad interview task for a company which wishes to weed out jumped up HTML hairdressers who think they can code because they know a bit of javascript from actual programmers.

    But you wouldn't be looking for a bug documented as a feature.

  • Alex (unregistered) in reply to mallard
    Or, more generally, MAX_INT + 1 = MIN_INT. Not all systems have 32-bit integers.
    Even more generally, not all systems use two's complement arithmetic for integers!

Leave a comment on “The Nightly Session Drop”

Log In or post as a guest

Replying to comment #:

« Return to Article