Re: [ Attn: Randy ] Ad-hoc Parsing?

From: Herbert Kleebauer (klee_at_unibwm.de)
Date: 12/23/04


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.



Relevant Pages

  • Re: How to get the application path
    ... Why do you limit this to "Unix"? ... shell process waiting until the the binary proper returns. ... Could you tell me the equivalent of my script in CMD.exe? ... installation location in the registry and how I ...
    (comp.lang.ada)
  • Re: [ Attn: Randy ] Ad-hoc Parsing?
    ... > within the script whereas sed.exe is a separate file on ... > when the external program is available). ... >>Because the Windows shell has inadequate quoting facilities. ... One can in Unix. ...
    (alt.lang.asm)
  • Re: How to get the application path
    ... Why do you limit this to "Unix"? ... shell process waiting until the the binary proper returns. ... Could you tell me the equivalent of my script in CMD.exe? ... Application paths in Windows are supposed to be set in the registry; ...
    (comp.lang.ada)
  • comp.unix.shell FAQ - Answers to Frequently Asked Questions
    ... It spells "unix" in lower case letters ... The other level is how to write shell scripts. ... than standard unix utilities, it should be included in this FAQ. ... How do I get a script to update my current environment? ...
    (comp.unix.shell)
  • Re: perl Vs Shell
    ... Can we write a perl script which does all the activities of a shell ... While Perl can be used to 'replace' shell scripts, ... calling external programs, then portability has nothing to do with it. ...
    (comp.lang.perl.misc)

Loading