Joined September 2012
·

LokiAstari

Architecture of Anarchy at SEOmoz
·
SEOmoz
·
·
·

OK. What I am saying is that you would never write either in a script.

So the only place you use this is on a command line.
Given that. Yours is just way too unreadable for general usage and the error messages mine produce are quite fine (or ignorable). In other-words this is not a tip (or even useful).

If you write that in a script that has to be maintained you should be fired.

Have to disagree. Its two ugly to remember for a simple command line
On the command line:

rm -rf . .*

This is just intuitively obvious (unlike the reg-ex monstrosity you concocted) and the error messages are logical. So are not a problem.

In a script (both are stupid but you can correct for the error message):

(rm -rf . .* || echo "Delete * .* Done") 2> /dev/null

This is still so much more readable than your original code.

Though you would still never do that. If this is a repeatable script that you are tidying up from then you are going to do something is easy to read and maintain:

# Clean up the current directory (which we are in)
# This directory holds some state and thus must be cleaned
# So scour it absolutely clean before use.
function scourDirectory {
    dir=`pwd`
    local=${dir##*/}
    cd ..
    rm -rf ${local}
    mkdir ${local}
    cd ${local}
}

Here verbosity is your friend not a hindrance.

You can't delete . or .. so trying does not matter.

rm -rf * .*
Posted to C++ command line arguments over 1 year ago

@ehevutov That's why the title is "C++ command line arguments"

Unfortunately coderwall does not support the tag C++ yet.

Posted to Prettier Vim Linewrap Markers over 1 year ago

For the uninitiated: The u21aa means unicode code-point 21aa http://www.fileformat.info/info/unicode/char/21aa/index.htm

Posted to Segmentation fault over 1 year ago

@khasinski :-) Neither did yours until you added int. But you need to resolve the main issue in that your may not actually crash with a good compiler. Using g++-4.2. Examine the output from g++ -Wall -Wextra -Werror -O -S you will see your tail recursion is been converted into a loop. and thus it will never crash. In older versions you may need to up the optimization level but in 4.2 -O is enough.

Posted to Segmentation fault over 1 year ago

Hate to disagree:
int main(){raise(11);}

Or a more standardized version:
#include<signal.h> int main(){raise(SIGSEGV);}

There is also the potential for a good optimizing compiler to convert your tail recursion into loop. Thus potentially sending you into an infinite loop rather than a crash. Theoretically an empty loop (with no side affects) may also be optimized away to make your code do nothing and thus just return.

Posted to git diff in your editor over 1 year ago

How to use an external diff-tool via get config files: http://technotales.wordpress.com/2009/05/17/git-diff-with-vimdiff/

Achievements
293 Karma
11,208 Total ProTip Views