reactos/base
Hermès Bélusca-Maïto 8ce4b73920
[CMD] Correctly honour the "short" path flag in %~var enhanced variables expansion. (#5433)
CORE-14096, CORE-8002

Patch based on an earlier fix attempt by Doug Lyons.
It should fix the problem observed by contributor 'whindsaks' in PR #5403.

This bug has always been present since the implementation of this feature
in commit a1eb1f6ba (r40024).

The expansion of %~dpX ennhanced variables used to incorrectly show some
directories in uppercase. For example:

```batch
:: testcmd.cmd
echo '%~dp0'
echo '%~dps0'
echo '%~s0'
```

would show:

```
P:\Documents and Settings\Administrator\Desktop>echo 'P:\Documents and Settings\Administrator\DESKTOP\'
'P:\Documents and Settings\Administrator\DESKTOP\'

P:\Documents and Settings\Administrator\Desktop>echo 'P:\DOCUME~1\ADMINI~1\DESKTOP\'
'P:\DOCUME~1\ADMINI~1\DESKTOP\'

P:\Documents and Settings\Administrator\Desktop>echo 'P:\DOCUME~1\ADMINI~1\DESKTOP\testcmd.cmd'
'P:\DOCUME~1\ADMINI~1\DESKTOP\testcmd.cmd'
```

instead of the correct:

```
P:\Documents and Settings\Administrator\Desktop>echo 'P:\Documents and Settings\Administrator\Desktop\'
'P:\Documents and Settings\Administrator\Desktop\'

P:\Documents and Settings\Administrator\Desktop>echo 'P:\DOCUME~1\ADMINI~1\DESKTOP\'
'P:\DOCUME~1\ADMINI~1\DESKTOP\'

P:\Documents and Settings\Administrator\Desktop>echo 'P:\DOCUME~1\ADMINI~1\DESKTOP\testcmd.cmd'
'P:\DOCUME~1\ADMINI~1\DESKTOP\testcmd.cmd'
```

The reason was a wrong handling of the presence (or absence) of the
"short" path format specifier 's' in those enhanced variables.
In the examples above, the "Desktop" sub-directory has a short-path
name available (because it is in a FAT partition). The short-path name
was used some times also even with the 's' specifier absent.

Co-authored-by: Doug Lyons <douglyons@douglyons.com>
2023-07-14 14:36:55 +02:00
..
applications [MSTSC] Update copyright years in Romanian (ro-RO) translation (#5437) 2023-07-13 22:56:55 +03:00
services [UMPNPMGR] PNP_Get(First/Next)LogConf: return proper tags for the resource list case 2023-06-29 18:06:02 +02:00
setup [TRANSLATION] Improve Dutch (nl-NL) translation (#4765) 2023-06-10 18:32:03 +03:00
shell [CMD] Correctly honour the "short" path flag in %~var enhanced variables expansion. (#5433) 2023-07-14 14:36:55 +02:00
system [TRANSLATION] Update Portuguese (pt-PT) translation (#5414) 2023-07-10 22:04:31 +03:00
CMakeLists.txt Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00