8.1.1 Failure of XCOPY in a tool

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
chrisjj
Posts: 149
Joined: Sat Jan 21, 2006 10:32 pm

8.1.1 Failure of XCOPY in a tool

Post by chrisjj »

(I find no place for reporting bugs on this forum or https://www.textpad.com/support/ so I'm reporting this here.)

I was hoping that the upgrade to 8.1.1 would fix the long-standing failure of XCOPY in a tool, but sadly not.

On Windows 7 64-bit.

Code:
REM Run on TP 8.1.1 (64-bit edition) as tool https://i.imgur.com/xXY5IQH.png
echo test > %TEMP%\src.bat
del /q %TEMP%\dest.bat
xcopy %TEMP%\src.bat %TEMP%\dest.bat
dir /b %TEMP%\dest.bat
REM Expected: 1 File(s)
REM Observed: File not found https://i.imgur.com/nxRDqXh.png


When run outside TP, succeeds as expected https://i.imgur.com/nUbeplw.png
With XCOPY replaced by COPY, succeeds as expected https://i.imgur.com/LGYFng5.png.
Last edited by chrisjj on Mon Oct 15, 2018 11:41 am, edited 2 times in total.
miked
Posts: 55
Joined: Tue Feb 27, 2007 11:17 am

Post by miked »

But your example showing it working outside TP uses copy, not xcopy

When using XCOPY to copy a source to a destination it normally prompts asking if the destination specifies a file or directory, but that may be OS version specific. The simple answer is to use copy, as you have found.
User avatar
AmigoJack
Posts: 500
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: 8.1.1 Failure of XCOPY in a tool

Post by AmigoJack »

chrisjj wrote:When run outside TP, succeeds as expected
This can't be true and your screenshot shows COPY, not XCOPY - the latter would always query if the destination is a file or directory. Try again "outside" TextPad with XCOPY.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

/I option assumes that a given destination is a directory.
chrisjj
Posts: 149
Joined: Sat Jan 21, 2006 10:32 pm

Post by chrisjj »

miked wrote:But your example showing it working outside TP uses copy, not xcopy
Oops! Well spotted. Thanks. That was a erroneous screenshot, now corrected to show that XCOPY does succeed outside TP.
miked wrote:When using XCOPY to copy a source to a destination it normally prompts asking if the destination specifies a file or directory, but that may be OS version specific.
Outside TP it does here.

And inside TP, feeding-in an 'f' gives success https://i.imgur.com/HcRYlA4.png .

So it seems that, inside TP, XCOPY is somehow being terminated before its prompt.

And not due to the prompt, it seems. Adding an asterisk to the destination path to specify a file and inhibit the prompt (outside TP https://i.imgur.com/AYqZsoE.png ) makes no difference to the fail inside TP https://i.imgur.com/Oa25rgV.png .

EDIT: XCOPY /? shows the same!

Outside TP, OK: https://i.imgur.com/FACCYOs.png

Inside TP, fail:

Image
miked wrote:The simple answer is to use copy, as you have found.
That works in this minimal test case, but unfortunately not in general. COPY is not in general a substitute for XCOPY.
User avatar
AmigoJack
Posts: 500
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

chrisjj wrote:inside TP, XCOPY is somehow being terminated before its prompt
Programs can detect if STDIN is available or not, and most likely TextPad does not provide any - hence XCOPY seems to act differently to you (when in fact it just corresponds to the environment and quits if no STDIN is available - unbound to if it ever needs it).

A workaround to simulate STDIN for that one query would be to use

Code: Select all

echo f | xcopy %temp%\src.txt %temp%\dst.txt
chrisjj
Posts: 149
Joined: Sat Jan 21, 2006 10:32 pm

Post by chrisjj »

AmigoJack wrote:hence XCOPY seems to act differently to you (when in fact it just corresponds to the environment and quits if no STDIN is available - unbound to if it ever needs it).
If it is quitting due to STDIN being absent (needlessly in the /? case) then there's no 'seems'. It is acting differently.
AmigoJack wrote:A workaround to simulate STDIN for that one query would be to use

Code: Select all

echo f | xcopy %temp%\src.txt %temp%\dst.txt
Thanks. That will fail in other locales, but this version won't:

Image

And echo fixes XCOPY /? too!

Image
Post Reply