| Ticket UUID: | 1292143 | ||
| Title: | glob does not accept backslash for directory separtor | ||
| Type: | Bug | Created on: | 2005-09-15 16:50:22 |
| Submitter: | gwlester | Assigned to: | dgp |
| Subsystem: | 37. File System | Severity: | |
| Priority: | 5 Medium | Last modified: | 2005-09-16 00:16:29 |
| Status: | Closed | Closed by: | vincentdarley |
| Resolution: | Invalid | Closed on: | 2005-09-15 17:16:29 |
| Version: | obsolete: 8.4.11 | ||
| Description: | ||||
When using windows native file separator on Windows XP glob returns incorrect results (see example below). (bin) 65 % set foo C:\Clients\LMMSS\PMES\Source\CAPP\Procs\interfaces\copics\item_master\* (bin) 66 % set bar C:/Clients/LMMSS/PMES/Source/CAPP/Procs/interfaces/copics/item_master/* (bin) 67 % glob $foo no files matched glob pattern "C:\Clients\LMMSS\PMES\Source\CAPP\Procs\interfaces\copics\item_master\*" (bin) 68 % glob $bar C:/Clients/LMMSS/PMES/Source/CAPP/Procs/interfaces/copics/item_master/brasfile C:/Clients/LMMSS/PMES/Source/CAPP/Procs/interfaces/copics/item_master/LoadItemMaster.tcl | ||||
| User Comments: | ||||
dgp added on 2005-09-16 00:04:51:
Logged In: YES user_id=80530 Not a fix, but consider using [glob -directory] as a workaround. dgp added on 2005-09-16 00:09:38:
Logged In: YES user_id=80530 I think this excerpt from glob.n explains it: "Since the backslash character has a special meaning to the glob command, glob patterns containing Windows style path separators need special care. The pattern \fIC:\e\efoo\e\e*\fR is interpreted as \fIC:\efoo\e*\fR where \fI\ef\fR will match the single character \fIf\fR and \fI\e*\fR will match the single character \fI*\fR and will not be interpreted as a wildcard character. One solution to this problem is to use the Unix style forward slash as a path separator. Windows style paths can be converted to Unix style paths with the command \fBfile join $path\fR (or \fBfile normalize $path\fR in Tcl 8.4)." vincentdarley added on 2005-09-16 00:16:29:
Logged In: YES user_id=32170 Glob does handle windows native separators just fine, but you need to read the glob man page where you will see that glob interprets: \x (backslash-x) as an attempt to match the character x. Hence you will need to double up your backslashes if you want glob to interpret them as directory separators. If you read the end of the glob man page, you will see this: Since the backslash character has a special meaning to the glob command, glob patterns containing Windows style path separators need special care. The pattern \fIC:\e\efoo\e\e*\fR is interpreted as \fIC:\efoo\e*\fR where \fI\ef\fR will match the single character \fIf\fR and \fI\e*\fR will match the single character \fI*\fR and will not be interpreted as a wildcard character. One solution to this problem is to use the Unix style forward slash as a path separator. Windows style paths can be converted to Unix style paths with the command \fBfile join $path\fR (or \fBfile normalize $path\fR in Tcl 8.4). which explains exactly your problem. | ||||
