bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: in error messages, do not output raw non-printable characters to the


From: Greg Wooledge
Subject: Re: in error messages, do not output raw non-printable characters to the terminal
Date: Wed, 10 Sep 2014 14:30:18 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Sep 10, 2014 at 01:32:18PM -0400, Steve Simmons wrote:
> is a helluva lot more sensible than
> 
>    cd $LOG
>    # take actions here...
>    rm *

Oh dear gods.  That's madness.  Never EVER do that.  If the cd command
fails for any reason, you will remove all the files in the wrong
directory.

cd "$LOG" && rm -- *      # This is much, much safer.

Or if there are several actions that all need to be done in the $LOG
directory, wrap it in something you can escape from, like a function:

cleanup() {
    cd "$LOG" || return
    # other actions
    rm -- *
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]