This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Little cygpath improvement request


> 
> On Sun, Feb 16, 2014 at 12:30 PM, Buchbinder, Barry (NIH/NIAID) [E] wrote
> > if [ ! -z "$2" ] ; then NATIVE="$(cygpath -ml "$2")" ; fi
> 
> That might better be written as this
> 
>     [ "$2" ] && NATIVE=$(cygpath -ml "$2")
> 
> You do not need the extra quotes when setting a variable in this way.
> 
Goodness. If code cleanliness is the issue, Why not simply hide this construct in a function?

function dospath() {
        [ "$1" ] && cygpath -ml "$1"
}

Then 

NATIVE=$(dospath $1)

Which is about as simple and clear as it gets.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]