Oleg Verych
2007-Oct-19 08:37 UTC
[klibc] Size and performance efficient rewriting of the `dash.test` built-in
== Proposition A. Do not implement `-a' and `-o'. = Why. 1. Most of the `test` usage is 2 or 3 arg. ops. 2. Issues (and possible `||', `&&' substitutions), described in [0] [0] http://www.opengroup.org/onlinepubs/000095399/utilities/test.html 3. In case of usage of it, `exec /usr/bin/test $args` can be implemented. Thus, smart users of `-a' and `-o' will have to install some kind of external `test` or `[`, e.g. GNU coreutils.>From the point of view of my current state of the rewrite, i haveeverything open coded and unrolled, very size and speed optimized. Making any kind of recursive implementation for `-a' && `-o' *and* thus `\(', `\)', will cause me to copy same stuff in functions (i have room for that) or replacing current things with those functions, which is ugly and more work on testing. == Proposition B. Extend `-ot' and `-nt' to check a list of files. = This are not POSIX ops, described in [0] as to be not included from original KornShell, due to not including `[[' semantics. Nonetheless, they are present in `dash` and in other implementations. Maybe because of [0]: Additional implementation-defined operators and primary_operators may be provided by implementations. They shall be of the form - operator where the first character of operator is not a digit. Now, i want to add something like this: #!/bin/dash cd /mnt/path/to/src test file.c -ot [ utils/foo.c include/bar.h ] && do_update [ file.c -nt [ utils/foo.c include/bar.h ] ] || do_nothing test vmlinux.o -nt [ $DEP_LIST ] || do_something #shend When using parameter, IFS can split any kind of list separation, so list syntax, basically, is not that much important. Why. Because of my intention of getting rid of the `make` based built system(s). It was discussed many time by many people. The Linux kernel kbuild/kconfig flame wars ended without any positive result. In addition to that, any kind of smart up-to-date heuristics can be scripted easily. This change is not going to be major, because now it is possible to multiply calls or using `-a' || `-o'. But going to be very good optimization for such kinds of applications. It doesn't introduce hidden incompatibilities or buggy usage. Using can be done only in small, specific areas, such as `klibc'. Square braces `[' && `]' proposed, because they not require escaping from the shell. -- -o--=O`C #oo'L O <___=E M
Herbert Xu
2007-Oct-19 09:26 UTC
[klibc] Size and performance efficient rewriting of the `dash.test` built-in
Oleg Verych <olecom at flower.upol.cz> wrote:> > == Proposition A. Do not implement `-a' and `-o'. =I sympathise with your view Oleg. Indeed, if you raised this a few years back I'd have removed it with no hesitation :) Unfortunately these days there are too many systems that already use dash out there (mostly Debian + Ubuntu) that have loads of scripts on them that use -a or -o. There's no way that we can get away with just breaking these scripts.> == Proposition B. Extend `-ot' and `-nt' to check a list of files. => > This are not POSIX ops, described in [0] as to be not included from > original KornShell, due to not including `[[' semantics. > > Nonetheless, they are present in `dash` and in other implementations. > Maybe because of [0]: > > Additional implementation-defined operators and primary_operators > may be provided by implementations. They shall be of the form - > operator where the first character of operator is not a digit. > > Now, i want to add something like this: > > #!/bin/dash > cd /mnt/path/to/src > > test file.c -ot [ utils/foo.c include/bar.h ] && do_update > [ file.c -nt [ utils/foo.c include/bar.h ] ] || do_nothing > > test vmlinux.o -nt [ $DEP_LIST ] || do_somethingIt looks neat but I'm not convinced that we need this feature. I have two reasons for this: 1) This can just as easily be done in a script: { [ file.c -ot utils/foo.c ] || [ file.c -ot include/bar.h ]; } && do_update { [ file.c -nt utils/foo.c ] && [ file.c -nt include/bar.h ]; } || do_nothing for i in $DEP_LIST; do [ vmlinux.o -nt "$i" ] || ! break done || do_something You can probably write a shell function that implemented this in the syntax you want. 2) POSIX does not require this. In other words, I would consider a new feature for dash if it is either required by POSIX or if it's useful enough and that it can't easily be done using existing shell primitives. Thanks, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} <herbert at gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt