Re: [ Attn: Randy ] Ad-hoc Parsing?
From: Herbert Kleebauer (klee_at_unibwm.de)
Date: 12/23/04
- Next message: T.M. Sommers: "Re: Seeking scoring advice"
- Previous message: Randall Hyde: "Seeking scoring advice"
- In reply to: C: "Re: [ Attn: Randy ] Ad-hoc Parsing?"
- Next in thread: Percival: "Re: [ Attn: Randy ] Ad-hoc Parsing?"
- Reply: Percival: "Re: [ Attn: Randy ] Ad-hoc Parsing?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Dec 2004 20:34:21 +0100
C wrote:
> Herbert Kleebauer wrote:
> > And if an assembler program can do it, than also a batch script can do it,
> > because you can embed the program within the batch code.
>
> Yes, but the resulting code will be effectively unmaintainable --
> therefore you loose the primary advantage of writing a script and may
The opposite is true. To put some functions in a black box
makes the rest of the code better maintainable. If you have
to do some text manipulation, the script is much cleaner if
you use sed instead of doing the string manipulation with the
limited abilities of the shell itself. And for the readability
it doesn't matter whether sed is a program somewhere on the
hard disk or a black box of program code embedded within the
script.
> Well lets have a look...
>
> > @echo off
> > for /f %%i in ('dir /b /ad ^|findstr ^^^^[^^^^_]') do (
>
> 'findstr' is an external programme -- by your 'rules' we cannot
> use external programmes (even common ones such as grep, sed or awk)
> in Unix so you should not use them in DOS to get functionality
> matching Unix.
That's funny. You use six external programs ('tidy', 'make-make',
'make', 'nasm', 'ld' and 'strip') in your script and care about
findstr? Normally I would have used a simple IF statement to compare
the first letter with "_" (which makes the code even better readable),
but used findstr instead to avoid an answer like: "Not even regular
expression support in Windows?".
> > for %%j in (*.asm) do (
> > echo ../_tools/make-make -p../_macro/ -g${%%j}.o $p ^
> > -c "nasm -felf -O999v -I../_macro/ -l${%%j}.lst $p" ^
>
> That results in the files 'file.asm.o', you should be getting
> 'file.o', ie. the extension is not being removed correctly.
Did only adopt the control structures and not the parameters
of your external programs (did also not change the / to \).
CMD allows direct access to the parts of a file name (drive,
path, name, extension), so this is trivial.
> > ^| make -f /dev/stdin)
> > cd ..)
> >
> > echo ld -shared -E -x -O3 -T _link ^
> > --dynamic-linker /lib/ld-linux.so.2 -o libigltk.so
> -soname=libigltk.so.0 ^
> > /usr/X11R6/lib/libX11.so.6 [^_]*/*.o
>
> That gets the file list wrong, you cannot expect a programme to
> expand "[^_]*/*.o" itself -- the results would be too inconsistant.
We already had this discussion that in this case Windows is
superior to unix, because the wildcard expansion is done by the
program and not by the shell, which is much more flexible.
But if the shell should do it, no problem, insert a for
loop to collect all names.
- Next message: T.M. Sommers: "Re: Seeking scoring advice"
- Previous message: Randall Hyde: "Seeking scoring advice"
- In reply to: C: "Re: [ Attn: Randy ] Ad-hoc Parsing?"
- Next in thread: Percival: "Re: [ Attn: Randy ] Ad-hoc Parsing?"
- Reply: Percival: "Re: [ Attn: Randy ] Ad-hoc Parsing?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|