Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
User Journal

Journal Cliff's Journal: Using ".*" Almost Always Results in Something You Don't Want 14

OK, this might seem like an unnecessary rant, but I, like this poster have been caught by the ".*" bug when issuing Unix commands. I think it's kind of rediculous that most unix commands will do an UPWARD recursive traversal (thanks to the ".." directory entry) as well as a downwards traversal. Most folks, when dealing with TREE structures only expect the latter, not realizing that the former is always possible.

Why is it that Unix commands, expecially rm, and chmod deal with the ".." directory entry without a specific flag telling them to do so? I think it's downright misleading and this feature will cause more problems than it solves as people learn Unix.

Yes, you can replace ".*" with ".[^.]*", but it's extra typing an unintuitive for most people, so why not add in the extra flag.

Basically, this is me writing a journal entry trying to tell a computer to "Do what I say, not what I mean!"

Bored am I! Move along, now. Nothing to see, here.
This discussion has been archived. No new comments can be posted.

Using ".*" Almost Always Results in Something You Don't Want

Comments Filter:
  • mind-reading hardware, I'll see what I can do about working up a do-what-I-mean-to patch for rm. :-)

    And, unless you do -r or a -f, it prompts you and doesn't recurse. So most newbies should figure out that .* can be baadddd fairly quickly.

    Then they can hop on /. submit an ask slashdot question, which if it gets accepted(probably because you're on vacation and Michael or some drunk editor is working your queue), will somehow be sectioned to the main page, and they'll get the joy of having hundreds of geek
    • This usually catches me when I'm trying to change ownerships of home directories. I'm generally VERY VERY careful when I'm using 'rm -rf', as once you rm you can't....oh you're just SOL (and I you can't make anything useful rhyme with it, anyways).
    • mind-reading hardware

      My co-workers and I refer to this as the 'ESP API. Usually followed with whisking a pen across the forehead and saying, "I just sent you an email about it."
  • I always name my dot files with .??* -- it's easier than .[^.]*, but assumes no 2 character .? files. Why the heck is slashcode not letting me post this comment!?!?! ["Cat got your tongue? (something important seems to be missing from your comment ... like the body or the subject!)"] A: subject lines must have at least one alphanumeric.
  • Why is it that Unix commands, expecially rm, and chmod deal with the ".." directory entry without a specific flag telling them to do so? I think it's downright misleading and this feature will cause more problems than it solves as people learn Unix.

    It's just doing what you told it. "." and ".." appear in your directory listings because they really are nothing more than files. Therefore when you use ".*", you will naturally match "..", and if you tell the command to recurse, of course it is going to go up
    • The design is flawed, because it allows silly people like me to make a mistake in those oh-so-common-but-shouldn't-be 5am coding sessions that I may get into without a constant IV of caffiene to keep me sane, aware and vigilant.

      Oh, nevermind. ;)
      • The design is flawed, [...]

        Hey, at least the wildcard expansion is done by the shell, not each and every command line utility. That way it is consistently flawed across all utilities unlike Winders, where, if you do get wild card support on the command line, it is likely that the coder implemented his own, twisted idea of how to do the expansion. That was one thing I could never get used to in DOS/Windows...

        Simple solution though - write your own! Isn't that how the Open Source religion works? ;-)

Always draw your curves, then plot your reading.

Working...