A Tour of the ast Commands and Libraries
Glenn Fowler AT&T Labs - Research Murray Hill, NJ 07974
bin executable binaries and scripts fun ksh93 shell functions lib libraries lib/command related files for command src/cmd/xxx source for command xxx src/lib/libxxx source for library xxxTo access the commands and related data files:
export PATH=$INSTALLROOT/bin:$PATHFor each command that has a related data file file, file is found by searching $PATH for e.g., the magic file for the file command is ../lib/file/magic on $PATH. If $HOME/bin is before $INSTALLROOT/bin in $PATH then you can selectively override standard ast related files by placing them in the directory This allows executables to be built without hard-coded pathnames and also requires only a change in $PATH when $INSTALLROOT changes. On systems with shared libraries one of
export LD_LIBRARY_PATH=$INSTALLROOT/lib:$LD_LIBRARY_PATH export LIBPATH=$INSTALLROOT/lib:$LIBPATH export LPATH=$INSTALLROOT/lib:$LPATHis required to locate the ast shared libraries.
tw -d / -e "uid=='root' && (mode&'u+s') && parent.uid!=uid"to change the owner of all of bozo's files:
tw -d / -e "uid=='bozo'" chown clown:circustw collects file pathname arguments up to the exec arg limit before it executes the command. For paranoid users:
tw chmod go-rwxwhich is equivalent to:
chmod -R go-rwx(Now you don't need to add a -R option to your favorite commands.) To find all source files that include foo.h:
tw -e "name=='*.[chly]'" grep -l '^#.*include.*["<]foo.h[>"]'libast handles the magic number matching for the file command. The magic file, $INSTALLROOT/lib/file/magic, is carefully constructed to give the same output across all architectures:
cd $HOME/arch file */bin/catmight produce:
att.i386/bin/cat: elf i386 executable, 32-bit, little-endian, .. bsd.i386/bin/cat: bsd 386 executable, compact, paged, pure, no.. hp.pa/bin/cat: hp pa-risc executable, shared, dynamically l.. sgi.mips2/bin/cat: elf mips executable, 32-bit, dynamically lin.. sol.sun4/bin/cat: elf sparc executable, 32-bit, dynamically li.. sun4/bin/cat: sun sparc executable, paged, dynamically lin..tw uses the same interface, making it easy to search for files based on type, name and content. The following searches for executable scripts:
tw -e "(mode&'+x') && type!=DIR && magic!='*executable*'"The tw algorithm efficiently detects file system loops, so following symbolic links is not a problem. The same algorithm is used by all ast commands that traverse directory hierarchies, and the following options to control pathname resolution:
-L (logical) follow symbolic links -P (physical) don't follow symbolic links -H (metaphysical) -L for command line files, -P otherwiseThe ksh93 getconf builtin controls the default traversal mode:
getconf PATH_RESOLVE - { logical, physical, metaphysical }
April 18, 1997