Usage: Foreach
FILE/S,LINE/S,Strings/M/A,DO=Command/K/A,ALL=ALLFILES/S,LF=AddLF/S,V=VERBOSE/S,F
REESTACK/S,FA=FailAt/K/N
Execute "command" for every word in "strings".
A "%s" in "command" will be replaced with the current word in "strings".
If a command returned an error, the execution gets aborted!
If you specify FILE on the commandline every word in "strings" is treated as a
file
incl. pattern matching! Non existing files are skipped.
f.e. Foreach FILE "ram:#?" "sys:#?" DO "echo %s"
I use it in combination with my ecx-script to compile multiple sources with one
command.
Its written in AmigaE with the ecx compiler by Leif Salomonsson!
I also included a 68k and AmigaOS4 version.
History:
05-Sep-16: v1.9
fix: a small fix with OR handling
24-Mai-16: v1.8
fix: Foreach didn't hold the Result2 value anymore due to recently changes
new: ENV:Foreach_LastFile holds the last processed filename
usefull f.e. if you want to get the filename which aborts the execution
14-Mai-16: v1.7
new: added a FailAt/K/N option, like Shell's FailAt commmand, to change
failure limit of executed commands (0=Ok, 5=Warn, 10=Error, 20=Fail)
To NOT abort execution if only one file throws an error
Default is 10
13-Dez-15:
fix: Starting Foreach with no arguments printed many bogus chars
30-Mar-15: v1.6
new: added LINE/S, to do a command for every line in a file
The files are specified via the "<strings>" options.
Multiple files and pattern matching are supported and the ALL option
fix: Sometimes the ALL/S switch to return recursively all files didn't worked
correct
23-Dec-14: v1.5
fix: option VERBOSE/S didn't prints the argument in front of the output
sometimes,
f.e. if c:Type was used
new: added FREESTACK/S option to show the free stack, only for debugging
purpose
new: you can now use upto 8 "%s" in the DO option
11-Mar-14: v1.4
chg: Raised stack to 32KB, cause I have some weird hits sometimes, lets see if
it helps...
05-Aug-13: v1.3
chg: The VERBOSE option now prints the current argument in front of the output
new: added LF=AddLF/S switch, append a LF after the commands output.
Usefull if the command doesn't outputs an LF at the end
01-Aug-13: v1.2
new: added ALL=ALLFILES/S switch, to recursively scan directories, if FILE is
set
fix: if FILE is set, then don't execute the command for directories
09-Jul-13: v1.1
new: added a FILE/S switch, "strings" are then treated as files, incl. pattern
matching!
01-Jul-13: v1.0 first release
|