chgpath

NAME

chgpath, ntpath2posix, posixpath2nt - convert path names between Windows format and POSIX format

SYNOPSIS

chgpath [-n|-p] [-l|-u|-c|-q] path

ntpath2posix [-l|-u|-c|-q] path
posixpath2nt [-l|-u|-q] path

DESCRIPTION

The chgpath(1) utility converts a path name between the Win32 format (for example, c:\SFU\usr\share) and the POSIX format (for example, /dev/fs/C/SFU/usr/share). The converted path name is written to standard output.

If called as ntpath2posix(1), it converts from Win32 format to POSIX format. If called as posixpath2nt(1), it converts from POSIX format to Win32 format.

By default, the utility maintains the case of the path, although when converting to POSIX format, it will always produce an uppercase drive letter.

OPTIONS

-c
Adjust case to match an existing path name. (This only applies to chgpath -p and ntpath2posix(1).) After translating the path name into POSIX format, the utility adjusts the case on a component-by-component basis. Nonexistent components are not changed. The -c option takes precedence over -l and -u.
-l
Produces a file name that is in lowercase. For ntpath2posix(1), the drive letter is always an uppercase letter, even if this option is given.
-n
When given to chgpath(1), converts a POSIX-style path name to a Win32-style path name (posixpath2nt(1)).
-p
When given to chgpath(1), converts a Win32-style path name to a POSIX-style path name (ntpath2posix(1)).
-q
Produces quiet operations. Suppresses messages such as warnings. See EXAMPLES.
-u
Produces a file name that is in uppercase.

These commands are normally used in shell scripts that, in turn, invoke Win32 commands.

DIAGNOSTICS

Chgpath(1) returns 0 for success and >0 for failure.

EXAMPLES

To set the current TMP environment variable in a form that Win32 programs can understand:

export TMP=$(posixpath2nt $TMP)

To return it to the form expected by the Interix utilities:

export TMP=$(ntpath2posix $TMP)

Assuming Interix is installed in /dev/fs/C/SFU:

$ ntpath2posix -c /dev/fs/C/SFU
/dev/fs/C/SFU

The following example displays output that contains a warning:

$  chgpath -n -c /usr
chgpath: WARNING: ignoring -c flag. Converting to an NT path.
C:\SFU\usr

To suppress the warning, you can use the -q option:

$  chgpath -n -c -q /usr
C:\SFU\usr

NOTES

The -c option matches the first path name component returned by readdir(3). It is not recursive, so it can be misled by file hierarchies that are very complicated. For example, suppose you have the files and directories:

C:\Something
C:\Something\BIN
C:\Something\BIN\file
C:\Something\BIn\file
C:\Something\Bin
C:\Something\Bin\MyStuff
C:\Something\Bin\MyStuff\myProg

This command will not work:

$ ntpath2posix -c C:\something\bin\mystuff\myprog
/dev/fs/C/Something/Bin/myStuff/myProg
This is still a useful option without providing a general replacement for find(1).

The internal buffer is limited to 512 characters, so path names longer than this will not be returned correctly.

SEE ALSO

find(1)