0
Goal: Issue a simple command to add the current directory to the PATH statement. Rather than type in every agonizing stroke, I would rather call a batch file, say xpath (where xpath.bat sits in an active path).
Doesn't work: path=%path%;%cd%
does not work under command.com, neither in batch nor on the command line, although it works perfectly in later cmd.exe systems.
Confusing: Several other system variables or strings can be manipulated this way.
%CD% (or CD) is behaving differently.
Environment: I am using FreeDOS 1.2 under Virtualbox 5.2.22
This failure is consistent under MS-DOS 6.22 also under Vbx 5.2.22
C:\SSH>path
PATH=C:\FDOS\BIN
C:\SSH>set newdir=C:\SSH\CONTRIB
C:\SSH>echo %newdir%
C:\SSH\CONTRIB // success
C:\SSH>path=%path%;%newdir%
C:\SSH>path
PATH=C:\FDOS\BIN;C:\SSH\CONTRIB // success
*** But
C:\SSH>path
PATH=C:\FDOS\BIN
C:\SSH>set newdir=%cd%
C:\SSH>echo %newdir%
ECHO is on // unexpected
C:\SSH>path=%path%;%newdir%
C:\SSH>path
PATH=C:\FDOS\BIN;C:\SSH\CONTRIB //unchanged
The "echo is on" as well as other failures are consistent with %cd% resolving to nothing.
So CD, like PATH, appears to be a COMMAND whose output can be captured by evaluating it as a %VARIABLE%, but this is probably only the desired appearance. Sounds like the two are fundamentally different, and CD does not work consistently under COMMAND.COM.
NOTE that there is another question floating around out there with a solution that works nicely under cmd.exe. This is not that.
Formatting completely ruined by StackExchange ! – user990536 – 2019-01-27T10:53:22.923