Skip to content

Commit

Permalink
Merge fix for [4f0b5767ac]. Exec of App Execution Aliases on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
apnadkarni committed Jan 28, 2025
2 parents 4f15fed + 5a9b2f0 commit f62e5de
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tests/exec.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ source [file join [file dirname [info script]] tcltests.tcl]
# Some skips when running in a macOS CI environment
testConstraint noosxCI [expr {![info exists ::env(MAC_CI)]}]

# Need a App Exec Alias for testing exec of reparse points
if {[info exists ::env(LOCALAPPDATA)] &&
[file exists [file join $::env(LOCALAPPDATA) "Microsoft" "WindowsApps" "winget.exe"]]} {
testConstraint haveWinget 1
}

unset -nocomplain path

# Utilities that are like Bourne shell stalwarts, but cross-platform.
Expand Down Expand Up @@ -706,6 +712,11 @@ test exec-20.1 {exec .CMD file} -constraints {win} -body {
exec [makeFile "echo %1> $log" exec201.CMD] "Testing exec-20.1"
viewFile $log
} -result "\"Testing exec-20.1\""

test exec-bug-4f0b5767ac {exec App Execution Alias} -constraints haveWinget -body {
exec winget --info
} -result "Windows Package Manager*" -match glob


# ----------------------------------------------------------------------
# cleanup
Expand Down
3 changes: 3 additions & 0 deletions tools/tcltk-man2html.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,9 @@ try {
break
}
}
} on error {} {
puts "package folder without package ignored: $dir"
continue
} finally {
catch {close $f; unset f}
}
Expand Down
13 changes: 12 additions & 1 deletion win/tclWinPipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1323,11 +1323,22 @@ ApplicationType(

hFile = CreateFileW(nativeFullPath,
GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OPEN_REPARSE_POINT, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
continue;
}

if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
/*
* But [4f0b5767ac]. Likely a App Execution Alias. This can only
* be a Win32 APP. Attempt to ReadFile below will fail. We assume
* that if it is on the PATH, and it is a reparse point, it is an
* App Execution Alias.
*/
applType = APPL_WIN32;
break;
}

header.e_magic = 0;
ReadFile(hFile, (void *) &header, sizeof(header), &read, NULL);
if (header.e_magic != IMAGE_DOS_SIGNATURE) {
Expand Down

0 comments on commit f62e5de

Please sign in to comment.