This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: Little cygpath improvement request
- From: "Andy Hall" <fixpertise-consulting at comcast dot net>
- To: <cygwin at cygwin dot com>
- Date: Sun, 16 Feb 2014 17:07:15 -0800
- Subject: RE: Little cygpath improvement request
- Authentication-results: sourceware.org; auth=none
- References: <111910987 dot 20140214222230 at mtu-net dot ru> <52FE6397 dot 5010105 at cygwin dot com> <187072112 dot 20140214234339 at mtu-net dot ru> <20140215125606 dot GM2246 at calimero dot vinschen dot de> <1745533059 dot 20140215225708 at mtu-net dot ru> <20140216120042 dot GP2246 at calimero dot vinschen dot de> <40596392 dot 20140216184131 at yandex dot ru> <20140216151107 dot GT2246 at calimero dot vinschen dot de> <6CF2FC1279D0844C9357664DC5A08BA224229D at MLBXV06 dot nih dot gov> <CAAXzdLXEoNujigUD68xFhQv3XS=dCn_mYnqKnx1M4Rq0bVdhpg at mail dot gmail dot com>
>
> 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