• (cs) in reply to DoctorFriday

    lol.. $perms are cool

  • C (unregistered) in reply to jamface

    Sigh, it's "chmod 777 article".

    But this is the DailyWTF, so what's a few more WTFs in the comments...

  • Anon Barbarzyńca (unregistered) in reply to MacFrog
    MacFrog:
    The RWTF is the
    $perms->mode & 0777
    .

    <flamebait>TRWTF is you</flamebait>. The bits above 0777 are 04000 (setuid), 02000 (setgid) and 01000 (sticky). Above that there are values for determining whether the inode you've stat()ed is a file, directory, symlink, char dev, block dev, fifo etc.

    $mode & 0777 is perfectly legitimate in certain situations.

  • Rhialto (unregistered) in reply to Dan
    Dan:
    Maurits:
    Benn:
    ..and of course there's...
    $permsbin =~ s/.*(.)..(.)..(.)../$1$2$3/;
    I won't go into the mechanics of backtracking etc., but that expression could conceivably take many many millions of years to run...

    Nonsense. It will succeed very quickly or fail in a small handful of iterations.

    Actually this Regexp depends on the compiler to do what the programmer wanted. If it is set to take the first possible solution, ... If it is set to do greedy matching, ...

    But really, '-r' should be used in place of the whole mess.

    The Kleene Star (*) is defined to match greedily in Perl (and most other) regular expressions. (Perl offers .*? for a non-greedy Kleene Star).

    So what happens is that the .* gobbles up the whole input, which means it can't match the remaining 9 characters. So it will backtrack 1 character 9 times, after which it can succeed.

    But of course I agree about using -r.

  • Level 2 (unregistered) in reply to Christopher
    Christopher:
    Well, PERL is an acronym for "Practical Extraction and Report Language", so it's not incorrect to write it out in all caps.
    Pathologically Eclectic Rubbish Lister
  • Not wanted to be named (unregistered) in reply to DoctorFriday

    and $permsbin lol one step before the $permbank

  • jk (unregistered) in reply to fanguad

    By definition, any problem that can be solved with a regular expression (and only a regexp), isn't interesting.

  • JimmyVile (unregistered) in reply to jk
    jk:
    By definition, any problem that can be solved with a regular expression (and *only* a regexp), isn't interesting.

    By definition, you suck.

    /hate it when people use "by definition". //Unless it is, y'know...actually by definition.

  • London Contractor Mart (unregistered) in reply to Even Easier
    Even Easier:
    '-r $path' ... wow

    so $perms from the -r $path ends up in the $permsbin...

    Sounds like some really messy coding!!!

  • Kehvarl (unregistered) in reply to Bendynachos
    Bendynachos:
    DoctorFriday:
    Heh...heh...it says "$perms".

    That made my day...

    because that's the first thing I thought of. Does that make me immature?

    What irritates me is the fact that I didn't even notice this until I'd seen 2 or 3 people post about the joke. :/ Damn my "$"-heavy programming language background!

  • Rich (unregistered) in reply to JimmyVile
    JimmyVile:
    jk:
    By definition, any problem that can be solved with a regular expression (and *only* a regexp), isn't interesting.

    By definition, you suck.

    /hate it when people use "by definition". //Unless it is, y'know...actually by definition.

    Yeah, I agree, it literally makes me explode with rage.

  • Still alive (unregistered)

    'cause I often stumble over code like this (and no, I didnt change indenting):

    function GetFilePerms($perms) {
    
        if (($perms & 0xC000) == 0xC000) {$info = 's'; } // Socket
        elseif (($perms & 0xA000) == 0xA000) {$info = 'l'; } // Symbolic Link
        elseif (($perms & 0x8000) == 0x8000) {$info = '-'; } // Regular
        elseif (($perms & 0x6000) == 0x6000) {$info = 'b'; } // Block special
        elseif (($perms & 0x4000) == 0x4000) {$info = 'd'; } // Directory
        elseif (($perms & 0x2000) == 0x2000) {$info = 'c'; } // Character special
        elseif (($perms & 0x1000) == 0x1000) {$info = 'p'; } // FIFO pipe
        else {$info = '?';} // Unknown
        // Owner
        $info .= (($perms & 0x0100) ? 'r' : '-');
        $info .= (($perms & 0x0080) ? 'w' : '-');
        $info .= (($perms & 0x0040) ?
           (($perms & 0x0800) ? 's' : 'x' ) :
           (($perms & 0x0800) ? 'S' : '-'));
        // Group
        $info .= (($perms & 0x0020) ? 'r' : '-');
        $info .= (($perms & 0x0010) ? 'w' : '-');
        $info .= (($perms & 0x0008) ?
              (($perms & 0x0400) ? 's' : 'x' ) :
              (($perms & 0x0400) ? 'S' : '-'));
        // World
        $info .= (($perms & 0x0004) ? 'r' : '-');
        $info .= (($perms & 0x0002) ? 'w' : '-');
        $info .= (($perms & 0x0001) ?
           (($perms & 0x0200) ? 't' : 'x' ) :
           (($perms & 0x0200) ? 'T' : '-'));
      return $info;
    }

    in the code my predecessor left me. And yes, the code that reads the permissions is .. interesting.

  • Konrad (unregistered) in reply to DoctorFriday

    You got me with this one, I literally "LOL"ed. Thanks for this comment.

  • Konrad (unregistered) in reply to DoctorFriday
    DoctorFriday:
    Heh...heh...it says "$perms".
    Oh my god, I literally "LOL"ed. Thanks for this brilliant observation.
  • WTF (unregistered) in reply to DoctorFriday

    $permsbin...i can't begin to imagine...

  • spellingnazi (unregistered) in reply to JimmyVile
    JimmyVile:
    jk:
    By definition, any problem that can be solved with a regular expression (and *only* a regexp), isn't interesting.

    By definition, you suck.

    /hate it when people use "by definition". //Unless it is, y'know...actually by definition.

    I read it as a pun on the word regular. Try eating breakfast in the morning. It may improve your mood throughout the day.

  • The Coffey Maker (unregistered) in reply to DoctorFriday
    DoctorFriday:
    Heh...heh...it says "$perms".

    lol yeah. but see, it's wrong. It says my $perms = stat($path);

    when in the REAL world

    MY $perms = splat($face);

  • Just Some Guy (unregistered) in reply to Django
    Django:
    Contrary to common beliefs, MS-Dos is a product that came quite late in Microsoft history,

    Xenis was first released in 1980, while MS-DOS came out in 1981. That's not exactly a long span.

    Bill Gates was always involved in business, but he kept a deep technical role until 2-3 years ago when Ray Ozzie came onboard at Microsoft. (Ozzie is the Lotus Notes guy).

    Says the 'pedia:

    He has not officially been on a development team since working on the TRS-80 Model 100 line, but wrote code as late as 1989 that shipped in the company's products.

    Finally...

    A few years back there was a contest during a convention, a competition between Bill Gates and many famous technical journalists (all experienced IT guys), to see who would come up with some specific feature in a software in the shortest time possible. Bill Gates won.

    Reference or it didn't happen.

  • (cs) in reply to Rich
    Rich:
    JimmyVile:
    jk:
    By definition, any problem that can be solved with a regular expression (and *only* a regexp), isn't interesting.

    By definition, you suck.

    /hate it when people use "by definition". //Unless it is, y'know...actually by definition.

    Yeah, I agree, it literally makes me explode with rage.

    Don't let us stop you. I find that ten gallons of water inside an hour or so does the trick ... well, literally. Can't speak about the rage bit.
  • Anonymous (unregistered) in reply to jamface

    Dno if you realize this, but 7 = "it's a dir!" and 6 means rwx ....

  • Evil.Martin (unregistered) in reply to DoctorFriday

    ...and $permsbin...thehehee...

  • the_doc (unregistered)

    As always, this site reminds me that no matter how shitty of a programmer I think I am, there are plenty of worse examples out there.

  • Toby Haynes (unregistered)

    And what was wrong with

    if (-r $file) {

    This is readable

    ... }

    or even

    open FILE, "$file" or print "Can't open $file: $!\n";

  • Taran Alvein (unregistered) in reply to DoctorFriday

    God, the programmer in me is way too serious. It took me two read-throughs to read that as intended. I first read it as simply "perms". XD

  • Anonymous Cowherd (unregistered) in reply to Anonymous

    Um, no.

    Seriously, was that what the "RWTF" guy on the first comment page was complaining about with "$perms->mode & 0777"? I thought it was some arcana related to octal or that Perl's "&" doesn't work the same way as C's. If he was just retarded, that makes his comment a lot less intriguing.

  • Anonymous (unregistered)

    Um, you got it backwards. Owner read is 0400, group is 0040, and world is 0004.

  • Corwin (unregistered) in reply to Franz Kafka
    Franz Kafka:
    meanwhile, windows still uses file extensions to work out executable permission

    False. Windows uses ACLs to determine executable permission. Right click on an executable. Select Properties. Select the Security tab. See the check boxes marked "read and execute".

  • lokey (unregistered) in reply to London Contractor Mart
    London Contractor Mart:
    Even Easier:
    '-r $path' ... wow

    so $perms from the -r $path ends up in the $permsbin...

    Sounds like some really messy coding!!!

    Gives new meaning to "sticky bit"...

  • lokey (unregistered) in reply to WTF
    WTF:
    $permsbin...i can't begin to imagine...

    NOT the one you take home to Mom!

  • hpa (unregistered)

    Of course, either of the methods mentioned give "is this file readable for anyone." The simple chunk:

    if (-r $path) { ... }

    ... gives "is this file readable for me"...

  • Tbot (unregistered) in reply to DoctorFriday

    LOL $perms Why is that so funny

    Wait I know

  • bleh (unregistered) in reply to DoctorFriday

    bleh it even haz this:

    $permsbin =~

  • cat (unregistered) in reply to jamface

    Actually, it's chmod 777 article. You guys always get the parameter order wrong.

Leave a comment on “Now I Have Two Hundred Problems”

Log In or post as a guest

Replying to comment #228634:

« Return to Article