Little cygpath improvement request

Andy Hall fixpertise-consulting@comcast.net
Mon Feb 17 02:35:00 GMT 2014


> 
> 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



More information about the Cygwin mailing list