cygpath and star character

Sam Edge sam.edge.cygwin@gmx.com
Thu Jul 15 06:18:30 GMT 2021


On 15/07/2021 00:07, Tomas Jura via Cygwin wrote:

> Hi
>
> My use case is building the CLASSPATH environment variable for java.
> Like:
>
> export CLASSPATH="${CLASSPATH}${PATH_SEPARATOR}$(cygpath -w
> 'my/java/jar/directory/*' )"
>
> CLASSPATH can contain the star character at the end on Windows.
> Example C:\Apps\java\lib\* , which means something different then just
> C:\Apps\java\lib, ie. the star is necessary there.
>
> Tomas
>
>

So do:

export CLASSPATH="${CLASSPATH}${PATH_SEPARATOR}$(cygpath -w
'my/java/jar/directory')\*"

If you pass the asterisk to cygpath it will naturally consider it to be
a character in a pathname and give you the equivalent Windows path that
Cygwin would construct using the open() syscall. This is cygpath's
purpose, after all!

--
Sam Edge



More information about the Cygwin mailing list