TOUCH.COM 1.4.3 (minor fix: debug script) (Developers)
FreeDOS' TOUCH.COM works fine and is well-written (IMHO) although it still needs some tweaking (e.g. convert to NASM or FASM, add LFN support).
However, the main issue I have with it (among other touch utils) is that none seem to allow touching a read-only file! Why? I can't imagine that's really a worthwhile protection. At least two (DR-DOS' TOUCH.EXE and 4DOS's built-in TOUCH) support overriding it (/R or /F, respectively) but most others don't (even Charles Dye's improved version).
There's also no common way to easily preserve file attributes before touching in order to be restored afterwards either, so that's bad for .BAT files. Anyways, in the interest of simplicity (and because it's a minor fix), I wrote a debug script instead of updating the TASM srcs. In short, if not creating a new file (which -C forbids), why open for read/write (3D02)??
Feedback welcome.
@echo off
if not exist %0 %0.bat
if not exist touch.com goto end
if not exist touch2.com copy /b touch.com touch2.com
attrib -r touch2.com
debug touch2.com < %0
goto end
; patch for Kris Heidenstrom's TOUCH.COM 1.4.3 (for FreeDOS)
; Monday 01 March 2010, rugxulo _AT_ gmail _DOT_ com
; what it does: lets -C also permit touching readonly +R files
; int 21h,3D '02'h (read/write) fails to open on +R files
; TODO: convert whole program from TASM to FASM; fix this; add LFN support
;NewCall=09C0
;NewEOF=0145h
;Patch=0146h
;CFlag=058Eh
;ret=0151h
; (only if you want to bump the version number to 1.4.'4' for -F)
;e 127
;34
a 09C0
; former home of "mov ax,3D02", patched with call to fix
call 0146
a 0145
; = 13 bytes below
; (1Ah = EOF / Ctrl-Z marker for "type")
db 1A
mov ax,3D02
test byte ptr [058E],1
jz 0151
; salc
db D6
ret
w
Q
Q
:end
for %%a in (touch touch2) do if not exist %%a.com goto bye
dir touch*.com | find /i "com"
echo on
REM ... generate an error (to prove it didn't work before)
attrib +r touch.com
touch2 touch.com
REM ... try again with -C (to prove it works now)
touch2 -C touch.com
@echo off
dir touch*.com | find /i "com"
:bye
EDIT: Changed ".com" to "com" for some DOS shells.
---
Know your limits.h
Complete thread:
- TOUCH.COM 1.4.3 (minor fix: debug script) - Rugxulo, 02.03.2010, 01:10 (Developers)
- GZIPDATE.REX (uses TOUCH) - Rugxulo, 02.03.2010, 01:22
- GZIPDATE.REX (uses TOUCH) - Arjay, 11.03.2010, 17:09
- GZIPDATE.REX (uses TOUCH) - Rugxulo, 11.03.2010, 19:41
- GZIPDATE.REX (uses TOUCH) - Arjay, 18.03.2010, 16:31
- GZIPDATE.REX (uses TOUCH) - Rugxulo, 19.03.2010, 00:58
- GZIPDATE.REX (uses TOUCH) - Arjay, 22.03.2010, 00:40
- GZIPDATE.REX (uses TOUCH) - Rugxulo, 22.03.2010, 17:47
- GZIPDATE.REX (uses TOUCH) / Tim Paterson / DOS v3 required - Arjay, 23.03.2010, 16:25
- GZIPDATE.REX (uses TOUCH) / Tim Paterson / DOS v3 required - Rugxulo, 23.03.2010, 16:59
- [deleted] - Arjay, 23.03.2010, 19:32
- TOUCH 1.4.4 - Rugxulo, 07.04.2010, 00:05
- [deleted] - Arjay, 23.03.2010, 19:32
- GZIPDATE.REX (uses TOUCH) / Tim Paterson / DOS v3 required - Rugxulo, 23.03.2010, 16:59
- GZIPDATE.REX (uses TOUCH) / Tim Paterson / DOS v3 required - Arjay, 23.03.2010, 16:25
- GZIPDATE.REX (uses TOUCH) - Rugxulo, 22.03.2010, 17:47
- GZIPDATE.REX (uses TOUCH) - Arjay, 22.03.2010, 00:40
- GZIPDATE.REX (uses TOUCH) - Rugxulo, 19.03.2010, 00:58
- GZIPDATE.REX (uses TOUCH) - Arjay, 18.03.2010, 16:31
- GZIPDATE.REX (uses TOUCH) - Rugxulo, 11.03.2010, 19:41
- GZIPDATE.REX (uses TOUCH) - Rugxulo, 07.04.2010, 01:06
- GZIPDATE.REX (uses TOUCH) - Arjay, 11.03.2010, 17:09
- GZIPDATE.REX (uses TOUCH) - Rugxulo, 02.03.2010, 01:22