Changeset 6867 for trunk/tools/bin
- Timestamp:
- Sep 30, 2001, 2:24:35 AM (24 years ago)
- Location:
- trunk/tools/bin
- Files:
-
- 1 added
- 2 edited
-
DoDirs.cmd (modified) (3 diffs)
-
DoMakes.cmd (added)
-
DoWithDirs.cmd (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/bin/DoDirs.cmd
r5532 r6867 1 /* $Id: DoDirs.cmd,v 1. 3 2001-04-17 04:00:41bird Exp $1 /* $Id: DoDirs.cmd,v 1.4 2001-09-30 00:24:35 bird Exp $ 2 2 * 3 3 * Rexx script which executes a given command in each of the given … … 13 13 14 14 parse arg '"'sDirs'" 'sCommand 15 16 /* 17 * Color config. 18 */ 19 if ( (value('BUILD_NOCOLOR',,'OS2ENVIRONMENT') = ''), 20 & (value('SLKRUNS',,'OS2ENVIRONMENT') = '')) then 21 do 22 sClrMak = '[35;1m' 23 sClrErr = '[31;1m' 24 sClrRst = '[0m' 25 end 26 else 27 do 28 sClrMak = '' 29 sClrErr = '' 30 sClrRst = '' 31 end 32 15 33 16 34 /* … … 46 64 if (directory(sDir) <> '') then 47 65 do 48 say '[Entering directory:' directory()']'66 say sClrMak||'[Entering directory:' directory()']'||sClrRst; 49 67 sCommand 50 68 if (rc <> 0) then 51 69 do 52 say '[Failed rc='rc' directory:' directory()']';70 say sClrErr||'[Failed rc='rc' directory:' directory()']'||sClrRst; 53 71 exit(rc); 54 72 end 55 say '[Leaving directory:' directory()']'73 say sClrMak||'[Leaving directory:' directory()']'||sClrRst; 56 74 end 57 75 else 58 76 do 59 say '[Failed to change directory to' sDir']';77 say sClrErr||'[Failed to change directory to' sDir']'||sClrRst; 60 78 exit(267); /* ERROR_DIRECTORY */ 61 79 end -
trunk/tools/bin/DoWithDirs.cmd
r5717 r6867 1 /* $Id: DoWithDirs.cmd,v 1.1 1 2001-05-16 01:14:03bird Exp $1 /* $Id: DoWithDirs.cmd,v 1.12 2001-09-30 00:24:35 bird Exp $ 2 2 * 3 3 * Syntax: dowithdirs.cmd [-e<list of excludes>] [-c] [-i] [-l] [-r] <cmd with args...> … … 14 14 */ 15 15 16 if RxFuncQuery('SysLoadFuncs')=1 THEN 17 DO 18 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' 19 call SysLoadFuncs 20 END 21 22 23 /* init options */ 24 fIgnoreFailure = 0; 25 asIgnore.0 = 0; 26 fCD = 0; 27 fLocking = 0; 28 fDontStop = 0; 29 fReverse = 0; 30 fExitOnLock = 1; 31 sLockTag = ''; 32 33 /* parse arguments */ 34 parse arg sArg.1 sArg.2 sArg.3 sArg.4 sArg.5 sArg.6 sArg.7 sArg.8 sArg.9 35 sArg.0 = 9; 36 do i = 1 to sArg.0 37 if (sArg.i <> '') then 38 do 39 if (substr(sArg.i, 1, 1) = '-') then 40 do 41 ch = translate(substr(sArg.i, 2, 1)); 42 select 43 when ch = 'E' then 44 do 45 sLeft = substr(sArg.i, 3); 46 do while (sLeft <> '' & sLeft <> ';') 47 j = asIgnore.0 + 1; 48 iPos = pos(';', sLeft); 49 if (iPos < 1) then do 50 asIgnore.j = sLeft; 51 sLeft = ''; 52 asIgnore.0 = j; 53 end 54 else do 55 asIgnore.j = substr(sLeft, 1, iPos - 1); 56 sLeft = substr(sLeft, iPos + 1); 57 asIgnore.0 = j; 58 end 16 if (RxFuncQuery('SysLoadFuncs') = 1) then 17 do 18 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' 19 call SysLoadFuncs 20 end 21 22 23 /* 24 * Color config. 25 */ 26 if ( (value('BUILD_NOCOLOR',,'OS2ENVIRONMENT') = ''), 27 & (value('SLKRUNS',,'OS2ENVIRONMENT') = '')) then 28 do 29 sClrMak = '[35;1m' 30 sClrErr = '[31;1m' 31 sClrRst = '[0m' 32 end 33 else 34 do 35 sClrMak = '' 36 sClrErr = '' 37 sClrRst = '' 38 end 39 40 41 /* init options */ 42 fIgnoreFailure = 0; 43 asIgnore.0 = 0; 44 fCD = 0; 45 fLocking = 0; 46 fDontStop = 0; 47 fReverse = 0; 48 fExitOnLock = 1; 49 sLockTag = ''; 50 51 /* parse arguments */ 52 parse arg sArg.1 sArg.2 sArg.3 sArg.4 sArg.5 sArg.6 sArg.7 sArg.8 sArg.9 53 sArg.0 = 9; 54 do i = 1 to sArg.0 55 if (sArg.i <> '') then 56 do 57 if (substr(sArg.i, 1, 1) = '-') then 58 do 59 ch = translate(substr(sArg.i, 2, 1)); 60 select 61 when ch = 'E' then 62 do 63 sLeft = substr(sArg.i, 3); 64 do while (sLeft <> '' & sLeft <> ';') 65 j = asIgnore.0 + 1; 66 iPos = pos(';', sLeft); 67 if (iPos < 1) then do 68 asIgnore.j = sLeft; 69 sLeft = ''; 70 asIgnore.0 = j; 59 71 end 60 /* 61 do j = 1 to asIgnore.0 62 say 'dbg:' asIgnore.j; 72 else do 73 asIgnore.j = substr(sLeft, 1, iPos - 1); 74 sLeft = substr(sLeft, iPos + 1); 75 asIgnore.0 = j; 63 76 end 64 */ 65 end 66 67 when ch = 'C' then 68 do 69 fCD = 1; 70 end 71 72 when ch = 'I' then 73 do 74 fIgnoreFailure = 1; 75 end 76 77 when ch = 'R' then 78 do 79 fReverse = 1; 80 end 81 82 when ch = 'L' then 83 do 84 fLocking = 1; 85 sLockTag = substr(sArg.i, 3); 86 end 87 88 when ch = 'S' then 89 do 90 fExitOnLock = 0; 91 end 92 93 otherwise 94 say 'unknown argument:' sArg.i; 95 call syntax; 96 end 97 end 98 else 99 do /* the rest of the args is part of the cmd */ 100 sCmds = ''; 101 do j = i to sArg.0; 102 if (sArg.j <> '') then 103 sCmds = sCmds || ' ' || sArg.j; 104 end 105 i = sArg.0; 77 end 78 /* 79 do j = 1 to asIgnore.0 80 say 'dbg:' asIgnore.j; 81 end 82 */ 83 end 84 85 when ch = 'C' then 86 do 87 fCD = 1; 88 end 89 90 when ch = 'I' then 91 do 92 fIgnoreFailure = 1; 93 end 94 95 when ch = 'R' then 96 do 97 fReverse = 1; 98 end 99 100 when ch = 'L' then 101 do 102 fLocking = 1; 103 sLockTag = substr(sArg.i, 3); 104 end 105 106 when ch = 'S' then 107 do 108 fExitOnLock = 0; 109 end 110 111 otherwise 112 say 'unknown argument:' sArg.i; 113 call syntax; 106 114 end 107 115 end 108 116 else 109 do 110 say 'missing cmd.'; 111 call syntax; 117 do /* the rest of the args is part of the cmd */ 118 sCmds = ''; 119 do j = i to sArg.0; 120 if (sArg.j <> '') then 121 sCmds = sCmds || ' ' || sArg.j; 122 end 123 i = sArg.0; 112 124 end 113 125 end 114 115 /* sanity check */ 116 if (fLocking & \fCD) then 126 else 117 127 do 118 say ' -l (Locking) requires -cd to be specified!';128 say 'missing cmd.'; 119 129 call syntax; 120 130 end 121 122 /* process directories */ 123 rc = SysFileTree('*.', 'asDirs', 'DO'); 124 if rc <> 0 then do 125 say 'SysFileTree failed rc='rc; 126 exit(rc); 131 end 132 133 /* sanity check */ 134 if (fLocking & \fCD) then 135 do 136 say '-l (Locking) requires -cd to be specified!'; 137 call syntax; 138 end 139 140 /* process directories */ 141 rc = SysFileTree('*.', 'asDirs', 'DO'); 142 if rc <> 0 then do 143 say sClrErr||'SysFileTree failed rc='rc||sClrRst; 144 exit(rc); 145 end 146 147 sArgDirs = ' '; 148 do ii = 1 to asDirs.0 149 /* calculate index */ 150 if (fReverse) then 151 i = asDirs.0 - ii + 1; 152 else 153 i = ii; 154 155 /* ignore the directory? */ 156 fFound = 0; 157 do j = 1 to asIgnore.0 158 if translate(asIgnore.j) = translate(filespec('name', asDirs.i)) then 159 do 160 fFound = 1; 161 leave; 162 end 127 163 end 128 164 129 sArgDirs = ' '; 130 do ii = 1 to asDirs.0 131 /* calculate index */ 132 if (fReverse) then 133 i = asDirs.0 - ii + 1; 165 if \fFound then 166 do 167 /* switch execution type. */ 168 if (fCD) then 169 do 170 /* exectute the command in the directory */ 171 say sClrMak||'[Entering directory:' asDirs.i']'||sClrRst; 172 /* save old dir and enter the new dir. */ 173 sOldDir = directory(); 174 call directory asDirs.i; 175 176 /* Lock the directory? */ 177 fOK = 1; 178 if (fLocking) then 179 if (\lockdir(sLockTag)) then 180 do 181 if (fExitOnLock) then 182 do 183 /* restore old directory and return sucessfully */ 184 call directory sOldDir; 185 say '[ !Lock found, stops processing.]'; 186 exit(0); 187 end 188 say sClrMak||'[ !Skipping ' || asDirs.i || ' - directory was locked.]'||sClrRst; 189 fOK = 0; 190 end 191 192 /* continue only if locking was successful. */ 193 if (fOK) then 194 do 195 /* execute command */ 196 'call' sCmds; 197 ret = rc; 198 199 /* unlock directory */ 200 if (fLocking & fOk) then 201 call unlockdir sLockTag; 202 203 /* check for return? */ 204 if (ret <> 0) then 205 do 206 /* complain and fail if errors aren't ignored. */ 207 if (\fIgnoreFailure) then 208 do 209 say sClrErr||'[ - rc = 'ret' ' || asDirs.i || ']'||sClrErr; 210 exit(rc); 211 end 212 say '[ - rc = 'ret' ' || asDirs.i || ']'; 213 end 214 end 215 216 /* restore old directory */ 217 say sClrMak||'[Leaving directory:' directory()']'||sClrRst; 218 call directory sOldDir; 219 end 134 220 else 135 i = ii; 136 137 /* ignore the directory? */ 138 fFound = 0; 139 do j = 1 to asIgnore.0 140 if translate(asIgnore.j) = translate(filespec('name', asDirs.i)) then 221 do 222 /* execute the command with the directory as the last parameter */ 223 'call' sCmds filespec('name', asDirs.i); 224 if (rc <> 0) then 141 225 do 142 fFound = 1; 143 leave; 144 end 145 end 146 147 if \fFound then 148 do 149 /* switch execution type. */ 150 if (fCD) then 151 do 152 /* exectute the command in the directory */ 153 say '[Entering directory:' asDirs.i']'; 154 /* save old dir and enter the new dir. */ 155 sOldDir = directory(); 156 call directory asDirs.i; 157 158 /* Lock the directory? */ 159 fOK = 1; 160 if (fLocking) then 161 if (\lockdir(sLockTag)) then 162 do 163 if (fExitOnLock) then 164 do 165 /* restore old directory and return sucessfully */ 166 call directory sOldDir; 167 say '[ !Lock found, stops processing.]'; 168 exit(0); 169 end 170 say '[ !Skipping ' || asDirs.i || ' - directory was locked.]'; 171 fOK = 0; 172 end 173 174 /* continue only if locking was successful. */ 175 if (fOK) then 176 do 177 /* execute command */ 178 'call' sCmds; 179 ret = rc; 180 181 /* unlock directory */ 182 if (fLocking & fOk) then 183 call unlockdir sLockTag; 184 185 /* check for return? */ 186 if (ret <> 0) then 187 do 188 /* complain and fail if errors aren't ignored. */ 189 say '[ - rc = 'ret' ' || asDirs.i || ']'; 190 if (\fIgnoreFailure) then 191 exit(rc); 192 end 193 end 194 195 /* restore old directory */ 196 say '[Leaving directory:' directory()']' 197 call directory sOldDir; 198 end 199 else 200 do 201 /* execute the command with the directory as the last parameter */ 202 'call' sCmds filespec('name', asDirs.i); 203 if (rc <> 0) then 204 do 205 say '[ - rc = ' || rc']'; 206 if (\fIgnoreFailure) then 207 exit(rc); 208 end 209 end 210 end /* loop */ 211 end 212 213 exit(rc); 226 say '[ - rc = ' || rc']'; 227 if (\fIgnoreFailure) then 228 exit(rc); 229 end 230 end 231 end /* loop */ 232 end 233 234 exit(rc); 214 235 215 236
Note:
See TracChangeset
for help on using the changeset viewer.
