mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-31 04:45:39 +01:00
Compare commits
120
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
606cad63e0 | ||
|
|
da00f4efc2 | ||
|
|
32521d32d0 | ||
|
|
1df7c9c31d | ||
|
|
f241006773 | ||
|
|
43afd0bf1c | ||
|
|
74435f8eb3 | ||
|
|
6b73bc0356 | ||
|
|
7cf9efac69 | ||
|
|
970d5bae18 | ||
|
|
1e6d5626c8 | ||
|
|
bcce53dd34 | ||
|
|
a26e715d37 | ||
|
|
4fcbd8c517 | ||
|
|
882db38555 | ||
|
|
9d9668a3f2 | ||
|
|
8d8602badd | ||
|
|
1def6ae0d1 | ||
|
|
896ecc9a30 | ||
|
|
52d36a71f1 | ||
|
|
58a89d2d23 | ||
|
|
dbab9c6029 | ||
|
|
c99fcd78ed | ||
|
|
1e8b639eba | ||
|
|
8510587725 | ||
|
|
7d08752b0e | ||
|
|
18731eb4b9 | ||
|
|
1279beffe8 | ||
|
|
32e9c3c95d | ||
|
|
0925ddc26f | ||
|
|
bb581dec3c | ||
|
|
915446aa4a | ||
|
|
9c65783076 | ||
|
|
49c68b4b0d | ||
|
|
a0bccd8472 | ||
|
|
e6d6e4a290 | ||
|
|
814e9babff | ||
|
|
42884803ec | ||
|
|
d4f3f321a2 | ||
|
|
9b754369c0 | ||
|
|
ed2ab96198 | ||
|
|
49e842606b | ||
|
|
ee1754104e | ||
|
|
9d15ac2014 | ||
|
|
c867c8b833 | ||
|
|
4287d70395 | ||
|
|
1259db48a3 | ||
|
|
26687284d9 | ||
|
|
3dcc89db84 | ||
|
|
94a5228bc6 | ||
|
|
831b94a0a8 | ||
|
|
94aabdf0f0 | ||
|
|
5df5dfdee1 | ||
|
|
1122e55277 | ||
|
|
a303f06e5b | ||
|
|
104628a2ae | ||
|
|
9e2f957e5a | ||
|
|
b9214dfb5f | ||
|
|
958d51720e | ||
|
|
3fb61e5330 | ||
|
|
ef218d763b | ||
|
|
f586cc6b49 | ||
|
|
706d15887a | ||
|
|
4f97efb6bf | ||
|
|
48a5b0fd6f | ||
|
|
181e50d2d2 | ||
|
|
a0e41bfba0 | ||
|
|
5ee43a7150 | ||
|
|
527d1e545b | ||
|
|
d3272a1036 | ||
|
|
db0a3b0996 | ||
|
|
b8fd368d37 | ||
|
|
4ffec030cc | ||
|
|
b6b197f3ec | ||
|
|
94bc73d703 | ||
|
|
8b16a3e13f | ||
|
|
0530043136 | ||
|
|
23f4913235 | ||
|
|
1972241807 | ||
|
|
77897c7469 | ||
|
|
1c9e602cfc | ||
|
|
db7425715e | ||
|
|
c5da444134 | ||
|
|
bc3f1177e9 | ||
|
|
ccb3cc5657 | ||
|
|
5ce1ad7a0c | ||
|
|
cea81f798b | ||
|
|
e386cb2e50 | ||
|
|
0c4ed717bc | ||
|
|
42a7770592 | ||
|
|
b7c917e9fa | ||
|
|
806fe6d23c | ||
|
|
fc9e8f4340 | ||
|
|
7fde5307de | ||
|
|
87e637e2df | ||
|
|
43b09ad426 | ||
|
|
0bc95402c8 | ||
|
|
212d3e48d9 | ||
|
|
99b47403d8 | ||
|
|
2a92ef7ded | ||
|
|
4a08d5ba45 | ||
|
|
e8e9a92bbd | ||
|
|
775326df3d | ||
|
|
d6ff0fd311 | ||
|
|
ad65ee2a34 | ||
|
|
d155565e32 | ||
|
|
4804a5ef45 | ||
|
|
9851eed6f3 | ||
|
|
eeaeb5b79a | ||
|
|
c52ce4bcc2 | ||
|
|
151e79b844 | ||
|
|
21eca5f815 | ||
|
|
5205c1aaa2 | ||
|
|
1ed30f6426 | ||
|
|
0a379c9386 | ||
|
|
5ebecde547 | ||
|
|
e4de098331 | ||
|
|
423c6ff15d | ||
|
|
26859bad80 | ||
|
|
b7a5a03069 |
No files matched your search
@@ -30,7 +30,9 @@
|
||||
# tree. This makefile executes a child make process, forcing it to use
|
||||
# the mk files from the source tree which are supposed to DTRT.
|
||||
#
|
||||
# The user-driven targets (as listed above) are implemented in Makefile.inc1.
|
||||
# The user-driven targets (as listed above) are implemented in Makefile.inc0
|
||||
# and the private targets are in Makefile.inc1. These are kept separate
|
||||
# to help the bootstrap build from aout to elf format.
|
||||
#
|
||||
# If you want to build your system from source be sure that /usr/obj has
|
||||
# at least 400MB of diskspace available.
|
||||
@@ -63,11 +65,6 @@
|
||||
# release of 4.0. You have exactly one major release to move entirely
|
||||
# to elf.
|
||||
#
|
||||
# If TARGET_ARCH=arch (e.g. alpha) is specified you can
|
||||
# cross build world for other architectures using the buildworld target,
|
||||
# and once the world is built you can cross build a kernel using the
|
||||
# buildkernel target.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# Upgrading an i386 system from a.out to elf format
|
||||
@@ -96,19 +93,11 @@
|
||||
# Define the user-driven targets. These are listed here in alphabetical
|
||||
# order, but that's not important.
|
||||
#
|
||||
TGTS= all all-man buildkernel buildworld checkdpadd clean \
|
||||
cleandepend cleandir depend distribute distributeworld everything \
|
||||
hierarchy install installcheck installkernel \
|
||||
reinstallkernel installmost installworld libraries lint maninstall \
|
||||
mk most obj objlink regress rerelease tags update
|
||||
|
||||
BITGTS= files includes
|
||||
BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
|
||||
|
||||
.ORDER: buildworld installworld
|
||||
.ORDER: buildworld distributeworld
|
||||
.ORDER: buildkernel installkernel
|
||||
.ORDER: buildkernel reinstallkernel
|
||||
TGTS= afterdistribute all all-man buildkernel buildworld checkdpadd clean \
|
||||
cleandepend cleandir depend distribute everything hierarchy includes \
|
||||
install installcheck installkernel installmost installworld kernel \
|
||||
libraries lint maninstall mk most obj objlink regress \
|
||||
reinstallkernel rerelease tags update
|
||||
|
||||
PATH= /sbin:/bin:/usr/sbin:/usr/bin
|
||||
MAKE= PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
|
||||
@@ -116,7 +105,7 @@ MAKE= PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
|
||||
#
|
||||
# Handle the user-driven targets, using the source relative mk files.
|
||||
#
|
||||
${TGTS} ${BITGTS}: upgrade_checks
|
||||
${TGTS}: upgrade_checks
|
||||
@cd ${.CURDIR}; \
|
||||
${MAKE} ${.TARGET}
|
||||
|
||||
@@ -155,13 +144,6 @@ world: upgrade_checks
|
||||
@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n (started ${STARTTIME})\n"
|
||||
@echo "--------------------------------------------------------------"
|
||||
|
||||
#
|
||||
# kernel
|
||||
#
|
||||
# Short hand for `make buildkernel installkernel'
|
||||
#
|
||||
kernel: buildkernel installkernel
|
||||
|
||||
#
|
||||
# Perform a few tests to determine if the installed tools are adequate
|
||||
# for building the world. These are for older systems (prior to 2.2.5).
|
||||
@@ -172,26 +154,15 @@ kernel: buildkernel installkernel
|
||||
#
|
||||
upgrade_checks:
|
||||
@cd ${.CURDIR}; \
|
||||
if ! make -m ${.CURDIR}/share/mk -Dnotdef test >/dev/null 2>&1; then \
|
||||
make make; \
|
||||
fi
|
||||
@cd ${.CURDIR}; \
|
||||
if make -V .CURDIR:C/.// 2>&1 >/dev/null | \
|
||||
grep -q "Unknown modifier 'C'"; then \
|
||||
make make; \
|
||||
fi
|
||||
if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
|
||||
make make; \
|
||||
fi
|
||||
|
||||
#
|
||||
# A simple test target used as part of the test to see if make supports
|
||||
# the -m argument. Also test that make will only evaluate a conditional
|
||||
# as far as is necessary to determine its value.
|
||||
# the -m argument.
|
||||
#
|
||||
test:
|
||||
.if defined(notdef)
|
||||
.undef notdef
|
||||
.if defined(notdef) && ${notdef:U}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
#
|
||||
# Upgrade the installed make to the current version using the installed
|
||||
|
||||
+217
-164
@@ -76,9 +76,6 @@ SUBDIR+= libexec
|
||||
.if exists(${.CURDIR}/sbin)
|
||||
SUBDIR+= sbin
|
||||
.endif
|
||||
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
SUBDIR+= secure
|
||||
.endif
|
||||
.if exists(${.CURDIR}/share) && !defined(NOSHARE)
|
||||
SUBDIR+= share
|
||||
.endif
|
||||
@@ -91,6 +88,9 @@ SUBDIR+= usr.bin
|
||||
.if exists(${.CURDIR}/usr.sbin)
|
||||
SUBDIR+= usr.sbin
|
||||
.endif
|
||||
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
SUBDIR+= secure
|
||||
.endif
|
||||
|
||||
# etc must be last for "distribute" to work
|
||||
.if exists(${.CURDIR}/etc)
|
||||
@@ -107,10 +107,6 @@ SUBDIR+= ${_DIR}
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
.if defined(SUBDIR_OVERRIDE)
|
||||
SUBDIR= ${SUBDIR_OVERRIDE}
|
||||
.endif
|
||||
|
||||
.if defined(NOCLEANDIR)
|
||||
CLEANDIR= clean cleandepend
|
||||
.else
|
||||
@@ -125,21 +121,17 @@ SUPFLAGS+= -h ${SUPHOST}
|
||||
|
||||
MAKEOBJDIRPREFIX?= /usr/obj
|
||||
TARGET_ARCH?= ${MACHINE_ARCH}
|
||||
.if ${TARGET_ARCH} == ${MACHINE_ARCH}
|
||||
TARGET?= ${MACHINE}
|
||||
.else
|
||||
TARGET?= ${TARGET_ARCH}
|
||||
.endif
|
||||
.if make(buildworld)
|
||||
BUILD_ARCH!= sysctl -n hw.machine_arch
|
||||
.if ${MACHINE_ARCH} != ${BUILD_ARCH}
|
||||
.error To cross-build, set TARGET_ARCH.
|
||||
.endif
|
||||
.endif
|
||||
.if ${MACHINE} == ${TARGET}
|
||||
.if ${MACHINE_ARCH} == ${TARGET_ARCH}
|
||||
OBJTREE= ${MAKEOBJDIRPREFIX}
|
||||
.else
|
||||
OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
|
||||
OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET_ARCH}
|
||||
.endif
|
||||
WORLDTMP= ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
|
||||
# /usr/games added for fortune which depend on strfile
|
||||
@@ -187,8 +179,7 @@ BMAKEENV= MAKEOBJDIRPREFIX=${WORLDTMP} \
|
||||
DESTDIR= \
|
||||
INSTALL="sh ${.CURDIR}/tools/install.sh"
|
||||
BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
|
||||
-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
|
||||
-DNO_WERROR
|
||||
-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
|
||||
|
||||
# build-tool stage
|
||||
TMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE} \
|
||||
@@ -234,8 +225,8 @@ USRDIRS= usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
|
||||
usr/share/groff_font/devutf8 \
|
||||
usr/share/tmac/mdoc usr/share/tmac/mm
|
||||
|
||||
INCDIRS= arpa dev fs g++/std isc isofs libmilter objc openssl \
|
||||
protocols readline rpc rpcsvc security ufs
|
||||
INCDIRS= arpa g++/std isc objc protocols readline rpc rpcsvc openssl \
|
||||
security ss
|
||||
|
||||
#
|
||||
# buildworld
|
||||
@@ -243,17 +234,13 @@ INCDIRS= arpa dev fs g++/std isc isofs libmilter objc openssl \
|
||||
# Attempt to rebuild the entire system, with reasonable chance of
|
||||
# success, regardless of how old your existing system is.
|
||||
#
|
||||
_worldtmp:
|
||||
buildworld:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Rebuilding the temporary build tree"
|
||||
@echo "--------------------------------------------------------------"
|
||||
.if !defined(NOCLEAN)
|
||||
rm -rf ${WORLDTMP}
|
||||
.else
|
||||
# XXX - These two can depend on any header file.
|
||||
rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
|
||||
rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
|
||||
.endif
|
||||
.for _dir in ${USRDIRS}
|
||||
mkdir -p ${WORLDTMP}/${_dir}
|
||||
@@ -262,13 +249,11 @@ _worldtmp:
|
||||
mkdir -p ${WORLDTMP}/usr/include/${_dir}
|
||||
.endfor
|
||||
ln -sf ${.CURDIR}/sys ${WORLDTMP}
|
||||
_bootstrap-tools:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 1: bootstrap tools"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${BMAKE} bootstrap-tools
|
||||
_cleanobj:
|
||||
.if !defined(NOCLEAN)
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@@ -276,62 +261,47 @@ _cleanobj:
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
|
||||
.endif
|
||||
_obj:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 2: rebuilding the object tree"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} par-obj
|
||||
_build-tools:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 2: build tools"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${TMAKE} build-tools
|
||||
_cross-tools:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 3: cross tools"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${XMAKE} cross-tools
|
||||
_includes:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
|
||||
_libraries:
|
||||
cd ${.CURDIR}; ${WMAKE} SHARED=copies includes
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 4: building libraries"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
|
||||
_depend:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 4: make dependencies"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} par-depend
|
||||
everything:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 4: building everything.."
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} all
|
||||
|
||||
|
||||
WMAKE_TGTS=
|
||||
.if !defined(SUBDIR_OVERRIDE)
|
||||
WMAKE_TGTS+= _worldtmp _bootstrap-tools
|
||||
.endif
|
||||
WMAKE_TGTS+= _cleanobj _obj _build-tools
|
||||
.if !defined(SUBDIR_OVERRIDE)
|
||||
WMAKE_TGTS+= _cross-tools
|
||||
.endif
|
||||
WMAKE_TGTS+= _includes _libraries _depend everything
|
||||
|
||||
buildworld: ${WMAKE_TGTS}
|
||||
.ORDER: ${WMAKE_TGTS}
|
||||
everything:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Building everything.."
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} all
|
||||
|
||||
#
|
||||
# installcheck
|
||||
@@ -350,23 +320,19 @@ installcheck:
|
||||
fi
|
||||
.endif
|
||||
|
||||
#
|
||||
# distributeworld
|
||||
#
|
||||
# Distributes everything compiled by a `buildworld'.
|
||||
#
|
||||
# installworld
|
||||
#
|
||||
# Installs everything compiled by a 'buildworld'.
|
||||
#
|
||||
distributeworld installworld: installcheck
|
||||
installworld: installcheck
|
||||
mkdir -p ${INSTALLTMP}
|
||||
for prog in [ awk cat chflags chmod chown date echo egrep find grep \
|
||||
ln make makewhatis mtree mv perl pwd_mkdb rm sed sh sysctl \
|
||||
ln make makewhatis mtree mv perl rm sed sh sysctl \
|
||||
test true uname wc zic; do \
|
||||
cp `which $$prog` ${INSTALLTMP}; \
|
||||
done
|
||||
cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
|
||||
cd ${.CURDIR}; ${IMAKE} reinstall
|
||||
rm -rf ${INSTALLTMP}
|
||||
|
||||
#
|
||||
@@ -386,7 +352,7 @@ reinstall:
|
||||
@echo ">>> Installing everything.."
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
|
||||
.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
|
||||
.if !defined(NOMAN)
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Rebuilding man page indices"
|
||||
@@ -394,11 +360,14 @@ reinstall:
|
||||
cd ${.CURDIR}/share/man; ${MAKE} makedb
|
||||
.endif
|
||||
|
||||
redistribute:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Distributing everything.."
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
|
||||
#
|
||||
# distribworld
|
||||
#
|
||||
# Front-end to distribute to make sure the search path contains
|
||||
# the object directory. Needed for miniperl.
|
||||
#
|
||||
distribworld:
|
||||
cd ${.CURDIR}; PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 distribute
|
||||
|
||||
#
|
||||
# buildkernel and installkernel
|
||||
@@ -422,6 +391,13 @@ KERNCONF?= GENERIC
|
||||
.endif
|
||||
INSTKERNNAME?= kernel
|
||||
|
||||
# The only exotic TARGET_ARCH/TARGET combination valid at this
|
||||
# time is i386/pc98. In all other cases set TARGET equal to
|
||||
# TARGET_ARCH.
|
||||
.if ${TARGET_ARCH} != "i386" || ${TARGET} != "pc98"
|
||||
TARGET= ${TARGET_ARCH}
|
||||
.endif
|
||||
|
||||
KRNLSRCDIR= ${.CURDIR}/sys
|
||||
KRNLCONFDIR= ${KRNLSRCDIR}/${TARGET}/conf
|
||||
KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR}
|
||||
@@ -466,16 +442,17 @@ buildkernel:
|
||||
config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} ${_kernel}
|
||||
.endif
|
||||
.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
|
||||
.if defined(MODULES_WITH_WORLD) || defined(NO_MODULES) || !exists(${KRNLSRCDIR}/modules)
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
|
||||
.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} clean
|
||||
.else
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} clean cleandir
|
||||
.endif
|
||||
.endif
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
|
||||
${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
|
||||
MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
|
||||
${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
|
||||
.if !defined(NO_KERNELDEPEND)
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
|
||||
@@ -492,9 +469,19 @@ buildkernel:
|
||||
#
|
||||
# Install the kernel defined by INSTALLKERNEL
|
||||
#
|
||||
installkernel reinstallkernel:
|
||||
installkernel:
|
||||
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
|
||||
${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
|
||||
${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} install
|
||||
reinstallkernel:
|
||||
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
|
||||
${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
|
||||
|
||||
#
|
||||
# kernel
|
||||
#
|
||||
# Short hand for `make buildkernel installkernel'
|
||||
#
|
||||
kernel: buildkernel installkernel
|
||||
|
||||
#
|
||||
# update
|
||||
@@ -527,7 +514,7 @@ update:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
|
||||
cd ${.CURDIR}; cvs -q update -rRELENG_4_6 -P -d
|
||||
.endif
|
||||
|
||||
#
|
||||
@@ -539,9 +526,14 @@ most:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Building programs only"
|
||||
@echo "--------------------------------------------------------------"
|
||||
.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
|
||||
cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ all
|
||||
.endfor
|
||||
cd ${.CURDIR}/bin; ${MAKE} all
|
||||
cd ${.CURDIR}/sbin; ${MAKE} all
|
||||
cd ${.CURDIR}/libexec; ${MAKE} all
|
||||
cd ${.CURDIR}/usr.bin; ${MAKE} all
|
||||
cd ${.CURDIR}/usr.sbin; ${MAKE} all
|
||||
cd ${.CURDIR}/gnu/libexec; ${MAKE} all
|
||||
cd ${.CURDIR}/gnu/usr.bin; ${MAKE} all
|
||||
cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} all
|
||||
|
||||
#
|
||||
# installmost
|
||||
@@ -553,9 +545,14 @@ installmost:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Installing programs only"
|
||||
@echo "--------------------------------------------------------------"
|
||||
.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
|
||||
cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ install
|
||||
.endfor
|
||||
cd ${.CURDIR}/bin; ${MAKE} install
|
||||
cd ${.CURDIR}/sbin; ${MAKE} install
|
||||
cd ${.CURDIR}/libexec; ${MAKE} install
|
||||
cd ${.CURDIR}/usr.bin; ${MAKE} install
|
||||
cd ${.CURDIR}/usr.sbin; ${MAKE} install
|
||||
cd ${.CURDIR}/gnu/libexec; ${MAKE} install
|
||||
cd ${.CURDIR}/gnu/usr.bin; ${MAKE} install
|
||||
cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} install
|
||||
|
||||
#
|
||||
# ------------------------------------------------------------------------
|
||||
@@ -576,16 +573,14 @@ _strfile= games/fortune/strfile
|
||||
.endif
|
||||
|
||||
bootstrap-tools:
|
||||
.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef \
|
||||
usr.bin/uudecode usr.bin/xinstall \
|
||||
.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.bin/xinstall \
|
||||
usr.sbin/config \
|
||||
gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo
|
||||
${ECHODIR} "===> ${_tool}"; \
|
||||
cd ${.CURDIR}/${_tool}; \
|
||||
${MAKE} DIRPRFX=${_tool}/ obj; \
|
||||
${MAKE} DIRPRFX=${_tool}/ depend; \
|
||||
${MAKE} DIRPRFX=${_tool}/ all; \
|
||||
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
|
||||
cd ${.CURDIR}/${_tool}; \
|
||||
${MAKE} obj; \
|
||||
${MAKE} depend; \
|
||||
${MAKE} all; \
|
||||
${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
|
||||
.endfor
|
||||
|
||||
#
|
||||
@@ -614,20 +609,13 @@ _libroken4= kerberosIV/lib/libroken
|
||||
|
||||
.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
|
||||
!defined(NOCRYPT) && defined(MAKE_KERBEROS5)
|
||||
_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
|
||||
kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
|
||||
.endif
|
||||
|
||||
.if defined(RELEASEDIR)
|
||||
_sysinstall= release/sysinstall
|
||||
_libkrb5= kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
|
||||
.endif
|
||||
|
||||
build-tools:
|
||||
.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
|
||||
${_perl} ${_libroken4} ${_libkrb5} lib/libncurses ${_share} \
|
||||
usr.bin/awk usr.bin/file ${_sysinstall}
|
||||
${ECHODIR} "===> ${_tool}"; \
|
||||
cd ${.CURDIR}/${_tool}; ${MAKE} DIRPRFX=${_tool}/ build-tools
|
||||
${_perl} ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.bin/file
|
||||
cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
|
||||
.endfor
|
||||
|
||||
#
|
||||
@@ -642,15 +630,13 @@ _btxld= usr.sbin/btxld
|
||||
.endif
|
||||
|
||||
cross-tools:
|
||||
.for _tool in ${_btxld} ${_elf2exe} usr.bin/genassym usr.bin/gensetdefs \
|
||||
gnu/usr.bin/binutils usr.bin/objformat usr.sbin/crunch/crunchide \
|
||||
gnu/usr.bin/cc
|
||||
${ECHODIR} "===> ${_tool}"; \
|
||||
cd ${.CURDIR}/${_tool}; \
|
||||
${MAKE} DIRPRFX=${_tool}/ obj; \
|
||||
${MAKE} DIRPRFX=${_tool}/ depend; \
|
||||
${MAKE} DIRPRFX=${_tool}/ all; \
|
||||
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
|
||||
.for _tool in ${_btxld} ${_elf2exe} usr.bin/genassym \
|
||||
usr.bin/gensetdefs gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
|
||||
cd ${.CURDIR}/${_tool}; \
|
||||
${MAKE} obj; \
|
||||
${MAKE} depend; \
|
||||
${MAKE} all; \
|
||||
${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
|
||||
.endfor
|
||||
|
||||
#
|
||||
@@ -659,96 +645,163 @@ cross-tools:
|
||||
hierarchy:
|
||||
cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
|
||||
|
||||
#
|
||||
# includes - possibly generate and install the include files.
|
||||
#
|
||||
includes:
|
||||
cd ${.CURDIR}/include; ${MAKE} -B all install
|
||||
cd ${.CURDIR}/gnu/include; ${MAKE} install
|
||||
cd ${.CURDIR}/gnu/lib/libmp; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libobjc; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libreadline/readline; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libregex; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libstdc++; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libdialog; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/lib/libgmp; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus; ${MAKE} beforeinstall
|
||||
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
.if exists(${.CURDIR}/secure/lib/libcrypto)
|
||||
cd ${.CURDIR}/secure/lib/libcrypto; ${MAKE} beforeinstall
|
||||
.endif
|
||||
.if exists(${.CURDIR}/secure/lib/libssl)
|
||||
cd ${.CURDIR}/secure/lib/libssl; ${MAKE} beforeinstall
|
||||
.endif
|
||||
.endif
|
||||
.if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
|
||||
defined(MAKE_KERBEROS4)
|
||||
cd ${.CURDIR}/kerberosIV/lib/libacl; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libkadm; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libkafs; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libkdb; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libkrb; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
|
||||
.elif exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
cd ${.CURDIR}/secure/lib/libtelnet; ${MAKE} beforeinstall
|
||||
.else
|
||||
cd ${.CURDIR}/lib/libtelnet; ${MAKE} beforeinstall
|
||||
.endif
|
||||
.if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
|
||||
defined(MAKE_KERBEROS5)
|
||||
cd ${.CURDIR}/kerberos5/lib/libasn1; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libhdb; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libkadm5clnt; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libkadm5srv; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libkafs5; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libkrb5; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/kerberos5/lib/libsl; ${MAKE} beforeinstall
|
||||
.endif
|
||||
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
|
||||
cd ${.CURDIR}/lib/csu/${MACHINE_ARCH}; ${MAKE} beforeinstall
|
||||
.endif
|
||||
cd ${.CURDIR}/gnu/lib/csu; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libalias; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libatm; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libdevstat; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libc; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libcalendar; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libcam; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libdisk; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libedit; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libfetch; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libftpio; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libkvm; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libmd; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/msun; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libncp; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libncurses; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libnetgraph; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libopie; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libpam/libpam; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libpcap; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libradius; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/librpcsvc; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libskey; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libstand; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libtacplus; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libcom_err; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libusbhid; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libutil; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libvgl; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libwrap; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/lib/libz; ${MAKE} beforeinstall
|
||||
cd ${.CURDIR}/usr.bin/lex; ${MAKE} beforeinstall
|
||||
|
||||
#
|
||||
# libraries - build all libraries, and install them under ${DESTDIR}.
|
||||
#
|
||||
# The list of libraries with dependents (${_prebuild_libs}) and their
|
||||
# interdependencies (__L) are built automatically by the
|
||||
# ${.CURDIR}/tools/make_libdeps.sh script.
|
||||
# The following dependencies exist between the libraries:
|
||||
#
|
||||
libraries:
|
||||
cd ${.CURDIR}; \
|
||||
${MAKE} -f Makefile.inc1 _startup_libs; \
|
||||
${MAKE} -f Makefile.inc1 _prebuild_libs; \
|
||||
${MAKE} -f Makefile.inc1 _generic_libs;
|
||||
|
||||
# These dependencies are not automatically generated:
|
||||
# lib*: csu libgcc_pic
|
||||
# libatm: libmd
|
||||
# libcrypt: libmd
|
||||
# libdialog: libncurses
|
||||
# libedit: libncurses
|
||||
# libg++: msun
|
||||
# libkrb: libcrypt
|
||||
# libopie: libmd
|
||||
# libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
|
||||
# libskey libtacplus libutil libz libssh
|
||||
# libradius: libmd
|
||||
# libreadline: libncurses
|
||||
# libskey: libcrypt libmd
|
||||
# libssh: libcrypto libz
|
||||
# libstc++: msun
|
||||
# libtacplus: libmd
|
||||
#
|
||||
# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
|
||||
# shared libraries for ELF.
|
||||
# Across directories this comes down to (rougly):
|
||||
#
|
||||
_startup_libs= gnu/lib/csu gnu/lib/libgcc
|
||||
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-${OBJFORMAT})
|
||||
_startup_libs+= lib/csu/${MACHINE_ARCH}-${OBJFORMAT}
|
||||
# gnu/lib: lib/msun lib/libncurses
|
||||
# kerberosIV/lib kerberos5/lib: lib/libcrypt
|
||||
# lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb \
|
||||
# secure/lib/libssh lib/libz
|
||||
# secure/lib: secure/lib/libcrypto lib/libmd lib/libz
|
||||
#
|
||||
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
|
||||
_csu= lib/csu/${MACHINE_ARCH}.pcc
|
||||
.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
|
||||
_csu= lib/csu/i386-elf
|
||||
.else
|
||||
_startup_libs+= lib/csu/${MACHINE_ARCH}
|
||||
_csu= lib/csu/${MACHINE_ARCH}
|
||||
.endif
|
||||
|
||||
_prebuild_libs=
|
||||
|
||||
_generic_libs= gnu/lib
|
||||
|
||||
.if !defined(NOPERL)
|
||||
_generic_libs+= gnu/usr.bin/perl/libperl
|
||||
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
_secure_lib= secure/lib
|
||||
.if exists(${.CURDIR}/secure/lib/libcrypto)
|
||||
_libcrypto= secure/lib/libcrypto
|
||||
.endif
|
||||
|
||||
.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
|
||||
_prebuild_libs+= kerberos5/lib/libasn1
|
||||
_prebuild_libs+= kerberos5/lib/libgssapi
|
||||
_prebuild_libs+= kerberos5/lib/libkrb5
|
||||
_prebuild_libs+= kerberos5/lib/libroken
|
||||
_generic_libs+= kerberos5/lib
|
||||
.endif
|
||||
|
||||
.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
|
||||
_prebuild_libs+= kerberosIV/lib/libkrb
|
||||
kerberosIV/lib/libkrb__L: lib/libcrypt__L
|
||||
_generic_libs+= kerberosIV/lib
|
||||
_kerberosIV_lib= kerberosIV/lib
|
||||
.endif
|
||||
|
||||
_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
|
||||
lib/libncurses lib/libopie lib/libradius lib/libskey \
|
||||
lib/libtacplus lib/libutil \
|
||||
lib/libz lib/msun
|
||||
|
||||
lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
|
||||
lib/libskey__L: lib/libcrypt__L lib/libmd__L
|
||||
|
||||
_generic_libs+= lib
|
||||
|
||||
.if !defined(NOCRYPT) && !defined(NOSECURE)
|
||||
.if !defined(NO_OPENSSL)
|
||||
_prebuild_libs+= secure/lib/libcrypto
|
||||
.if !defined(NO_OPENSSH)
|
||||
_prebuild_libs+= secure/lib/libssh
|
||||
secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
|
||||
.endif
|
||||
.endif
|
||||
_generic_libs+= secure/lib
|
||||
.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
|
||||
_kerberos5_lib= kerberos5/lib
|
||||
.endif
|
||||
|
||||
_generic_libs+= usr.bin/lex/lib
|
||||
.if !defined(NOPERL)
|
||||
_libperl= gnu/usr.bin/perl/libperl
|
||||
.endif
|
||||
|
||||
.if ${MACHINE_ARCH} == "i386"
|
||||
_generic_libs+= usr.sbin/pcvt/keycap
|
||||
_libkeycap= usr.sbin/pcvt/keycap
|
||||
.endif
|
||||
|
||||
.for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
|
||||
${_lib}__L: .PHONY
|
||||
libraries:
|
||||
.for _lib in ${_csu} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt \
|
||||
lib/libz ${_libcrypto} ${_secure_lib} ${_kerberosIV_lib} \
|
||||
${_kerberos5_lib} lib/libcom_err lib/msun lib/libncurses \
|
||||
lib/libopie lib/libradius lib/libskey lib/libtacplus lib/libutil \
|
||||
lib gnu/lib ${_libperl} usr.bin/lex/lib ${_libkeycap}
|
||||
.if exists(${.CURDIR}/${_lib})
|
||||
${ECHODIR} "===> ${_lib}"; \
|
||||
cd ${.CURDIR}/${_lib}; \
|
||||
${MAKE} DIRPRFX=${_lib}/ depend; \
|
||||
${MAKE} DIRPRFX=${_lib}/ all; \
|
||||
${MAKE} DIRPRFX=${_lib}/ install
|
||||
cd ${.CURDIR}/${_lib}; \
|
||||
${MAKE} depend; \
|
||||
${MAKE} all; \
|
||||
${MAKE} install
|
||||
.endif
|
||||
.endfor
|
||||
|
||||
_startup_libs: ${_startup_libs:S/$/__L/}
|
||||
_prebuild_libs: ${_prebuild_libs:S/$/__L/}
|
||||
_generic_libs: ${_generic_libs:S/$/__L/}
|
||||
|
||||
.for __target in clean cleandepend cleandir depend includes obj
|
||||
.for __target in clean cleandepend cleandir depend obj
|
||||
.for entry in ${SUBDIR}
|
||||
${entry}.${__target}__D: .PHONY
|
||||
@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
|
||||
|
||||
@@ -8,24 +8,76 @@ A reverse chronology since 4.0 was released is included, followed by
|
||||
the common items quick how-tos, followed by entries for versions of
|
||||
-current prior to 4.0 Release.
|
||||
|
||||
20020807:
|
||||
COPY is being deprecated. The 20020703 change was reverted, as
|
||||
it causes far more pain than was expected, and to always compare
|
||||
before installing, please use INSTALL="install -C" again. The
|
||||
-C option is now silently ignored when used with the -d option.
|
||||
This is for the 4.6 release branch. All entries since 4.6 are an
|
||||
itemized list of commits to this branch, numbered from the beginning.
|
||||
|
||||
20020704:
|
||||
OpenSSH has been upgraded to 3.4p1 and fully PAMified. Note
|
||||
that the protocol version now defaults to 2 rather than 1,
|
||||
which means clients might get warnings about unknown host keys
|
||||
their hostfiles only list the ssh1 RSA key. See ssh_config(5)
|
||||
and sshd_config(5) for more information on configuring ssh and
|
||||
sshd.
|
||||
The security advisories related to various patches contain information
|
||||
on how to build/install a minimal set of binaries and start/stop a
|
||||
minimal number of processes, if possible, for that patch. For those
|
||||
updates that don't have an advisory, or to be safe, you can do a full
|
||||
build and install as described in the COMMON ITEMS section.
|
||||
|
||||
20020703:
|
||||
The install(1) utility no longer allows the -d and -C options
|
||||
to be specified together. "INSTALL=install -C" in make.conf
|
||||
should be replaced with "COPY=-C".
|
||||
20020813: p11
|
||||
Bounds checking errors in accept(), getsockname(),
|
||||
getpeername(), and a VESA ioctl() command were corrected.
|
||||
|
||||
20020805: p10 FreeBSD-SA-02:33.openssl
|
||||
Correct a bug in the ASN.1 decoder which was introduced with
|
||||
the recent OpenSSL update.
|
||||
|
||||
20020805: p9 FreeBSD-SA-02:37.kqueue
|
||||
Registering an EVFILT_WRITE event on a pipe whose far end had
|
||||
already been closed would cause a kernel panic.
|
||||
|
||||
20020804: p8
|
||||
Bugfix for READ_BIG errors with ATAPI devices.
|
||||
|
||||
20020801: p7 FreeBSD-SA-02:36.nfs
|
||||
RPCs with zero-length payload would cause an infinite loop.
|
||||
|
||||
20020801: p6 FreeBSD-SA-02:34.rpc
|
||||
The original fix applied to the XDR decoder was in error.
|
||||
|
||||
20020731: p5 FreeBSD-SA-02:35.ffs
|
||||
A bounds checking error in FFS filesize limits was corrected.
|
||||
|
||||
20020731: p4 FreeBSD-SA-02:34.rpc
|
||||
A bounds checking error in the XDR decoder was corrected.
|
||||
|
||||
20020730: p3 FreeBSD-SA-02:33.openssl
|
||||
Upgrade to OpenSSL 0.9.6e.
|
||||
|
||||
20020730: p2 FreeBSD-SA-02:32.pppd
|
||||
A race condition in pppd(8) was corrected.
|
||||
|
||||
20020730: p1 FreeBSD-SA-02:23.stdio.v1.2
|
||||
A bug in the previous patch for the vulnerability described
|
||||
in FreeBSD-SA-02:23.stdio was found and corrected.
|
||||
|
||||
20020718:
|
||||
"Hang in atprq" bugfix for ATAPI CDROMs.
|
||||
|
||||
20020716:
|
||||
OpenSSH 3.4p1 update.
|
||||
|
||||
20020715: p3
|
||||
Upgrade to BIND 8.3.3.
|
||||
|
||||
20020714:
|
||||
pcic power bugfix.
|
||||
sendmail DNS map bugfix.
|
||||
|
||||
20020712: p2 FreeBSD-SA-02:29.tcpdump
|
||||
A buffer overflow in tcpdump has been corrected.
|
||||
|
||||
20020711: FreeBSD-SA-02:30.ktrace
|
||||
Prevent users from tracing previously privileged processes.
|
||||
|
||||
20020708:
|
||||
A tags bug in the ata(4) subsystem has been corrected.
|
||||
|
||||
20020626: p1 FreeBSD-SA-02:28.resolv
|
||||
A fix for a buffer overflow in libc has been corrected.
|
||||
|
||||
20020615:
|
||||
FreeBSD 4.6-RELEASE.
|
||||
@@ -59,9 +111,7 @@ the common items quick how-tos, followed by entries for versions of
|
||||
are very benign, some of them have created a bit of a stir.
|
||||
Use the new version of mergemaster to update /etc, either by
|
||||
updating /etc after installworld, or by doing:
|
||||
cd /usr/src/usr.sbin/mergemaster; make all install
|
||||
before you run installworld.
|
||||
|
||||
cd /usr/src/usr.sbin/mergemaster; make all install [clean]
|
||||
Then use the new -C option to double-check your rc.conf settings.
|
||||
You should also double-check settings in [defaults/]rc.conf,
|
||||
syslog.conf, newsyslog.conf, and anything else important
|
||||
@@ -97,7 +147,7 @@ the common items quick how-tos, followed by entries for versions of
|
||||
'mergemaster -p' will do this. You may need to install
|
||||
mergemaster before this will work if you are updating from a
|
||||
very old version of stable. This can be done with:
|
||||
cd /usr/src/usr.sbin/mergemaster; make all install
|
||||
cd /usr/src/usr.sbin/mergemaster; make all install [clean]
|
||||
|
||||
20020325:
|
||||
sendmail 8.12.2 has been imported. The sendmail binary is no
|
||||
|
||||
+5
-15
@@ -135,14 +135,13 @@ scanfiles(argv, cooked)
|
||||
{
|
||||
int i = 0;
|
||||
char *path;
|
||||
FILE *fp;
|
||||
|
||||
while ((path = argv[i]) != NULL || i == 0) {
|
||||
int fd;
|
||||
|
||||
if (path == NULL || strcmp(path, "-") == 0) {
|
||||
filename = "stdin";
|
||||
fd = STDIN_FILENO;
|
||||
fd = 0;
|
||||
} else {
|
||||
filename = path;
|
||||
fd = open(path, O_RDONLY);
|
||||
@@ -155,17 +154,12 @@ scanfiles(argv, cooked)
|
||||
warn("%s", path);
|
||||
rval = 1;
|
||||
} else if (cooked) {
|
||||
if (fd == STDIN_FILENO)
|
||||
cook_cat(stdin);
|
||||
else {
|
||||
fp = fdopen(fd, "r");
|
||||
cook_cat(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
FILE *fp = fdopen(fd, "r");
|
||||
cook_cat(fp);
|
||||
fclose(fp);
|
||||
} else {
|
||||
raw_cat(fd);
|
||||
if (fd != STDIN_FILENO)
|
||||
close(fd);
|
||||
close(fd);
|
||||
}
|
||||
if (path == NULL)
|
||||
break;
|
||||
@@ -179,10 +173,6 @@ cook_cat(fp)
|
||||
{
|
||||
register int ch, gobble, line, prev;
|
||||
|
||||
/* Reset EOF condition on stdin. */
|
||||
if (fp == stdin && feof(stdin))
|
||||
clearerr(stdin);
|
||||
|
||||
line = gobble = 0;
|
||||
for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
|
||||
if (prev == '\n') {
|
||||
|
||||
+19
-19
@@ -83,19 +83,19 @@ Do not display a diagnostic message if
|
||||
.Nm
|
||||
could not modify the mode for
|
||||
.Va file .
|
||||
.It Fl h
|
||||
If the file is a symbolic link, change the mode of the link itself
|
||||
rather than the file that the link points to.
|
||||
.It Fl v
|
||||
Cause
|
||||
.Nm
|
||||
to be verbose, showing filenames as the mode is modified.
|
||||
If the
|
||||
.Fl v
|
||||
flag is specified more than once, the old and new modes of the file
|
||||
will also be printed, in both octal and symbolic notation.
|
||||
to be verbose, showing files as the mode is modified.
|
||||
.El
|
||||
.Pp
|
||||
Symbolic links do not have modes, so unless the
|
||||
.Fl H
|
||||
or
|
||||
.Fl L
|
||||
option is set,
|
||||
.Nm
|
||||
on a symbolic link always succeeds and has no effect.
|
||||
The
|
||||
.Fl H ,
|
||||
.Fl L
|
||||
@@ -130,37 +130,37 @@ and the
|
||||
option to
|
||||
.Xr mount 8 .
|
||||
.It Li 2000
|
||||
(the set-group-ID-on-execution bit) Executable files with this bit set
|
||||
(the set-group-ID-on-execution bit) Executable files with this bit set
|
||||
will run with effective gid set to the gid of the file owner.
|
||||
.It Li 1000
|
||||
(the sticky bit)
|
||||
See
|
||||
.Xr chmod 2
|
||||
and
|
||||
.Xr sticky 8 .
|
||||
When set on a directory, unprivileged users can delete and rename
|
||||
only those files in the directory that are owned by them, regardless of
|
||||
the permissions on the directory. Under
|
||||
.Fx ,
|
||||
the sticky bit is
|
||||
ignored for executable files and may only be set for directories (see
|
||||
.Xr sticky 8 ) .
|
||||
.It Li 0400
|
||||
Allow read by owner.
|
||||
.It Li 0200
|
||||
Allow write by owner.
|
||||
.It Li 0100
|
||||
For files, allow execution by owner.
|
||||
For directories, allow the owner to
|
||||
For files, allow execution by owner. For directories, allow the owner to
|
||||
search in the directory.
|
||||
.It Li 0040
|
||||
Allow read by group members.
|
||||
.It Li 0020
|
||||
Allow write by group members.
|
||||
.It Li 0010
|
||||
For files, allow execution by group members.
|
||||
For directories, allow
|
||||
For files, allow execution by group members. For directories, allow
|
||||
group members to search in the directory.
|
||||
.It Li 0004
|
||||
Allow read by others.
|
||||
.It Li 0002
|
||||
Allow write by others.
|
||||
.It Li 0001
|
||||
For files, allow execution by others.
|
||||
For directories allow others to
|
||||
For files, allow execution by others. For directories allow others to
|
||||
search in the directory.
|
||||
.El
|
||||
.Pp
|
||||
|
||||
+4
-19
@@ -35,7 +35,7 @@
|
||||
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd August 10, 2002
|
||||
.Dd April 18, 1994
|
||||
.Dt CP 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -47,7 +47,7 @@
|
||||
.Fl R
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Oc
|
||||
.Op Fl f | i | n
|
||||
.Op Fl f | i
|
||||
.Op Fl pv
|
||||
.Ar source_file target_file
|
||||
.Nm
|
||||
@@ -55,7 +55,7 @@
|
||||
.Fl R
|
||||
.Op Fl H | Fl L | Fl P
|
||||
.Oc
|
||||
.Op Fl f | i | n
|
||||
.Op Fl f | i
|
||||
.Op Fl pv
|
||||
.Ar source_file ... target_directory
|
||||
.Sh DESCRIPTION
|
||||
@@ -121,8 +121,6 @@ regardless of its permissions.
|
||||
.Fl f
|
||||
option overrides any previous
|
||||
.Fl i
|
||||
or
|
||||
.Fl n
|
||||
options.)
|
||||
.It Fl i
|
||||
Cause
|
||||
@@ -138,17 +136,6 @@ the file copy is attempted.
|
||||
.Fl i
|
||||
option overrides any previous
|
||||
.Fl f
|
||||
or
|
||||
.Fl n
|
||||
options.)
|
||||
.It Fl n
|
||||
Do not overwrite an existing file.
|
||||
(The
|
||||
.Fl n
|
||||
option overrides any previous
|
||||
.Fl f
|
||||
or
|
||||
.Fl i
|
||||
options.)
|
||||
.It Fl p
|
||||
Cause
|
||||
@@ -239,9 +226,7 @@ or fifo's.
|
||||
.Pp
|
||||
The
|
||||
.Fl v
|
||||
and
|
||||
.Fl n
|
||||
options are non-standard and their use in scripts is not recommended.
|
||||
option is non-standard and its use in scripts is not recommended.
|
||||
.Sh SEE ALSO
|
||||
.Xr mv 1 ,
|
||||
.Xr rcp 1 ,
|
||||
|
||||
+7
-12
@@ -84,7 +84,7 @@ static const char rcsid[] =
|
||||
|
||||
PATH_T to = { to.p_path, "", "" };
|
||||
|
||||
int Rflag, fflag, iflag, nflag, pflag, rflag, vflag;
|
||||
int Rflag, iflag, pflag, rflag, fflag, vflag;
|
||||
|
||||
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
|
||||
|
||||
@@ -102,7 +102,7 @@ main(argc, argv)
|
||||
char *target;
|
||||
|
||||
Hflag = Lflag = Pflag = 0;
|
||||
while ((ch = getopt(argc, argv, "HLPRfinprv")) != -1)
|
||||
while ((ch = getopt(argc, argv, "HLPRfiprv")) != -1)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
@@ -121,15 +121,11 @@ main(argc, argv)
|
||||
break;
|
||||
case 'f':
|
||||
fflag = 1;
|
||||
iflag = nflag = 0;
|
||||
iflag = 0;
|
||||
break;
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
fflag = nflag = 0;
|
||||
break;
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
fflag = iflag = 0;
|
||||
fflag = 0;
|
||||
break;
|
||||
case 'p':
|
||||
pflag = 1;
|
||||
@@ -350,10 +346,9 @@ copy(argv, type, fts_options)
|
||||
* honour setuid, setgid and sticky bits, but we
|
||||
* normally want to preserve them on directories.
|
||||
*/
|
||||
if (pflag) {
|
||||
if (setfile(curr->fts_statp, 0))
|
||||
rval = 1;
|
||||
} else {
|
||||
if (pflag)
|
||||
rval = setfile(curr->fts_statp, 0);
|
||||
else {
|
||||
mode = curr->fts_statp->st_mode;
|
||||
if ((mode & (S_ISUID | S_ISGID | S_ISTXT)) ||
|
||||
((mode | S_IRWXU) & mask) != (mode & mask))
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ typedef struct {
|
||||
} PATH_T;
|
||||
|
||||
extern PATH_T to;
|
||||
extern int fflag, iflag, nflag, pflag, vflag;
|
||||
extern int iflag, pflag, fflag, vflag;
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
|
||||
+3
-7
@@ -88,11 +88,7 @@ copy_file(entp, dne)
|
||||
*/
|
||||
if (!dne) {
|
||||
#define YESNO "(y/n [n]) "
|
||||
if (nflag) {
|
||||
if (vflag)
|
||||
printf("%s not overwritten\n", to.p_path);
|
||||
return (0);
|
||||
} else if (iflag) {
|
||||
if (iflag) {
|
||||
(void)fprintf(stderr, "overwrite %s? %s",
|
||||
to.p_path, YESNO);
|
||||
checkch = ch = getchar();
|
||||
@@ -316,7 +312,7 @@ usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target",
|
||||
" cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory");
|
||||
"usage: cp [-R [-H | -L | -P]] [-f | -i] [-pv] src target",
|
||||
" cp [-R [-H | -L | -P]] [-f | -i] [-pv] src1 ... srcN directory");
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
@@ -13,3 +13,5 @@ CLEANFILES+= tcsh.cat tcsh.msg
|
||||
all: tcsh.cat
|
||||
|
||||
tcsh.cat: tcsh.msg
|
||||
|
||||
distribute:
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -11,7 +11,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -13,7 +13,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -12,7 +12,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -11,7 +11,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -11,7 +11,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
.for i in ${LL}
|
||||
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
|
||||
|
||||
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
+2
-1
@@ -57,7 +57,8 @@ displays the number of complete and partial input and output blocks
|
||||
and truncated input records to the standard error output.
|
||||
.Pp
|
||||
The following operands are available:
|
||||
.Bl -tag -width ".Cm of Ns = Ns Ar file"
|
||||
.\" XXX
|
||||
.Bl -tag -width of=file
|
||||
.It Cm bs Ns = Ns Ar n
|
||||
Set both input and output block size to
|
||||
.Ar n
|
||||
|
||||
+5
-3
@@ -209,9 +209,11 @@ main(int argc, char *argv[])
|
||||
rv = 0;
|
||||
if (!*argv) {
|
||||
mntsize = regetmntinfo(&mntbuf, mntsize, vfslist);
|
||||
bzero(&maxwidths, sizeof(maxwidths));
|
||||
for (i = 0; i < mntsize; i++)
|
||||
update_maxwidths(&maxwidths, &mntbuf[i]);
|
||||
if (vfslist != NULL) {
|
||||
bzero(&maxwidths, sizeof(maxwidths));
|
||||
for (i = 0; i < mntsize; i++)
|
||||
update_maxwidths(&maxwidths, &mntbuf[i]);
|
||||
}
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0)
|
||||
prtstat(&mntbuf[i], &maxwidths);
|
||||
|
||||
+60
-148
@@ -12,35 +12,19 @@
|
||||
.Op Fl sx
|
||||
.Op Fl p Ar string
|
||||
.Op Ar file
|
||||
.Nm red
|
||||
.Op Fl
|
||||
.Op Fl sx
|
||||
.Op Fl p Ar string
|
||||
.Op Ar file
|
||||
.\" .LP
|
||||
.\" red [-] [-sx] [-p \fIstring\fR] [\fIfile\fR]
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility is a line-oriented text editor.
|
||||
It is used to create, display, modify and otherwise manipulate text
|
||||
files.
|
||||
When invoked as
|
||||
.Nm red ,
|
||||
the editor runs in
|
||||
.Qq restricted
|
||||
mode, in which the only difference is that the editor restricts the
|
||||
use of filenames which start with
|
||||
.Ql \&!
|
||||
(interpreted as shell commands by
|
||||
.Nm )
|
||||
or contain a
|
||||
.Ql \&/ .
|
||||
Note that editing outside of the current directory is only prohibited
|
||||
if the user does not have write access to the current directory.
|
||||
If a user has write access to the current directory, then symbolic
|
||||
links can be created in the current directory, in which case
|
||||
.Nm red
|
||||
will not stop the user from editing the file that the symbolic link
|
||||
points to.
|
||||
.\" .B red
|
||||
.\" is a restricted
|
||||
.\" .BR ed :
|
||||
.\" it can only edit files in the current
|
||||
.\" directory and cannot execute shell commands.
|
||||
.Pp
|
||||
If invoked with a
|
||||
.Ar file
|
||||
@@ -52,7 +36,7 @@ Changes are made to this copy and not directly to
|
||||
itself.
|
||||
Upon quitting
|
||||
.Nm ,
|
||||
any changes not explicitly saved with a
|
||||
any changes not explicitly saved with a
|
||||
.Em w
|
||||
command are lost.
|
||||
.Pp
|
||||
@@ -87,13 +71,11 @@ When an input command, such as
|
||||
.Em c
|
||||
(change), is given,
|
||||
.Nm
|
||||
enters input mode.
|
||||
This is the primary means
|
||||
enters input mode. This is the primary means
|
||||
of adding text to a file.
|
||||
In this mode, no commands are available;
|
||||
instead, the standard input is written
|
||||
directly to the editor buffer.
|
||||
Lines consist of text up to and
|
||||
directly to the editor buffer. Lines consist of text up to and
|
||||
including a
|
||||
.Em newline
|
||||
character.
|
||||
@@ -111,8 +93,7 @@ command deletes lines; the
|
||||
.Em m
|
||||
command moves lines, and so on.
|
||||
It is possible to modify only a portion of a line by means of replacement,
|
||||
as in the example above.
|
||||
However even here, the
|
||||
as in the example above. However even here, the
|
||||
.Em s
|
||||
command is applied to whole lines at a time.
|
||||
.Pp
|
||||
@@ -130,8 +111,7 @@ commands have the structure:
|
||||
.Sm on
|
||||
.Pp
|
||||
The address(es) indicate the line or range of lines to be affected by the
|
||||
command.
|
||||
If fewer addresses are given than the command accepts, then
|
||||
command. If fewer addresses are given than the command accepts, then
|
||||
default addresses are supplied.
|
||||
.Sh OPTIONS
|
||||
The following options are available:
|
||||
@@ -147,17 +127,14 @@ Prompt for an encryption key to be used in subsequent reads and writes
|
||||
.Em x
|
||||
command).
|
||||
.It Fl p Ar string
|
||||
Specify a command prompt.
|
||||
This may be toggled on and off with the
|
||||
Specify a command prompt. This may be toggled on and off with the
|
||||
.Em P
|
||||
command.
|
||||
.It Ar file
|
||||
Specify the name of a file to read.
|
||||
If
|
||||
Specify the name of a file to read. If
|
||||
.Ar file
|
||||
is prefixed with a
|
||||
bang (!), then it is interpreted as a shell command.
|
||||
In this case,
|
||||
bang (!), then it is interpreted as a shell command. In this case,
|
||||
what is read is
|
||||
the standard output of
|
||||
.Ar file
|
||||
@@ -177,15 +154,13 @@ utility maintains a
|
||||
.Em current address
|
||||
which is
|
||||
typically supplied to commands as the default address when none is specified.
|
||||
When a file is first read, the current address is set to the last line
|
||||
of the file.
|
||||
In general, the current address is set to the last line
|
||||
When a file is first read, the current address is set to the last line
|
||||
of the file. In general, the current address is set to the last line
|
||||
affected by a command.
|
||||
.Pp
|
||||
A line address is
|
||||
constructed from one of the bases in the list below, optionally followed
|
||||
by a numeric offset.
|
||||
The offset may include any combination
|
||||
by a numeric offset. The offset may include any combination
|
||||
of digits, operators (i.e.,
|
||||
.Em + ,
|
||||
.Em -
|
||||
@@ -205,10 +180,8 @@ and is legal wherever it makes sense.
|
||||
An address range is two addresses separated either by a comma or
|
||||
semi-colon.
|
||||
The value of the first address in a range cannot exceed the
|
||||
value of the second.
|
||||
If only one address is given in a range, then
|
||||
the second address is set to the given address.
|
||||
If an
|
||||
value of the second. If only one address is given in a range, then
|
||||
the second address is set to the given address. If an
|
||||
.Em n Ns -tuple
|
||||
of addresses is given where
|
||||
.Em "n\ >\ 2" ,
|
||||
@@ -218,8 +191,7 @@ the
|
||||
If only one address is expected, then the last address is used.
|
||||
.Pp
|
||||
Each address in a comma-delimited range is interpreted relative to the
|
||||
current address.
|
||||
In a semi-colon-delimited range, the first address is
|
||||
current address. In a semi-colon-delimited range, the first address is
|
||||
used to set the current address, and the second address is interpreted
|
||||
relative to the first.
|
||||
.Pp
|
||||
@@ -260,13 +232,11 @@ next line, where
|
||||
.Em n
|
||||
is a non-negative number.
|
||||
.It , or %
|
||||
The first through last lines in the buffer.
|
||||
This is equivalent to
|
||||
The first through last lines in the buffer. This is equivalent to
|
||||
the address range
|
||||
.Em 1,$ .
|
||||
.It ;
|
||||
The current through last lines in the buffer.
|
||||
This is equivalent to
|
||||
The current through last lines in the buffer. This is equivalent to
|
||||
the address range
|
||||
.Em .,$ .
|
||||
.It /re/
|
||||
@@ -309,8 +279,7 @@ command for selecting old text to be replaced with new.
|
||||
.Pp
|
||||
In addition to a specifying string literals, regular expressions can
|
||||
represent
|
||||
classes of strings.
|
||||
Strings thus represented are said to be matched
|
||||
classes of strings. Strings thus represented are said to be matched
|
||||
by the corresponding regular expression.
|
||||
If it is possible for a regular expression
|
||||
to match several strings in a line, then the left-most longest match is
|
||||
@@ -321,43 +290,24 @@ The following symbols are used in constructing regular expressions:
|
||||
.It c
|
||||
Any character
|
||||
.Em c
|
||||
not listed below, including
|
||||
.Ql \&{ ,
|
||||
.Ql \&} ,
|
||||
.Ql \&( ,
|
||||
.Ql \&) ,
|
||||
.Ql <
|
||||
and
|
||||
.Ql > ,
|
||||
not listed below, including `{', '}', `(', `)', `<' and `>',
|
||||
matches itself.
|
||||
.It Pf \e c
|
||||
Any backslash-escaped character
|
||||
.Em c ,
|
||||
except for
|
||||
.Ql \&{ ,
|
||||
.Ql \&} ,
|
||||
.Ql \&( ,
|
||||
.Ql \&) ,
|
||||
.Ql <
|
||||
and
|
||||
.Ql > ,
|
||||
except for `{', '}', `(', `)', `<' and `>',
|
||||
matches itself.
|
||||
.It .
|
||||
Match any single character.
|
||||
.It Op char-class
|
||||
Match any single character in
|
||||
.Em char-class .
|
||||
To include a
|
||||
.Ql \&]
|
||||
To include a `]'
|
||||
in
|
||||
.Em char-class ,
|
||||
it must be the first character.
|
||||
A range of characters may be specified by separating the end characters
|
||||
of the range with a
|
||||
.Ql - ,
|
||||
e.g.,
|
||||
.Ql a-z
|
||||
specifies the lower case characters.
|
||||
of the range with a `-', e.g., `a-z' specifies the lower case characters.
|
||||
The following literal expressions can also be used in
|
||||
.Em char-class
|
||||
to specify sets of characters:
|
||||
@@ -368,9 +318,7 @@ to specify sets of characters:
|
||||
.It [:blank:] Ta [:graph:] Ta [:punct:] Ta [:xdigit:]
|
||||
.El
|
||||
.Pp
|
||||
If
|
||||
.Ql -
|
||||
appears as the first or last
|
||||
If `-' appears as the first or last
|
||||
character of
|
||||
.Em char-class ,
|
||||
then it matches itself.
|
||||
@@ -437,31 +385,21 @@ where
|
||||
is a number in the range [1,9], expands to the text matched by the
|
||||
.Em n Ns th
|
||||
subexpression.
|
||||
For example, the regular expression
|
||||
.Ql \e(.*\e)\e1
|
||||
matches any string
|
||||
For example, the regular expression `\e(.*\e)\e1' matches any string
|
||||
consisting of identical adjacent substrings.
|
||||
Subexpressions are ordered relative to
|
||||
their left delimiter.
|
||||
.It *
|
||||
Match the single character regular expression or subexpression
|
||||
immediately preceding it zero or more times.
|
||||
If
|
||||
immediately preceding it zero or more times. If
|
||||
.Em *
|
||||
is the first
|
||||
character of a regular expression or subexpression, then it matches
|
||||
itself.
|
||||
The
|
||||
itself. The
|
||||
.Em *
|
||||
operator sometimes yields unexpected results.
|
||||
For example, the regular expression
|
||||
.Ql b*
|
||||
matches the beginning of
|
||||
the string
|
||||
.Ql abbb
|
||||
(as opposed to the substring
|
||||
.Ql bbb ) ,
|
||||
since a null match
|
||||
For example, the regular expression `b*' matches the beginning of
|
||||
the string `abbb' (as opposed to the substring `bbb'), since a null match
|
||||
is the only left-most match.
|
||||
.It \e{n,m\e} or \e{n,\e} or \e{n\e}
|
||||
Match the single character regular expression or subexpression
|
||||
@@ -509,8 +447,7 @@ and returning the editor to command mode.
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
recognizes the following commands.
|
||||
The commands are shown together with
|
||||
recognizes the following commands. The commands are shown together with
|
||||
the default address or address range supplied if none is
|
||||
specified (in parenthesis).
|
||||
.Bl -tag -width indent
|
||||
@@ -519,8 +456,7 @@ Append text to the buffer after the addressed line.
|
||||
Text is entered in input mode.
|
||||
The current address is set to last line entered.
|
||||
.It (.,.)c
|
||||
Change lines in the buffer.
|
||||
The addressed lines are deleted
|
||||
Change lines in the buffer. The addressed lines are deleted
|
||||
from the buffer, and text is appended in their place.
|
||||
Text is entered in input mode.
|
||||
The current address is set to last line entered.
|
||||
@@ -536,7 +472,7 @@ Edit
|
||||
and sets the default filename.
|
||||
If
|
||||
.Ar file
|
||||
is not specified, then the default filename is used.
|
||||
is not specified, then the default filename is used.
|
||||
Any lines in the buffer are deleted before
|
||||
the new file is read.
|
||||
The current address is set to the last line read.
|
||||
@@ -614,11 +550,8 @@ The format of
|
||||
.Ar command-list
|
||||
is the same as that of the
|
||||
.Em g
|
||||
command.
|
||||
A newline alone acts as a null command list.
|
||||
A single
|
||||
.Ql &
|
||||
repeats the last non-null command list.
|
||||
command. A newline alone acts as a null command list.
|
||||
A single `&' repeats the last non-null command list.
|
||||
.It H
|
||||
Toggle the printing of error explanations.
|
||||
By default, explanations are not printed.
|
||||
@@ -631,26 +564,23 @@ Insert text in the buffer before the current line.
|
||||
Text is entered in input mode.
|
||||
The current address is set to the last line entered.
|
||||
.It (.,.+1)j
|
||||
Join the addressed lines.
|
||||
The addressed lines are
|
||||
Join the addressed lines. The addressed lines are
|
||||
deleted from the buffer and replaced by a single
|
||||
line containing their joined text.
|
||||
The current address is set to the resultant line.
|
||||
.It (.)klc
|
||||
Mark a line with a lower case letter
|
||||
.Em lc .
|
||||
The line can then be addressed as
|
||||
The line can then be addressed as
|
||||
.Em 'lc
|
||||
(i.e., a single quote followed by
|
||||
.Em lc )
|
||||
in subsequent commands.
|
||||
The mark is not cleared until the line is
|
||||
in subsequent commands. The mark is not cleared until the line is
|
||||
deleted or otherwise modified.
|
||||
.It (.,.)l
|
||||
Print the addressed lines unambiguously.
|
||||
If a single line fills for than one screen (as might be the case
|
||||
when viewing a binary file, for instance), a
|
||||
.Dq Li --More--
|
||||
when viewing a binary file, for instance), a `--More--'
|
||||
prompt is printed on the last line.
|
||||
The
|
||||
.Nm
|
||||
@@ -659,8 +589,7 @@ before displaying the next screen.
|
||||
The current address is set to the last line
|
||||
printed.
|
||||
.It (.,.)m(.)
|
||||
Move lines in the buffer.
|
||||
The addressed lines are moved to after the
|
||||
Move lines in the buffer. The addressed lines are moved to after the
|
||||
right-hand destination address, which may be the address
|
||||
.Em 0
|
||||
(zero).
|
||||
@@ -668,8 +597,7 @@ The current address is set to the
|
||||
last line moved.
|
||||
.It (.,.)n
|
||||
Print the addressed lines along with
|
||||
their line numbers.
|
||||
The current address is set to the last line
|
||||
their line numbers. The current address is set to the last line
|
||||
printed.
|
||||
.It (.,.)p
|
||||
Print the addressed lines.
|
||||
@@ -694,12 +622,10 @@ except that unwritten changes are discarded without warning.
|
||||
.It ($)r Ar file
|
||||
Read
|
||||
.Ar file
|
||||
to after the addressed line.
|
||||
If
|
||||
to after the addressed line. If
|
||||
.Ar file
|
||||
is not specified, then the default
|
||||
filename is used.
|
||||
If there was no default filename prior to the command,
|
||||
filename is used. If there was no default filename prior to the command,
|
||||
then the default filename is set to
|
||||
.Ar file .
|
||||
Otherwise, the default filename is unchanged.
|
||||
@@ -749,9 +675,7 @@ affected is printed as though the print suffix
|
||||
.Em p
|
||||
were specified.
|
||||
.Pp
|
||||
An unescaped
|
||||
.Ql &
|
||||
in
|
||||
An unescaped `&' in
|
||||
.Ar replacement
|
||||
is replaced by the currently matched text.
|
||||
The character sequence
|
||||
@@ -763,9 +687,7 @@ is a number in the range [1,9], is replaced by the
|
||||
backreference expression of the matched text.
|
||||
If
|
||||
.Ar replacement
|
||||
consists of a single
|
||||
.Ql % ,
|
||||
then
|
||||
consists of a single `%', then
|
||||
.Ar replacement
|
||||
from the last substitution is used.
|
||||
Newlines may be embedded in
|
||||
@@ -840,8 +762,7 @@ Any previous contents of
|
||||
is lost without warning.
|
||||
If there is no default filename, then the default filename is set to
|
||||
.Ar file ,
|
||||
otherwise it is unchanged.
|
||||
If no filename is specified, then the default
|
||||
otherwise it is unchanged. If no filename is specified, then the default
|
||||
filename is used.
|
||||
The current address is unchanged.
|
||||
.It (1,$)wq Ar file
|
||||
@@ -866,18 +787,15 @@ command, expect that the previous contents of file is not clobbered.
|
||||
The current address is unchanged.
|
||||
.It x
|
||||
Prompt for an encryption key which is used in subsequent reads and
|
||||
writes.
|
||||
If a newline alone is entered as the key, then encryption is
|
||||
turned off.
|
||||
Otherwise, echoing is disabled while a key is read.
|
||||
writes. If a newline alone is entered as the key, then encryption is
|
||||
turned off. Otherwise, echoing is disabled while a key is read.
|
||||
Encryption/decryption is done using the
|
||||
.Xr bdes 1
|
||||
algorithm.
|
||||
.It Pf (.+1)z n
|
||||
Scroll
|
||||
.Ar n
|
||||
lines at a time starting at addressed line.
|
||||
If
|
||||
lines at a time starting at addressed line. If
|
||||
.Ar n
|
||||
is not specified, then the current window size is used.
|
||||
The current address is set to the last line printed.
|
||||
@@ -888,9 +806,7 @@ via
|
||||
.Xr sh 1 .
|
||||
If the first character of
|
||||
.Ar command
|
||||
is
|
||||
.Ql \&! ,
|
||||
then it is replaced by text of the
|
||||
is `!', then it is replaced by text of the
|
||||
previous
|
||||
.Ar !command .
|
||||
The
|
||||
@@ -901,8 +817,7 @@ for backslash (\\) escapes.
|
||||
However, an unescaped
|
||||
.Em %
|
||||
is replaced by the default filename.
|
||||
When the shell returns from execution, a
|
||||
.Ql \&!
|
||||
When the shell returns from execution, a `!'
|
||||
is printed to the standard output.
|
||||
The current line is unchanged.
|
||||
.It ($)=
|
||||
@@ -918,7 +833,7 @@ buffer file
|
||||
.It ed.hup
|
||||
the file to which
|
||||
.Nm
|
||||
attempts to write the buffer if the terminal hangs up
|
||||
attempts to write the buffer if the terminal hangs up
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr bdes 1 ,
|
||||
@@ -940,15 +855,14 @@ The
|
||||
.Nm
|
||||
utility processes
|
||||
.Ar file
|
||||
arguments for backslash escapes, i.e., in a filename,
|
||||
arguments for backslash escapes, i.e., in a filename,
|
||||
any characters preceded by a backslash (\\) are
|
||||
interpreted literally.
|
||||
.Pp
|
||||
If a text (non-binary) file is not terminated by a newline character,
|
||||
then
|
||||
.Nm
|
||||
appends one on reading/writing it.
|
||||
In the case of a binary file,
|
||||
appends one on reading/writing it. In the case of a binary file,
|
||||
.Nm
|
||||
does not append a newline on reading/writing.
|
||||
.Pp
|
||||
@@ -956,9 +870,7 @@ per line overhead: 4 ints
|
||||
.Sh DIAGNOSTICS
|
||||
When an error occurs,
|
||||
.Nm
|
||||
prints a
|
||||
.Ql \&?
|
||||
and either returns to command mode
|
||||
prints a `?' and either returns to command mode
|
||||
or exits if its input is from a script.
|
||||
An explanation of the last error can be
|
||||
printed with the
|
||||
@@ -967,7 +879,7 @@ printed with the
|
||||
.Pp
|
||||
Since the
|
||||
.Em g
|
||||
(global) command masks any errors from failed searches and substitutions,
|
||||
(global) command masks any errors from failed searches and substitutions,
|
||||
it can be used to perform conditional operations in scripts; e.g.,
|
||||
.Pp
|
||||
.Sm off
|
||||
|
||||
+6
-25
@@ -50,19 +50,17 @@
|
||||
.Fl l
|
||||
.Op Ar exit_status
|
||||
.Nm
|
||||
.Fl Ar signal_name
|
||||
.Fl signal_name
|
||||
.Ar pid
|
||||
\&...
|
||||
.Nm
|
||||
.Fl Ar signal_number
|
||||
.Fl signal_number
|
||||
.Ar pid
|
||||
\&...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility sends a signal to the processes specified by the
|
||||
.Ar pid
|
||||
operand(s).
|
||||
utility sends a signal to the processes specified by the pid operand(s).
|
||||
.Pp
|
||||
Only the super-user may send signals to other users' processes.
|
||||
.Pp
|
||||
@@ -77,11 +75,11 @@ default
|
||||
If no operand is given, list the signal names; otherwise, write
|
||||
the signal name corresponding to
|
||||
.Ar exit_status .
|
||||
.It Fl Ar signal_name
|
||||
.It Fl signal_name
|
||||
A symbolic signal name specifying the signal to be sent instead of the
|
||||
default
|
||||
.Dv TERM .
|
||||
.It Fl Ar signal_number
|
||||
.It Fl signal_number
|
||||
A non-negative decimal integer, specifying the signal to be sent instead
|
||||
of the default
|
||||
.Dv TERM .
|
||||
@@ -118,23 +116,6 @@ command which is similar or identical to this utility.
|
||||
Consult the
|
||||
.Xr builtin 1
|
||||
manual page.
|
||||
.Sh EXAMPLES
|
||||
Terminate
|
||||
the processes with pids 142 and 157:
|
||||
.Pp
|
||||
.Dl "kill 142 157"
|
||||
.Pp
|
||||
Send the hangup signal
|
||||
.Pq Dv SIGHUP
|
||||
to the process with pid 507:
|
||||
.Pp
|
||||
.Dl "kill -s HUP 507"
|
||||
.Pp
|
||||
Terminate the process group with pgid 117:
|
||||
.Pp
|
||||
.Dl "kill -- -117"
|
||||
.Sh DIAGNOSTICS
|
||||
.Ex -std
|
||||
.Sh SEE ALSO
|
||||
.Xr builtin 1 ,
|
||||
.Xr csh 1 ,
|
||||
@@ -152,7 +133,7 @@ compatible.
|
||||
A
|
||||
.Nm
|
||||
command appeared in
|
||||
.At v3 .
|
||||
.At v6 .
|
||||
.Sh BUGS
|
||||
A replacement for the command
|
||||
.Dq Li kill 0
|
||||
|
||||
+18
-15
@@ -41,9 +41,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
@@ -53,13 +53,16 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void nosig(char *);
|
||||
void printsignals(FILE *);
|
||||
int signame_to_signum(char *);
|
||||
void usage(void);
|
||||
int main __P((int, char *[]));
|
||||
void nosig __P((char *));
|
||||
void printsignals __P((FILE *));
|
||||
int signame_to_signum __P((char *));
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int errors, numsig, pid;
|
||||
char *ep;
|
||||
@@ -103,7 +106,7 @@ main(int argc, char *argv[])
|
||||
} else
|
||||
numsig = 0;
|
||||
argc--, argv++;
|
||||
} else if (**argv == '-' && *(*argv + 1) != '-') {
|
||||
} else if (**argv == '-') {
|
||||
++*argv;
|
||||
if (isalpha(**argv)) {
|
||||
if ((numsig = signame_to_signum(*argv)) < 0)
|
||||
@@ -119,9 +122,6 @@ main(int argc, char *argv[])
|
||||
argc--, argv++;
|
||||
}
|
||||
|
||||
if (argc > 0 && strncmp(*argv, "--", 2) == 0)
|
||||
argc--, argv++;
|
||||
|
||||
if (argc == 0)
|
||||
usage();
|
||||
|
||||
@@ -140,7 +140,8 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
int
|
||||
signame_to_signum(char *sig)
|
||||
signame_to_signum(sig)
|
||||
char *sig;
|
||||
{
|
||||
int n;
|
||||
|
||||
@@ -154,7 +155,8 @@ signame_to_signum(char *sig)
|
||||
}
|
||||
|
||||
void
|
||||
nosig(char *name)
|
||||
nosig(name)
|
||||
char *name;
|
||||
{
|
||||
|
||||
warnx("unknown signal %s; valid signals:", name);
|
||||
@@ -163,7 +165,8 @@ nosig(char *name)
|
||||
}
|
||||
|
||||
void
|
||||
printsignals(FILE *fp)
|
||||
printsignals(fp)
|
||||
FILE *fp;
|
||||
{
|
||||
int n;
|
||||
|
||||
@@ -177,7 +180,7 @@ printsignals(FILE *fp)
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
|
||||
|
||||
+4
-4
@@ -46,11 +46,11 @@
|
||||
.Nm
|
||||
.Op Fl fhinsv
|
||||
.Ar source_file
|
||||
.Op Ar target_file
|
||||
.Op target_file
|
||||
.Nm
|
||||
.Op Fl fhinsv
|
||||
.Ar source_file ...
|
||||
.Ar target_dir
|
||||
.Op target_dir
|
||||
.Nm link
|
||||
.Ar source_file Ar target_file
|
||||
.Sh DESCRIPTION
|
||||
@@ -124,7 +124,7 @@ links.
|
||||
A hard link to a file is indistinguishable from the original directory entry;
|
||||
any changes to a file are effectively independent of the name used to reference
|
||||
the file.
|
||||
Hard links may not normally refer to directories and may not span filesystems.
|
||||
Hard links may not normally refer to directories and may not span file systems.
|
||||
.Pp
|
||||
A symbolic link contains the name of the file to
|
||||
which it is linked. The referenced file is used when an
|
||||
@@ -138,7 +138,7 @@ must be done to obtain information about the link.
|
||||
The
|
||||
.Xr readlink 2
|
||||
call may be used to read the contents of a symbolic link.
|
||||
Symbolic links may span filesystems and may refer to directories.
|
||||
Symbolic links may span file systems and may refer to directories.
|
||||
.Pp
|
||||
Given one or two arguments,
|
||||
.Nm
|
||||
|
||||
+18
-23
@@ -41,9 +41,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ln.c 8.2 (Berkeley) 3/31/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -62,14 +62,17 @@ int iflag; /* Interactive mode. */
|
||||
int sflag; /* Symbolic, not hard, link. */
|
||||
int vflag; /* Verbose output. */
|
||||
/* System link call. */
|
||||
int (*linkf)(const char *, const char *);
|
||||
int (*linkf) __P((const char *, const char *));
|
||||
char linkch;
|
||||
|
||||
int linkit(const char *, const char *, int);
|
||||
void usage(void);
|
||||
int linkit __P((const char *, const char *, int));
|
||||
int main __P((int, char *[]));
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
struct stat sb;
|
||||
char *p, *sourcedir;
|
||||
@@ -85,14 +88,11 @@ main(int argc, char *argv[])
|
||||
else
|
||||
++p;
|
||||
if (strcmp(p, "link") == 0) {
|
||||
while (getopt(argc, argv, "") != -1)
|
||||
if (argc == 3) {
|
||||
linkf = link;
|
||||
exit(linkit(argv[1], argv[2], 0));
|
||||
} else
|
||||
usage();
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc != 2)
|
||||
usage();
|
||||
linkf = link;
|
||||
exit(linkit(argv[0], argv[1], 0));
|
||||
}
|
||||
|
||||
while ((ch = getopt(argc, argv, "fhinsv")) != -1)
|
||||
@@ -134,8 +134,6 @@ main(int argc, char *argv[])
|
||||
exit(linkit(argv[0], ".", 1));
|
||||
case 2: /* ln target source */
|
||||
exit(linkit(argv[0], argv[1], 0));
|
||||
default:
|
||||
;
|
||||
}
|
||||
/* ln target1 target2 directory */
|
||||
sourcedir = argv[argc - 1];
|
||||
@@ -157,7 +155,9 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
int
|
||||
linkit(const char *target, const char *source, int isdir)
|
||||
linkit(target, source, isdir)
|
||||
const char *target, *source;
|
||||
int isdir;
|
||||
{
|
||||
struct stat sb;
|
||||
const char *p;
|
||||
@@ -189,12 +189,7 @@ linkit(const char *target, const char *source, int isdir)
|
||||
p = target;
|
||||
else
|
||||
++p;
|
||||
if (snprintf(path, sizeof(path), "%s/%s", source, p) >=
|
||||
sizeof(path)) {
|
||||
errno = ENAMETOOLONG;
|
||||
warn("%s", target);
|
||||
return (1);
|
||||
}
|
||||
(void)snprintf(path, sizeof(path), "%s/%s", source, p);
|
||||
source = path;
|
||||
}
|
||||
|
||||
@@ -237,7 +232,7 @@ linkit(const char *target, const char *source, int isdir)
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr, "%s\n%s\n%s\n",
|
||||
"usage: ln [-fhinsv] file1 file2",
|
||||
|
||||
+5
-5
@@ -34,14 +34,14 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmp.c 8.1 (Berkeley) 5/31/93";
|
||||
#endif /* not lint */
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -46,7 +46,6 @@ int revstatcmp(const FTSENT *, const FTSENT *);
|
||||
void printcol(DISPLAY *);
|
||||
void printlong(DISPLAY *);
|
||||
void printscol(DISPLAY *);
|
||||
void printstream(DISPLAY *);
|
||||
void usage(void);
|
||||
size_t len_octal(const char *, int);
|
||||
int prn_octal(const char *);
|
||||
|
||||
+11
-25
@@ -43,7 +43,7 @@
|
||||
.Nd list directory contents
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl ABCFGHLPRTWabcdfghiklmnopqrstuwx1
|
||||
.Op Fl ABCFGHLPRTWabcdfghiklnoqrstuw1
|
||||
.Op Ar
|
||||
.Sh DESCRIPTION
|
||||
For each operand that names a
|
||||
@@ -190,8 +190,6 @@ List in long format.
|
||||
(See below.)
|
||||
If the output is to a terminal, a total sum for all the file
|
||||
sizes is output on a line before the long listing.
|
||||
.It Fl m
|
||||
Stream output format; list files across the page, separated by commas.
|
||||
.It Fl n
|
||||
Display user and group IDs numerically rather than converting to a user
|
||||
or group name in a long
|
||||
@@ -201,10 +199,6 @@ output.
|
||||
Include the file flags in a long
|
||||
.Pq Fl l
|
||||
output.
|
||||
.It Fl p
|
||||
Write a slash
|
||||
.Pq Ql /
|
||||
after each filename if that file is a directory.
|
||||
.It Fl q
|
||||
Force printing of non-graphic characters in file names as
|
||||
the character
|
||||
@@ -214,7 +208,7 @@ this is the default when output is to a terminal.
|
||||
Reverse the order of the sort to get reverse
|
||||
lexicographical order or the oldest entries first.
|
||||
.It Fl s
|
||||
Display the number of filesystem blocks actually used by each file, in units
|
||||
Display the number of file system blocks actually used by each file, in units
|
||||
of 512 bytes, where partial units are rounded up to the next integer value.
|
||||
If the output is to a terminal, a total sum for all the file
|
||||
sizes is output on a line before the listing.
|
||||
@@ -236,11 +230,6 @@ or printing
|
||||
Force raw printing of non-printable characters.
|
||||
This is the default
|
||||
when output is not to a terminal.
|
||||
.It Fl x
|
||||
The same as
|
||||
.Fl C ,
|
||||
except that the multi-column output is produced with entries sorted
|
||||
across, rather than down, the columns.
|
||||
.It Fl 1
|
||||
(The numeric digit
|
||||
.Dq one . )
|
||||
@@ -251,7 +240,7 @@ output is not to a terminal.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Fl 1 , C , x ,
|
||||
.Fl 1 , C ,
|
||||
and
|
||||
.Fl l
|
||||
options all override each other; the last one specified determines
|
||||
@@ -283,9 +272,7 @@ By default,
|
||||
lists one entry per line to standard
|
||||
output; the exceptions are to terminals or when the
|
||||
.Fl C
|
||||
or
|
||||
.Fl x
|
||||
options are specified.
|
||||
option is specified.
|
||||
.Pp
|
||||
File information is displayed with one or more
|
||||
.Ao blank Ac Ns s
|
||||
@@ -491,9 +478,7 @@ utility calculates how
|
||||
many pathname text columns to display
|
||||
based on the width provided.
|
||||
(See
|
||||
.Fl C
|
||||
and
|
||||
.Fl x . )
|
||||
.Fl C . )
|
||||
.It Ev LANG
|
||||
The locale to use when determining the order of day and month in the long
|
||||
.Fl l
|
||||
@@ -623,16 +608,17 @@ specification.
|
||||
.Xr termcap 5 ,
|
||||
.Xr symlink 7 ,
|
||||
.Xr sticky 8
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
utility conforms to
|
||||
.St -p1003.1-2001 .
|
||||
.Sh HISTORY
|
||||
An
|
||||
.Nm
|
||||
command appeared in
|
||||
.At v1 .
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
utility is expected to be a superset of the
|
||||
.St -p1003.2
|
||||
specification.
|
||||
.Sh BUGS
|
||||
To maintain backward compatibility, the relationships between the many
|
||||
options are quite complex.
|
||||
+15
-40
@@ -40,13 +40,14 @@ static const char copyright[] =
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#if 0
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
|
||||
#endif /* not lint */
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -110,10 +111,7 @@ static int f_reversesort; /* reverse whatever sort is used */
|
||||
int f_sectime; /* print the real time for all files */
|
||||
static int f_singlecol; /* use single column output */
|
||||
int f_size; /* list size in short listing */
|
||||
int f_slash; /* similar to f_type, but only for dirs */
|
||||
int f_sortacross; /* sort across rows, not down columns */
|
||||
int f_statustime; /* use time of last mode change */
|
||||
int f_stream; /* stream the output, separate with commas */
|
||||
static int f_timesort; /* sort by time vice name */
|
||||
int f_type; /* add type character for non-regular files */
|
||||
static int f_whiteout; /* show whiteout entries */
|
||||
@@ -146,11 +144,11 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Terminal defaults to -Cq, non-terminal defaults to -1. */
|
||||
if (isatty(STDOUT_FILENO)) {
|
||||
termwidth = 80;
|
||||
if ((p = getenv("COLUMNS")) != NULL && *p != '\0')
|
||||
termwidth = atoi(p);
|
||||
else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != -1 &&
|
||||
win.ws_col > 0)
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == -1 ||
|
||||
!win.ws_col) {
|
||||
if ((p = getenv("COLUMNS")) != NULL)
|
||||
termwidth = atoi(p);
|
||||
} else
|
||||
termwidth = win.ws_col;
|
||||
f_nonprint = 1;
|
||||
} else {
|
||||
@@ -166,17 +164,15 @@ main(int argc, char *argv[])
|
||||
f_listdot = 1;
|
||||
|
||||
fts_options = FTS_PHYSICAL;
|
||||
while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfghiklmnopqrstuwx"))
|
||||
!= -1) {
|
||||
while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfghiklnoqrstuw")) != -1) {
|
||||
switch (ch) {
|
||||
/*
|
||||
* The -1, -C, -x and -l options all override each other so
|
||||
* shell aliasing works right.
|
||||
* The -1, -C and -l options all override each other so shell
|
||||
* aliasing works right.
|
||||
*/
|
||||
case '1':
|
||||
f_singlecol = 1;
|
||||
f_longform = 0;
|
||||
f_stream = 0;
|
||||
break;
|
||||
case 'B':
|
||||
f_nonprint = 0;
|
||||
@@ -184,17 +180,11 @@ main(int argc, char *argv[])
|
||||
f_octal_escape = 0;
|
||||
break;
|
||||
case 'C':
|
||||
f_sortacross = f_longform = f_singlecol = 0;
|
||||
f_longform = f_singlecol = 0;
|
||||
break;
|
||||
case 'l':
|
||||
f_longform = 1;
|
||||
f_singlecol = 0;
|
||||
f_stream = 0;
|
||||
break;
|
||||
case 'x':
|
||||
f_sortacross = 1;
|
||||
f_longform = 0;
|
||||
f_singlecol = 0;
|
||||
break;
|
||||
/* The -c and -u options override each other. */
|
||||
case 'c':
|
||||
@@ -207,7 +197,6 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 'F':
|
||||
f_type = 1;
|
||||
f_slash = 0;
|
||||
break;
|
||||
case 'H':
|
||||
fts_options |= FTS_COMFOLLOW;
|
||||
@@ -252,21 +241,12 @@ main(int argc, char *argv[])
|
||||
case 'k':
|
||||
f_kblocks = 1;
|
||||
break;
|
||||
case 'm':
|
||||
f_stream = 1;
|
||||
f_singlecol = 0;
|
||||
f_longform = 0;
|
||||
break;
|
||||
case 'n':
|
||||
f_numericonly = 1;
|
||||
break;
|
||||
case 'o':
|
||||
f_flags = 1;
|
||||
break;
|
||||
case 'p':
|
||||
f_slash = 1;
|
||||
f_type = 1;
|
||||
break;
|
||||
case 'q':
|
||||
f_nonprint = 1;
|
||||
f_octal = 0;
|
||||
@@ -404,8 +384,6 @@ main(int argc, char *argv[])
|
||||
printfcn = printscol;
|
||||
else if (f_longform)
|
||||
printfcn = printlong;
|
||||
else if (f_stream)
|
||||
printfcn = printstream;
|
||||
else
|
||||
printfcn = printcol;
|
||||
|
||||
@@ -478,7 +456,6 @@ traverse(int argc, char *argv[], int options)
|
||||
(void)fts_set(ftsp, p, FTS_SKIP);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (errno)
|
||||
err(1, "fts_read");
|
||||
@@ -504,8 +481,7 @@ display(FTSENT *p, FTSENT *list)
|
||||
size_t flen, ulen, glen;
|
||||
char *initmax;
|
||||
int entries, needstats;
|
||||
const char *user, *group;
|
||||
char *flags;
|
||||
char *user, *group, *flags;
|
||||
char buf[STRBUF_SIZEOF(u_quad_t) + 1];
|
||||
char ngroup[STRBUF_SIZEOF(uid_t) + 1];
|
||||
char nuser[STRBUF_SIZEOF(gid_t) + 1];
|
||||
@@ -588,7 +564,6 @@ display(FTSENT *p, FTSENT *list)
|
||||
f_notabs = 0;
|
||||
/* fall through */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
maxinode = makenines(maxinode);
|
||||
maxblock = makenines(maxblock);
|
||||
|
||||
@@ -52,8 +52,6 @@ extern int f_octal_escape; /* like f_octal but use C escapes if possible */
|
||||
extern int f_nonprint; /* show unprintables as ? */
|
||||
extern int f_sectime; /* print the real time for all files */
|
||||
extern int f_size; /* list size in short listing */
|
||||
extern int f_slash; /* append a '/' if the file is a directory */
|
||||
extern int f_sortacross; /* sort across rows, not down columns */
|
||||
extern int f_statustime; /* use time of last mode change */
|
||||
extern int f_notabs; /* don't use tab-separated multi-col output */
|
||||
extern int f_type; /* add type character for non-regular files */
|
||||
|
||||
+7
-52
@@ -34,13 +34,14 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
|
||||
#endif /* not lint */
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -218,31 +219,6 @@ printlong(DISPLAY *dp)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
printstream(DISPLAY *dp)
|
||||
{
|
||||
FTSENT *p;
|
||||
extern int termwidth;
|
||||
int chcnt;
|
||||
|
||||
for (p = dp->list, chcnt = 0; p; p = p->fts_link) {
|
||||
if (p->fts_number == NO_PRINT)
|
||||
continue;
|
||||
if (strlen(p->fts_name) + chcnt +
|
||||
(p->fts_link ? 2 : 0) >= (unsigned)termwidth) {
|
||||
putchar('\n');
|
||||
chcnt = 0;
|
||||
}
|
||||
chcnt += printaname(p, dp->s_inode, dp->s_block);
|
||||
if (p->fts_link) {
|
||||
printf(", ");
|
||||
chcnt += 2;
|
||||
}
|
||||
}
|
||||
if (chcnt)
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void
|
||||
printcol(DISPLAY *dp)
|
||||
{
|
||||
@@ -303,26 +279,15 @@ printcol(DISPLAY *dp)
|
||||
|
||||
if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
|
||||
(void)printf("total %lu\n", howmany(dp->btotal, blocksize));
|
||||
|
||||
if (f_sortacross)
|
||||
base = 0;
|
||||
for (row = 0; row < numrows; ++row) {
|
||||
endcol = colwidth;
|
||||
if (!f_sortacross)
|
||||
base = row;
|
||||
for (col = 0, chcnt = 0; col < numcols; ++col) {
|
||||
for (base = row, chcnt = col = 0; col < numcols; ++col) {
|
||||
chcnt += printaname(array[base], dp->s_inode,
|
||||
dp->s_block);
|
||||
if (f_sortacross)
|
||||
base++;
|
||||
else
|
||||
base += numrows;
|
||||
if (base >= num)
|
||||
if ((base += numrows) >= num)
|
||||
break;
|
||||
while ((cnt = ((chcnt + tabwidth) & ~(tabwidth - 1)))
|
||||
<= endcol) {
|
||||
if (f_sortacross && col + 1 >= numcols)
|
||||
break;
|
||||
(void)putchar(f_notabs ? ' ' : '\t');
|
||||
chcnt = cnt;
|
||||
}
|
||||
@@ -396,15 +361,6 @@ printtime(time_t ftime)
|
||||
static int
|
||||
printtype(u_int mode)
|
||||
{
|
||||
|
||||
if (f_slash) {
|
||||
if ((mode & S_IFMT) == S_IFDIR) {
|
||||
(void)putchar('/');
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
switch (mode & S_IFMT) {
|
||||
case S_IFDIR:
|
||||
(void)putchar('/');
|
||||
@@ -422,7 +378,6 @@ printtype(u_int mode)
|
||||
(void)putchar('%');
|
||||
return (1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
|
||||
(void)putchar('*');
|
||||
|
||||
+5
-4
@@ -34,13 +34,14 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
|
||||
#endif /* not lint */
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
+2
-4
@@ -58,12 +58,10 @@ as modified by the current
|
||||
The options are as follows:
|
||||
.Pp
|
||||
.Bl -tag -width indent
|
||||
.It Fl m Ar mode
|
||||
.It Fl m
|
||||
Set the file permission bits of the final created directory to
|
||||
the specified mode.
|
||||
The
|
||||
.Ar mode
|
||||
argument can be in any of the formats specified to the
|
||||
The mode argument can be in any of the formats specified to the
|
||||
.Xr chmod 1
|
||||
command.
|
||||
If a symbolic mode is specified, the operation characters
|
||||
|
||||
+4
-19
@@ -35,7 +35,7 @@
|
||||
.\" @(#)mv.1 8.1 (Berkeley) 5/31/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd August 18, 2002
|
||||
.Dd May 31, 1993
|
||||
.Dt MV 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -43,11 +43,11 @@
|
||||
.Nd move files
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl f | i | n
|
||||
.Op Fl f | Fl i
|
||||
.Op Fl v
|
||||
.Ar source target
|
||||
.Nm
|
||||
.Op Fl f | i | n
|
||||
.Op Fl f | Fl i
|
||||
.Op Fl v
|
||||
.Ar source ... directory
|
||||
.Sh DESCRIPTION
|
||||
@@ -81,8 +81,6 @@ path.
|
||||
.Fl f
|
||||
option overrides any previous
|
||||
.Fl i
|
||||
or
|
||||
.Fl n
|
||||
options.)
|
||||
.It Fl i
|
||||
Cause
|
||||
@@ -98,17 +96,6 @@ the move is attempted.
|
||||
.Fl i
|
||||
option overrides any previous
|
||||
.Fl f
|
||||
or
|
||||
.Fl n
|
||||
options.)
|
||||
.It Fl n
|
||||
Do not overwrite an existing file.
|
||||
(The
|
||||
.Fl n
|
||||
option overrides any previous
|
||||
.Fl f
|
||||
or
|
||||
.Fl i
|
||||
options.)
|
||||
.It Fl v
|
||||
Cause
|
||||
@@ -149,10 +136,8 @@ rm -f destination_path && \e
|
||||
.Xr symlink 7
|
||||
.Sh COMPATIBILITY
|
||||
The
|
||||
.Fl n
|
||||
and
|
||||
.Fl v
|
||||
options are non-standard and their use in scripts is not recommended.
|
||||
option is non-standard and its use in scripts is not recommended.
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
|
||||
+9
-17
@@ -66,7 +66,7 @@ static const char rcsid[] =
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
int fflg, iflg, nflg, vflg;
|
||||
int fflg, iflg, vflg;
|
||||
|
||||
int copy __P((char *, char *));
|
||||
int do_move __P((char *, char *));
|
||||
@@ -85,19 +85,15 @@ main(argc, argv)
|
||||
int ch;
|
||||
char path[PATH_MAX];
|
||||
|
||||
while ((ch = getopt(argc, argv, "finv")) != -1)
|
||||
while ((ch = getopt(argc, argv, "fiv")) != -1)
|
||||
switch (ch) {
|
||||
case 'i':
|
||||
iflg = 1;
|
||||
fflg = nflg = 0;
|
||||
fflg = 0;
|
||||
break;
|
||||
case 'f':
|
||||
fflg = 1;
|
||||
iflg = nflg = 0;
|
||||
break;
|
||||
case 'n':
|
||||
nflg = 1;
|
||||
fflg = iflg = 0;
|
||||
iflg = 0;
|
||||
break;
|
||||
case 'v':
|
||||
vflg = 1;
|
||||
@@ -177,11 +173,7 @@ do_move(from, to)
|
||||
|
||||
#define YESNO "(y/n [n]) "
|
||||
ask = 0;
|
||||
if (nflg) {
|
||||
if (vflg)
|
||||
printf("%s not overwritten\n", to);
|
||||
return (0);
|
||||
} else if (iflg) {
|
||||
if (iflg) {
|
||||
(void)fprintf(stderr, "overwrite %s? %s", to, YESNO);
|
||||
ask = 1;
|
||||
} else if (access(to, W_OK) && !stat(to, &sb)) {
|
||||
@@ -339,7 +331,7 @@ copy(from, to)
|
||||
int pid, status;
|
||||
|
||||
if ((pid = fork()) == 0) {
|
||||
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", "--", from, to,
|
||||
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", from, to,
|
||||
(char *)NULL);
|
||||
warn("%s", _PATH_CP);
|
||||
_exit(1);
|
||||
@@ -358,7 +350,7 @@ copy(from, to)
|
||||
return (1);
|
||||
}
|
||||
if (!(pid = vfork())) {
|
||||
execl(_PATH_RM, "mv", "-rf", "--", from, (char *)NULL);
|
||||
execl(_PATH_RM, "mv", "-rf", from, (char *)NULL);
|
||||
warn("%s", _PATH_RM);
|
||||
_exit(1);
|
||||
}
|
||||
@@ -383,7 +375,7 @@ usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: mv [-f | -i | -n] [-v] source target",
|
||||
" mv [-f | -i | -n] [-v] source ... directory");
|
||||
"usage: mv [-f | -i] [-v] source target",
|
||||
" mv [-f | -i] [-v] source ... directory");
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
+23
-24
@@ -179,12 +179,12 @@
|
||||
.Op Ar
|
||||
.Ar directory
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility will read, write, and list the members of an archive file,
|
||||
.Nm Pax
|
||||
will read, write, and list the members of an archive file,
|
||||
and will copy directory hierarchies.
|
||||
These operations are independent of the specific archive format,
|
||||
and support a wide variety of different archive formats.
|
||||
.Nm Pax
|
||||
operation is independent of the specific archive format,
|
||||
and supports a wide variety of different archive formats.
|
||||
A list of supported archive formats can be found under the description of the
|
||||
.Fl x
|
||||
option.
|
||||
@@ -202,7 +202,8 @@ and
|
||||
.Bl -tag -width 6n
|
||||
.It <none>
|
||||
.Em List .
|
||||
Write to
|
||||
.Nm Pax
|
||||
will write to
|
||||
.Dv standard output
|
||||
a table of contents of the members of the archive file read from
|
||||
.Dv standard input ,
|
||||
@@ -212,7 +213,8 @@ The table of contents contains one filename per line
|
||||
and is written using single line buffering.
|
||||
.It Fl r
|
||||
.Em Read .
|
||||
Extract the members of the archive file read from the
|
||||
.Nm Pax
|
||||
extracts the members of the archive file read from the
|
||||
.Dv standard input ,
|
||||
with pathnames matching the specified
|
||||
.Ar patterns .
|
||||
@@ -226,7 +228,8 @@ the extracted files are discussed in more detail under the
|
||||
option.
|
||||
.It Fl w
|
||||
.Em Write .
|
||||
Write an archive containing the
|
||||
.Nm Pax
|
||||
writes an archive containing the
|
||||
.Ar file
|
||||
operands to
|
||||
.Dv standard output
|
||||
@@ -241,7 +244,8 @@ operand is also a directory, the entire file hierarchy rooted
|
||||
at that directory will be included.
|
||||
.It Fl r Fl w
|
||||
.Em Copy .
|
||||
Copy the
|
||||
.Nm Pax
|
||||
copies the
|
||||
.Ar file
|
||||
operands to the destination
|
||||
.Ar directory .
|
||||
@@ -461,17 +465,15 @@ operand,
|
||||
will prompt to
|
||||
.Pa /dev/tty
|
||||
giving the name of the file, its file mode and its modification time.
|
||||
The
|
||||
.Nm
|
||||
utility will then read a line from
|
||||
.Nm Pax
|
||||
will then read a line from
|
||||
.Pa /dev/tty .
|
||||
If this line is blank, the file or archive member is skipped.
|
||||
If this line consists of a single period, the
|
||||
file or archive member is processed with no modification to its name.
|
||||
Otherwise, its name is replaced with the contents of the line.
|
||||
The
|
||||
.Nm
|
||||
utility will immediately exit with a non-zero exit status if
|
||||
.Nm Pax
|
||||
will immediately exit with a non-zero exit status if
|
||||
.Dv <EOF>
|
||||
is encountered when reading a response or if
|
||||
.Pa /dev/tty
|
||||
@@ -689,9 +691,8 @@ is not buffered, and is written only after the file has been read or written.
|
||||
.It Fl x Ar format
|
||||
Specify the output archive format, with the default format being
|
||||
.Ar ustar .
|
||||
The
|
||||
.Nm
|
||||
utility currently supports the following formats:
|
||||
.Nm Pax
|
||||
currently supports the following formats:
|
||||
.Bl -tag -width "sv4cpio"
|
||||
.It Ar cpio
|
||||
The extended cpio interchange format specified in the
|
||||
@@ -752,9 +753,8 @@ The default blocksize for this format is 10240 bytes.
|
||||
Pathnames stored by this format must be 250 characters or less in length.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
utility will detect and report any file that it is unable to store or extract
|
||||
.Nm Pax
|
||||
will detect and report any file that it is unable to store or extract
|
||||
as the result of any specific archive format restrictions.
|
||||
The individual archive formats may impose additional restrictions on use.
|
||||
Typical archive format restrictions include (but are not limited to):
|
||||
@@ -1145,9 +1145,8 @@ utility appeared in
|
||||
.An Keith Muller
|
||||
at the University of California, San Diego
|
||||
.Sh DIAGNOSTICS
|
||||
The
|
||||
.Nm
|
||||
utility will exit with one of the following values:
|
||||
.Nm Pax
|
||||
will exit with one of the following values:
|
||||
.Bl -tag -width 2n
|
||||
.It 0
|
||||
All files were processed successfully.
|
||||
|
||||
+2
-6
@@ -51,9 +51,7 @@
|
||||
.Nm
|
||||
.Op Fl L
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
.Nm Ps
|
||||
displays a header line followed by lines containing information about your
|
||||
processes that have controlling terminals.
|
||||
This information is sorted by controlling terminal, then by process
|
||||
@@ -327,9 +325,7 @@ When printing using the command keyword, a process that has exited and
|
||||
has a parent that has not yet waited for the process (in other words, a zombie)
|
||||
is listed as ``<defunct>'', and a process which is blocked while trying
|
||||
to exit is listed as ``<exiting>''.
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
.Nm Ps
|
||||
makes an educated guess as to the file name and arguments given when the
|
||||
process was created by examining memory or the swap area.
|
||||
The method is inherently somewhat unreliable and in any event a process
|
||||
|
||||
+10
-24
@@ -86,10 +86,8 @@ int totwidth; /* calculated width of requested variables */
|
||||
static int needuser, needcomm, needenv;
|
||||
#if defined(LAZY_PS)
|
||||
static int forceuread=0;
|
||||
#define PS_ARGS "aCcefghjLlM:mN:O:o:p:rSTt:U:uvwx"
|
||||
#else
|
||||
static int forceuread=1;
|
||||
#define PS_ARGS "aCceghjLlM:mN:O:o:p:rSTt:U:uvwx"
|
||||
#endif
|
||||
|
||||
enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT;
|
||||
@@ -126,9 +124,9 @@ main(argc, argv)
|
||||
dev_t ttydev;
|
||||
pid_t pid;
|
||||
uid_t *uids;
|
||||
int all, ch, flag, i, fmt, lineno, nentries, nocludge, dropgid;
|
||||
int all, ch, flag, i, fmt, lineno, nentries, dropgid;
|
||||
int prtheader, wflag, what, xflg, uid, nuids;
|
||||
char *cp, *nlistf, *memf, errbuf[_POSIX2_LINE_MAX];
|
||||
char *nlistf, *memf, errbuf[_POSIX2_LINE_MAX];
|
||||
|
||||
(void) setlocale(LC_ALL, "");
|
||||
|
||||
@@ -140,25 +138,8 @@ main(argc, argv)
|
||||
else
|
||||
termwidth = ws.ws_col - 1;
|
||||
|
||||
/*
|
||||
* Don't apply a kludge if the first argument is an option taking an
|
||||
* argument
|
||||
*/
|
||||
if (argc > 1) {
|
||||
nocludge = 0;
|
||||
if (argv[1][0] == '-') {
|
||||
for (cp = PS_ARGS; *cp != '\0'; cp++) {
|
||||
if (*cp != ':')
|
||||
continue;
|
||||
if (*(cp - 1) == argv[1][1]) {
|
||||
nocludge = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nocludge == 0)
|
||||
argv[1] = kludge_oldps_options(argv[1]);
|
||||
}
|
||||
if (argc > 1)
|
||||
argv[1] = kludge_oldps_options(argv[1]);
|
||||
|
||||
all = fmt = prtheader = wflag = xflg = 0;
|
||||
pid = -1;
|
||||
@@ -167,7 +148,12 @@ main(argc, argv)
|
||||
ttydev = NODEV;
|
||||
dropgid = 0;
|
||||
memf = nlistf = _PATH_DEVNULL;
|
||||
while ((ch = getopt(argc, argv, PS_ARGS)) != -1)
|
||||
while ((ch = getopt(argc, argv,
|
||||
#if defined(LAZY_PS)
|
||||
"aCcefghjLlM:mN:O:o:p:rSTt:U:uvwx")) != -1)
|
||||
#else
|
||||
"aCceghjLlM:mN:O:o:p:rSTt:U:uvwx")) != -1)
|
||||
#endif
|
||||
switch((char)ch) {
|
||||
case 'a':
|
||||
all = 1;
|
||||
|
||||
+9
-32
@@ -35,7 +35,7 @@
|
||||
.\" @(#)pwd.1 8.2 (Berkeley) 4/28/95
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd February 4, 2002
|
||||
.Dd April 28, 1995
|
||||
.Dt PWD 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -43,11 +43,9 @@
|
||||
.Nd return working directory name
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl LP
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility writes the absolute pathname of the current working directory to
|
||||
.Nm Pwd
|
||||
writes the absolute pathname of the current working directory to
|
||||
the standard output.
|
||||
.Pp
|
||||
Some shells may provide a builtin
|
||||
@@ -56,32 +54,17 @@ command which is similar or identical to this utility.
|
||||
Consult the
|
||||
.Xr builtin 1
|
||||
manual page.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl L
|
||||
Display the logical current working directory.
|
||||
.It Fl P
|
||||
Display the physical current working directory (all symbolic links resolved).
|
||||
.El
|
||||
.Pp
|
||||
If no options are specified, the
|
||||
.Fl P
|
||||
option is assumed.
|
||||
.Sh ENVIRONMENT
|
||||
Environment variables used by
|
||||
.Nm :
|
||||
.Bl -tag -width ".Ev PWD"
|
||||
.It Ev PWD
|
||||
Logical current working directory.
|
||||
.El
|
||||
.Sh DIAGNOSTICS
|
||||
.Ex -std
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
utility conforms to
|
||||
.St -p1003.1-2001 .
|
||||
utility is expected to be
|
||||
.St -p1003.2
|
||||
compatible.
|
||||
The
|
||||
.Fl L
|
||||
flag is not supported.
|
||||
.Sh SEE ALSO
|
||||
.Xr builtin 1 ,
|
||||
.Xr cd 1 ,
|
||||
@@ -97,9 +80,3 @@ is always faster because it is built into that shell.
|
||||
However, it can give a different answer in the rare case
|
||||
that the current directory or a containing directory was moved after
|
||||
the shell descended into it.
|
||||
.Pp
|
||||
The
|
||||
.Fl L
|
||||
option does not work unless the
|
||||
.Ev PWD
|
||||
environment variable is exported by the shell.
|
||||
+27
-61
@@ -45,45 +45,34 @@ static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
static char *getcwd_logical(void);
|
||||
void usage(void);
|
||||
int main __P((int, char *[]));
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int physical;
|
||||
int ch;
|
||||
char *p;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
if (strcmp(getprogname(), "realpath") == 0) {
|
||||
if (argc != 2)
|
||||
usage();
|
||||
if ((p = realpath(argv[1], buf)) == NULL)
|
||||
err(1, "%s", argv[1]);
|
||||
(void)printf("%s\n", p);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
physical = 1;
|
||||
while ((ch = getopt(argc, argv, "LP")) != -1)
|
||||
/*
|
||||
* Flags for pwd are a bit strange. The POSIX 1003.2B/D9 document
|
||||
* has an optional -P flag for physical, which is what this program
|
||||
* will produce by default. The logical flag, -L, should fail, as
|
||||
* there's no way to display a logical path after forking.
|
||||
*/
|
||||
while ((ch = getopt(argc, argv, "P")) != -1)
|
||||
switch (ch) {
|
||||
case 'L':
|
||||
physical = 0;
|
||||
break;
|
||||
case 'P':
|
||||
physical = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
@@ -92,50 +81,27 @@ main(int argc, char *argv[])
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 0)
|
||||
if (argc == 1) {
|
||||
p = realpath(argv[0], buf);
|
||||
if (p == NULL)
|
||||
err(1, "%s", argv[0]);
|
||||
(void)printf("%s\n", p);
|
||||
} else if (argc == 0) {
|
||||
p = getcwd(NULL, (size_t)0);
|
||||
if (p == NULL)
|
||||
err(1, ".");
|
||||
(void)printf("%s\n", p);
|
||||
} else {
|
||||
usage();
|
||||
|
||||
/*
|
||||
* If we're trying to find the logical current directory and that
|
||||
* fails, behave as if -P was specified.
|
||||
*/
|
||||
if ((!physical && (p = getcwd_logical()) != NULL) ||
|
||||
(p = getcwd(NULL, 0)) != NULL)
|
||||
printf("%s\n", p);
|
||||
else
|
||||
err(1, ".");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
usage()
|
||||
{
|
||||
|
||||
if (strcmp(getprogname(), "realpath") == 0)
|
||||
(void)fprintf(stderr, "usage: realpath [path]\n");
|
||||
else
|
||||
(void)fprintf(stderr, "usage: pwd [-LP]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static char *
|
||||
getcwd_logical(void)
|
||||
{
|
||||
struct stat log, phy;
|
||||
char *pwd;
|
||||
|
||||
/*
|
||||
* Check that $PWD is an absolute logical pathname referring to
|
||||
* the current working directory.
|
||||
*/
|
||||
if ((pwd = getenv("PWD")) != NULL && *pwd == '/') {
|
||||
if (stat(pwd, &log) == -1 || stat(".", &phy) == -1)
|
||||
return (NULL);
|
||||
if (log.st_dev == phy.st_dev && log.st_ino == phy.st_ino)
|
||||
return (pwd);
|
||||
}
|
||||
|
||||
errno = ENOENT;
|
||||
return (NULL);
|
||||
(void)fprintf(stderr, "usage: pwd\n");
|
||||
exit(1);
|
||||
}
|
||||
+2
-4
@@ -4,13 +4,11 @@
|
||||
PROG= rcp
|
||||
SRCS= rcp.c util.c
|
||||
CFLAGS+=-DBINDIR=${BINDIR}
|
||||
WARNS= 0
|
||||
WFORMAT=0
|
||||
|
||||
.if defined(MAKE_KERBEROS4) && !defined(NO_OPENSSL) && !defined(NOCRYPT)
|
||||
.if exists(${DESTDIR}${LIBDIR}/libkrb.a) && defined(MAKE_KERBEROS4)
|
||||
SRCS+= krcmd.c kcmd.c rcmd_util.c
|
||||
DPADD= ${LIBUTIL} ${LIBKRB} ${LIBCRYPTO}
|
||||
CFLAGS+=-DCRYPT -DHAVE_CONFIG_H \
|
||||
CFLAGS+=-DKERBEROS -DCRYPT -DHAVE_CONFIG_H \
|
||||
-I${.CURDIR}/../../kerberosIV/include \
|
||||
-I${.CURDIR}/../../crypto/kerberosIV/include \
|
||||
-I${.CURDIR}/../../crypto/kerberosIV/lib/roken \
|
||||
|
||||
+9
-9
@@ -35,17 +35,17 @@
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
size_t cnt;
|
||||
int cnt;
|
||||
char *buf;
|
||||
} BUF;
|
||||
|
||||
extern int iamremote;
|
||||
|
||||
BUF *allocbuf(BUF *, int, int);
|
||||
char *colon(char *);
|
||||
void lostconn(int);
|
||||
void nospace(void);
|
||||
int okname(char *);
|
||||
void run_err(const char *, ...) __printflike(1, 2);
|
||||
int susystem(char *, int);
|
||||
void verifydir(char *);
|
||||
BUF *allocbuf __P((BUF *, int, int));
|
||||
char *colon __P((char *));
|
||||
void lostconn __P((int));
|
||||
void nospace __P((void));
|
||||
int okname __P((char *));
|
||||
void run_err __P((const char *, ...)) __printflike(1, 2);
|
||||
int susystem __P((char *, int));
|
||||
void verifydir __P((char *));
|
||||
@@ -1,5 +1,3 @@
|
||||
/* $NetBSD: pathnames.h,v 1.10 2000/03/06 21:42:26 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@@ -32,20 +30,13 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)pathnames.h 8.1 (Berkeley) 6/4/93
|
||||
* @(#)pathnames.h 8.1 (Berkeley) 5/31/93
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _DEFAULT_CONFDIR
|
||||
#define _DEFAULT_CONFDIR "/etc"
|
||||
#endif
|
||||
#include <paths.h>
|
||||
|
||||
#define _PATH_FTPCHROOT "ftpchroot"
|
||||
#define _PATH_FTPDCONF "ftpd.conf"
|
||||
#define _PATH_FTPLOGINMESG "motd"
|
||||
#undef _PATH_FTPUSERS
|
||||
#define _PATH_FTPUSERS "ftpusers"
|
||||
#define _PATH_FTPWELCOME "ftpwelcome"
|
||||
|
||||
#define _PATH_CLASSPIDS "/var/run/ftpd.pids-"
|
||||
|
||||
#define TMPFILE "/tmp/ftpdXXXXXXX"
|
||||
#define _PATH_CP "/bin/cp"
|
||||
#define _PATH_RCP "/bin/rcp"
|
||||
#define _PATH_RLOGIN "/usr/bin/rlogin"
|
||||
#define _PATH_RSH "/usr/bin/rsh"
|
||||
+2
-6
@@ -40,11 +40,11 @@
|
||||
.Nd remote file copy
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl 46Kpx
|
||||
.Op Fl Kpx
|
||||
.Op Fl k Ar realm
|
||||
.Ar file1 file2
|
||||
.Nm
|
||||
.Op Fl 46Kprx
|
||||
.Op Fl Kprx
|
||||
.Op Fl k Ar realm
|
||||
.Ar
|
||||
.Ar directory
|
||||
@@ -63,10 +63,6 @@ or a `/' before any `:'s).
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width indent
|
||||
.It Fl 4
|
||||
Use IPv4 addresses only.
|
||||
.It Fl 6
|
||||
Use IPv6 addresses only.
|
||||
.It Fl K
|
||||
Turn off all Kerberos authentication.
|
||||
.It Fl k
|
||||
|
||||
+87
-76
@@ -1,13 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1983, 1990, 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* Copyright (c) 2002 Networks Associates Technology, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Portions of this software were developed for the FreeBSD Project by
|
||||
* ThinkSec AS and NAI Labs, the Security Research Division of Network
|
||||
* Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
|
||||
* ("CBOSS"), as part of the DARPA CHATS research program.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -48,9 +41,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)rcp.c 8.2 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -68,7 +61,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <libutil.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <paths.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -77,6 +69,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
#include "extern.h"
|
||||
|
||||
#ifdef KERBEROS
|
||||
@@ -87,17 +80,17 @@ __FBSDID("$FreeBSD$");
|
||||
char dst_realm_buf[REALM_SZ];
|
||||
char *dest_realm = NULL;
|
||||
int use_kerberos = 1;
|
||||
CREDENTIALS cred;
|
||||
CREDENTIALS cred;
|
||||
Key_schedule schedule;
|
||||
extern char *krb_realmofhost();
|
||||
#ifdef CRYPT
|
||||
int doencrypt = 0;
|
||||
#define OPTIONS "46dfKk:prtx"
|
||||
#define OPTIONS "dfKk:prtx"
|
||||
#else
|
||||
#define OPTIONS "46dfKk:prt"
|
||||
#define OPTIONS "dfKk:prt"
|
||||
#endif
|
||||
#else
|
||||
#define OPTIONS "46dfprt"
|
||||
#define OPTIONS "dfprt"
|
||||
#endif
|
||||
|
||||
struct passwd *pwd;
|
||||
@@ -105,7 +98,6 @@ u_short port;
|
||||
uid_t userid;
|
||||
int errs, rem;
|
||||
int pflag, iamremote, iamrecursive, targetshouldbedirectory;
|
||||
int family = PF_UNSPEC;
|
||||
|
||||
static int argc_copy;
|
||||
static char **argv_copy;
|
||||
@@ -114,20 +106,22 @@ static char **argv_copy;
|
||||
char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */
|
||||
|
||||
#ifdef KERBEROS
|
||||
int kerberos(char **, char *, char *, char *);
|
||||
void oldw(const char *, ...) __printflike(1, 2);
|
||||
int kerberos __P((char **, char *, char *, char *));
|
||||
void oldw __P((const char *, ...)) __printflike(1, 2);
|
||||
#endif
|
||||
int response(void);
|
||||
void rsource(char *, struct stat *);
|
||||
void run_err(const char *, ...) __printflike(1, 2);
|
||||
void sink(int, char *[]);
|
||||
void source(int, char *[]);
|
||||
void tolocal(int, char *[]);
|
||||
void toremote(char *, int, char *[]);
|
||||
void usage(void);
|
||||
int response __P((void));
|
||||
void rsource __P((char *, struct stat *));
|
||||
void run_err __P((const char *, ...)) __printflike(1, 2);
|
||||
void sink __P((int, char *[]));
|
||||
void source __P((int, char *[]));
|
||||
void tolocal __P((int, char *[]));
|
||||
void toremote __P((char *, int, char *[]));
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
struct servent *sp;
|
||||
int ch, fflag, i, tflag;
|
||||
@@ -155,14 +149,6 @@ main(int argc, char *argv[])
|
||||
fflag = tflag = 0;
|
||||
while ((ch = getopt(argc, argv, OPTIONS)) != -1)
|
||||
switch(ch) { /* User-visible flags. */
|
||||
case '4':
|
||||
family = PF_INET;
|
||||
break;
|
||||
|
||||
case '6':
|
||||
family = PF_INET6;
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
#ifdef KERBEROS
|
||||
use_kerberos = 0;
|
||||
@@ -283,7 +269,9 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
void
|
||||
toremote(char *targ, int argc, char *argv[])
|
||||
toremote(targ, argc, argv)
|
||||
char *targ, *argv[];
|
||||
int argc;
|
||||
{
|
||||
int i, len, tos;
|
||||
char *bp, *host, *src, *suser, *thost, *tuser;
|
||||
@@ -316,7 +304,7 @@ toremote(char *targ, int argc, char *argv[])
|
||||
strlen(src) + (tuser ? strlen(tuser) : 0) +
|
||||
strlen(thost) + strlen(targ) + CMDNEEDS + 20;
|
||||
if (!(bp = malloc(len)))
|
||||
err(1, "malloc");
|
||||
err(1, NULL);
|
||||
if (host) {
|
||||
*host++ = 0;
|
||||
suser = argv[i];
|
||||
@@ -343,7 +331,7 @@ toremote(char *targ, int argc, char *argv[])
|
||||
if (rem == -1) {
|
||||
len = strlen(targ) + CMDNEEDS + 20;
|
||||
if (!(bp = malloc(len)))
|
||||
err(1, "malloc");
|
||||
err(1, NULL);
|
||||
(void)snprintf(bp, len, "%s -t %s", cmd, targ);
|
||||
host = thost;
|
||||
#ifdef KERBEROS
|
||||
@@ -353,18 +341,15 @@ toremote(char *targ, int argc, char *argv[])
|
||||
tuser ? tuser : pwd->pw_name);
|
||||
else
|
||||
#endif
|
||||
rem = rcmd_af(&host, port,
|
||||
pwd->pw_name,
|
||||
rem = rcmd(&host, port, pwd->pw_name,
|
||||
tuser ? tuser : pwd->pw_name,
|
||||
bp, 0, family);
|
||||
bp, 0);
|
||||
if (rem < 0)
|
||||
exit(1);
|
||||
if (family == PF_INET) {
|
||||
tos = IPTOS_THROUGHPUT;
|
||||
if (setsockopt(rem, IPPROTO_IP, IP_TOS,
|
||||
&tos, sizeof(int)) < 0)
|
||||
warn("TOS (ignored)");
|
||||
}
|
||||
tos = IPTOS_THROUGHPUT;
|
||||
if (setsockopt(rem, IPPROTO_IP, IP_TOS,
|
||||
&tos, sizeof(int)) < 0)
|
||||
warn("TOS (ignored)");
|
||||
if (response() < 0)
|
||||
exit(1);
|
||||
(void)free(bp);
|
||||
@@ -376,7 +361,9 @@ toremote(char *targ, int argc, char *argv[])
|
||||
}
|
||||
|
||||
void
|
||||
tolocal(int argc, char *argv[])
|
||||
tolocal(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int i, len, tos;
|
||||
char *bp, *host, *src, *suser;
|
||||
@@ -386,7 +373,7 @@ tolocal(int argc, char *argv[])
|
||||
len = strlen(_PATH_CP) + strlen(argv[i]) +
|
||||
strlen(argv[argc - 1]) + 20;
|
||||
if (!(bp = malloc(len)))
|
||||
err(1, "malloc");
|
||||
err(1, NULL);
|
||||
(void)snprintf(bp, len, "exec %s%s%s %s %s", _PATH_CP,
|
||||
iamrecursive ? " -PR" : "", pflag ? " -p" : "",
|
||||
argv[i], argv[argc - 1]);
|
||||
@@ -413,27 +400,23 @@ tolocal(int argc, char *argv[])
|
||||
}
|
||||
len = strlen(src) + CMDNEEDS + 20;
|
||||
if ((bp = malloc(len)) == NULL)
|
||||
err(1, "malloc");
|
||||
err(1, NULL);
|
||||
(void)snprintf(bp, len, "%s -f %s", cmd, src);
|
||||
rem =
|
||||
#ifdef KERBEROS
|
||||
use_kerberos ?
|
||||
kerberos(&host, bp, pwd->pw_name, suser) :
|
||||
#endif
|
||||
rcmd_af(&host, port, pwd->pw_name, suser, bp, 0,
|
||||
family);
|
||||
rcmd(&host, port, pwd->pw_name, suser, bp, 0);
|
||||
(void)free(bp);
|
||||
if (rem < 0) {
|
||||
++errs;
|
||||
continue;
|
||||
}
|
||||
(void)seteuid(userid);
|
||||
if (family == PF_INET) {
|
||||
tos = IPTOS_THROUGHPUT;
|
||||
if (setsockopt(rem, IPPROTO_IP, IP_TOS, &tos,
|
||||
sizeof(int)) < 0)
|
||||
warn("TOS (ignored)");
|
||||
}
|
||||
tos = IPTOS_THROUGHPUT;
|
||||
if (setsockopt(rem, IPPROTO_IP, IP_TOS, &tos, sizeof(int)) < 0)
|
||||
warn("TOS (ignored)");
|
||||
sink(1, argv + argc - 1);
|
||||
(void)seteuid(0);
|
||||
(void)close(rem);
|
||||
@@ -442,7 +425,9 @@ tolocal(int argc, char *argv[])
|
||||
}
|
||||
|
||||
void
|
||||
source(int argc, char *argv[])
|
||||
source(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
struct stat stb;
|
||||
static BUF buffer;
|
||||
@@ -452,7 +437,7 @@ source(int argc, char *argv[])
|
||||
char *last, *name, buf[BUFSIZ];
|
||||
|
||||
for (indx = 0; indx < argc; ++indx) {
|
||||
name = argv[indx];
|
||||
name = argv[indx];
|
||||
if ((fd = open(name, O_RDONLY, 0)) < 0)
|
||||
goto syserr;
|
||||
if (fstat(fd, &stb)) {
|
||||
@@ -528,7 +513,9 @@ next: (void)close(fd);
|
||||
}
|
||||
|
||||
void
|
||||
rsource(char *name, struct stat *statp)
|
||||
rsource(name, statp)
|
||||
char *name;
|
||||
struct stat *statp;
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
@@ -579,7 +566,9 @@ rsource(char *name, struct stat *statp)
|
||||
}
|
||||
|
||||
void
|
||||
sink(int argc, char *argv[])
|
||||
sink(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
static BUF buffer;
|
||||
struct stat stb;
|
||||
@@ -686,17 +675,14 @@ sink(int argc, char *argv[])
|
||||
if (*cp++ != ' ')
|
||||
SCREWUP("size not delimited");
|
||||
if (targisdir) {
|
||||
static char *namebuf = NULL;
|
||||
static size_t cursize;
|
||||
static char *namebuf;
|
||||
static int cursize;
|
||||
size_t need;
|
||||
|
||||
need = strlen(targ) + strlen(cp) + 250;
|
||||
if (need > cursize) {
|
||||
if (namebuf != NULL)
|
||||
free(namebuf);
|
||||
if (!(namebuf = malloc(need)))
|
||||
run_err("%s", strerror(errno));
|
||||
cursize = need;
|
||||
}
|
||||
(void)snprintf(namebuf, need, "%s%s%s", targ,
|
||||
*targ ? "/" : "", cp);
|
||||
@@ -820,7 +806,8 @@ screwup:
|
||||
|
||||
#ifdef KERBEROS
|
||||
int
|
||||
kerberos(char **host, char *bp, char *locuser, char *user)
|
||||
kerberos(host, bp, locuser, user)
|
||||
char **host, *bp, *locuser, *user;
|
||||
{
|
||||
if (use_kerberos) {
|
||||
setuid(getuid());
|
||||
@@ -850,14 +837,14 @@ kerberos(char **host, char *bp, char *locuser, char *user)
|
||||
errx(1,
|
||||
"the -x option requires Kerberos authentication");
|
||||
#endif
|
||||
rem = rcmd_af(host, port, locuser, user, bp, 0, family);
|
||||
rem = rcmd(host, port, locuser, user, bp, 0);
|
||||
}
|
||||
return (rem);
|
||||
}
|
||||
#endif /* KERBEROS */
|
||||
|
||||
int
|
||||
response(void)
|
||||
response()
|
||||
{
|
||||
char ch, *cp, resp, rbuf[BUFSIZ];
|
||||
|
||||
@@ -890,34 +877,48 @@ response(void)
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
usage()
|
||||
{
|
||||
#ifdef KERBEROS
|
||||
#ifdef CRYPT
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: rcp [-46Kpx] [-k realm] f1 f2",
|
||||
" rcp [-46Kprx] [-k realm] f1 ... fn directory");
|
||||
"usage: rcp [-Kpx] [-k realm] f1 f2",
|
||||
" rcp [-Kprx] [-k realm] f1 ... fn directory");
|
||||
#else
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: rcp [-46Kp] [-k realm] f1 f2",
|
||||
" rcp [-46Kpr] [-k realm] f1 ... fn directory");
|
||||
"usage: rcp [-Kp] [-k realm] f1 f2",
|
||||
" rcp [-Kpr] [-k realm] f1 ... fn directory");
|
||||
#endif
|
||||
#else
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
"usage: rcp [-46p] f1 f2",
|
||||
" rcp [-46pr] f1 ... fn directory");
|
||||
"usage: rcp [-p] f1 f2",
|
||||
" rcp [-pr] f1 ... fn directory");
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#ifdef KERBEROS
|
||||
void
|
||||
#if __STDC__
|
||||
oldw(const char *fmt, ...)
|
||||
#else
|
||||
oldw(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "rcp: ");
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)fprintf(stderr, ", using standard rcp\n");
|
||||
@@ -926,11 +927,21 @@ oldw(const char *fmt, ...)
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
run_err(const char *fmt, ...)
|
||||
#else
|
||||
run_err(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
static FILE *fp;
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
|
||||
++errs;
|
||||
if (fp == NULL && !(fp = fdopen(rem, "w")))
|
||||
|
||||
+16
-8
@@ -35,9 +35,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)util.c 8.2 (Berkeley) 4/2/94";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -56,7 +56,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include "extern.h"
|
||||
|
||||
char *
|
||||
colon(char *cp)
|
||||
colon(cp)
|
||||
char *cp;
|
||||
{
|
||||
if (*cp == ':') /* Leading colon is part of file name. */
|
||||
return (0);
|
||||
@@ -71,7 +72,8 @@ colon(char *cp)
|
||||
}
|
||||
|
||||
void
|
||||
verifydir(char *cp)
|
||||
verifydir(cp)
|
||||
char *cp;
|
||||
{
|
||||
struct stat stb;
|
||||
|
||||
@@ -85,7 +87,8 @@ verifydir(char *cp)
|
||||
}
|
||||
|
||||
int
|
||||
okname(char *cp0)
|
||||
okname(cp0)
|
||||
char *cp0;
|
||||
{
|
||||
int c;
|
||||
char *cp;
|
||||
@@ -105,7 +108,9 @@ bad: warnx("%s: invalid user name", cp0);
|
||||
}
|
||||
|
||||
int
|
||||
susystem(char *s, int userid)
|
||||
susystem(s, userid)
|
||||
int userid;
|
||||
char *s;
|
||||
{
|
||||
sig_t istat, qstat;
|
||||
int status;
|
||||
@@ -131,7 +136,9 @@ susystem(char *s, int userid)
|
||||
}
|
||||
|
||||
BUF *
|
||||
allocbuf(BUF *bp, int fd, int blksize)
|
||||
allocbuf(bp, fd, blksize)
|
||||
BUF *bp;
|
||||
int fd, blksize;
|
||||
{
|
||||
struct stat stb;
|
||||
size_t size;
|
||||
@@ -155,7 +162,8 @@ allocbuf(BUF *bp, int fd, int blksize)
|
||||
}
|
||||
|
||||
void
|
||||
lostconn(int signo)
|
||||
lostconn(signo)
|
||||
int signo;
|
||||
{
|
||||
if (!iamremote)
|
||||
warnx("lost connection");
|
||||
|
||||
+31
-24
@@ -40,10 +40,11 @@ static const char copyright[] =
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
|
||||
#else
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
@@ -62,12 +63,12 @@ __FBSDID("$FreeBSD$");
|
||||
int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
|
||||
uid_t uid;
|
||||
|
||||
int check(char *, char *, struct stat *);
|
||||
void checkdot(char **);
|
||||
void rm_file(char **);
|
||||
void rm_overwrite(char *, struct stat *);
|
||||
void rm_tree(char **);
|
||||
void usage(void);
|
||||
int check __P((char *, char *, struct stat *));
|
||||
void checkdot __P((char **));
|
||||
void rm_file __P((char **));
|
||||
void rm_overwrite __P((char *, struct stat *));
|
||||
void rm_tree __P((char **));
|
||||
void usage __P((void));
|
||||
|
||||
/*
|
||||
* rm --
|
||||
@@ -77,7 +78,9 @@ void usage(void);
|
||||
* file removal.
|
||||
*/
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int ch, rflag;
|
||||
char *p;
|
||||
@@ -92,14 +95,11 @@ main(int argc, char *argv[])
|
||||
else
|
||||
++p;
|
||||
if (strcmp(p, "unlink") == 0) {
|
||||
while (getopt(argc, argv, "") != -1)
|
||||
if (argc == 2) {
|
||||
rm_file(&argv[1]);
|
||||
exit(eval);
|
||||
} else
|
||||
usage();
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc != 1)
|
||||
usage();
|
||||
rm_file(&argv[0]);
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
Pflag = rflag = 0;
|
||||
@@ -157,7 +157,8 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
void
|
||||
rm_tree(char **argv)
|
||||
rm_tree(argv)
|
||||
char **argv;
|
||||
{
|
||||
FTS *fts;
|
||||
FTSENT *p;
|
||||
@@ -288,7 +289,8 @@ err:
|
||||
}
|
||||
|
||||
void
|
||||
rm_file(char **argv)
|
||||
rm_file(argv)
|
||||
char **argv;
|
||||
{
|
||||
struct stat sb;
|
||||
int rval;
|
||||
@@ -355,12 +357,14 @@ rm_file(char **argv)
|
||||
* XXX
|
||||
* This is a cheap way to *really* delete files. Note that only regular
|
||||
* files are deleted, directories (and therefore names) will remain.
|
||||
* Also, this assumes a fixed-block filesystem (like FFS, or a V7 or a
|
||||
* System V filesystem). In a logging filesystem, you'll have to have
|
||||
* Also, this assumes a fixed-block file system (like FFS, or a V7 or a
|
||||
* System V file system). In a logging file system, you'll have to have
|
||||
* kernel support.
|
||||
*/
|
||||
void
|
||||
rm_overwrite(char *file, struct stat *sbp)
|
||||
rm_overwrite(file, sbp)
|
||||
char *file;
|
||||
struct stat *sbp;
|
||||
{
|
||||
struct stat sb;
|
||||
struct statfs fsb;
|
||||
@@ -412,7 +416,9 @@ err: eval = 1;
|
||||
|
||||
|
||||
int
|
||||
check(char *path, char *name, struct stat *sp)
|
||||
check(path, name, sp)
|
||||
char *path, *name;
|
||||
struct stat *sp;
|
||||
{
|
||||
int ch, first;
|
||||
char modep[15], *flagsp;
|
||||
@@ -453,7 +459,8 @@ check(char *path, char *name, struct stat *sp)
|
||||
|
||||
#define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2])))
|
||||
void
|
||||
checkdot(char **argv)
|
||||
checkdot(argv)
|
||||
char **argv;
|
||||
{
|
||||
char *p, **save, **t;
|
||||
int complained;
|
||||
@@ -477,7 +484,7 @@ checkdot(char **argv)
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n",
|
||||
|
||||
+27
-25
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "shell.h"
|
||||
@@ -56,13 +56,14 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
struct alias *atab[ATABSIZE];
|
||||
|
||||
STATIC void setalias(char *, char *);
|
||||
STATIC int unalias(char *);
|
||||
STATIC struct alias **hashalias(char *);
|
||||
STATIC void setalias __P((char *, char *));
|
||||
STATIC int unalias __P((char *));
|
||||
STATIC struct alias **hashalias __P((char *));
|
||||
|
||||
STATIC
|
||||
void
|
||||
setalias(char *name, char *val)
|
||||
setalias(name, val)
|
||||
char *name, *val;
|
||||
{
|
||||
struct alias *ap, **app;
|
||||
|
||||
@@ -115,8 +116,9 @@ setalias(char *name, char *val)
|
||||
}
|
||||
|
||||
STATIC int
|
||||
unalias(char *name)
|
||||
{
|
||||
unalias(name)
|
||||
char *name;
|
||||
{
|
||||
struct alias *ap, **app;
|
||||
|
||||
app = hashalias(name);
|
||||
@@ -156,8 +158,7 @@ SHELLPROC {
|
||||
#endif
|
||||
|
||||
void
|
||||
rmaliases(void)
|
||||
{
|
||||
rmaliases() {
|
||||
struct alias *ap, *tmp;
|
||||
int i;
|
||||
|
||||
@@ -177,7 +178,9 @@ rmaliases(void)
|
||||
}
|
||||
|
||||
struct alias *
|
||||
lookupalias(char *name, int check)
|
||||
lookupalias(name, check)
|
||||
char *name;
|
||||
int check;
|
||||
{
|
||||
struct alias *ap = *hashalias(name);
|
||||
|
||||
@@ -196,7 +199,9 @@ lookupalias(char *name, int check)
|
||||
* TODO - sort output
|
||||
*/
|
||||
int
|
||||
aliascmd(int argc, char **argv)
|
||||
aliascmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *n, *v;
|
||||
int ret = 0;
|
||||
@@ -207,11 +212,8 @@ aliascmd(int argc, char **argv)
|
||||
|
||||
for (i = 0; i < ATABSIZE; i++)
|
||||
for (ap = atab[i]; ap; ap = ap->next) {
|
||||
if (*ap->name != '\0') {
|
||||
out1fmt("alias %s=", ap->name);
|
||||
out1qstr(ap->val);
|
||||
out1c('\n');
|
||||
}
|
||||
if (*ap->name != '\0')
|
||||
out1fmt("alias %s=%s\n", ap->name, ap->val);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
@@ -220,11 +222,8 @@ aliascmd(int argc, char **argv)
|
||||
if ((ap = lookupalias(n, 0)) == NULL) {
|
||||
outfmt(out2, "alias: %s not found\n", n);
|
||||
ret = 1;
|
||||
} else {
|
||||
out1fmt("alias %s=", n);
|
||||
out1qstr(ap->val);
|
||||
out1c('\n');
|
||||
}
|
||||
} else
|
||||
out1fmt("alias %s=%s\n", n, ap->val);
|
||||
else {
|
||||
*v++ = '\0';
|
||||
setalias(n, v);
|
||||
@@ -235,7 +234,9 @@ aliascmd(int argc, char **argv)
|
||||
}
|
||||
|
||||
int
|
||||
unaliascmd(int argc __unused, char **argv __unused)
|
||||
unaliascmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -252,8 +253,9 @@ unaliascmd(int argc __unused, char **argv __unused)
|
||||
}
|
||||
|
||||
STATIC struct alias **
|
||||
hashalias(char *p)
|
||||
{
|
||||
hashalias(p)
|
||||
char *p;
|
||||
{
|
||||
unsigned int hashval;
|
||||
|
||||
hashval = *p << 4;
|
||||
|
||||
+4
-4
@@ -46,7 +46,7 @@ struct alias {
|
||||
int flag;
|
||||
};
|
||||
|
||||
struct alias *lookupalias(char *, int);
|
||||
int aliascmd(int, char **);
|
||||
int unaliascmd(int, char **);
|
||||
void rmaliases(void);
|
||||
struct alias *lookupalias __P((char *, int));
|
||||
int aliascmd __P((int, char **));
|
||||
int unaliascmd __P((int, char **));
|
||||
void rmaliases __P((void));
|
||||
+2
-2
@@ -34,5 +34,5 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
int arith(char *);
|
||||
int expcmd(int , char **);
|
||||
int arith __P((char *));
|
||||
int expcmd __P((int , char **));
|
||||
+15
-8
@@ -87,6 +87,8 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -105,11 +107,12 @@ static const char rcsid[] =
|
||||
char *arith_buf, *arith_startbuf;
|
||||
extern void arith_lex_reset();
|
||||
|
||||
int yylex(void);
|
||||
int yyparse(void);
|
||||
int yylex __P((void));
|
||||
int yyparse __P((void));
|
||||
|
||||
int
|
||||
arith(char *s)
|
||||
arith(s)
|
||||
char *s;
|
||||
{
|
||||
long result;
|
||||
|
||||
@@ -124,7 +127,8 @@ arith(char *s)
|
||||
}
|
||||
|
||||
void
|
||||
yyerror(char *s)
|
||||
yyerror(s)
|
||||
char *s;
|
||||
{
|
||||
|
||||
yyerrok;
|
||||
@@ -137,7 +141,9 @@ yyerror(char *s)
|
||||
* The exp(1) builtin.
|
||||
*/
|
||||
int
|
||||
expcmd(int argc, char **argv)
|
||||
expcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *p;
|
||||
char *concat;
|
||||
@@ -174,12 +180,13 @@ expcmd(int argc, char **argv)
|
||||
/*************************/
|
||||
#ifdef TEST_ARITH
|
||||
#include <stdio.h>
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
printf("%d\n", exp(argv[1]));
|
||||
}
|
||||
|
||||
error(char *s)
|
||||
error(s)
|
||||
char *s;
|
||||
{
|
||||
fprintf(stderr, "exp: %s\n", s);
|
||||
exit(1);
|
||||
|
||||
+3
-2
@@ -33,6 +33,8 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@@ -83,7 +85,6 @@ extern char *arith_buf, *arith_startbuf;
|
||||
%%
|
||||
|
||||
void
|
||||
arith_lex_reset()
|
||||
{
|
||||
arith_lex_reset() {
|
||||
YY_NEW_FILE;
|
||||
}
|
||||
@@ -83,8 +83,13 @@
|
||||
#define INITARGS(argv) if ((commandname = argv[0]) == NULL) {fputs("Argc is zero\n", stderr); exit(2);} else
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
pointer stalloc(int);
|
||||
void error(const char *, ...) __printf0like(1, 2);
|
||||
#else
|
||||
pointer stalloc();
|
||||
void error();
|
||||
#endif
|
||||
|
||||
|
||||
extern char *commandname;
|
||||
+3
-1
@@ -48,7 +48,9 @@
|
||||
/* #define eflag 1 */
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char **ap;
|
||||
char *p;
|
||||
|
||||
+1
-3
@@ -49,8 +49,7 @@
|
||||
#
|
||||
# NOTE: bltincmd must come first!
|
||||
|
||||
bltincmd builtin
|
||||
commandcmd command
|
||||
bltincmd command
|
||||
#alloccmd alloc
|
||||
bgcmd -j bg
|
||||
breakcmd break continue
|
||||
@@ -92,4 +91,3 @@ waitcmd wait
|
||||
aliascmd alias
|
||||
ulimitcmd ulimit
|
||||
testcmd test [
|
||||
bindcmd bind
|
||||
+105
-114
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
/*
|
||||
* The cd and pwd commands.
|
||||
@@ -68,47 +67,27 @@ __FBSDID("$FreeBSD$");
|
||||
#include "show.h"
|
||||
#include "cd.h"
|
||||
|
||||
STATIC int cdlogical(char *);
|
||||
STATIC int cdphysical(char *);
|
||||
STATIC int docd(char *, int, int);
|
||||
STATIC char *getcomponent(void);
|
||||
STATIC int updatepwd(char *);
|
||||
STATIC int docd __P((char *, int));
|
||||
STATIC char *getcomponent __P((void));
|
||||
STATIC void updatepwd __P((char *));
|
||||
|
||||
char *curdir = NULL; /* current working directory */
|
||||
char *prevdir; /* previous working directory */
|
||||
STATIC char *cdcomppath;
|
||||
|
||||
int
|
||||
cdcmd(int argc, char **argv)
|
||||
cdcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
char *dest;
|
||||
char *path;
|
||||
char *p;
|
||||
struct stat statb;
|
||||
int ch, phys, print = 0;
|
||||
int print = 0;
|
||||
|
||||
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
|
||||
phys = Pflag;
|
||||
while ((ch = getopt(argc, argv, "LP")) != -1) {
|
||||
switch (ch) {
|
||||
case 'L':
|
||||
phys = 0;
|
||||
break;
|
||||
case 'P':
|
||||
phys = 1;
|
||||
break;
|
||||
default:
|
||||
error("unknown option: -%c", optopt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc > 1)
|
||||
error("too many arguments");
|
||||
|
||||
if ((dest = *argv) == NULL && (dest = bltinlookup("HOME", 1)) == NULL)
|
||||
nextopt(nullstr);
|
||||
if ((dest = *argptr) == NULL && (dest = bltinlookup("HOME", 1)) == NULL)
|
||||
error("HOME not set");
|
||||
if (*dest == '\0')
|
||||
dest = ".";
|
||||
@@ -131,8 +110,9 @@ cdcmd(int argc, char **argv)
|
||||
p += 2;
|
||||
print = strcmp(p, dest);
|
||||
}
|
||||
if (docd(p, print, phys) >= 0)
|
||||
if (docd(p, print) >= 0)
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
error("can't cd to %s", dest);
|
||||
@@ -142,27 +122,13 @@ cdcmd(int argc, char **argv)
|
||||
|
||||
|
||||
/*
|
||||
* Actually change the directory. In an interactive shell, print the
|
||||
* Actually do the chdir. In an interactive shell, print the
|
||||
* directory name if "print" is nonzero.
|
||||
*/
|
||||
STATIC int
|
||||
docd(char *dest, int print, int phys)
|
||||
{
|
||||
|
||||
TRACE(("docd(\"%s\", %d, %d) called\n", dest, print, phys));
|
||||
|
||||
/* If logical cd fails, fall back to physical. */
|
||||
if ((phys || cdlogical(dest) < 0) && cdphysical(dest) < 0)
|
||||
return (-1);
|
||||
|
||||
if (print && iflag && curdir)
|
||||
out1fmt("%s\n", curdir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC int
|
||||
cdlogical(char *dest)
|
||||
docd(dest, print)
|
||||
char *dest;
|
||||
int print;
|
||||
{
|
||||
char *p;
|
||||
char *q;
|
||||
@@ -171,6 +137,8 @@ cdlogical(char *dest)
|
||||
int first;
|
||||
int badstat;
|
||||
|
||||
TRACE(("docd(\"%s\", %d) called\n", dest, print));
|
||||
|
||||
/*
|
||||
* Check each component of the path. If we find a symlink or
|
||||
* something we can't stat, clear curdir to force a getcwd()
|
||||
@@ -197,40 +165,33 @@ cdlogical(char *dest)
|
||||
if (equal(component, ".."))
|
||||
continue;
|
||||
STACKSTRNUL(p);
|
||||
if (lstat(stackblock(), &statb) < 0) {
|
||||
if ((lstat(stackblock(), &statb) < 0)
|
||||
|| (S_ISLNK(statb.st_mode))) {
|
||||
/* print = 1; */
|
||||
badstat = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
INTOFF;
|
||||
if (updatepwd(badstat ? NULL : dest) < 0 || chdir(curdir) < 0) {
|
||||
if (chdir(dest) < 0) {
|
||||
INTON;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
updatepwd(badstat ? NULL : dest);
|
||||
INTON;
|
||||
return (0);
|
||||
if (print && iflag && curdir)
|
||||
out1fmt("%s\n", curdir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC int
|
||||
cdphysical(char *dest)
|
||||
{
|
||||
|
||||
INTOFF;
|
||||
if (chdir(dest) < 0 || updatepwd(NULL) < 0) {
|
||||
INTON;
|
||||
return (-1);
|
||||
}
|
||||
INTON;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the next component of the path name pointed to by cdcomppath.
|
||||
* This routine overwrites the string pointed to by cdcomppath.
|
||||
*/
|
||||
STATIC char *
|
||||
getcomponent(void)
|
||||
getcomponent()
|
||||
{
|
||||
char *p;
|
||||
char *start;
|
||||
@@ -255,8 +216,9 @@ getcomponent(void)
|
||||
* cd command. We also call hashcd to let the routines in exec.c know
|
||||
* that the current directory has changed.
|
||||
*/
|
||||
STATIC int
|
||||
updatepwd(char *dir)
|
||||
STATIC void
|
||||
updatepwd(dir)
|
||||
char *dir;
|
||||
{
|
||||
char *new;
|
||||
char *p;
|
||||
@@ -274,14 +236,12 @@ updatepwd(char *dir)
|
||||
INTOFF;
|
||||
prevdir = curdir;
|
||||
curdir = NULL;
|
||||
if (getpwd() == NULL) {
|
||||
INTON;
|
||||
return (-1);
|
||||
}
|
||||
if (getpwd() == NULL)
|
||||
error("getcwd() failed: %s", strerror(errno));
|
||||
setvar("PWD", curdir, VEXPORT);
|
||||
setvar("OLDPWD", prevdir, VEXPORT);
|
||||
INTON;
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
cdcomppath = stalloc(strlen(dir) + 1);
|
||||
scopy(dir, cdcomppath);
|
||||
@@ -313,61 +273,51 @@ updatepwd(char *dir)
|
||||
setvar("PWD", curdir, VEXPORT);
|
||||
setvar("OLDPWD", prevdir, VEXPORT);
|
||||
INTON;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
pwdcmd(int argc, char **argv)
|
||||
pwdcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
int ch, phys;
|
||||
|
||||
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
|
||||
phys = Pflag;
|
||||
while ((ch = getopt(argc, argv, "LP")) != -1) {
|
||||
switch (ch) {
|
||||
case 'L':
|
||||
phys = 0;
|
||||
break;
|
||||
case 'P':
|
||||
phys = 1;
|
||||
break;
|
||||
default:
|
||||
error("unknown option: -%c", optopt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 0)
|
||||
error("too many arguments");
|
||||
|
||||
if (!phys && getpwd()) {
|
||||
out1str(curdir);
|
||||
out1c('\n');
|
||||
} else {
|
||||
if (getcwd(buf, sizeof(buf)) == NULL)
|
||||
error(".: %s", strerror(errno));
|
||||
out1str(buf);
|
||||
out1c('\n');
|
||||
}
|
||||
|
||||
if (!getpwd())
|
||||
error("getcwd() failed: %s", strerror(errno));
|
||||
out1str(curdir);
|
||||
out1c('\n');
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define MAXPWD 256
|
||||
|
||||
/*
|
||||
* Find out what the current directory is. If we already know the current
|
||||
* directory, this routine returns immediately.
|
||||
*/
|
||||
char *
|
||||
getpwd(void)
|
||||
getpwd()
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
char buf[MAXPWD];
|
||||
|
||||
if (curdir)
|
||||
return curdir;
|
||||
/*
|
||||
* Things are a bit complicated here; we could have just used
|
||||
* getcwd, but traditionally getcwd is implemented using popen
|
||||
* to /bin/pwd. This creates a problem for us, since we cannot
|
||||
* keep track of the job if it is being ran behind our backs.
|
||||
* So we re-implement getcwd(), and we suppress interrupts
|
||||
* throughout the process. This is not completely safe, since
|
||||
* the user can still break out of it by killing the pwd program.
|
||||
* We still try to use getcwd for systems that we know have a
|
||||
* c implementation of getcwd, that does not open a pipe to
|
||||
* /bin/pwd.
|
||||
*/
|
||||
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__SVR4)
|
||||
|
||||
if (getcwd(buf, sizeof(buf)) == NULL) {
|
||||
char *pwd = getenv("PWD");
|
||||
struct stat stdot, stpwd;
|
||||
@@ -382,6 +332,47 @@ getpwd(void)
|
||||
return NULL;
|
||||
}
|
||||
curdir = savestr(buf);
|
||||
#else
|
||||
{
|
||||
char *p;
|
||||
int i;
|
||||
int status;
|
||||
struct job *jp;
|
||||
int pip[2];
|
||||
|
||||
INTOFF;
|
||||
if (pipe(pip) < 0)
|
||||
error("Pipe call failed: %s", strerror(errno));
|
||||
jp = makejob((union node *)NULL, 1);
|
||||
if (forkshell(jp, (union node *)NULL, FORK_NOJOB) == 0) {
|
||||
(void) close(pip[0]);
|
||||
if (pip[1] != 1) {
|
||||
close(1);
|
||||
copyfd(pip[1], 1);
|
||||
close(pip[1]);
|
||||
}
|
||||
(void) execl("/bin/pwd", "pwd", (char *)0);
|
||||
error("Cannot exec /bin/pwd");
|
||||
}
|
||||
(void) close(pip[1]);
|
||||
pip[1] = -1;
|
||||
p = buf;
|
||||
while ((i = read(pip[0], p, buf + MAXPWD - p)) > 0
|
||||
|| (i == -1 && errno == EINTR)) {
|
||||
if (i > 0)
|
||||
p += i;
|
||||
}
|
||||
(void) close(pip[0]);
|
||||
pip[0] = -1;
|
||||
status = waitforjob(jp);
|
||||
if (status != 0)
|
||||
error((char *)0);
|
||||
if (i < 0 || p == buf || p[-1] != '\n')
|
||||
error("pwd command failed");
|
||||
p[-1] = '\0';
|
||||
}
|
||||
curdir = savestr(buf);
|
||||
INTON;
|
||||
#endif
|
||||
return curdir;
|
||||
}
|
||||
+3
-3
@@ -33,6 +33,6 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
char *getpwd(void);
|
||||
int cdcmd (int, char **);
|
||||
int pwdcmd(int, char **);
|
||||
char *getpwd __P((void));
|
||||
int cdcmd __P((int, char **));
|
||||
int pwdcmd __P((int, char **));
|
||||
+46
-9
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Errors and exceptions.
|
||||
@@ -71,7 +71,7 @@ volatile sig_atomic_t intpending;
|
||||
char *commandname;
|
||||
|
||||
|
||||
static void exverror(int, const char *, va_list) __printf0like(2, 0);
|
||||
static void exverror __P((int, const char *, va_list)) __printf0like(2, 0);
|
||||
|
||||
/*
|
||||
* Called to raise an exception. Since C doesn't include exceptions, we
|
||||
@@ -80,7 +80,8 @@ static void exverror(int, const char *, va_list) __printf0like(2, 0);
|
||||
*/
|
||||
|
||||
void
|
||||
exraise(int e)
|
||||
exraise(e)
|
||||
int e;
|
||||
{
|
||||
if (handler == NULL)
|
||||
abort();
|
||||
@@ -100,8 +101,7 @@ exraise(int e)
|
||||
*/
|
||||
|
||||
void
|
||||
onint(void)
|
||||
{
|
||||
onint() {
|
||||
sigset_t sigset;
|
||||
|
||||
/*
|
||||
@@ -140,7 +140,10 @@ onint(void)
|
||||
* formatting. It then raises the error exception.
|
||||
*/
|
||||
static void
|
||||
exverror(int cond, const char *msg, va_list ap)
|
||||
exverror(cond, msg, ap)
|
||||
int cond;
|
||||
const char *msg;
|
||||
va_list ap;
|
||||
{
|
||||
CLEAR_PENDING_INT;
|
||||
INTOFF;
|
||||
@@ -162,21 +165,51 @@ exverror(int cond, const char *msg, va_list ap)
|
||||
}
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
error(const char *msg, ...)
|
||||
#else
|
||||
void
|
||||
error(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifndef __STDC__
|
||||
const char *msg;
|
||||
#endif
|
||||
va_list ap;
|
||||
#ifdef __STDC__
|
||||
va_start(ap, msg);
|
||||
#else
|
||||
va_start(ap);
|
||||
msg = va_arg(ap, char *);
|
||||
#endif
|
||||
exverror(EXERROR, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
exerror(int cond, const char *msg, ...)
|
||||
#else
|
||||
void
|
||||
exerror(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifndef __STDC__
|
||||
int cond;
|
||||
char *msg;
|
||||
#endif
|
||||
va_list ap;
|
||||
#ifdef __STDC__
|
||||
va_start(ap, msg);
|
||||
#else
|
||||
va_start(ap);
|
||||
cond = va_arg(ap, int);
|
||||
msg = va_arg(ap, char *);
|
||||
#endif
|
||||
exverror(cond, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
@@ -221,6 +254,9 @@ STATIC const struct errname errormsg[] = {
|
||||
{ ENXIO, ALL, "no such device or address" },
|
||||
{ EROFS, ALL, "read-only file system" },
|
||||
{ ETXTBSY, ALL, "text busy" },
|
||||
#ifdef SYSV
|
||||
{ EAGAIN, E_EXEC, "not enough memory" },
|
||||
#endif
|
||||
{ ENOMEM, ALL, "not enough memory" },
|
||||
#ifdef ENOLINK
|
||||
{ ENOLINK, ALL, "remote access failed" },
|
||||
@@ -244,7 +280,6 @@ STATIC const struct errname errormsg[] = {
|
||||
#ifdef ELIBACC
|
||||
{ ELIBACC, E_EXEC, "shared library missing" },
|
||||
#endif
|
||||
{ EEXIST, E_CREAT, "file exists" },
|
||||
{ 0, 0, NULL },
|
||||
};
|
||||
|
||||
@@ -256,7 +291,9 @@ STATIC const struct errname errormsg[] = {
|
||||
*/
|
||||
|
||||
char *
|
||||
errmsg(int e, int action)
|
||||
errmsg(e, action)
|
||||
int e;
|
||||
int action;
|
||||
{
|
||||
struct errname const *ep;
|
||||
static char buf[12];
|
||||
|
||||
+7
-5
@@ -89,11 +89,11 @@ extern volatile sig_atomic_t intpending;
|
||||
#define CLEAR_PENDING_INT intpending = 0
|
||||
#define int_pending() intpending
|
||||
|
||||
void exraise(int);
|
||||
void onint(void);
|
||||
void error(const char *, ...) __printf0like(1, 2);
|
||||
void exerror(int, const char *, ...) __printf0like(2, 3);
|
||||
char *errmsg(int, int);
|
||||
void exraise __P((int));
|
||||
void onint __P((void));
|
||||
void error __P((const char *, ...)) __printf0like(1, 2);
|
||||
void exerror __P((int, const char *, ...)) __printf0like(2, 3);
|
||||
char *errmsg __P((int, int));
|
||||
|
||||
|
||||
/*
|
||||
@@ -101,5 +101,7 @@ char *errmsg(int, int);
|
||||
* so we use _setjmp instead.
|
||||
*/
|
||||
|
||||
#ifdef BSD
|
||||
#define setjmp(jmploc) _setjmp(jmploc)
|
||||
#define longjmp(jmploc, val) _longjmp(jmploc, val)
|
||||
#endif
|
||||
+62
-85
@@ -38,11 +38,10 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <paths.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h> /* For WIFSIGNALED(status) */
|
||||
@@ -93,14 +92,14 @@ int exitstatus; /* exit status of last command */
|
||||
int oexitstatus; /* saved exit status */
|
||||
|
||||
|
||||
STATIC void evalloop(union node *);
|
||||
STATIC void evalfor(union node *);
|
||||
STATIC void evalcase(union node *, int);
|
||||
STATIC void evalsubshell(union node *, int);
|
||||
STATIC void expredir(union node *);
|
||||
STATIC void evalpipe(union node *);
|
||||
STATIC void evalcommand(union node *, int, struct backcmd *);
|
||||
STATIC void prehash(union node *);
|
||||
STATIC void evalloop __P((union node *));
|
||||
STATIC void evalfor __P((union node *));
|
||||
STATIC void evalcase __P((union node *, int));
|
||||
STATIC void evalsubshell __P((union node *, int));
|
||||
STATIC void expredir __P((union node *));
|
||||
STATIC void evalpipe __P((union node *));
|
||||
STATIC void evalcommand __P((union node *, int, struct backcmd *));
|
||||
STATIC void prehash __P((union node *));
|
||||
|
||||
|
||||
/*
|
||||
@@ -128,7 +127,9 @@ SHELLPROC {
|
||||
*/
|
||||
|
||||
int
|
||||
evalcmd(int argc, char **argv)
|
||||
evalcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char *p;
|
||||
char *concat;
|
||||
@@ -160,8 +161,9 @@ evalcmd(int argc, char **argv)
|
||||
*/
|
||||
|
||||
void
|
||||
evalstring(char *s)
|
||||
{
|
||||
evalstring(s)
|
||||
char *s;
|
||||
{
|
||||
union node *n;
|
||||
struct stackmark smark;
|
||||
|
||||
@@ -183,7 +185,9 @@ evalstring(char *s)
|
||||
*/
|
||||
|
||||
void
|
||||
evaltree(union node *n, int flags)
|
||||
evaltree(n, flags)
|
||||
union node *n;
|
||||
int flags;
|
||||
{
|
||||
if (n == NULL) {
|
||||
TRACE(("evaltree(NULL) called\n"));
|
||||
@@ -301,7 +305,8 @@ out:
|
||||
|
||||
|
||||
STATIC void
|
||||
evalloop(union node *n)
|
||||
evalloop(n)
|
||||
union node *n;
|
||||
{
|
||||
int status;
|
||||
|
||||
@@ -337,7 +342,8 @@ skipping: if (evalskip == SKIPCONT && --skipcount <= 0) {
|
||||
|
||||
|
||||
STATIC void
|
||||
evalfor(union node *n)
|
||||
evalfor(n)
|
||||
union node *n;
|
||||
{
|
||||
struct arglist arglist;
|
||||
union node *argp;
|
||||
@@ -377,7 +383,9 @@ out:
|
||||
|
||||
|
||||
STATIC void
|
||||
evalcase(union node *n, int flags)
|
||||
evalcase(n, flags)
|
||||
union node *n;
|
||||
int flags;
|
||||
{
|
||||
union node *cp;
|
||||
union node *patp;
|
||||
@@ -409,7 +417,9 @@ out:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
evalsubshell(union node *n, int flags)
|
||||
evalsubshell(n, flags)
|
||||
union node *n;
|
||||
int flags;
|
||||
{
|
||||
struct job *jp;
|
||||
int backgnd = (n->type == NBACKGND);
|
||||
@@ -436,7 +446,8 @@ evalsubshell(union node *n, int flags)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
expredir(union node *n)
|
||||
expredir(n)
|
||||
union node *n;
|
||||
{
|
||||
union node *redir;
|
||||
|
||||
@@ -449,7 +460,6 @@ expredir(union node *n)
|
||||
case NTO:
|
||||
case NFROMTO:
|
||||
case NAPPEND:
|
||||
case NCLOBBER:
|
||||
expandarg(redir->nfile.fname, &fn, EXP_TILDE | EXP_REDIR);
|
||||
redir->nfile.expfname = fn.list->text;
|
||||
break;
|
||||
@@ -474,7 +484,8 @@ expredir(union node *n)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
evalpipe(union node *n)
|
||||
evalpipe(n)
|
||||
union node *n;
|
||||
{
|
||||
struct job *jp;
|
||||
struct nodelist *lp;
|
||||
@@ -540,7 +551,9 @@ evalpipe(union node *n)
|
||||
*/
|
||||
|
||||
void
|
||||
evalbackcmd(union node *n, struct backcmd *result)
|
||||
evalbackcmd(n, result)
|
||||
union node *n;
|
||||
struct backcmd *result;
|
||||
{
|
||||
int pip[2];
|
||||
struct job *jp;
|
||||
@@ -590,7 +603,10 @@ out:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
|
||||
evalcommand(cmd, flags, backcmd)
|
||||
union node *cmd;
|
||||
int flags;
|
||||
struct backcmd *backcmd;
|
||||
{
|
||||
struct stackmark smark;
|
||||
union node *argp;
|
||||
@@ -748,9 +764,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
|
||||
&& (cmdentry.cmdtype != CMDBUILTIN
|
||||
|| cmdentry.u.index == CDCMD
|
||||
|| cmdentry.u.index == DOTCMD
|
||||
|| cmdentry.u.index == EVALCMD))
|
||||
|| (cmdentry.cmdtype == CMDBUILTIN &&
|
||||
cmdentry.u.index == COMMANDCMD)) {
|
||||
|| cmdentry.u.index == EVALCMD))) {
|
||||
jp = makejob(cmd, 1);
|
||||
mode = cmd->ncmd.backgnd;
|
||||
if (flags & EV_BACKCMD) {
|
||||
@@ -872,8 +886,7 @@ cmddone:
|
||||
#ifndef NO_HISTORY
|
||||
|| cmdentry.u.index == HISTCMD
|
||||
#endif
|
||||
|| cmdentry.u.index == EXECCMD
|
||||
|| cmdentry.u.index == COMMANDCMD)
|
||||
|| cmdentry.u.index == EXECCMD)
|
||||
exraise(e);
|
||||
FORCEINTON;
|
||||
}
|
||||
@@ -931,7 +944,8 @@ out:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
prehash(union node *n)
|
||||
prehash(n)
|
||||
union node *n;
|
||||
{
|
||||
struct cmdentry entry;
|
||||
|
||||
@@ -954,7 +968,9 @@ prehash(union node *n)
|
||||
*/
|
||||
|
||||
int
|
||||
bltincmd(int argc __unused, char **argv __unused)
|
||||
bltincmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
listsetvar(cmdenviron);
|
||||
/*
|
||||
@@ -977,7 +993,9 @@ bltincmd(int argc __unused, char **argv __unused)
|
||||
*/
|
||||
|
||||
int
|
||||
breakcmd(int argc, char **argv)
|
||||
breakcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int n = argc > 1 ? number(argv[1]) : 1;
|
||||
|
||||
@@ -990,62 +1008,15 @@ breakcmd(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The `command' command.
|
||||
*/
|
||||
int
|
||||
commandcmd(int argc, char **argv)
|
||||
{
|
||||
static char stdpath[] = _PATH_STDPATH;
|
||||
struct jmploc loc, *old;
|
||||
struct strlist *sp;
|
||||
char *path;
|
||||
int ch;
|
||||
|
||||
for (sp = cmdenviron; sp ; sp = sp->next)
|
||||
setvareq(sp->text, VEXPORT|VSTACK);
|
||||
path = pathval();
|
||||
|
||||
optind = optreset = 1;
|
||||
opterr = 0;
|
||||
while ((ch = getopt(argc, argv, "p")) != -1) {
|
||||
switch (ch) {
|
||||
case 'p':
|
||||
path = stdpath;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
error("unknown option: -%c", optopt);
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 0) {
|
||||
old = handler;
|
||||
handler = &loc;
|
||||
if (setjmp(handler->loc) == 0)
|
||||
shellexec(argv, environment(), path, 0);
|
||||
handler = old;
|
||||
if (exception == EXEXEC)
|
||||
exit(exerrno);
|
||||
exraise(exception);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do nothing successfully if no command was specified;
|
||||
* ksh also does this.
|
||||
*/
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The return command.
|
||||
*/
|
||||
|
||||
int
|
||||
returncmd(int argc, char **argv)
|
||||
returncmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int ret = argc > 1 ? number(argv[1]) : oexitstatus;
|
||||
|
||||
@@ -1062,21 +1033,27 @@ returncmd(int argc, char **argv)
|
||||
|
||||
|
||||
int
|
||||
falsecmd(int argc __unused, char **argv __unused)
|
||||
falsecmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
truecmd(int argc __unused, char **argv __unused)
|
||||
truecmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
execcmd(int argc, char **argv)
|
||||
execcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
if (argc > 1) {
|
||||
struct strlist *sp;
|
||||
|
||||
+10
-11
@@ -49,18 +49,17 @@ struct backcmd { /* result of evalbackcmd */
|
||||
struct job *jp; /* job structure for command */
|
||||
};
|
||||
|
||||
int evalcmd(int, char **);
|
||||
void evalstring(char *);
|
||||
int evalcmd __P((int, char **));
|
||||
void evalstring __P((char *));
|
||||
union node; /* BLETCH for ansi C */
|
||||
void evaltree(union node *, int);
|
||||
void evalbackcmd(union node *, struct backcmd *);
|
||||
int bltincmd(int, char **);
|
||||
int breakcmd(int, char **);
|
||||
int returncmd(int, char **);
|
||||
int falsecmd(int, char **);
|
||||
int truecmd(int, char **);
|
||||
int execcmd(int, char **);
|
||||
int commandcmd(int, char **);
|
||||
void evaltree __P((union node *, int));
|
||||
void evalbackcmd __P((union node *, struct backcmd *));
|
||||
int bltincmd __P((int, char **));
|
||||
int breakcmd __P((int, char **));
|
||||
int returncmd __P((int, char **));
|
||||
int falsecmd __P((int, char **));
|
||||
int truecmd __P((int, char **));
|
||||
int execcmd __P((int, char **));
|
||||
|
||||
/* in_function returns nonzero if we are currently evaluating a function */
|
||||
#define in_function() funcnest
|
||||
|
||||
+182
-35
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -99,10 +99,13 @@ STATIC int builtinloc = -1; /* index in path of %builtin, or -1 */
|
||||
int exerrno = 0; /* Last exec error */
|
||||
|
||||
|
||||
STATIC void tryexec(char *, char **, char **);
|
||||
STATIC void printentry(struct tblentry *, int);
|
||||
STATIC struct tblentry *cmdlookup(char *, int);
|
||||
STATIC void delete_cmd_entry(void);
|
||||
STATIC void tryexec __P((char *, char **, char **));
|
||||
#ifndef BSD
|
||||
STATIC void execinterp __P((char **, char **));
|
||||
#endif
|
||||
STATIC void printentry __P((struct tblentry *, int));
|
||||
STATIC struct tblentry *cmdlookup __P((char *, int));
|
||||
STATIC void delete_cmd_entry __P((void));
|
||||
|
||||
|
||||
|
||||
@@ -112,7 +115,10 @@ STATIC void delete_cmd_entry(void);
|
||||
*/
|
||||
|
||||
void
|
||||
shellexec(char **argv, char **envp, char *path, int index)
|
||||
shellexec(argv, envp, path, index)
|
||||
char **argv, **envp;
|
||||
char *path;
|
||||
int index;
|
||||
{
|
||||
char *cmdname;
|
||||
int e;
|
||||
@@ -149,16 +155,36 @@ shellexec(char **argv, char **envp, char *path, int index)
|
||||
|
||||
|
||||
STATIC void
|
||||
tryexec(char *cmd, char **argv, char **envp)
|
||||
{
|
||||
tryexec(cmd, argv, envp)
|
||||
char *cmd;
|
||||
char **argv;
|
||||
char **envp;
|
||||
{
|
||||
int e;
|
||||
#ifndef BSD
|
||||
char *p;
|
||||
#endif
|
||||
|
||||
#ifdef SYSV
|
||||
do {
|
||||
execve(cmd, argv, envp);
|
||||
} while (errno == EINTR);
|
||||
#else
|
||||
execve(cmd, argv, envp);
|
||||
#endif
|
||||
e = errno;
|
||||
if (e == ENOEXEC) {
|
||||
initshellproc();
|
||||
setinputfile(cmd, 0);
|
||||
commandname = arg0 = savestr(argv[0]);
|
||||
#ifndef BSD
|
||||
pgetc(); pungetc(); /* fill up input buffer */
|
||||
p = parsenextc;
|
||||
if (parsenleft > 2 && p[0] == '#' && p[1] == '!') {
|
||||
argv[0] = cmd;
|
||||
execinterp(argv, envp);
|
||||
}
|
||||
#endif
|
||||
setparam(argv + 1);
|
||||
exraise(EXSHELLPROC);
|
||||
/*NOTREACHED*/
|
||||
@@ -166,6 +192,86 @@ tryexec(char *cmd, char **argv, char **envp)
|
||||
errno = e;
|
||||
}
|
||||
|
||||
|
||||
#ifndef BSD
|
||||
/*
|
||||
* Execute an interpreter introduced by "#!", for systems where this
|
||||
* feature has not been built into the kernel. If the interpreter is
|
||||
* the shell, return (effectively ignoring the "#!"). If the execution
|
||||
* of the interpreter fails, exit.
|
||||
*
|
||||
* This code peeks inside the input buffer in order to avoid actually
|
||||
* reading any input. It would benefit from a rewrite.
|
||||
*/
|
||||
|
||||
#define NEWARGS 5
|
||||
|
||||
STATIC void
|
||||
execinterp(argv, envp)
|
||||
char **argv, **envp;
|
||||
{
|
||||
int n;
|
||||
char *inp;
|
||||
char *outp;
|
||||
char c;
|
||||
char *p;
|
||||
char **ap;
|
||||
char *newargs[NEWARGS];
|
||||
int i;
|
||||
char **ap2;
|
||||
char **new;
|
||||
|
||||
n = parsenleft - 2;
|
||||
inp = parsenextc + 2;
|
||||
ap = newargs;
|
||||
for (;;) {
|
||||
while (--n >= 0 && (*inp == ' ' || *inp == '\t'))
|
||||
inp++;
|
||||
if (n < 0)
|
||||
goto bad;
|
||||
if ((c = *inp++) == '\n')
|
||||
break;
|
||||
if (ap == &newargs[NEWARGS])
|
||||
bad: error("Bad #! line");
|
||||
STARTSTACKSTR(outp);
|
||||
do {
|
||||
STPUTC(c, outp);
|
||||
} while (--n >= 0 && (c = *inp++) != ' ' && c != '\t' && c != '\n');
|
||||
STPUTC('\0', outp);
|
||||
n++, inp--;
|
||||
*ap++ = grabstackstr(outp);
|
||||
}
|
||||
if (ap == newargs + 1) { /* if no args, maybe no exec is needed */
|
||||
p = newargs[0];
|
||||
for (;;) {
|
||||
if (equal(p, "sh") || equal(p, "ash")) {
|
||||
return;
|
||||
}
|
||||
while (*p != '/') {
|
||||
if (*p == '\0')
|
||||
goto break2;
|
||||
p++;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
break2:;
|
||||
}
|
||||
i = (char *)ap - (char *)newargs; /* size in bytes */
|
||||
if (i == 0)
|
||||
error("Bad #! line");
|
||||
for (ap2 = argv ; *ap2++ != NULL ; );
|
||||
new = ckmalloc(i + ((char *)ap2 - (char *)argv));
|
||||
ap = newargs, ap2 = new;
|
||||
while ((i -= sizeof (char **)) >= 0)
|
||||
*ap2++ = *ap++;
|
||||
ap = argv;
|
||||
while (*ap2++ = *ap++);
|
||||
shellexec(new, envp, pathval(), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Do a path search. The variable path (passed by reference) should be
|
||||
* set to the start of the path before the first call; padvance will update
|
||||
@@ -179,8 +285,10 @@ tryexec(char *cmd, char **argv, char **envp)
|
||||
char *pathopt;
|
||||
|
||||
char *
|
||||
padvance(char **path, char *name)
|
||||
{
|
||||
padvance(path, name)
|
||||
char **path;
|
||||
char *name;
|
||||
{
|
||||
char *p, *q;
|
||||
char *start;
|
||||
int len;
|
||||
@@ -217,7 +325,9 @@ padvance(char **path, char *name)
|
||||
|
||||
|
||||
int
|
||||
hashcmd(int argc __unused, char **argv __unused)
|
||||
hashcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
struct tblentry **pp;
|
||||
struct tblentry *cmdp;
|
||||
@@ -237,8 +347,7 @@ hashcmd(int argc __unused, char **argv __unused)
|
||||
if (*argptr == NULL) {
|
||||
for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
|
||||
for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
|
||||
if (cmdp->cmdtype == CMDNORMAL)
|
||||
printentry(cmdp, verbose);
|
||||
printentry(cmdp, verbose);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -266,8 +375,10 @@ hashcmd(int argc __unused, char **argv __unused)
|
||||
|
||||
|
||||
STATIC void
|
||||
printentry(struct tblentry *cmdp, int verbose)
|
||||
{
|
||||
printentry(cmdp, verbose)
|
||||
struct tblentry *cmdp;
|
||||
int verbose;
|
||||
{
|
||||
int index;
|
||||
char *path;
|
||||
char *name;
|
||||
@@ -310,7 +421,11 @@ printentry(struct tblentry *cmdp, int verbose)
|
||||
*/
|
||||
|
||||
void
|
||||
find_command(char *name, struct cmdentry *entry, int printerr, char *path)
|
||||
find_command(name, entry, printerr, path)
|
||||
char *name;
|
||||
struct cmdentry *entry;
|
||||
int printerr;
|
||||
char *path;
|
||||
{
|
||||
struct tblentry *cmdp;
|
||||
int index;
|
||||
@@ -379,7 +494,11 @@ loop:
|
||||
TRACE(("searchexec \"%s\": no change\n", name));
|
||||
goto success;
|
||||
}
|
||||
if (stat(fullname, &statb) < 0) {
|
||||
while (stat(fullname, &statb) < 0) {
|
||||
#ifdef SYSV
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
#endif
|
||||
if (errno != ENOENT && errno != ENOTDIR)
|
||||
e = errno;
|
||||
goto loop;
|
||||
@@ -437,7 +556,8 @@ success:
|
||||
*/
|
||||
|
||||
int
|
||||
find_builtin(char *name)
|
||||
find_builtin(name)
|
||||
char *name;
|
||||
{
|
||||
const struct builtincmd *bp;
|
||||
|
||||
@@ -456,8 +576,7 @@ find_builtin(char *name)
|
||||
*/
|
||||
|
||||
void
|
||||
hashcd(void)
|
||||
{
|
||||
hashcd() {
|
||||
struct tblentry **pp;
|
||||
struct tblentry *cmdp;
|
||||
|
||||
@@ -479,7 +598,8 @@ hashcd(void)
|
||||
*/
|
||||
|
||||
void
|
||||
changepath(const char *newval)
|
||||
changepath(newval)
|
||||
const char *newval;
|
||||
{
|
||||
const char *old, *new;
|
||||
int index;
|
||||
@@ -523,7 +643,8 @@ changepath(const char *newval)
|
||||
*/
|
||||
|
||||
void
|
||||
clearcmdentry(int firstchange)
|
||||
clearcmdentry(firstchange)
|
||||
int firstchange;
|
||||
{
|
||||
struct tblentry **tblp;
|
||||
struct tblentry **pp;
|
||||
@@ -561,8 +682,7 @@ SHELLPROC {
|
||||
#endif
|
||||
|
||||
void
|
||||
deletefuncs(void)
|
||||
{
|
||||
deletefuncs() {
|
||||
struct tblentry **tblp;
|
||||
struct tblentry **pp;
|
||||
struct tblentry *cmdp;
|
||||
@@ -597,7 +717,9 @@ struct tblentry **lastcmdentry;
|
||||
|
||||
|
||||
STATIC struct tblentry *
|
||||
cmdlookup(char *name, int add)
|
||||
cmdlookup(name, add)
|
||||
char *name;
|
||||
int add;
|
||||
{
|
||||
int hashval;
|
||||
char *p;
|
||||
@@ -634,8 +756,7 @@ cmdlookup(char *name, int add)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
delete_cmd_entry(void)
|
||||
{
|
||||
delete_cmd_entry() {
|
||||
struct tblentry *cmdp;
|
||||
|
||||
INTOFF;
|
||||
@@ -647,14 +768,35 @@ delete_cmd_entry(void)
|
||||
|
||||
|
||||
|
||||
#ifdef notdef
|
||||
void
|
||||
getcmdentry(name, entry)
|
||||
char *name;
|
||||
struct cmdentry *entry;
|
||||
{
|
||||
struct tblentry *cmdp = cmdlookup(name, 0);
|
||||
|
||||
if (cmdp) {
|
||||
entry->u = cmdp->param;
|
||||
entry->cmdtype = cmdp->cmdtype;
|
||||
} else {
|
||||
entry->cmdtype = CMDUNKNOWN;
|
||||
entry->u.index = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Add a new command entry, replacing any existing command entry for
|
||||
* the same name.
|
||||
*/
|
||||
|
||||
void
|
||||
addcmdentry(char *name, struct cmdentry *entry)
|
||||
{
|
||||
addcmdentry(name, entry)
|
||||
char *name;
|
||||
struct cmdentry *entry;
|
||||
{
|
||||
struct tblentry *cmdp;
|
||||
|
||||
INTOFF;
|
||||
@@ -673,8 +815,10 @@ addcmdentry(char *name, struct cmdentry *entry)
|
||||
*/
|
||||
|
||||
void
|
||||
defun(char *name, union node *func)
|
||||
{
|
||||
defun(name, func)
|
||||
char *name;
|
||||
union node *func;
|
||||
{
|
||||
struct cmdentry entry;
|
||||
|
||||
INTOFF;
|
||||
@@ -690,8 +834,9 @@ defun(char *name, union node *func)
|
||||
*/
|
||||
|
||||
int
|
||||
unsetfunc(char *name)
|
||||
{
|
||||
unsetfunc(name)
|
||||
char *name;
|
||||
{
|
||||
struct tblentry *cmdp;
|
||||
|
||||
if ((cmdp = cmdlookup(name, 0)) != NULL && cmdp->cmdtype == CMDFUNCTION) {
|
||||
@@ -707,7 +852,9 @@ unsetfunc(char *name)
|
||||
*/
|
||||
|
||||
int
|
||||
typecmd(int argc, char **argv)
|
||||
typecmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct cmdentry entry;
|
||||
struct tblentry *cmdp;
|
||||
|
||||
+14
-14
@@ -56,17 +56,17 @@ struct cmdentry {
|
||||
extern char *pathopt; /* set by padvance */
|
||||
extern int exerrno; /* last exec error */
|
||||
|
||||
void shellexec(char **, char **, char *, int);
|
||||
char *padvance(char **, char *);
|
||||
int hashcmd(int, char **);
|
||||
void find_command(char *, struct cmdentry *, int, char *);
|
||||
int find_builtin(char *);
|
||||
void hashcd(void);
|
||||
void changepath(const char *);
|
||||
void deletefuncs(void);
|
||||
void getcmdentry(char *, struct cmdentry *);
|
||||
void addcmdentry(char *, struct cmdentry *);
|
||||
void defun(char *, union node *);
|
||||
int unsetfunc(char *);
|
||||
int typecmd(int, char **);
|
||||
void clearcmdentry(int);
|
||||
void shellexec __P((char **, char **, char *, int));
|
||||
char *padvance __P((char **, char *));
|
||||
int hashcmd __P((int, char **));
|
||||
void find_command __P((char *, struct cmdentry *, int, char *));
|
||||
int find_builtin __P((char *));
|
||||
void hashcd __P((void));
|
||||
void changepath __P((const char *));
|
||||
void deletefuncs __P((void));
|
||||
void getcmdentry __P((char *, struct cmdentry *));
|
||||
void addcmdentry __P((char *, struct cmdentry *));
|
||||
void defun __P((char *, union node *));
|
||||
int unsetfunc __P((char *));
|
||||
int typecmd __P((int, char **));
|
||||
void clearcmdentry __P((int));
|
||||
+105
-68
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
@@ -95,27 +95,27 @@ struct ifsregion ifsfirst; /* first struct in list of ifs regions */
|
||||
struct ifsregion *ifslastp; /* last struct in list */
|
||||
struct arglist exparg; /* holds expanded arg list */
|
||||
|
||||
STATIC void argstr(char *, int);
|
||||
STATIC char *exptilde(char *, int);
|
||||
STATIC void expbackq(union node *, int, int);
|
||||
STATIC int subevalvar(char *, char *, int, int, int, int);
|
||||
STATIC char *evalvar(char *, int);
|
||||
STATIC int varisset(char *, int);
|
||||
STATIC void varvalue(char *, int, int);
|
||||
STATIC void recordregion(int, int, int);
|
||||
STATIC void removerecordregions(int);
|
||||
STATIC void ifsbreakup(char *, struct arglist *);
|
||||
STATIC void expandmeta(struct strlist *, int);
|
||||
STATIC void expmeta(char *, char *);
|
||||
STATIC void addfname(char *);
|
||||
STATIC struct strlist *expsort(struct strlist *);
|
||||
STATIC struct strlist *msort(struct strlist *, int);
|
||||
STATIC int pmatch(char *, char *, int);
|
||||
STATIC char *cvtnum(int, char *);
|
||||
STATIC int collate_range_cmp(int, int);
|
||||
STATIC void argstr __P((char *, int));
|
||||
STATIC char *exptilde __P((char *, int));
|
||||
STATIC void expbackq __P((union node *, int, int));
|
||||
STATIC int subevalvar __P((char *, char *, int, int, int, int));
|
||||
STATIC char *evalvar __P((char *, int));
|
||||
STATIC int varisset __P((char *, int));
|
||||
STATIC void varvalue __P((char *, int, int));
|
||||
STATIC void recordregion __P((int, int, int));
|
||||
STATIC void removerecordregions __P((int));
|
||||
STATIC void ifsbreakup __P((char *, struct arglist *));
|
||||
STATIC void expandmeta __P((struct strlist *, int));
|
||||
STATIC void expmeta __P((char *, char *));
|
||||
STATIC void addfname __P((char *));
|
||||
STATIC struct strlist *expsort __P((struct strlist *));
|
||||
STATIC struct strlist *msort __P((struct strlist *, int));
|
||||
STATIC int pmatch __P((char *, char *, int));
|
||||
STATIC char *cvtnum __P((int, char *));
|
||||
STATIC int collate_range_cmp __P((int, int));
|
||||
|
||||
STATIC int
|
||||
collate_range_cmp (int c1, int c2)
|
||||
STATIC int collate_range_cmp (c1, c2)
|
||||
int c1, c2;
|
||||
{
|
||||
static char s1[2], s2[2];
|
||||
int ret;
|
||||
@@ -133,13 +133,13 @@ collate_range_cmp (int c1, int c2)
|
||||
|
||||
/*
|
||||
* Expand shell variables and backquotes inside a here document.
|
||||
* union node *arg the document
|
||||
* int fd; where to write the expanded version
|
||||
*/
|
||||
|
||||
void
|
||||
expandhere(union node *arg, int fd)
|
||||
{
|
||||
expandhere(arg, fd)
|
||||
union node *arg; /* the document */
|
||||
int fd; /* where to write the expanded version */
|
||||
{
|
||||
herefd = fd;
|
||||
expandarg(arg, (struct arglist *)NULL, 0);
|
||||
xwrite(fd, stackblock(), expdest - stackblock());
|
||||
@@ -154,7 +154,10 @@ expandhere(union node *arg, int fd)
|
||||
*/
|
||||
|
||||
void
|
||||
expandarg(union node *arg, struct arglist *arglist, int flag)
|
||||
expandarg(arg, arglist, flag)
|
||||
union node *arg;
|
||||
struct arglist *arglist;
|
||||
int flag;
|
||||
{
|
||||
struct strlist *sp;
|
||||
char *p;
|
||||
@@ -210,7 +213,9 @@ expandarg(union node *arg, struct arglist *arglist, int flag)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
argstr(char *p, int flag)
|
||||
argstr(p, flag)
|
||||
char *p;
|
||||
int flag;
|
||||
{
|
||||
char c;
|
||||
int quotes = flag & (EXP_FULL | EXP_CASE); /* do CTLESC */
|
||||
@@ -272,7 +277,9 @@ breakloop:;
|
||||
}
|
||||
|
||||
STATIC char *
|
||||
exptilde(char *p, int flag)
|
||||
exptilde(p, flag)
|
||||
char *p;
|
||||
int flag;
|
||||
{
|
||||
char c, *startp = p;
|
||||
struct passwd *pw;
|
||||
@@ -320,7 +327,8 @@ lose:
|
||||
|
||||
|
||||
STATIC void
|
||||
removerecordregions(int endoff)
|
||||
removerecordregions(endoff)
|
||||
int endoff;
|
||||
{
|
||||
if (ifslastp == NULL)
|
||||
return;
|
||||
@@ -363,7 +371,8 @@ removerecordregions(int endoff)
|
||||
* evaluate, place result in (backed up) result, adjust string position.
|
||||
*/
|
||||
void
|
||||
expari(int flag)
|
||||
expari(flag)
|
||||
int flag;
|
||||
{
|
||||
char *p, *start;
|
||||
int result;
|
||||
@@ -422,7 +431,10 @@ expari(int flag)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
expbackq(union node *cmd, int quoted, int flag)
|
||||
expbackq(cmd, quoted, flag)
|
||||
union node *cmd;
|
||||
int quoted;
|
||||
int flag;
|
||||
{
|
||||
struct backcmd in;
|
||||
int i;
|
||||
@@ -495,8 +507,13 @@ expbackq(union node *cmd, int quoted, int flag)
|
||||
|
||||
|
||||
STATIC int
|
||||
subevalvar(char *p, char *str, int strloc, int subtype, int startloc,
|
||||
int varflags)
|
||||
subevalvar(p, str, strloc, subtype, startloc, varflags)
|
||||
char *p;
|
||||
char *str;
|
||||
int strloc;
|
||||
int subtype;
|
||||
int startloc;
|
||||
int varflags;
|
||||
{
|
||||
char *startp;
|
||||
char *loc = NULL;
|
||||
@@ -621,7 +638,9 @@ recordleft:
|
||||
*/
|
||||
|
||||
STATIC char *
|
||||
evalvar(char *p, int flag)
|
||||
evalvar(p, flag)
|
||||
char *p;
|
||||
int flag;
|
||||
{
|
||||
int subtype;
|
||||
int varflags;
|
||||
@@ -657,17 +676,6 @@ again: /* jump here after setting a variable with ${var=text} */
|
||||
}
|
||||
varlen = 0;
|
||||
startloc = expdest - stackblock();
|
||||
if (!set && uflag) {
|
||||
switch (subtype) {
|
||||
case VSNORMAL:
|
||||
case VSTRIMLEFT:
|
||||
case VSTRIMLEFTMAX:
|
||||
case VSTRIMRIGHT:
|
||||
case VSTRIMRIGHTMAX:
|
||||
case VSLENGTH:
|
||||
error("%.*s: parameter not set", p - var - 1, var);
|
||||
}
|
||||
}
|
||||
if (set && subtype != VSPLUS) {
|
||||
/* insert the value of the variable */
|
||||
if (special) {
|
||||
@@ -796,7 +804,9 @@ record:
|
||||
*/
|
||||
|
||||
STATIC int
|
||||
varisset(char *name, int nulok)
|
||||
varisset(name, nulok)
|
||||
char *name;
|
||||
int nulok;
|
||||
{
|
||||
|
||||
if (*name == '!')
|
||||
@@ -838,7 +848,10 @@ varisset(char *name, int nulok)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
varvalue(char *name, int quoted, int allow_split)
|
||||
varvalue(name, quoted, allow_split)
|
||||
char *name;
|
||||
int quoted;
|
||||
int allow_split;
|
||||
{
|
||||
int num;
|
||||
char *p;
|
||||
@@ -929,7 +942,10 @@ numvar:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
recordregion(int start, int end, int nulonly)
|
||||
recordregion(start, end, nulonly)
|
||||
int start;
|
||||
int end;
|
||||
int nulonly;
|
||||
{
|
||||
struct ifsregion *ifsp;
|
||||
|
||||
@@ -954,8 +970,10 @@ recordregion(int start, int end, int nulonly)
|
||||
* searched for IFS characters have been stored by recordregion.
|
||||
*/
|
||||
STATIC void
|
||||
ifsbreakup(char *string, struct arglist *arglist)
|
||||
{
|
||||
ifsbreakup(string, arglist)
|
||||
char *string;
|
||||
struct arglist *arglist;
|
||||
{
|
||||
struct ifsregion *ifsp;
|
||||
struct strlist *sp;
|
||||
char *start;
|
||||
@@ -1050,7 +1068,9 @@ char *expdir;
|
||||
|
||||
|
||||
STATIC void
|
||||
expandmeta(struct strlist *str, int flag __unused)
|
||||
expandmeta(str, flag)
|
||||
struct strlist *str;
|
||||
int flag __unused;
|
||||
{
|
||||
char *p;
|
||||
struct strlist **savelastp;
|
||||
@@ -1104,8 +1124,10 @@ nometa:
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
expmeta(char *enddir, char *name)
|
||||
{
|
||||
expmeta(enddir, name)
|
||||
char *enddir;
|
||||
char *name;
|
||||
{
|
||||
char *p;
|
||||
char *q;
|
||||
char *start;
|
||||
@@ -1233,8 +1255,9 @@ expmeta(char *enddir, char *name)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
addfname(char *name)
|
||||
{
|
||||
addfname(name)
|
||||
char *name;
|
||||
{
|
||||
char *p;
|
||||
struct strlist *sp;
|
||||
|
||||
@@ -1254,8 +1277,9 @@ addfname(char *name)
|
||||
*/
|
||||
|
||||
STATIC struct strlist *
|
||||
expsort(struct strlist *str)
|
||||
{
|
||||
expsort(str)
|
||||
struct strlist *str;
|
||||
{
|
||||
int len;
|
||||
struct strlist *sp;
|
||||
|
||||
@@ -1267,7 +1291,9 @@ expsort(struct strlist *str)
|
||||
|
||||
|
||||
STATIC struct strlist *
|
||||
msort(struct strlist *list, int len)
|
||||
msort(list, len)
|
||||
struct strlist *list;
|
||||
int len;
|
||||
{
|
||||
struct strlist *p, *q = NULL;
|
||||
struct strlist **lpp;
|
||||
@@ -1313,8 +1339,11 @@ msort(struct strlist *list, int len)
|
||||
*/
|
||||
|
||||
int
|
||||
patmatch(char *pattern, char *string, int squoted)
|
||||
{
|
||||
patmatch(pattern, string, squoted)
|
||||
char *pattern;
|
||||
char *string;
|
||||
int squoted; /* string might have quote chars */
|
||||
{
|
||||
#ifdef notdef
|
||||
if (pattern[0] == '!' && pattern[1] == '!')
|
||||
return 1 - pmatch(pattern + 2, string);
|
||||
@@ -1325,8 +1354,11 @@ patmatch(char *pattern, char *string, int squoted)
|
||||
|
||||
|
||||
STATIC int
|
||||
pmatch(char *pattern, char *string, int squoted)
|
||||
{
|
||||
pmatch(pattern, string, squoted)
|
||||
char *pattern;
|
||||
char *string;
|
||||
int squoted;
|
||||
{
|
||||
char *p, *q;
|
||||
char c;
|
||||
|
||||
@@ -1450,7 +1482,8 @@ breakloop:
|
||||
*/
|
||||
|
||||
void
|
||||
rmescapes(char *str)
|
||||
rmescapes(str)
|
||||
char *str;
|
||||
{
|
||||
char *p, *q;
|
||||
|
||||
@@ -1479,8 +1512,10 @@ rmescapes(char *str)
|
||||
*/
|
||||
|
||||
int
|
||||
casematch(union node *pattern, char *val)
|
||||
{
|
||||
casematch(pattern, val)
|
||||
union node *pattern;
|
||||
char *val;
|
||||
{
|
||||
struct stackmark smark;
|
||||
int result;
|
||||
char *p;
|
||||
@@ -1502,8 +1537,10 @@ casematch(union node *pattern, char *val)
|
||||
*/
|
||||
|
||||
STATIC char *
|
||||
cvtnum(int num, char *buf)
|
||||
{
|
||||
cvtnum(num, buf)
|
||||
int num;
|
||||
char *buf;
|
||||
{
|
||||
char temp[32];
|
||||
int neg = num < 0;
|
||||
char *p = temp + 31;
|
||||
|
||||
+6
-6
@@ -59,9 +59,9 @@ struct arglist {
|
||||
|
||||
|
||||
union node;
|
||||
void expandhere(union node *, int);
|
||||
void expandarg(union node *, struct arglist *, int);
|
||||
void expari(int);
|
||||
int patmatch(char *, char *, int);
|
||||
void rmescapes(char *);
|
||||
int casematch(union node *, char *);
|
||||
void expandhere __P((union node *, int));
|
||||
void expandarg __P((union node *, struct arglist *, int));
|
||||
void expari __P((int));
|
||||
int patmatch __P((char *, char *, int));
|
||||
void rmescapes __P((char *));
|
||||
int casematch __P((union node *, char *));
|
||||
+19
-31
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <limits.h>
|
||||
@@ -72,14 +72,14 @@ EditLine *el; /* editline cookie */
|
||||
int displayhist;
|
||||
static FILE *el_in, *el_out;
|
||||
|
||||
STATIC char *fc_replace(const char *, char *, char *);
|
||||
STATIC char *fc_replace __P((const char *, char *, char *));
|
||||
|
||||
/*
|
||||
* Set history and editing status. Called whenever the status may
|
||||
* have changed (figures out what to do).
|
||||
*/
|
||||
void
|
||||
histedit(void)
|
||||
histedit()
|
||||
{
|
||||
|
||||
#define editing (Eflag || Vflag)
|
||||
@@ -130,7 +130,6 @@ bad:
|
||||
el_set(el, EL_EDITOR, "vi");
|
||||
else if (Eflag)
|
||||
el_set(el, EL_EDITOR, "emacs");
|
||||
el_source(el, NULL);
|
||||
}
|
||||
} else {
|
||||
INTOFF;
|
||||
@@ -166,7 +165,9 @@ sethistsize(hs)
|
||||
* the Korn shell fc command. Oh well...
|
||||
*/
|
||||
int
|
||||
histcmd(int argc, char **argv)
|
||||
histcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int ch;
|
||||
char *editor = NULL;
|
||||
@@ -181,7 +182,6 @@ histcmd(int argc, char **argv)
|
||||
struct jmploc *volatile savehandler;
|
||||
char editfile[PATH_MAX];
|
||||
FILE *efp;
|
||||
int oldhistnum;
|
||||
#ifdef __GNUC__
|
||||
/* Avoid longjmp clobbering */
|
||||
(void) &editor;
|
||||
@@ -205,12 +205,11 @@ histcmd(int argc, char **argv)
|
||||
error("missing history argument");
|
||||
|
||||
optreset = 1; optind = 1; /* initialize getopt */
|
||||
opterr = 0;
|
||||
while (not_fcnumber(argv[optind]) &&
|
||||
(ch = getopt(argc, argv, ":e:lnrs")) != -1)
|
||||
switch ((char)ch) {
|
||||
case 'e':
|
||||
editor = optarg;
|
||||
editor = shoptarg;
|
||||
break;
|
||||
case 'l':
|
||||
lflg = 1;
|
||||
@@ -393,7 +392,9 @@ histcmd(int argc, char **argv)
|
||||
}
|
||||
|
||||
STATIC char *
|
||||
fc_replace(const char *s, char *p, char *r)
|
||||
fc_replace(s, p, r)
|
||||
const char *s;
|
||||
char *p, *r;
|
||||
{
|
||||
char *dest;
|
||||
int plen = strlen(p);
|
||||
@@ -415,7 +416,8 @@ fc_replace(const char *s, char *p, char *r)
|
||||
}
|
||||
|
||||
int
|
||||
not_fcnumber(char *s)
|
||||
not_fcnumber(s)
|
||||
char *s;
|
||||
{
|
||||
if (s == NULL)
|
||||
return (0);
|
||||
@@ -425,7 +427,9 @@ not_fcnumber(char *s)
|
||||
}
|
||||
|
||||
int
|
||||
str_to_event(char *str, int last)
|
||||
str_to_event(str, last)
|
||||
char *str;
|
||||
int last;
|
||||
{
|
||||
const HistEvent *he;
|
||||
char *s = str;
|
||||
@@ -471,33 +475,17 @@ str_to_event(char *str, int last)
|
||||
}
|
||||
return (he->num);
|
||||
}
|
||||
|
||||
int
|
||||
bindcmd(int argc, char **argv)
|
||||
{
|
||||
|
||||
if (el == NULL)
|
||||
error("line editing is disabled");
|
||||
return (el_parse(el, argc, argv));
|
||||
}
|
||||
|
||||
#else
|
||||
#include "error.h"
|
||||
|
||||
int
|
||||
histcmd(int argc, char **argv)
|
||||
histcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
|
||||
error("not compiled with history support");
|
||||
/*NOTREACHED*/
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
bindcmd(int argc, char **argv)
|
||||
{
|
||||
|
||||
error("not compiled with line editing support");
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
+3
-3
@@ -37,6 +37,6 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
void init(void);
|
||||
void reset(void);
|
||||
void initshellproc(void);
|
||||
void init __P((void));
|
||||
void reset __P((void));
|
||||
void initshellproc __P((void));
|
||||
+30
-32
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h> /* defines BUFSIZ */
|
||||
#include <fcntl.h>
|
||||
@@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include "alias.h"
|
||||
#include "parser.h"
|
||||
#include "myhistedit.h"
|
||||
#include "trap.h"
|
||||
|
||||
#define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */
|
||||
|
||||
@@ -108,8 +107,8 @@ int whichprompt; /* 1 == PS1, 2 == PS2 */
|
||||
|
||||
EditLine *el; /* cookie for editline package */
|
||||
|
||||
STATIC void pushfile(void);
|
||||
static int preadfd(void);
|
||||
STATIC void pushfile __P((void));
|
||||
static int preadfd __P((void));
|
||||
|
||||
#ifdef mkinit
|
||||
INCLUDE "input.h"
|
||||
@@ -138,7 +137,9 @@ SHELLPROC {
|
||||
*/
|
||||
|
||||
char *
|
||||
pfgets(char *line, int len)
|
||||
pfgets(line, len)
|
||||
char *line;
|
||||
int len;
|
||||
{
|
||||
char *p = line;
|
||||
int nleft = len;
|
||||
@@ -167,24 +168,18 @@ pfgets(char *line, int len)
|
||||
*/
|
||||
|
||||
int
|
||||
pgetc(void)
|
||||
pgetc()
|
||||
{
|
||||
return pgetc_macro();
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
preadfd(void)
|
||||
preadfd()
|
||||
{
|
||||
int nr;
|
||||
parsenextc = parsefile->buf;
|
||||
|
||||
#ifndef NO_HISTORY
|
||||
if (el != NULL && gotwinch) {
|
||||
gotwinch = 0;
|
||||
el_resize(el);
|
||||
}
|
||||
#endif
|
||||
retry:
|
||||
#ifndef NO_HISTORY
|
||||
if (parsefile->fd == 0 && el) {
|
||||
@@ -232,7 +227,7 @@ retry:
|
||||
*/
|
||||
|
||||
int
|
||||
preadbuffer(void)
|
||||
preadbuffer()
|
||||
{
|
||||
char *p, *q;
|
||||
int more;
|
||||
@@ -319,8 +314,7 @@ check:
|
||||
*/
|
||||
|
||||
void
|
||||
pungetc(void)
|
||||
{
|
||||
pungetc() {
|
||||
parsenleft++;
|
||||
parsenextc--;
|
||||
}
|
||||
@@ -330,8 +324,11 @@ pungetc(void)
|
||||
* We handle aliases this way.
|
||||
*/
|
||||
void
|
||||
pushstring(char *s, int len, void *ap)
|
||||
{
|
||||
pushstring(s, len, ap)
|
||||
char *s;
|
||||
int len;
|
||||
void *ap;
|
||||
{
|
||||
struct strpush *sp;
|
||||
|
||||
INTOFF;
|
||||
@@ -354,7 +351,7 @@ pushstring(char *s, int len, void *ap)
|
||||
}
|
||||
|
||||
void
|
||||
popstring(void)
|
||||
popstring()
|
||||
{
|
||||
struct strpush *sp = parsefile->strpush;
|
||||
|
||||
@@ -377,7 +374,9 @@ popstring(void)
|
||||
*/
|
||||
|
||||
void
|
||||
setinputfile(char *fname, int push)
|
||||
setinputfile(fname, push)
|
||||
char *fname;
|
||||
int push;
|
||||
{
|
||||
int fd;
|
||||
int fd2;
|
||||
@@ -403,7 +402,8 @@ setinputfile(char *fname, int push)
|
||||
*/
|
||||
|
||||
void
|
||||
setinputfd(int fd, int push)
|
||||
setinputfd(fd, push)
|
||||
int fd, push;
|
||||
{
|
||||
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
if (push) {
|
||||
@@ -425,8 +425,10 @@ setinputfd(int fd, int push)
|
||||
*/
|
||||
|
||||
void
|
||||
setinputstring(char *string, int push)
|
||||
{
|
||||
setinputstring(string, push)
|
||||
char *string;
|
||||
int push;
|
||||
{
|
||||
INTOFF;
|
||||
if (push)
|
||||
pushfile();
|
||||
@@ -445,8 +447,7 @@ setinputstring(char *string, int push)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
pushfile(void)
|
||||
{
|
||||
pushfile() {
|
||||
struct parsefile *pf;
|
||||
|
||||
parsefile->nleft = parsenleft;
|
||||
@@ -463,8 +464,7 @@ pushfile(void)
|
||||
|
||||
|
||||
void
|
||||
popfile(void)
|
||||
{
|
||||
popfile() {
|
||||
struct parsefile *pf = parsefile;
|
||||
|
||||
INTOFF;
|
||||
@@ -489,8 +489,7 @@ popfile(void)
|
||||
*/
|
||||
|
||||
void
|
||||
popallfiles(void)
|
||||
{
|
||||
popallfiles() {
|
||||
while (parsefile != &basepf)
|
||||
popfile();
|
||||
}
|
||||
@@ -503,8 +502,7 @@ popallfiles(void)
|
||||
*/
|
||||
|
||||
void
|
||||
closescript(void)
|
||||
{
|
||||
closescript() {
|
||||
popallfiles();
|
||||
if (parsefile->fd > 0) {
|
||||
close(parsefile->fd);
|
||||
|
||||
+12
-12
@@ -49,17 +49,17 @@ extern int parsenleft; /* number of characters left in input buffer */
|
||||
extern char *parsenextc; /* next character in input buffer */
|
||||
extern int init_editline; /* 0 == not setup, 1 == OK, -1 == failed */
|
||||
|
||||
char *pfgets(char *, int);
|
||||
int pgetc(void);
|
||||
int preadbuffer(void);
|
||||
void pungetc(void);
|
||||
void pushstring(char *, int, void *);
|
||||
void popstring(void);
|
||||
void setinputfile(char *, int);
|
||||
void setinputfd(int, int);
|
||||
void setinputstring(char *, int);
|
||||
void popfile(void);
|
||||
void popallfiles(void);
|
||||
void closescript(void);
|
||||
char *pfgets __P((char *, int));
|
||||
int pgetc __P((void));
|
||||
int preadbuffer __P((void));
|
||||
void pungetc __P((void));
|
||||
void pushstring __P((char *, int, void *));
|
||||
void popstring __P((void));
|
||||
void setinputfile __P((char *, int));
|
||||
void setinputfd __P((int, int));
|
||||
void setinputstring __P((char *, int));
|
||||
void popfile __P((void));
|
||||
void popallfiles __P((void));
|
||||
void closescript __P((void));
|
||||
|
||||
#define pgetc_macro() (--parsenleft >= 0? *parsenextc++ : preadbuffer())
|
||||
+266
-337
@@ -38,26 +38,31 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <paths.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
#ifdef BSD
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <paths.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "shell.h"
|
||||
#if JOBS
|
||||
#if OLD_TTY_DRIVER
|
||||
#include "sgtty.h"
|
||||
#else
|
||||
#include <termios.h>
|
||||
#endif
|
||||
#undef CEOF /* syntax.h redefines this */
|
||||
#endif
|
||||
#include "redir.h"
|
||||
@@ -80,84 +85,90 @@ struct job *jobtab; /* array of jobs */
|
||||
int njobs; /* size of array */
|
||||
MKINIT pid_t backgndpid = -1; /* pid of last background process */
|
||||
#if JOBS
|
||||
struct job *jobmru; /* most recently used job list */
|
||||
pid_t initialpgrp; /* pgrp of shell on invocation */
|
||||
int initialpgrp; /* pgrp of shell on invocation */
|
||||
int curjob; /* current job */
|
||||
#endif
|
||||
int in_waitcmd = 0; /* are we in waitcmd()? */
|
||||
int in_dowait = 0; /* are we in dowait()? */
|
||||
volatile sig_atomic_t breakwaitcmd = 0; /* should wait be terminated? */
|
||||
static int ttyfd = -1;
|
||||
|
||||
#if JOBS
|
||||
STATIC void restartjob(struct job *);
|
||||
STATIC void restartjob __P((struct job *));
|
||||
#endif
|
||||
STATIC void freejob(struct job *);
|
||||
STATIC struct job *getjob(char *);
|
||||
STATIC pid_t dowait(int, struct job *);
|
||||
STATIC pid_t waitproc(int, int *);
|
||||
STATIC void cmdtxt(union node *);
|
||||
STATIC void cmdputs(char *);
|
||||
#if JOBS
|
||||
STATIC void setcurjob(struct job *);
|
||||
STATIC void deljob(struct job *);
|
||||
STATIC struct job *getcurjob(struct job *);
|
||||
STATIC void freejob __P((struct job *));
|
||||
STATIC struct job *getjob __P((char *));
|
||||
STATIC int dowait __P((int, struct job *));
|
||||
#if SYSV
|
||||
STATIC int onsigchild __P((void));
|
||||
#endif
|
||||
STATIC void showjob(struct job *, pid_t, int, int);
|
||||
STATIC int waitproc __P((int, int *));
|
||||
STATIC void cmdtxt __P((union node *));
|
||||
STATIC void cmdputs __P((char *));
|
||||
|
||||
|
||||
/*
|
||||
* Turn job control on and off.
|
||||
*
|
||||
* Note: This code assumes that the third arg to ioctl is a character
|
||||
* pointer, which is true on Berkeley systems but not System V. Since
|
||||
* System V doesn't have job control yet, this isn't a problem now.
|
||||
*/
|
||||
|
||||
MKINIT int jobctl;
|
||||
|
||||
#if JOBS
|
||||
void
|
||||
setjobctl(int on)
|
||||
setjobctl(on)
|
||||
int on;
|
||||
{
|
||||
int i;
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
int ldisc;
|
||||
#endif
|
||||
|
||||
if (on == jobctl || rootshell == 0)
|
||||
return;
|
||||
if (on) {
|
||||
if (ttyfd != -1)
|
||||
close(ttyfd);
|
||||
if ((ttyfd = open(_PATH_TTY, O_RDWR)) < 0) {
|
||||
i = 0;
|
||||
while (i <= 2 && !isatty(i))
|
||||
i++;
|
||||
if (i > 2 || (ttyfd = dup(i)) < 0)
|
||||
goto out;
|
||||
}
|
||||
if (fcntl(ttyfd, F_SETFD, FD_CLOEXEC) < 0) {
|
||||
close(ttyfd);
|
||||
ttyfd = -1;
|
||||
goto out;
|
||||
}
|
||||
do { /* while we are in the background */
|
||||
initialpgrp = tcgetpgrp(ttyfd);
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
if (ioctl(2, TIOCGPGRP, (char *)&initialpgrp) < 0) {
|
||||
#else
|
||||
initialpgrp = tcgetpgrp(2);
|
||||
if (initialpgrp < 0) {
|
||||
out: out2str("sh: can't access tty; job control turned off\n");
|
||||
#endif
|
||||
out2str("sh: can't access tty; job control turned off\n");
|
||||
mflag = 0;
|
||||
return;
|
||||
}
|
||||
if (initialpgrp == -1)
|
||||
initialpgrp = getpgrp();
|
||||
else if (initialpgrp != getpgrp()) {
|
||||
killpg(0, SIGTTIN);
|
||||
killpg(initialpgrp, SIGTTIN);
|
||||
continue;
|
||||
}
|
||||
} while (0);
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
if (ioctl(2, TIOCGETD, (char *)&ldisc) < 0 || ldisc != NTTYDISC) {
|
||||
out2str("sh: need new tty driver to run job control; job control turned off\n");
|
||||
mflag = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
setsignal(SIGTSTP);
|
||||
setsignal(SIGTTOU);
|
||||
setsignal(SIGTTIN);
|
||||
setpgid(0, rootpid);
|
||||
tcsetpgrp(ttyfd, rootpid);
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
ioctl(2, TIOCSPGRP, (char *)&rootpid);
|
||||
#else
|
||||
tcsetpgrp(2, rootpid);
|
||||
#endif
|
||||
} else { /* turning job control off */
|
||||
setpgid(0, initialpgrp);
|
||||
tcsetpgrp(ttyfd, initialpgrp);
|
||||
close(ttyfd);
|
||||
ttyfd = -1;
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
ioctl(2, TIOCSPGRP, (char *)&initialpgrp);
|
||||
#else
|
||||
tcsetpgrp(2, initialpgrp);
|
||||
#endif
|
||||
setsignal(SIGTSTP);
|
||||
setsignal(SIGTTOU);
|
||||
setsignal(SIGTTIN);
|
||||
@@ -184,22 +195,24 @@ SHELLPROC {
|
||||
|
||||
#if JOBS
|
||||
int
|
||||
fgcmd(int argc __unused, char **argv)
|
||||
fgcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv;
|
||||
{
|
||||
struct job *jp;
|
||||
pid_t pgrp;
|
||||
int pgrp;
|
||||
int status;
|
||||
|
||||
jp = getjob(argv[1]);
|
||||
if (jp->jobctl == 0)
|
||||
error("job not created under job control");
|
||||
out1str(jp->ps[0].cmd);
|
||||
out1c('\n');
|
||||
flushout(&output);
|
||||
pgrp = jp->ps[0].pid;
|
||||
tcsetpgrp(ttyfd, pgrp);
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
ioctl(2, TIOCSPGRP, (char *)&pgrp);
|
||||
#else
|
||||
tcsetpgrp(2, pgrp);
|
||||
#endif
|
||||
restartjob(jp);
|
||||
jp->foreground = 1;
|
||||
INTOFF;
|
||||
status = waitforjob(jp, (int *)NULL);
|
||||
INTON;
|
||||
@@ -208,37 +221,31 @@ fgcmd(int argc __unused, char **argv)
|
||||
|
||||
|
||||
int
|
||||
bgcmd(int argc, char **argv)
|
||||
bgcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char s[64];
|
||||
struct job *jp;
|
||||
|
||||
do {
|
||||
jp = getjob(*++argv);
|
||||
if (jp->jobctl == 0)
|
||||
error("job not created under job control");
|
||||
if (jp->state == JOBDONE)
|
||||
continue;
|
||||
restartjob(jp);
|
||||
jp->foreground = 0;
|
||||
fmtstr(s, 64, "[%d] ", jp - jobtab + 1);
|
||||
out1str(s);
|
||||
out1str(jp->ps[0].cmd);
|
||||
out1c('\n');
|
||||
} while (--argc > 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
STATIC void
|
||||
restartjob(struct job *jp)
|
||||
restartjob(jp)
|
||||
struct job *jp;
|
||||
{
|
||||
struct procstat *ps;
|
||||
int i;
|
||||
|
||||
if (jp->state == JOBDONE)
|
||||
return;
|
||||
setcurjob(jp);
|
||||
INTOFF;
|
||||
killpg(jp->ps[0].pid, SIGCONT);
|
||||
for (ps = jp->ps, i = jp->nprocs ; --i >= 0 ; ps++) {
|
||||
@@ -253,121 +260,14 @@ restartjob(struct job *jp)
|
||||
|
||||
|
||||
int
|
||||
jobscmd(int argc, char *argv[])
|
||||
jobscmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
char *id;
|
||||
int ch, sformat, lformat;
|
||||
|
||||
optind = optreset = 1;
|
||||
opterr = 0;
|
||||
sformat = lformat = 0;
|
||||
while ((ch = getopt(argc, argv, "ls")) != -1) {
|
||||
switch (ch) {
|
||||
case 'l':
|
||||
lformat = 1;
|
||||
break;
|
||||
case 's':
|
||||
sformat = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
error("unknown option: -%c", optopt);
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc == 0)
|
||||
showjobs(0, sformat, lformat);
|
||||
else
|
||||
while ((id = *argv++) != NULL)
|
||||
showjob(getjob(id), 0, sformat, lformat);
|
||||
|
||||
return (0);
|
||||
showjobs(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC void
|
||||
showjob(struct job *jp, pid_t pid, int sformat, int lformat)
|
||||
{
|
||||
char s[64];
|
||||
struct procstat *ps;
|
||||
struct job *j;
|
||||
int col, curr, i, jobno, prev, procno;
|
||||
char c;
|
||||
|
||||
procno = jp->nprocs;
|
||||
jobno = jp - jobtab + 1;
|
||||
curr = prev = 0;
|
||||
#if JOBS
|
||||
if ((j = getcurjob(NULL)) != NULL) {
|
||||
curr = j - jobtab + 1;
|
||||
if ((j = getcurjob(j)) != NULL)
|
||||
prev = j - jobtab + 1;
|
||||
}
|
||||
#endif
|
||||
for (ps = jp->ps ; ; ps++) { /* for each process */
|
||||
if (sformat) {
|
||||
out1fmt("%d\n", (int)ps->pid);
|
||||
goto skip;
|
||||
}
|
||||
if (!lformat && ps != jp->ps && pid == 0)
|
||||
goto skip;
|
||||
if (pid != 0 && pid != ps->pid)
|
||||
goto skip;
|
||||
if (jobno == curr && ps == jp->ps)
|
||||
c = '+';
|
||||
else if (jobno == prev && ps == jp->ps)
|
||||
c = '-';
|
||||
else
|
||||
c = ' ';
|
||||
if (ps == jp->ps)
|
||||
fmtstr(s, 64, "[%d] %c ", jobno, c);
|
||||
else
|
||||
fmtstr(s, 64, " %c ", c);
|
||||
out1str(s);
|
||||
col = strlen(s);
|
||||
if (lformat) {
|
||||
fmtstr(s, 64, "%d ", (int)ps->pid);
|
||||
out1str(s);
|
||||
col += strlen(s);
|
||||
}
|
||||
s[0] = '\0';
|
||||
if (ps != jp->ps) {
|
||||
*s = '\0';
|
||||
} else if (ps->status == -1) {
|
||||
strcpy(s, "Running");
|
||||
} else if (WIFEXITED(ps->status)) {
|
||||
if (WEXITSTATUS(ps->status) == 0)
|
||||
strcpy(s, "Done");
|
||||
else
|
||||
fmtstr(s, 64, "Done (%d)",
|
||||
WEXITSTATUS(ps->status));
|
||||
} else {
|
||||
#if JOBS
|
||||
if (WIFSTOPPED(ps->status))
|
||||
i = WSTOPSIG(ps->status);
|
||||
else
|
||||
#endif
|
||||
i = WTERMSIG(ps->status);
|
||||
if ((i & 0x7F) < NSIG && sys_siglist[i & 0x7F])
|
||||
scopy(sys_siglist[i & 0x7F], s);
|
||||
else
|
||||
fmtstr(s, 64, "Signal %d", i & 0x7F);
|
||||
if (WCOREDUMP(ps->status))
|
||||
strcat(s, " (core dumped)");
|
||||
}
|
||||
out1str(s);
|
||||
col += strlen(s);
|
||||
do {
|
||||
out1c(' ');
|
||||
col++;
|
||||
} while (col < 30);
|
||||
out1str(ps->cmd);
|
||||
out1c('\n');
|
||||
skip: if (--procno <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a list of jobs. If "change" is nonzero, only print jobs whose
|
||||
@@ -379,10 +279,16 @@ skip: if (--procno <= 0)
|
||||
*/
|
||||
|
||||
void
|
||||
showjobs(int change, int sformat, int lformat)
|
||||
showjobs(change)
|
||||
int change;
|
||||
{
|
||||
int jobno;
|
||||
int procno;
|
||||
int i;
|
||||
struct job *jp;
|
||||
struct procstat *ps;
|
||||
int col;
|
||||
char s[64];
|
||||
|
||||
TRACE(("showjobs(%d) called\n", change));
|
||||
while (dowait(0, (struct job *)NULL) > 0);
|
||||
@@ -395,7 +301,44 @@ showjobs(int change, int sformat, int lformat)
|
||||
}
|
||||
if (change && ! jp->changed)
|
||||
continue;
|
||||
showjob(jp, 0, sformat, lformat);
|
||||
procno = jp->nprocs;
|
||||
for (ps = jp->ps ; ; ps++) { /* for each process */
|
||||
if (ps == jp->ps)
|
||||
fmtstr(s, 64, "[%d] %d ", jobno, ps->pid);
|
||||
else
|
||||
fmtstr(s, 64, " %d ", ps->pid);
|
||||
out1str(s);
|
||||
col = strlen(s);
|
||||
s[0] = '\0';
|
||||
if (ps->status == -1) {
|
||||
/* don't print anything */
|
||||
} else if (WIFEXITED(ps->status)) {
|
||||
fmtstr(s, 64, "Exit %d", WEXITSTATUS(ps->status));
|
||||
} else {
|
||||
#if JOBS
|
||||
if (WIFSTOPPED(ps->status))
|
||||
i = WSTOPSIG(ps->status);
|
||||
else
|
||||
#endif
|
||||
i = WTERMSIG(ps->status);
|
||||
if ((i & 0x7F) < NSIG && sys_siglist[i & 0x7F])
|
||||
scopy(sys_siglist[i & 0x7F], s);
|
||||
else
|
||||
fmtstr(s, 64, "Signal %d", i & 0x7F);
|
||||
if (WCOREDUMP(ps->status))
|
||||
strcat(s, " (core dumped)");
|
||||
}
|
||||
out1str(s);
|
||||
col += strlen(s);
|
||||
do {
|
||||
out1c(' ');
|
||||
col++;
|
||||
} while (col < 30);
|
||||
out1str(ps->cmd);
|
||||
out1c('\n');
|
||||
if (--procno <= 0)
|
||||
break;
|
||||
}
|
||||
jp->changed = 0;
|
||||
if (jp->state == JOBDONE) {
|
||||
freejob(jp);
|
||||
@@ -409,8 +352,9 @@ showjobs(int change, int sformat, int lformat)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
freejob(struct job *jp)
|
||||
{
|
||||
freejob(jp)
|
||||
struct job *jp;
|
||||
{
|
||||
struct procstat *ps;
|
||||
int i;
|
||||
|
||||
@@ -423,7 +367,8 @@ freejob(struct job *jp)
|
||||
ckfree(jp->ps);
|
||||
jp->used = 0;
|
||||
#if JOBS
|
||||
deljob(jp);
|
||||
if (curjob == jp - jobtab + 1)
|
||||
curjob = 0;
|
||||
#endif
|
||||
INTON;
|
||||
}
|
||||
@@ -431,7 +376,9 @@ freejob(struct job *jp)
|
||||
|
||||
|
||||
int
|
||||
waitcmd(int argc, char **argv)
|
||||
waitcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct job *job;
|
||||
int status, retval;
|
||||
@@ -485,14 +432,16 @@ waitcmd(int argc, char **argv)
|
||||
|
||||
|
||||
int
|
||||
jobidcmd(int argc __unused, char **argv)
|
||||
jobidcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv;
|
||||
{
|
||||
struct job *jp;
|
||||
int i;
|
||||
|
||||
jp = getjob(argv[1]);
|
||||
for (i = 0 ; i < jp->nprocs ; ) {
|
||||
out1fmt("%d", (int)jp->ps[i].pid);
|
||||
out1fmt("%d", jp->ps[i].pid);
|
||||
out1c(++i < jp->nprocs? ' ' : '\n');
|
||||
}
|
||||
return 0;
|
||||
@@ -505,18 +454,20 @@ jobidcmd(int argc __unused, char **argv)
|
||||
*/
|
||||
|
||||
STATIC struct job *
|
||||
getjob(char *name)
|
||||
{
|
||||
getjob(name)
|
||||
char *name;
|
||||
{
|
||||
int jobno;
|
||||
struct job *found, *jp;
|
||||
pid_t pid;
|
||||
struct job *jp;
|
||||
int pid;
|
||||
int i;
|
||||
|
||||
if (name == NULL) {
|
||||
#if JOBS
|
||||
currentjob: if ((jp = getcurjob(NULL)) == NULL)
|
||||
currentjob:
|
||||
if ((jobno = curjob) == 0 || jobtab[jobno - 1].used == 0)
|
||||
error("No current job");
|
||||
return (jp);
|
||||
return &jobtab[jobno - 1];
|
||||
#else
|
||||
error("No current job");
|
||||
#endif
|
||||
@@ -529,28 +480,9 @@ currentjob: if ((jp = getcurjob(NULL)) == NULL)
|
||||
#if JOBS
|
||||
} else if (name[1] == '%' && name[2] == '\0') {
|
||||
goto currentjob;
|
||||
} else if (name[1] == '+' && name[2] == '\0') {
|
||||
goto currentjob;
|
||||
} else if (name[1] == '-' && name[2] == '\0') {
|
||||
if ((jp = getcurjob(NULL)) == NULL ||
|
||||
(jp = getcurjob(jp)) == NULL)
|
||||
error("No previous job");
|
||||
return (jp);
|
||||
#endif
|
||||
} else if (name[1] == '?') {
|
||||
found = NULL;
|
||||
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
|
||||
if (jp->used && jp->nprocs > 0
|
||||
&& strstr(jp->ps[0].cmd, name + 2) != NULL) {
|
||||
if (found)
|
||||
error("%s: ambiguous", name);
|
||||
found = jp;
|
||||
}
|
||||
}
|
||||
if (found != NULL)
|
||||
return (found);
|
||||
} else {
|
||||
found = NULL;
|
||||
struct job *found = NULL;
|
||||
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
|
||||
if (jp->used && jp->nprocs > 0
|
||||
&& prefix(name + 1, jp->ps[0].cmd)) {
|
||||
@@ -563,7 +495,7 @@ currentjob: if ((jp = getcurjob(NULL)) == NULL)
|
||||
return found;
|
||||
}
|
||||
} else if (is_number(name)) {
|
||||
pid = (pid_t)number(name);
|
||||
pid = number(name);
|
||||
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
|
||||
if (jp->used && jp->nprocs > 0
|
||||
&& jp->ps[jp->nprocs - 1].pid == pid)
|
||||
@@ -582,7 +514,9 @@ currentjob: if ((jp = getcurjob(NULL)) == NULL)
|
||||
*/
|
||||
|
||||
struct job *
|
||||
makejob(union node *node __unused, int nprocs)
|
||||
makejob(node, nprocs)
|
||||
union node *node __unused;
|
||||
int nprocs;
|
||||
{
|
||||
int i;
|
||||
struct job *jp;
|
||||
@@ -592,21 +526,9 @@ makejob(union node *node __unused, int nprocs)
|
||||
INTOFF;
|
||||
if (njobs == 0) {
|
||||
jobtab = ckmalloc(4 * sizeof jobtab[0]);
|
||||
#if JOBS
|
||||
jobmru = NULL;
|
||||
#endif
|
||||
} else {
|
||||
jp = ckmalloc((njobs + 4) * sizeof jobtab[0]);
|
||||
memcpy(jp, jobtab, njobs * sizeof jp[0]);
|
||||
#if JOBS
|
||||
/* Relocate `next' pointers and list head */
|
||||
if (jobmru != NULL)
|
||||
jobmru = &jp[jobmru - jobtab];
|
||||
for (i = 0; i < njobs; i++)
|
||||
if (jp[i].next != NULL)
|
||||
jp[i].next = &jp[jp[i].next -
|
||||
jobtab];
|
||||
#endif
|
||||
/* Relocate `ps' pointers */
|
||||
for (i = 0; i < njobs; i++)
|
||||
if (jp[i].ps == &jobtab[i].ps0)
|
||||
@@ -627,10 +549,8 @@ makejob(union node *node __unused, int nprocs)
|
||||
jp->used = 1;
|
||||
jp->changed = 0;
|
||||
jp->nprocs = 0;
|
||||
jp->foreground = 0;
|
||||
#if JOBS
|
||||
jp->jobctl = jobctl;
|
||||
jp->next = NULL;
|
||||
#endif
|
||||
if (nprocs > 1) {
|
||||
jp->ps = ckmalloc(nprocs * sizeof (struct procstat));
|
||||
@@ -643,65 +563,6 @@ makejob(union node *node __unused, int nprocs)
|
||||
return jp;
|
||||
}
|
||||
|
||||
#if JOBS
|
||||
STATIC void
|
||||
setcurjob(struct job *cj)
|
||||
{
|
||||
struct job *jp, *prev;
|
||||
|
||||
for (prev = NULL, jp = jobmru; jp != NULL; prev = jp, jp = jp->next) {
|
||||
if (jp == cj) {
|
||||
if (prev != NULL)
|
||||
prev->next = jp->next;
|
||||
else
|
||||
jobmru = jp->next;
|
||||
jp->next = jobmru;
|
||||
jobmru = cj;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cj->next = jobmru;
|
||||
jobmru = cj;
|
||||
}
|
||||
|
||||
STATIC void
|
||||
deljob(struct job *j)
|
||||
{
|
||||
struct job *jp, *prev;
|
||||
|
||||
for (prev = NULL, jp = jobmru; jp != NULL; prev = jp, jp = jp->next) {
|
||||
if (jp == j) {
|
||||
if (prev != NULL)
|
||||
prev->next = jp->next;
|
||||
else
|
||||
jobmru = jp->next;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the most recently used job that isn't `nj', and preferably one
|
||||
* that is stopped.
|
||||
*/
|
||||
STATIC struct job *
|
||||
getcurjob(struct job *nj)
|
||||
{
|
||||
struct job *jp;
|
||||
|
||||
/* Try to find a stopped one.. */
|
||||
for (jp = jobmru; jp != NULL; jp = jp->next)
|
||||
if (jp->used && jp != nj && jp->state == JOBSTOPPED)
|
||||
return (jp);
|
||||
/* Otherwise the most recently used job that isn't `nj' */
|
||||
for (jp = jobmru; jp != NULL; jp = jp->next)
|
||||
if (jp->used && jp != nj)
|
||||
return (jp);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fork of a subshell. If we are doing job control, give the subshell its
|
||||
@@ -718,11 +579,14 @@ getcurjob(struct job *nj)
|
||||
* in a pipeline).
|
||||
*/
|
||||
|
||||
pid_t
|
||||
forkshell(struct job *jp, union node *n, int mode)
|
||||
int
|
||||
forkshell(jp, n, mode)
|
||||
union node *n;
|
||||
struct job *jp;
|
||||
int mode;
|
||||
{
|
||||
pid_t pid;
|
||||
pid_t pgrp;
|
||||
int pid;
|
||||
int pgrp;
|
||||
|
||||
TRACE(("forkshell(%%%d, 0x%lx, %d) called\n", jp - jobtab, (long)n,
|
||||
mode));
|
||||
@@ -738,9 +602,12 @@ forkshell(struct job *jp, union node *n, int mode)
|
||||
int wasroot;
|
||||
int i;
|
||||
|
||||
TRACE(("Child shell %d\n", (int)getpid()));
|
||||
TRACE(("Child shell %d\n", getpid()));
|
||||
wasroot = rootshell;
|
||||
rootshell = 0;
|
||||
for (i = njobs, p = jobtab ; --i >= 0 ; p++)
|
||||
if (p->used)
|
||||
freejob(p);
|
||||
closescript();
|
||||
INTON;
|
||||
clear_traps();
|
||||
@@ -753,8 +620,13 @@ forkshell(struct job *jp, union node *n, int mode)
|
||||
pgrp = jp->ps[0].pid;
|
||||
if (setpgid(0, pgrp) == 0 && mode == FORK_FG) {
|
||||
/*** this causes superfluous TIOCSPGRPS ***/
|
||||
if (tcsetpgrp(ttyfd, pgrp) < 0)
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
if (ioctl(2, TIOCSPGRP, (char *)&pgrp) < 0)
|
||||
error("TIOCSPGRP failed, errno=%d", errno);
|
||||
#else
|
||||
if (tcsetpgrp(2, pgrp) < 0)
|
||||
error("tcsetpgrp failed, errno=%d", errno);
|
||||
#endif
|
||||
}
|
||||
setsignal(SIGTSTP);
|
||||
setsignal(SIGTTOU);
|
||||
@@ -782,11 +654,6 @@ forkshell(struct job *jp, union node *n, int mode)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
INTOFF;
|
||||
for (i = njobs, p = jobtab ; --i >= 0 ; p++)
|
||||
if (p->used)
|
||||
freejob(p);
|
||||
INTON;
|
||||
if (wasroot && iflag) {
|
||||
setsignal(SIGINT);
|
||||
setsignal(SIGQUIT);
|
||||
@@ -810,13 +677,9 @@ forkshell(struct job *jp, union node *n, int mode)
|
||||
ps->cmd = nullstr;
|
||||
if (iflag && rootshell && n)
|
||||
ps->cmd = commandtext(n);
|
||||
jp->foreground = mode == FORK_FG;
|
||||
#if JOBS
|
||||
setcurjob(jp);
|
||||
#endif
|
||||
}
|
||||
INTON;
|
||||
TRACE(("In parent shell: child = %d\n", (int)pid));
|
||||
TRACE(("In parent shell: child = %d\n", pid));
|
||||
return pid;
|
||||
}
|
||||
|
||||
@@ -842,10 +705,12 @@ forkshell(struct job *jp, union node *n, int mode)
|
||||
*/
|
||||
|
||||
int
|
||||
waitforjob(struct job *jp, int *origstatus)
|
||||
waitforjob(jp, origstatus)
|
||||
struct job *jp;
|
||||
int *origstatus;
|
||||
{
|
||||
#if JOBS
|
||||
pid_t mypgrp = getpgrp();
|
||||
int mypgrp = getpgrp();
|
||||
#endif
|
||||
int status;
|
||||
int st;
|
||||
@@ -857,11 +722,16 @@ waitforjob(struct job *jp, int *origstatus)
|
||||
dotrap();
|
||||
#if JOBS
|
||||
if (jp->jobctl) {
|
||||
if (tcsetpgrp(ttyfd, mypgrp) < 0)
|
||||
#ifdef OLD_TTY_DRIVER
|
||||
if (ioctl(2, TIOCSPGRP, (char *)&mypgrp) < 0)
|
||||
error("TIOCSPGRP failed, errno=%d\n", errno);
|
||||
#else
|
||||
if (tcsetpgrp(2, mypgrp) < 0)
|
||||
error("tcsetpgrp failed, errno=%d\n", errno);
|
||||
#endif
|
||||
}
|
||||
if (jp->state == JOBSTOPPED)
|
||||
setcurjob(jp);
|
||||
curjob = jp - jobtab + 1;
|
||||
#endif
|
||||
status = jp->ps[jp->nprocs - 1].status;
|
||||
if (origstatus != NULL)
|
||||
@@ -893,24 +763,26 @@ waitforjob(struct job *jp, int *origstatus)
|
||||
* Wait for a process to terminate.
|
||||
*/
|
||||
|
||||
STATIC pid_t
|
||||
dowait(int block, struct job *job)
|
||||
STATIC int
|
||||
dowait(block, job)
|
||||
int block;
|
||||
struct job *job;
|
||||
{
|
||||
pid_t pid;
|
||||
int pid;
|
||||
int status;
|
||||
struct procstat *sp;
|
||||
struct job *jp;
|
||||
struct job *thisjob;
|
||||
int done;
|
||||
int stopped;
|
||||
int core;
|
||||
int sig;
|
||||
int i;
|
||||
|
||||
in_dowait++;
|
||||
TRACE(("dowait(%d) called\n", block));
|
||||
do {
|
||||
pid = waitproc(block, &status);
|
||||
TRACE(("wait returns %d, status=%d\n", (int)pid, status));
|
||||
TRACE(("wait returns %d, status=%d\n", pid, status));
|
||||
} while ((pid == -1 && errno == EINTR && breakwaitcmd == 0) ||
|
||||
(WIFSTOPPED(status) && !iflag));
|
||||
in_dowait--;
|
||||
@@ -931,8 +803,7 @@ dowait(int block, struct job *job)
|
||||
continue;
|
||||
if (sp->pid == pid) {
|
||||
TRACE(("Changing status of proc %d from 0x%x to 0x%x\n",
|
||||
(int)pid, sp->status,
|
||||
status));
|
||||
pid, sp->status, status));
|
||||
sp->status = status;
|
||||
thisjob = jp;
|
||||
}
|
||||
@@ -947,8 +818,8 @@ dowait(int block, struct job *job)
|
||||
TRACE(("Job %d: changing state from %d to %d\n", jp - jobtab + 1, jp->state, state));
|
||||
jp->state = state;
|
||||
#if JOBS
|
||||
if (done)
|
||||
deljob(jp);
|
||||
if (done && curjob == jp - jobtab + 1)
|
||||
curjob = 0; /* no current job */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -956,29 +827,35 @@ dowait(int block, struct job *job)
|
||||
}
|
||||
INTON;
|
||||
if (! rootshell || ! iflag || (job && thisjob == job)) {
|
||||
core = WCOREDUMP(status);
|
||||
#if JOBS
|
||||
if (WIFSTOPPED(status))
|
||||
sig = WSTOPSIG(status);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
sig = 0;
|
||||
else
|
||||
sig = WTERMSIG(status);
|
||||
}
|
||||
|
||||
if (sig != 0 && sig != SIGINT && sig != SIGPIPE) {
|
||||
if (thisjob->foreground && !WIFSTOPPED(status)) {
|
||||
i = WTERMSIG(status);
|
||||
if ((i & 0x7F) < NSIG && sys_siglist[i & 0x7F])
|
||||
out1str(sys_siglist[i & 0x7F]);
|
||||
else
|
||||
out1fmt("Signal %d", i & 0x7F);
|
||||
if (WCOREDUMP(status))
|
||||
out1str(" (core dumped)");
|
||||
out1c('\n');
|
||||
} else
|
||||
showjob(thisjob, pid, 0, 0);
|
||||
if (thisjob != job)
|
||||
outfmt(out2, "%d: ", pid);
|
||||
#if JOBS
|
||||
if (sig == SIGTSTP && rootshell && iflag)
|
||||
outfmt(out2, "%%%d ", job - jobtab + 1);
|
||||
#endif
|
||||
if (sig < NSIG && sys_siglist[sig])
|
||||
out2str(sys_siglist[sig]);
|
||||
else
|
||||
outfmt(out2, "Signal %d", sig);
|
||||
if (core)
|
||||
out2str(" - core dumped");
|
||||
out2c('\n');
|
||||
flushout(&errout);
|
||||
} else {
|
||||
TRACE(("Not printing status: status=%d, sig=%d\n",
|
||||
status, sig));
|
||||
}
|
||||
} else {
|
||||
TRACE(("Not printing status, rootshell=%d, job=0x%x\n", rootshell, job));
|
||||
@@ -994,10 +871,46 @@ dowait(int block, struct job *job)
|
||||
* Do a wait system call. If job control is compiled in, we accept
|
||||
* stopped processes. If block is zero, we return a value of zero
|
||||
* rather than blocking.
|
||||
*
|
||||
* System V doesn't have a non-blocking wait system call. It does
|
||||
* have a SIGCLD signal that is sent to a process when one of it's
|
||||
* children dies. The obvious way to use SIGCLD would be to install
|
||||
* a handler for SIGCLD which simply bumped a counter when a SIGCLD
|
||||
* was received, and have waitproc bump another counter when it got
|
||||
* the status of a process. Waitproc would then know that a wait
|
||||
* system call would not block if the two counters were different.
|
||||
* This approach doesn't work because if a process has children that
|
||||
* have not been waited for, System V will send it a SIGCLD when it
|
||||
* installs a signal handler for SIGCLD. What this means is that when
|
||||
* a child exits, the shell will be sent SIGCLD signals continuously
|
||||
* until is runs out of stack space, unless it does a wait call before
|
||||
* restoring the signal handler. The code below takes advantage of
|
||||
* this (mis)feature by installing a signal handler for SIGCLD and
|
||||
* then checking to see whether it was called. If there are any
|
||||
* children to be waited for, it will be.
|
||||
*
|
||||
* If neither SYSV nor BSD is defined, we don't implement nonblocking
|
||||
* waits at all. In this case, the user will not be informed when
|
||||
* a background process until the next time she runs a real program
|
||||
* (as opposed to running a builtin command or just typing return),
|
||||
* and the jobs command may give out of date information.
|
||||
*/
|
||||
STATIC pid_t
|
||||
waitproc(int block, int *status)
|
||||
|
||||
#ifdef SYSV
|
||||
STATIC sig_atomic_t gotsigchild;
|
||||
|
||||
STATIC int onsigchild() {
|
||||
gotsigchild = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
STATIC int
|
||||
waitproc(block, status)
|
||||
int block;
|
||||
int *status;
|
||||
{
|
||||
#ifdef BSD
|
||||
int flags;
|
||||
|
||||
#if JOBS
|
||||
@@ -1008,6 +921,24 @@ waitproc(int block, int *status)
|
||||
if (block == 0)
|
||||
flags |= WNOHANG;
|
||||
return wait3(status, flags, (struct rusage *)NULL);
|
||||
#else
|
||||
#ifdef SYSV
|
||||
int (*save)();
|
||||
|
||||
if (block == 0) {
|
||||
gotsigchild = 0;
|
||||
save = signal(SIGCLD, onsigchild);
|
||||
signal(SIGCLD, save);
|
||||
if (gotsigchild == 0)
|
||||
return 0;
|
||||
}
|
||||
return wait(status);
|
||||
#else
|
||||
if (block == 0)
|
||||
return 0;
|
||||
return wait(status);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1015,7 +946,7 @@ waitproc(int block, int *status)
|
||||
*/
|
||||
int job_warning = 0;
|
||||
int
|
||||
stoppedjobs(void)
|
||||
stoppedjobs()
|
||||
{
|
||||
int jobno;
|
||||
struct job *jp;
|
||||
@@ -1045,8 +976,9 @@ STATIC int cmdnleft;
|
||||
#define MAXCMDTEXT 200
|
||||
|
||||
char *
|
||||
commandtext(union node *n)
|
||||
{
|
||||
commandtext(n)
|
||||
union node *n;
|
||||
{
|
||||
char *name;
|
||||
|
||||
cmdnextc = name = ckmalloc(MAXCMDTEXT);
|
||||
@@ -1058,8 +990,9 @@ commandtext(union node *n)
|
||||
|
||||
|
||||
STATIC void
|
||||
cmdtxt(union node *n)
|
||||
{
|
||||
cmdtxt(n)
|
||||
union node *n;
|
||||
{
|
||||
union node *np;
|
||||
struct nodelist *lp;
|
||||
char *p;
|
||||
@@ -1152,8 +1085,6 @@ until:
|
||||
p = ">>"; i = 1; goto redir;
|
||||
case NTOFD:
|
||||
p = ">&"; i = 1; goto redir;
|
||||
case NCLOBBER:
|
||||
p = ">|"; i = 1; goto redir;
|
||||
case NFROM:
|
||||
p = "<"; i = 0; goto redir;
|
||||
case NFROMTO:
|
||||
@@ -1168,10 +1099,7 @@ redir:
|
||||
}
|
||||
cmdputs(p);
|
||||
if (n->type == NTOFD || n->type == NFROMFD) {
|
||||
if (n->ndup.dupfd >= 0)
|
||||
s[0] = n->ndup.dupfd + '0';
|
||||
else
|
||||
s[0] = '-';
|
||||
s[0] = n->ndup.dupfd + '0';
|
||||
s[1] = '\0';
|
||||
cmdputs(s);
|
||||
} else {
|
||||
@@ -1191,8 +1119,9 @@ redir:
|
||||
|
||||
|
||||
STATIC void
|
||||
cmdputs(char *s)
|
||||
{
|
||||
cmdputs(s)
|
||||
char *s;
|
||||
{
|
||||
char *p, *q;
|
||||
char c;
|
||||
int subtype = 0;
|
||||
|
||||
+13
-15
@@ -67,14 +67,12 @@ struct job {
|
||||
struct procstat ps0; /* status of process */
|
||||
struct procstat *ps; /* status or processes when more than one */
|
||||
short nprocs; /* number of processes */
|
||||
pid_t pgrp; /* process group of this job */
|
||||
short pgrp; /* process group of this job */
|
||||
char state; /* true if job is finished */
|
||||
char used; /* true if this entry is in used */
|
||||
char changed; /* true if status has changed */
|
||||
char foreground; /* true if running in the foreground */
|
||||
#if JOBS
|
||||
char jobctl; /* job running under job control */
|
||||
struct job *next; /* job used after this one */
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -84,18 +82,18 @@ extern int in_waitcmd; /* are we in waitcmd()? */
|
||||
extern int in_dowait; /* are we in dowait()? */
|
||||
extern volatile sig_atomic_t breakwaitcmd; /* break wait to process traps? */
|
||||
|
||||
void setjobctl(int);
|
||||
int fgcmd(int, char **);
|
||||
int bgcmd(int, char **);
|
||||
int jobscmd(int, char **);
|
||||
void showjobs(int, int, int);
|
||||
int waitcmd(int, char **);
|
||||
int jobidcmd(int, char **);
|
||||
struct job *makejob(union node *, int);
|
||||
pid_t forkshell(struct job *, union node *, int);
|
||||
int waitforjob(struct job *, int *);
|
||||
int stoppedjobs(void);
|
||||
char *commandtext(union node *);
|
||||
void setjobctl __P((int));
|
||||
int fgcmd __P((int, char **));
|
||||
int bgcmd __P((int, char **));
|
||||
int jobscmd __P((int, char **));
|
||||
void showjobs __P((int));
|
||||
int waitcmd __P((int, char **));
|
||||
int jobidcmd __P((int, char **));
|
||||
struct job *makejob __P((union node *, int));
|
||||
int forkshell __P((struct job *, union node *, int));
|
||||
int waitforjob __P((struct job *, int *));
|
||||
int stoppedjobs __P((void));
|
||||
char *commandtext __P((union node *));
|
||||
|
||||
#if ! JOBS
|
||||
#define setjobctl(on) /* do nothing */
|
||||
|
||||
+4
-3
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mail.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Routines to check for mail. (Perhaps make part of main.c?)
|
||||
@@ -72,7 +72,8 @@ STATIC time_t mailtime[MAXMBOXES]; /* times of mailboxes */
|
||||
*/
|
||||
|
||||
void
|
||||
chkmail(int silent)
|
||||
chkmail(silent)
|
||||
int silent;
|
||||
{
|
||||
int i;
|
||||
char *mpath;
|
||||
|
||||
+1
-1
@@ -37,4 +37,4 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
void chkmail(int);
|
||||
void chkmail __P((int));
|
||||
+35
-13
@@ -44,9 +44,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/28/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@@ -86,8 +86,8 @@ short profile_buf[16384];
|
||||
extern int etext();
|
||||
#endif
|
||||
|
||||
STATIC void read_profile(char *);
|
||||
STATIC char *find_dot_file(char *);
|
||||
STATIC void read_profile __P((char *));
|
||||
STATIC char *find_dot_file __P((char *));
|
||||
|
||||
/*
|
||||
* Main routine. We initialize things, parse the arguments, execute
|
||||
@@ -98,7 +98,9 @@ STATIC char *find_dot_file(char *);
|
||||
*/
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct jmploc jmploc;
|
||||
struct stackmark smark;
|
||||
@@ -214,7 +216,8 @@ state4: /* XXX ??? - why isn't this before the "if" statement */
|
||||
*/
|
||||
|
||||
void
|
||||
cmdloop(int top)
|
||||
cmdloop(top)
|
||||
int top;
|
||||
{
|
||||
union node *n;
|
||||
struct stackmark smark;
|
||||
@@ -229,7 +232,7 @@ cmdloop(int top)
|
||||
inter = 0;
|
||||
if (iflag && top) {
|
||||
inter++;
|
||||
showjobs(1, 0, 0);
|
||||
showjobs(1);
|
||||
chkmail(0);
|
||||
flushout(&output);
|
||||
}
|
||||
@@ -266,8 +269,9 @@ cmdloop(int top)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
read_profile(char *name)
|
||||
{
|
||||
read_profile(name)
|
||||
char *name;
|
||||
{
|
||||
int fd;
|
||||
|
||||
INTOFF;
|
||||
@@ -287,7 +291,8 @@ read_profile(char *name)
|
||||
*/
|
||||
|
||||
void
|
||||
readcmdfile(char *name)
|
||||
readcmdfile(name)
|
||||
char *name;
|
||||
{
|
||||
int fd;
|
||||
|
||||
@@ -310,7 +315,8 @@ readcmdfile(char *name)
|
||||
|
||||
|
||||
STATIC char *
|
||||
find_dot_file(char *basename)
|
||||
find_dot_file(basename)
|
||||
char *basename;
|
||||
{
|
||||
static char localname[FILENAME_MAX+1];
|
||||
char *fullname;
|
||||
@@ -331,7 +337,9 @@ find_dot_file(char *basename)
|
||||
}
|
||||
|
||||
int
|
||||
dotcmd(int argc, char **argv)
|
||||
dotcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
struct strlist *sp;
|
||||
exitstatus = 0;
|
||||
@@ -352,7 +360,9 @@ dotcmd(int argc, char **argv)
|
||||
|
||||
|
||||
int
|
||||
exitcmd(int argc, char **argv)
|
||||
exitcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
extern int oexitstatus;
|
||||
|
||||
@@ -366,3 +376,15 @@ exitcmd(int argc, char **argv)
|
||||
/*NOTREACHED*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef notdef
|
||||
/*
|
||||
* Should never be called.
|
||||
*/
|
||||
|
||||
void
|
||||
exit(exitstatus) {
|
||||
_exit(exitstatus);
|
||||
}
|
||||
#endif
|
||||
+4
-4
@@ -40,7 +40,7 @@
|
||||
extern int rootpid; /* pid of main shell */
|
||||
extern int rootshell; /* true if we aren't a child of the main shell */
|
||||
|
||||
void readcmdfile(char *);
|
||||
void cmdloop(int);
|
||||
int dotcmd(int, char **);
|
||||
int exitcmd(int, char **);
|
||||
void readcmdfile __P((char *));
|
||||
void cmdloop __P((int));
|
||||
int dotcmd __P((int, char **));
|
||||
int exitcmd __P((int, char **));
|
||||
+26
-15
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "shell.h"
|
||||
#include "output.h"
|
||||
@@ -57,7 +57,8 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
|
||||
pointer
|
||||
ckmalloc(int nbytes)
|
||||
ckmalloc(nbytes)
|
||||
int nbytes;
|
||||
{
|
||||
pointer p;
|
||||
|
||||
@@ -72,7 +73,9 @@ ckmalloc(int nbytes)
|
||||
*/
|
||||
|
||||
pointer
|
||||
ckrealloc(pointer p, int nbytes)
|
||||
ckrealloc(p, nbytes)
|
||||
pointer p;
|
||||
int nbytes;
|
||||
{
|
||||
if ((p = realloc(p, nbytes)) == NULL)
|
||||
error("Out of space");
|
||||
@@ -85,7 +88,8 @@ ckrealloc(pointer p, int nbytes)
|
||||
*/
|
||||
|
||||
char *
|
||||
savestr(char *s)
|
||||
savestr(s)
|
||||
char *s;
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -123,7 +127,8 @@ int herefd = -1;
|
||||
|
||||
|
||||
pointer
|
||||
stalloc(int nbytes)
|
||||
stalloc(nbytes)
|
||||
int nbytes;
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -152,10 +157,11 @@ stalloc(int nbytes)
|
||||
|
||||
|
||||
void
|
||||
stunalloc(pointer p)
|
||||
stunalloc(p)
|
||||
pointer p;
|
||||
{
|
||||
if (p == NULL) { /*DEBUG */
|
||||
write(STDERR_FILENO, "stunalloc\n", 10);
|
||||
write(2, "stunalloc\n", 10);
|
||||
abort();
|
||||
}
|
||||
stacknleft += stacknxt - (char *)p;
|
||||
@@ -165,7 +171,8 @@ stunalloc(pointer p)
|
||||
|
||||
|
||||
void
|
||||
setstackmark(struct stackmark *mark)
|
||||
setstackmark(mark)
|
||||
struct stackmark *mark;
|
||||
{
|
||||
mark->stackp = stackp;
|
||||
mark->stacknxt = stacknxt;
|
||||
@@ -176,7 +183,8 @@ setstackmark(struct stackmark *mark)
|
||||
|
||||
|
||||
void
|
||||
popstackmark(struct stackmark *mark)
|
||||
popstackmark(mark)
|
||||
struct stackmark *mark;
|
||||
{
|
||||
struct stack_block *sp;
|
||||
|
||||
@@ -204,7 +212,7 @@ popstackmark(struct stackmark *mark)
|
||||
*/
|
||||
|
||||
void
|
||||
growstackblock(void)
|
||||
growstackblock()
|
||||
{
|
||||
char *p;
|
||||
int newlen;
|
||||
@@ -253,7 +261,8 @@ growstackblock(void)
|
||||
|
||||
|
||||
void
|
||||
grabstackblock(int len)
|
||||
grabstackblock(len)
|
||||
int len;
|
||||
{
|
||||
len = ALIGN(len);
|
||||
stacknxt += len;
|
||||
@@ -282,7 +291,7 @@ grabstackblock(int len)
|
||||
|
||||
|
||||
char *
|
||||
growstackstr(void)
|
||||
growstackstr()
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -303,7 +312,7 @@ growstackstr(void)
|
||||
*/
|
||||
|
||||
char *
|
||||
makestrspace(void)
|
||||
makestrspace()
|
||||
{
|
||||
int len;
|
||||
|
||||
@@ -316,7 +325,9 @@ makestrspace(void)
|
||||
|
||||
|
||||
void
|
||||
ungrabstackstr(char *s, char *p)
|
||||
ungrabstackstr(s, p)
|
||||
char *s;
|
||||
char *p;
|
||||
{
|
||||
stacknleft += stacknxt - s;
|
||||
stacknxt = s;
|
||||
|
||||
+12
-12
@@ -50,18 +50,18 @@ extern int stacknleft;
|
||||
extern int sstrnleft;
|
||||
extern int herefd;
|
||||
|
||||
pointer ckmalloc(int);
|
||||
pointer ckrealloc(pointer, int);
|
||||
char *savestr(char *);
|
||||
pointer stalloc(int);
|
||||
void stunalloc(pointer);
|
||||
void setstackmark(struct stackmark *);
|
||||
void popstackmark(struct stackmark *);
|
||||
void growstackblock(void);
|
||||
void grabstackblock(int);
|
||||
char *growstackstr(void);
|
||||
char *makestrspace(void);
|
||||
void ungrabstackstr(char *, char *);
|
||||
pointer ckmalloc __P((int));
|
||||
pointer ckrealloc __P((pointer, int));
|
||||
char *savestr __P((char *));
|
||||
pointer stalloc __P((int));
|
||||
void stunalloc __P((pointer));
|
||||
void setstackmark __P((struct stackmark *));
|
||||
void popstackmark __P((struct stackmark *));
|
||||
void growstackblock __P((void));
|
||||
void grabstackblock __P((int));
|
||||
char *growstackstr __P((void));
|
||||
char *makestrspace __P((void));
|
||||
void ungrabstackstr __P((char *, char *));
|
||||
|
||||
|
||||
|
||||
|
||||
+14
-8
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Miscellaneous builtins.
|
||||
@@ -75,7 +75,9 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
|
||||
int
|
||||
readcmd(int argc __unused, char **argv __unused)
|
||||
readcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
char **ap;
|
||||
int backslash;
|
||||
@@ -169,7 +171,7 @@ readcmd(int argc __unused, char **argv __unused)
|
||||
backslash = 0;
|
||||
STARTSTACKSTR(p);
|
||||
for (;;) {
|
||||
if (read(STDIN_FILENO, &c, 1) != 1) {
|
||||
if (read(0, &c, 1) != 1) {
|
||||
status = 1;
|
||||
break;
|
||||
}
|
||||
@@ -192,7 +194,7 @@ readcmd(int argc __unused, char **argv __unused)
|
||||
}
|
||||
startword = 0;
|
||||
if (backslash && c == '\\') {
|
||||
if (read(STDIN_FILENO, &c, 1) != 1) {
|
||||
if (read(0, &c, 1) != 1) {
|
||||
status = 1;
|
||||
break;
|
||||
}
|
||||
@@ -217,7 +219,9 @@ readcmd(int argc __unused, char **argv __unused)
|
||||
|
||||
|
||||
int
|
||||
umaskcmd(int argc __unused, char **argv)
|
||||
umaskcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv;
|
||||
{
|
||||
char *ap;
|
||||
int mask;
|
||||
@@ -349,7 +353,9 @@ static const struct limits limits[] = {
|
||||
};
|
||||
|
||||
int
|
||||
ulimitcmd(int argc __unused, char **argv __unused)
|
||||
ulimitcmd(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
int c;
|
||||
quad_t val = 0;
|
||||
@@ -361,7 +367,7 @@ ulimitcmd(int argc __unused, char **argv __unused)
|
||||
struct rlimit limit;
|
||||
|
||||
what = 'f';
|
||||
while ((optc = nextopt("HSatfdsmcnuvlb")) != '\0')
|
||||
while ((optc = nextopt("HSatfdsmcnulb")) != '\0')
|
||||
switch (optc) {
|
||||
case 'H':
|
||||
how = HARD;
|
||||
|
||||
@@ -54,7 +54,6 @@ cat <<\!
|
||||
* This file was generated by the mkbuiltins program.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "shell.h"
|
||||
#include "builtins.h"
|
||||
|
||||
|
||||
+63
-41
@@ -44,9 +44,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mkinit.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* This program scans all the source files for code to handle various
|
||||
@@ -152,25 +152,27 @@ struct text decls; /* declarations */
|
||||
int amiddecls; /* for formatting */
|
||||
|
||||
|
||||
void readfile(char *);
|
||||
int match(char *, char *);
|
||||
int gooddefine(char *);
|
||||
void doevent(struct event *, FILE *, char *);
|
||||
void doinclude(char *);
|
||||
void dodecl(char *, FILE *);
|
||||
void output(void);
|
||||
void addstr(char *, struct text *);
|
||||
void addchar(int, struct text *);
|
||||
void writetext(struct text *, FILE *);
|
||||
FILE *ckfopen(char *, char *);
|
||||
void *ckmalloc(int);
|
||||
char *savestr(char *);
|
||||
void error(char *);
|
||||
void readfile __P((char *));
|
||||
int match __P((char *, char *));
|
||||
int gooddefine __P((char *));
|
||||
void doevent __P((struct event *, FILE *, char *));
|
||||
void doinclude __P((char *));
|
||||
void dodecl __P((char *, FILE *));
|
||||
void output __P((void));
|
||||
void addstr __P((char *, struct text *));
|
||||
void addchar __P((int, struct text *));
|
||||
void writetext __P((struct text *, FILE *));
|
||||
FILE *ckfopen __P((char *, char *));
|
||||
void *ckmalloc __P((int));
|
||||
char *savestr __P((char *));
|
||||
void error __P((char *));
|
||||
|
||||
#define equal(s1, s2) (strcmp(s1, s2) == 0)
|
||||
|
||||
int
|
||||
main(int argc __unused, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv;
|
||||
{
|
||||
char **ap;
|
||||
|
||||
@@ -189,8 +191,9 @@ main(int argc __unused, char *argv[])
|
||||
*/
|
||||
|
||||
void
|
||||
readfile(char *fname)
|
||||
{
|
||||
readfile(fname)
|
||||
char *fname;
|
||||
{
|
||||
FILE *fp;
|
||||
char line[1024];
|
||||
struct event *ep;
|
||||
@@ -233,7 +236,9 @@ readfile(char *fname)
|
||||
|
||||
|
||||
int
|
||||
match(char *name, char *line)
|
||||
match(name, line)
|
||||
char *name;
|
||||
char *line;
|
||||
{
|
||||
char *p, *q;
|
||||
|
||||
@@ -249,7 +254,8 @@ match(char *name, char *line)
|
||||
|
||||
|
||||
int
|
||||
gooddefine(char *line)
|
||||
gooddefine(line)
|
||||
char *line;
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -272,8 +278,11 @@ gooddefine(char *line)
|
||||
|
||||
|
||||
void
|
||||
doevent(struct event *ep, FILE *fp, char *fname)
|
||||
{
|
||||
doevent(ep, fp, fname)
|
||||
struct event *ep;
|
||||
FILE *fp;
|
||||
char *fname;
|
||||
{
|
||||
char line[1024];
|
||||
int indent;
|
||||
char *p;
|
||||
@@ -309,8 +318,9 @@ doevent(struct event *ep, FILE *fp, char *fname)
|
||||
|
||||
|
||||
void
|
||||
doinclude(char *line)
|
||||
{
|
||||
doinclude(line)
|
||||
char *line;
|
||||
{
|
||||
char *p;
|
||||
char *name;
|
||||
char **pp;
|
||||
@@ -333,8 +343,10 @@ doinclude(char *line)
|
||||
|
||||
|
||||
void
|
||||
dodecl(char *line1, FILE *fp)
|
||||
{
|
||||
dodecl(line1, fp)
|
||||
char *line1;
|
||||
FILE *fp;
|
||||
{
|
||||
char line[1024];
|
||||
char *p, *q;
|
||||
|
||||
@@ -378,8 +390,7 @@ dodecl(char *line1, FILE *fp)
|
||||
*/
|
||||
|
||||
void
|
||||
output(void)
|
||||
{
|
||||
output() {
|
||||
FILE *fp;
|
||||
char **pp;
|
||||
struct event *ep;
|
||||
@@ -410,8 +421,10 @@ output(void)
|
||||
*/
|
||||
|
||||
void
|
||||
addstr(char *s, struct text *text)
|
||||
{
|
||||
addstr(s, text)
|
||||
char *s;
|
||||
struct text *text;
|
||||
{
|
||||
while (*s) {
|
||||
if (--text->nleft < 0)
|
||||
addchar(*s++, text);
|
||||
@@ -422,7 +435,9 @@ addstr(char *s, struct text *text)
|
||||
|
||||
|
||||
void
|
||||
addchar(int c, struct text *text)
|
||||
addchar(c, text)
|
||||
int c;
|
||||
struct text *text;
|
||||
{
|
||||
struct block *bp;
|
||||
|
||||
@@ -443,8 +458,10 @@ addchar(int c, struct text *text)
|
||||
* Write the contents of a text structure to a file.
|
||||
*/
|
||||
void
|
||||
writetext(struct text *text, FILE *fp)
|
||||
{
|
||||
writetext(text, fp)
|
||||
struct text *text;
|
||||
FILE *fp;
|
||||
{
|
||||
struct block *bp;
|
||||
|
||||
if (text->start != NULL) {
|
||||
@@ -455,8 +472,10 @@ writetext(struct text *text, FILE *fp)
|
||||
}
|
||||
|
||||
FILE *
|
||||
ckfopen(char *file, char *mode)
|
||||
{
|
||||
ckfopen(file, mode)
|
||||
char *file;
|
||||
char *mode;
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen(file, mode)) == NULL) {
|
||||
@@ -467,7 +486,8 @@ ckfopen(char *file, char *mode)
|
||||
}
|
||||
|
||||
void *
|
||||
ckmalloc(int nbytes)
|
||||
ckmalloc(nbytes)
|
||||
int nbytes;
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -477,8 +497,9 @@ ckmalloc(int nbytes)
|
||||
}
|
||||
|
||||
char *
|
||||
savestr(char *s)
|
||||
{
|
||||
savestr(s)
|
||||
char *s;
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = ckmalloc(strlen(s) + 1);
|
||||
@@ -487,8 +508,9 @@ savestr(char *s)
|
||||
}
|
||||
|
||||
void
|
||||
error(char *msg)
|
||||
{
|
||||
error(msg)
|
||||
char *msg;
|
||||
{
|
||||
if (curfile != NULL)
|
||||
fprintf(stderr, "%s:%d: ", curfile, linno);
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
|
||||
+55
-24
@@ -44,9 +44,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mknodes.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* This program reads the nodetypes file and nodes.c.pat file. It generates
|
||||
@@ -57,7 +57,12 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define MAXTYPES 50 /* max number of node types */
|
||||
#define MAXFIELDS 20 /* max fields in a structure */
|
||||
@@ -98,21 +103,23 @@ static char line[1024];
|
||||
static int linno;
|
||||
static char *linep;
|
||||
|
||||
static void parsenode(void);
|
||||
static void parsefield(void);
|
||||
static void output(char *);
|
||||
static void outsizes(FILE *);
|
||||
static void outfunc(FILE *, int);
|
||||
static void indent(int, FILE *);
|
||||
static int nextfield(char *);
|
||||
static void skipbl(void);
|
||||
static int readline(void);
|
||||
static void error(const char *, ...) __printf0like(1, 2);
|
||||
static char *savestr(const char *);
|
||||
static void parsenode __P((void));
|
||||
static void parsefield __P((void));
|
||||
static void output __P((char *));
|
||||
static void outsizes __P((FILE *));
|
||||
static void outfunc __P((FILE *, int));
|
||||
static void indent __P((int, FILE *));
|
||||
static int nextfield __P((char *));
|
||||
static void skipbl __P((void));
|
||||
static int readline __P((void));
|
||||
static void error __P((const char *, ...)) __printf0like(1, 2);
|
||||
static char *savestr __P((const char *));
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
if (argc != 3)
|
||||
error("usage: mknodes file");
|
||||
@@ -132,7 +139,7 @@ main(int argc, char *argv[])
|
||||
|
||||
|
||||
static void
|
||||
parsenode(void)
|
||||
parsenode()
|
||||
{
|
||||
char name[BUFLEN];
|
||||
char tag[BUFLEN];
|
||||
@@ -162,7 +169,7 @@ parsenode(void)
|
||||
|
||||
|
||||
static void
|
||||
parsefield(void)
|
||||
parsefield()
|
||||
{
|
||||
char name[BUFLEN];
|
||||
char type[BUFLEN];
|
||||
@@ -215,7 +222,8 @@ char writer[] = "\
|
||||
\n";
|
||||
|
||||
static void
|
||||
output(char *file)
|
||||
output(file)
|
||||
char *file;
|
||||
{
|
||||
FILE *hfile;
|
||||
FILE *cfile;
|
||||
@@ -252,8 +260,13 @@ output(char *file)
|
||||
fputs("\tstruct nodelist *next;\n", hfile);
|
||||
fputs("\tunion node *n;\n", hfile);
|
||||
fputs("};\n\n\n", hfile);
|
||||
fputs("#ifdef __STDC__\n", hfile);
|
||||
fputs("union node *copyfunc(union node *);\n", hfile);
|
||||
fputs("void freefunc(union node *);\n", hfile);
|
||||
fputs("#else\n", hfile);
|
||||
fputs("union node *copyfunc();\n", hfile);
|
||||
fputs("void freefunc();\n", hfile);
|
||||
fputs("#endif\n", hfile);
|
||||
|
||||
fputs(writer, cfile);
|
||||
while (fgets(line, sizeof line, patfile) != NULL) {
|
||||
@@ -272,7 +285,8 @@ output(char *file)
|
||||
|
||||
|
||||
static void
|
||||
outsizes(FILE *cfile)
|
||||
outsizes(cfile)
|
||||
FILE *cfile;
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -285,7 +299,9 @@ outsizes(FILE *cfile)
|
||||
|
||||
|
||||
static void
|
||||
outfunc(FILE *cfile, int calcsize)
|
||||
outfunc(cfile, calcsize)
|
||||
FILE *cfile;
|
||||
int calcsize;
|
||||
{
|
||||
struct str *sp;
|
||||
struct field *fp;
|
||||
@@ -364,7 +380,9 @@ outfunc(FILE *cfile, int calcsize)
|
||||
|
||||
|
||||
static void
|
||||
indent(int amount, FILE *fp)
|
||||
indent(amount, fp)
|
||||
int amount;
|
||||
FILE *fp;
|
||||
{
|
||||
while (amount >= 8) {
|
||||
putc('\t', fp);
|
||||
@@ -377,7 +395,8 @@ indent(int amount, FILE *fp)
|
||||
|
||||
|
||||
static int
|
||||
nextfield(char *buf)
|
||||
nextfield(buf)
|
||||
char *buf;
|
||||
{
|
||||
char *p, *q;
|
||||
|
||||
@@ -394,7 +413,7 @@ nextfield(char *buf)
|
||||
|
||||
|
||||
static void
|
||||
skipbl(void)
|
||||
skipbl()
|
||||
{
|
||||
while (*linep == ' ' || *linep == '\t')
|
||||
linep++;
|
||||
@@ -402,7 +421,7 @@ skipbl(void)
|
||||
|
||||
|
||||
static int
|
||||
readline(void)
|
||||
readline()
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -422,10 +441,21 @@ readline(void)
|
||||
|
||||
|
||||
static void
|
||||
#ifdef __STDC__
|
||||
error(const char *msg, ...)
|
||||
#else
|
||||
error(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
#ifdef __STDC__
|
||||
va_start(va, msg);
|
||||
#else
|
||||
const char *msg;
|
||||
va_start(va);
|
||||
msg = va_arg(va, char *);
|
||||
#endif
|
||||
|
||||
(void) fprintf(stderr, "line %d: ", linno);
|
||||
(void) vfprintf(stderr, msg, va);
|
||||
@@ -439,7 +469,8 @@ error(const char *msg, ...)
|
||||
|
||||
|
||||
static char *
|
||||
savestr(const char *s)
|
||||
savestr(s)
|
||||
const char *s;
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
||||
+20
-15
@@ -44,9 +44,9 @@ static char const copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mksyntax.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* This program creates syntax.h and syntax.c.
|
||||
@@ -111,15 +111,17 @@ static int size; /* number of values which a char variable can have */
|
||||
static int nbits; /* number of bits in a character */
|
||||
static int digit_contig;/* true if digits are contiguous */
|
||||
|
||||
static void filltable(char *);
|
||||
static void init(void);
|
||||
static void add(char *, char *);
|
||||
static void print(char *);
|
||||
static void output_type_macros(void);
|
||||
static void digit_convert(void);
|
||||
static void filltable __P((char *));
|
||||
static void init __P((void));
|
||||
static void add __P((char *, char *));
|
||||
static void print __P((char *));
|
||||
static void output_type_macros __P((void));
|
||||
static void digit_convert __P((void));
|
||||
|
||||
int
|
||||
main(int argc __unused, char **argv __unused)
|
||||
main(argc, argv)
|
||||
int argc __unused;
|
||||
char **argv __unused;
|
||||
{
|
||||
char c;
|
||||
char d;
|
||||
@@ -266,7 +268,8 @@ main(int argc __unused, char **argv __unused)
|
||||
*/
|
||||
|
||||
static void
|
||||
filltable(char *dftval)
|
||||
filltable(dftval)
|
||||
char *dftval;
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -280,7 +283,7 @@ filltable(char *dftval)
|
||||
*/
|
||||
|
||||
static void
|
||||
init(void)
|
||||
init()
|
||||
{
|
||||
filltable("CWORD");
|
||||
syntax[0] = "CEOF";
|
||||
@@ -300,7 +303,8 @@ init(void)
|
||||
*/
|
||||
|
||||
static void
|
||||
add(char *p, char *type)
|
||||
add(p, type)
|
||||
char *p, *type;
|
||||
{
|
||||
while (*p)
|
||||
syntax[*p++ + base] = type;
|
||||
@@ -313,7 +317,8 @@ add(char *p, char *type)
|
||||
*/
|
||||
|
||||
static void
|
||||
print(char *name)
|
||||
print(name)
|
||||
char *name;
|
||||
{
|
||||
int i;
|
||||
int col;
|
||||
@@ -355,7 +360,7 @@ static char *macro[] = {
|
||||
};
|
||||
|
||||
static void
|
||||
output_type_macros(void)
|
||||
output_type_macros()
|
||||
{
|
||||
char **pp;
|
||||
|
||||
@@ -376,7 +381,7 @@ output_type_macros(void)
|
||||
*/
|
||||
|
||||
static void
|
||||
digit_convert(void)
|
||||
digit_convert()
|
||||
{
|
||||
int maxdigit;
|
||||
static char digit[] = "0123456789";
|
||||
|
||||
+2
-2
@@ -81,14 +81,14 @@ const char tokendlist[] = {'
|
||||
awk '{print "\t" $2 ","}' $temp
|
||||
echo '};
|
||||
|
||||
const char *const tokname[] = {'
|
||||
char *const tokname[] = {'
|
||||
sed -e 's/"/\\"/g' \
|
||||
-e 's/[^ ]*[ ][ ]*[^ ]*[ ][ ]*\(.*\)/ "\1",/' \
|
||||
$temp
|
||||
echo '};
|
||||
'
|
||||
sed 's/"//g' $temp | awk '
|
||||
/TIF/{print "#define KWDOFFSET " NR-1; print ""; print "const char *const parsekwd[] = {"}
|
||||
/TIF/{print "#define KWDOFFSET " NR-1; print ""; print "char *const parsekwd[] = {"}
|
||||
/TIF/,/neverfound/{print " \"" $3 "\","}'
|
||||
echo ' 0
|
||||
};'
|
||||
|
||||
+5
-6
@@ -40,10 +40,9 @@ extern History *hist;
|
||||
extern EditLine *el;
|
||||
extern int displayhist;
|
||||
|
||||
void histedit(void);
|
||||
void sethistsize(const char *);
|
||||
int histcmd(int, char **);
|
||||
int not_fcnumber(char *);
|
||||
int str_to_event(char *, int);
|
||||
int bindcmd(int, char **);
|
||||
void histedit __P((void));
|
||||
void sethistsize __P((const char *));
|
||||
int histcmd __P((int, char **));
|
||||
int not_fcnumber __P((char *));
|
||||
int str_to_event __P((char *, int));
|
||||
|
||||
+18
-10
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)mystring.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* String functions.
|
||||
@@ -77,8 +77,11 @@ char nullstr[1]; /* zero length string */
|
||||
*/
|
||||
|
||||
void
|
||||
scopyn(const char *from, char *to, int size)
|
||||
{
|
||||
scopyn(from, to, size)
|
||||
char const *from;
|
||||
char *to;
|
||||
int size;
|
||||
{
|
||||
|
||||
while (--size > 0) {
|
||||
if ((*to++ = *from++) == '\0')
|
||||
@@ -93,8 +96,10 @@ scopyn(const char *from, char *to, int size)
|
||||
*/
|
||||
|
||||
int
|
||||
prefix(const char *pfx, const char *string)
|
||||
{
|
||||
prefix(pfx, string)
|
||||
char const *pfx;
|
||||
char const *string;
|
||||
{
|
||||
while (*pfx) {
|
||||
if (*pfx++ != *string++)
|
||||
return 0;
|
||||
@@ -109,8 +114,10 @@ prefix(const char *pfx, const char *string)
|
||||
*/
|
||||
|
||||
int
|
||||
number(const char *s)
|
||||
{
|
||||
number(s)
|
||||
const char *s;
|
||||
{
|
||||
|
||||
if (! is_number(s))
|
||||
error("Illegal number: %s", (char *)s);
|
||||
return atoi(s);
|
||||
@@ -123,8 +130,9 @@ number(const char *s)
|
||||
*/
|
||||
|
||||
int
|
||||
is_number(const char *p)
|
||||
{
|
||||
is_number(p)
|
||||
const char *p;
|
||||
{
|
||||
do {
|
||||
if (! is_digit(*p))
|
||||
return 0;
|
||||
|
||||
+4
-4
@@ -39,10 +39,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void scopyn(const char *, char *, int);
|
||||
int prefix(const char *, const char *);
|
||||
int number(const char *);
|
||||
int is_number(const char *);
|
||||
void scopyn __P((const char *, char *, int));
|
||||
int prefix __P((const char *, const char *));
|
||||
int number __P((const char *));
|
||||
int is_number __P((const char *));
|
||||
|
||||
#define equal(s1, s2) (strcmp(s1, s2) == 0)
|
||||
#define scopy(s1, s2) ((void)strcpy(s2, s1))
|
||||
+19
-12
@@ -57,11 +57,11 @@ char *funcstring; /* block to allocate strings from */
|
||||
%SIZES
|
||||
|
||||
|
||||
STATIC void calcsize(union node *);
|
||||
STATIC void sizenodelist(struct nodelist *);
|
||||
STATIC union node *copynode(union node *);
|
||||
STATIC struct nodelist *copynodelist(struct nodelist *);
|
||||
STATIC char *nodesavestr(char *);
|
||||
STATIC void calcsize __P((union node *));
|
||||
STATIC void sizenodelist __P((struct nodelist *));
|
||||
STATIC union node *copynode __P((union node *));
|
||||
STATIC struct nodelist *copynodelist __P((struct nodelist *));
|
||||
STATIC char *nodesavestr __P((char *));
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ STATIC char *nodesavestr(char *);
|
||||
*/
|
||||
|
||||
union node *
|
||||
copyfunc(union node *n)
|
||||
copyfunc(n)
|
||||
union node *n;
|
||||
{
|
||||
if (n == NULL)
|
||||
return NULL;
|
||||
@@ -85,7 +86,8 @@ copyfunc(union node *n)
|
||||
|
||||
|
||||
STATIC void
|
||||
calcsize(union node *n)
|
||||
calcsize(n)
|
||||
union node *n;
|
||||
{
|
||||
%CALCSIZE
|
||||
}
|
||||
@@ -93,7 +95,8 @@ calcsize(union node *n)
|
||||
|
||||
|
||||
STATIC void
|
||||
sizenodelist(struct nodelist *lp)
|
||||
sizenodelist(lp)
|
||||
struct nodelist *lp;
|
||||
{
|
||||
while (lp) {
|
||||
funcblocksize += ALIGN(sizeof(struct nodelist));
|
||||
@@ -105,7 +108,8 @@ sizenodelist(struct nodelist *lp)
|
||||
|
||||
|
||||
STATIC union node *
|
||||
copynode(union node *n)
|
||||
copynode(n)
|
||||
union node *n;
|
||||
{
|
||||
union node *new;
|
||||
|
||||
@@ -115,7 +119,8 @@ copynode(union node *n)
|
||||
|
||||
|
||||
STATIC struct nodelist *
|
||||
copynodelist(struct nodelist *lp)
|
||||
copynodelist(lp)
|
||||
struct nodelist *lp;
|
||||
{
|
||||
struct nodelist *start;
|
||||
struct nodelist **lpp;
|
||||
@@ -135,7 +140,8 @@ copynodelist(struct nodelist *lp)
|
||||
|
||||
|
||||
STATIC char *
|
||||
nodesavestr(char *s)
|
||||
nodesavestr(s)
|
||||
char *s;
|
||||
{
|
||||
char *p = s;
|
||||
char *q = funcstring;
|
||||
@@ -154,7 +160,8 @@ nodesavestr(char *s)
|
||||
*/
|
||||
|
||||
void
|
||||
freefunc(union node *n)
|
||||
freefunc(n)
|
||||
union node *n;
|
||||
{
|
||||
if (n)
|
||||
ckfree(n);
|
||||
|
||||
@@ -120,7 +120,6 @@ NTO nfile # fd> fname
|
||||
NFROM nfile # fd< fname
|
||||
NFROMTO nfile # fd<> fname
|
||||
NAPPEND nfile # fd>> fname
|
||||
NCLOBBER nfile # fd>| fname
|
||||
type int
|
||||
next nodeptr # next redirection in list
|
||||
fd int # file descriptor being redirected
|
||||
|
||||
+51
-45
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
@@ -73,10 +73,10 @@ char *optptr; /* used by nextopt */
|
||||
char *minusc; /* argument to -c option */
|
||||
|
||||
|
||||
STATIC void options(int);
|
||||
STATIC void minus_o(char *, int);
|
||||
STATIC void setoption(int, int);
|
||||
STATIC int getopts(char *, char *, char **, char ***, char **);
|
||||
STATIC void options __P((int));
|
||||
STATIC void minus_o __P((char *, int));
|
||||
STATIC void setoption __P((int, int));
|
||||
STATIC int getopts __P((char *, char *, char **, char ***, char **));
|
||||
|
||||
|
||||
/*
|
||||
@@ -84,7 +84,9 @@ STATIC int getopts(char *, char *, char **, char ***, char **);
|
||||
*/
|
||||
|
||||
void
|
||||
procargs(int argc, char **argv)
|
||||
procargs(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -125,7 +127,7 @@ procargs(int argc, char **argv)
|
||||
|
||||
|
||||
void
|
||||
optschanged(void)
|
||||
optschanged()
|
||||
{
|
||||
setinteractive(iflag);
|
||||
#ifndef NO_HISTORY
|
||||
@@ -140,7 +142,8 @@ optschanged(void)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
options(int cmdline)
|
||||
options(cmdline)
|
||||
int cmdline;
|
||||
{
|
||||
char *p;
|
||||
int val;
|
||||
@@ -198,30 +201,17 @@ options(int cmdline)
|
||||
}
|
||||
|
||||
STATIC void
|
||||
minus_o(char *name, int val)
|
||||
minus_o(name, val)
|
||||
char *name;
|
||||
int val;
|
||||
{
|
||||
int doneset, i;
|
||||
int i;
|
||||
|
||||
if (name == NULL) {
|
||||
if (val) {
|
||||
/* "Pretty" output. */
|
||||
out1str("Current option settings\n");
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
out1fmt("%-16s%s\n", optlist[i].name,
|
||||
optlist[i].val ? "on" : "off");
|
||||
} else {
|
||||
/* Output suitable for re-input to shell. */
|
||||
for (doneset = i = 0; i < NOPTS; i++)
|
||||
if (optlist[i].val) {
|
||||
if (!doneset) {
|
||||
out1str("set");
|
||||
doneset = 1;
|
||||
}
|
||||
out1fmt(" -o %s", optlist[i].name);
|
||||
}
|
||||
if (doneset)
|
||||
out1c('\n');
|
||||
}
|
||||
out1str("Current option settings\n");
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
out1fmt("%-16s%s\n", optlist[i].name,
|
||||
optlist[i].val ? "on" : "off");
|
||||
} else {
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
if (equal(name, optlist[i].name)) {
|
||||
@@ -238,8 +228,10 @@ minus_o(char *name, int val)
|
||||
|
||||
|
||||
STATIC void
|
||||
setoption(int flag, int val)
|
||||
{
|
||||
setoption(flag, val)
|
||||
char flag;
|
||||
int val;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NOPTS; i++)
|
||||
@@ -278,8 +270,9 @@ SHELLPROC {
|
||||
*/
|
||||
|
||||
void
|
||||
setparam(char **argv)
|
||||
{
|
||||
setparam(argv)
|
||||
char **argv;
|
||||
{
|
||||
char **newparam;
|
||||
char **ap;
|
||||
int nparam;
|
||||
@@ -303,8 +296,9 @@ setparam(char **argv)
|
||||
*/
|
||||
|
||||
void
|
||||
freeparam(struct shparam *param)
|
||||
{
|
||||
freeparam(param)
|
||||
struct shparam *param;
|
||||
{
|
||||
char **ap;
|
||||
|
||||
if (param->malloc) {
|
||||
@@ -321,7 +315,9 @@ freeparam(struct shparam *param)
|
||||
*/
|
||||
|
||||
int
|
||||
shiftcmd(int argc, char **argv)
|
||||
shiftcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int n;
|
||||
char **ap1, **ap2;
|
||||
@@ -351,7 +347,9 @@ shiftcmd(int argc, char **argv)
|
||||
*/
|
||||
|
||||
int
|
||||
setcmd(int argc, char **argv)
|
||||
setcmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
if (argc == 1)
|
||||
return showvarscmd(argc, argv);
|
||||
@@ -367,7 +365,8 @@ setcmd(int argc, char **argv)
|
||||
|
||||
|
||||
void
|
||||
getoptsreset(const char *value)
|
||||
getoptsreset(value)
|
||||
const char *value;
|
||||
{
|
||||
if (number(value) == 1) {
|
||||
shellparam.optnext = NULL;
|
||||
@@ -383,12 +382,14 @@ getoptsreset(const char *value)
|
||||
*/
|
||||
|
||||
int
|
||||
getoptscmd(int argc, char **argv)
|
||||
getoptscmd(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char **optbase = NULL;
|
||||
|
||||
if (argc < 3)
|
||||
error("usage: getopts optstring var [arg]");
|
||||
error("Usage: getopts optstring var [arg]");
|
||||
else if (argc == 3)
|
||||
optbase = shellparam.p;
|
||||
else
|
||||
@@ -405,8 +406,12 @@ getoptscmd(int argc, char **argv)
|
||||
}
|
||||
|
||||
STATIC int
|
||||
getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
|
||||
char **optptr)
|
||||
getopts(optstr, optvar, optfirst, optnext, optptr)
|
||||
char *optstr;
|
||||
char *optvar;
|
||||
char **optfirst;
|
||||
char ***optnext;
|
||||
char **optptr;
|
||||
{
|
||||
char *p, *q;
|
||||
char c = '?';
|
||||
@@ -510,8 +515,9 @@ out:
|
||||
*/
|
||||
|
||||
int
|
||||
nextopt(char *optstring)
|
||||
{
|
||||
nextopt(optstring)
|
||||
char *optstring;
|
||||
{
|
||||
char *p, *q;
|
||||
char c;
|
||||
|
||||
|
||||
+10
-12
@@ -65,9 +65,8 @@ struct shparam {
|
||||
#define uflag optlist[14].val
|
||||
#define privileged optlist[15].val
|
||||
#define Tflag optlist[16].val
|
||||
#define Pflag optlist[17].val
|
||||
|
||||
#define NOPTS 18
|
||||
#define NOPTS 17
|
||||
|
||||
struct optent {
|
||||
const char *name;
|
||||
@@ -94,7 +93,6 @@ struct optent optlist[NOPTS] = {
|
||||
{ "nounset", 'u', 0 },
|
||||
{ "privileged", 'p', 0 },
|
||||
{ "trapsasync", 'T', 0 },
|
||||
{ "physical", 'P', 0 },
|
||||
};
|
||||
#else
|
||||
extern struct optent optlist[NOPTS];
|
||||
@@ -108,12 +106,12 @@ extern char **argptr; /* argument list for builtin commands */
|
||||
extern char *shoptarg; /* set by nextopt */
|
||||
extern char *optptr; /* used by nextopt */
|
||||
|
||||
void procargs(int, char **);
|
||||
void optschanged(void);
|
||||
void setparam(char **);
|
||||
void freeparam(struct shparam *);
|
||||
int shiftcmd(int, char **);
|
||||
int setcmd(int, char **);
|
||||
int getoptscmd(int, char **);
|
||||
int nextopt(char *);
|
||||
void getoptsreset(const char *);
|
||||
void procargs __P((int, char **));
|
||||
void optschanged __P((void));
|
||||
void setparam __P((char **));
|
||||
void freeparam __P((struct shparam *));
|
||||
int shiftcmd __P((int, char **));
|
||||
int setcmd __P((int, char **));
|
||||
int getoptscmd __P((int, char **));
|
||||
int nextopt __P((char *));
|
||||
void getoptsreset __P((const char *));
|
||||
+148
-67
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)output.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Shell output routines. We use our own output routines because:
|
||||
@@ -58,7 +58,11 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h> /* defines BUFSIZ */
|
||||
#include <string.h>
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@@ -68,7 +72,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include "output.h"
|
||||
#include "memalloc.h"
|
||||
#include "error.h"
|
||||
#include "var.h"
|
||||
|
||||
|
||||
#define OUTBUFSIZ BUFSIZ
|
||||
@@ -102,73 +105,60 @@ RESET {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef notdef /* no longer used */
|
||||
/*
|
||||
* Set up an output file to write to memory rather than a file.
|
||||
*/
|
||||
|
||||
void
|
||||
out1str(const char *p)
|
||||
{
|
||||
open_mem(block, length, file)
|
||||
char *block;
|
||||
int length;
|
||||
struct output *file;
|
||||
{
|
||||
file->nextc = block;
|
||||
file->nleft = --length;
|
||||
file->fd = BLOCK_OUT;
|
||||
file->flags = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
out1str(p)
|
||||
const char *p;
|
||||
{
|
||||
outstr(p, out1);
|
||||
}
|
||||
|
||||
void
|
||||
out1qstr(const char *p)
|
||||
{
|
||||
outqstr(p, out1);
|
||||
}
|
||||
|
||||
void
|
||||
out2str(const char *p)
|
||||
{
|
||||
out2str(p)
|
||||
const char *p;
|
||||
{
|
||||
outstr(p, out2);
|
||||
}
|
||||
|
||||
void
|
||||
out2qstr(const char *p)
|
||||
{
|
||||
outqstr(p, out2);
|
||||
}
|
||||
|
||||
void
|
||||
outstr(const char *p, struct output *file)
|
||||
{
|
||||
outstr(p, file)
|
||||
const char *p;
|
||||
struct output *file;
|
||||
{
|
||||
while (*p)
|
||||
outc(*p++, file);
|
||||
if (file == out2)
|
||||
flushout(file);
|
||||
}
|
||||
|
||||
/* Like outstr(), but quote for re-input into the shell. */
|
||||
void
|
||||
outqstr(const char *p, struct output *file)
|
||||
{
|
||||
char ch;
|
||||
|
||||
if (p[strcspn(p, "|&;<>()$`\\\"'")] == '\0' && (!ifsset() ||
|
||||
p[strcspn(p, ifsval())] == '\0')) {
|
||||
outstr(p, file);
|
||||
return;
|
||||
}
|
||||
|
||||
out1c('\'');
|
||||
while ((ch = *p++) != '\0') {
|
||||
switch (ch) {
|
||||
case '\'':
|
||||
/*
|
||||
* Can't quote single quotes inside single quotes;
|
||||
* close them, write escaped single quote, open again.
|
||||
*/
|
||||
outstr("'\\''", file);
|
||||
break;
|
||||
default:
|
||||
outc(ch, file);
|
||||
}
|
||||
}
|
||||
out1c('\'');
|
||||
}
|
||||
|
||||
char out_junk[16];
|
||||
|
||||
|
||||
void
|
||||
emptyoutbuf(struct output *dest)
|
||||
{
|
||||
emptyoutbuf(dest)
|
||||
struct output *dest;
|
||||
{
|
||||
int offset;
|
||||
|
||||
if (dest->fd == BLOCK_OUT) {
|
||||
@@ -197,16 +187,16 @@ emptyoutbuf(struct output *dest)
|
||||
|
||||
|
||||
void
|
||||
flushall(void)
|
||||
{
|
||||
flushall() {
|
||||
flushout(&output);
|
||||
flushout(&errout);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
flushout(struct output *dest)
|
||||
{
|
||||
flushout(dest)
|
||||
struct output *dest;
|
||||
{
|
||||
|
||||
if (dest->buf == NULL || dest->nextc == dest->buf || dest->fd < 0)
|
||||
return;
|
||||
@@ -218,8 +208,7 @@ flushout(struct output *dest)
|
||||
|
||||
|
||||
void
|
||||
freestdout(void)
|
||||
{
|
||||
freestdout() {
|
||||
INTOFF;
|
||||
if (output.buf) {
|
||||
ckfree(output.buf);
|
||||
@@ -230,9 +219,9 @@ freestdout(void)
|
||||
}
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
void
|
||||
outfmt(struct output *file, const char *fmt, ...)
|
||||
{
|
||||
outfmt(struct output *file, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@@ -242,8 +231,7 @@ outfmt(struct output *file, const char *fmt, ...)
|
||||
|
||||
|
||||
void
|
||||
out1fmt(const char *fmt, ...)
|
||||
{
|
||||
out1fmt(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@@ -252,8 +240,7 @@ out1fmt(const char *fmt, ...)
|
||||
}
|
||||
|
||||
void
|
||||
dprintf(const char *fmt, ...)
|
||||
{
|
||||
dprintf(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@@ -263,8 +250,7 @@ dprintf(const char *fmt, ...)
|
||||
}
|
||||
|
||||
void
|
||||
fmtstr(char *outbuf, int length, const char *fmt, ...)
|
||||
{
|
||||
fmtstr(char *outbuf, int length, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
struct output strout;
|
||||
|
||||
@@ -279,6 +265,77 @@ fmtstr(char *outbuf, int length, const char *fmt, ...)
|
||||
outbuf[length - 1] = '\0';
|
||||
}
|
||||
|
||||
#else /* not __STDC__ */
|
||||
|
||||
void
|
||||
outfmt(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
va_list ap;
|
||||
struct output *file;
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
file = va_arg(ap, struct output *);
|
||||
fmt = va_arg(ap, char *);
|
||||
doformat(file, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
out1fmt(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
va_list ap;
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, char *);
|
||||
doformat(out1, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
dprintf(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
va_list ap;
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, char *);
|
||||
doformat(out2, fmt, ap);
|
||||
va_end(ap);
|
||||
flushout(out2);
|
||||
}
|
||||
|
||||
void
|
||||
fmtstr(va_alist)
|
||||
va_dcl
|
||||
{
|
||||
va_list ap;
|
||||
struct output strout;
|
||||
char *outbuf;
|
||||
int length;
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
outbuf = va_arg(ap, char *);
|
||||
length = va_arg(ap, int);
|
||||
fmt = va_arg(ap, char *);
|
||||
strout.nextc = outbuf;
|
||||
strout.nleft = length;
|
||||
strout.fd = BLOCK_OUT;
|
||||
strout.flags = 0;
|
||||
doformat(&strout, fmt, ap);
|
||||
outc('\0', &strout);
|
||||
if (strout.flags & OUTPUT_ERR)
|
||||
outbuf[length - 1] = '\0';
|
||||
}
|
||||
#endif /* __STDC__ */
|
||||
|
||||
|
||||
/*
|
||||
* Formatted output. This routine handles a subset of the printf formats:
|
||||
* - Formats supported: d, u, o, X, s, and c.
|
||||
@@ -298,8 +355,11 @@ static const char digit[] = "0123456789ABCDEF";
|
||||
|
||||
|
||||
void
|
||||
doformat(struct output *dest, const char *f, va_list ap)
|
||||
{
|
||||
doformat(dest, f, ap)
|
||||
struct output *dest;
|
||||
const char *f; /* format string */
|
||||
va_list ap;
|
||||
{
|
||||
char c;
|
||||
char temp[TEMPSIZE];
|
||||
int flushleft;
|
||||
@@ -469,8 +529,11 @@ number: /* process a number */
|
||||
*/
|
||||
|
||||
int
|
||||
xwrite(int fd, char *buf, int nbytes)
|
||||
{
|
||||
xwrite(fd, buf, nbytes)
|
||||
int fd;
|
||||
char *buf;
|
||||
int nbytes;
|
||||
{
|
||||
int ntry;
|
||||
int i;
|
||||
int n;
|
||||
@@ -492,3 +555,21 @@ xwrite(int fd, char *buf, int nbytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Version of ioctl that retries after a signal is caught.
|
||||
* XXX unused function
|
||||
*/
|
||||
|
||||
int
|
||||
xioctl(fd, request, arg)
|
||||
int fd;
|
||||
unsigned long request;
|
||||
char * arg;
|
||||
{
|
||||
int i;
|
||||
|
||||
while ((i = ioctl(fd, request, arg)) == -1 && errno == EINTR);
|
||||
return i;
|
||||
}
|
||||
+19
-17
@@ -39,7 +39,11 @@
|
||||
|
||||
#ifndef OUTPUT_INCL
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
struct output {
|
||||
char *nextc;
|
||||
@@ -56,23 +60,21 @@ extern struct output memout;
|
||||
extern struct output *out1;
|
||||
extern struct output *out2;
|
||||
|
||||
void open_mem(char *, int, struct output *);
|
||||
void out1str(const char *);
|
||||
void out1qstr(const char *);
|
||||
void out2str(const char *);
|
||||
void out2qstr(const char *);
|
||||
void outstr(const char *, struct output *);
|
||||
void outqstr(const char *, struct output *);
|
||||
void emptyoutbuf(struct output *);
|
||||
void flushall(void);
|
||||
void flushout(struct output *);
|
||||
void freestdout(void);
|
||||
void outfmt(struct output *, const char *, ...) __printflike(2, 3);
|
||||
void out1fmt(const char *, ...) __printflike(1, 2);
|
||||
void dprintf(const char *, ...) __printflike(1, 2);
|
||||
void fmtstr(char *, int, const char *, ...) __printflike(3, 4);
|
||||
void doformat(struct output *, const char *, va_list) __printflike(2, 0);
|
||||
int xwrite(int, char *, int);
|
||||
void open_mem __P((char *, int, struct output *));
|
||||
void out1str __P((const char *));
|
||||
void out2str __P((const char *));
|
||||
void outstr __P((const char *, struct output *));
|
||||
void emptyoutbuf __P((struct output *));
|
||||
void flushall __P((void));
|
||||
void flushout __P((struct output *));
|
||||
void freestdout __P((void));
|
||||
void outfmt __P((struct output *, const char *, ...)) __printflike(2, 3);
|
||||
void out1fmt __P((const char *, ...)) __printflike(1, 2);
|
||||
void dprintf __P((const char *, ...)) __printflike(1, 2);
|
||||
void fmtstr __P((char *, int, const char *, ...)) __printflike(3, 4);
|
||||
void doformat __P((struct output *, const char *, va_list)) __printflike(2, 0);
|
||||
int xwrite __P((int, char *, int));
|
||||
int xioctl __P((int, unsigned long, char *));
|
||||
|
||||
#define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c)))
|
||||
#define out1c(c) outc(c, out1);
|
||||
|
||||
+65
-60
@@ -38,9 +38,9 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -108,22 +108,22 @@ static const char types[] = "}-+?=";
|
||||
#endif
|
||||
|
||||
|
||||
STATIC union node *list(int);
|
||||
STATIC union node *andor(void);
|
||||
STATIC union node *pipeline(void);
|
||||
STATIC union node *command(void);
|
||||
STATIC union node *simplecmd(union node **, union node *);
|
||||
STATIC union node *makename(void);
|
||||
STATIC void parsefname(void);
|
||||
STATIC void parseheredoc(void);
|
||||
STATIC int peektoken(void);
|
||||
STATIC int readtoken(void);
|
||||
STATIC int xxreadtoken(void);
|
||||
STATIC int readtoken1(int, char const *, char *, int);
|
||||
STATIC int noexpand(char *);
|
||||
STATIC void synexpect(int);
|
||||
STATIC void synerror(char *);
|
||||
STATIC void setprompt(int);
|
||||
STATIC union node *list __P((int));
|
||||
STATIC union node *andor __P((void));
|
||||
STATIC union node *pipeline __P((void));
|
||||
STATIC union node *command __P((void));
|
||||
STATIC union node *simplecmd __P((union node **, union node *));
|
||||
STATIC union node *makename __P((void));
|
||||
STATIC void parsefname __P((void));
|
||||
STATIC void parseheredoc __P((void));
|
||||
STATIC int peektoken __P((void));
|
||||
STATIC int readtoken __P((void));
|
||||
STATIC int xxreadtoken __P((void));
|
||||
STATIC int readtoken1 __P((int, char const *, char *, int));
|
||||
STATIC int noexpand __P((char *));
|
||||
STATIC void synexpect __P((int));
|
||||
STATIC void synerror __P((char *));
|
||||
STATIC void setprompt __P((int));
|
||||
|
||||
|
||||
/*
|
||||
@@ -132,7 +132,8 @@ STATIC void setprompt(int);
|
||||
*/
|
||||
|
||||
union node *
|
||||
parsecmd(int interact)
|
||||
parsecmd(interact)
|
||||
int interact;
|
||||
{
|
||||
int t;
|
||||
|
||||
@@ -154,7 +155,8 @@ parsecmd(int interact)
|
||||
|
||||
|
||||
STATIC union node *
|
||||
list(int nlflag)
|
||||
list(nlflag)
|
||||
int nlflag;
|
||||
{
|
||||
union node *n1, *n2, *n3;
|
||||
int tok;
|
||||
@@ -224,8 +226,7 @@ list(int nlflag)
|
||||
|
||||
|
||||
STATIC union node *
|
||||
andor(void)
|
||||
{
|
||||
andor() {
|
||||
union node *n1, *n2, *n3;
|
||||
int t;
|
||||
|
||||
@@ -251,8 +252,7 @@ andor(void)
|
||||
|
||||
|
||||
STATIC union node *
|
||||
pipeline(void)
|
||||
{
|
||||
pipeline() {
|
||||
union node *n1, *n2, *pipenode;
|
||||
struct nodelist *lp, *prev;
|
||||
int negate;
|
||||
@@ -292,8 +292,7 @@ pipeline(void)
|
||||
|
||||
|
||||
STATIC union node *
|
||||
command(void)
|
||||
{
|
||||
command() {
|
||||
union node *n1, *n2;
|
||||
union node *ap, **app;
|
||||
union node *cp, **cpp;
|
||||
@@ -478,14 +477,14 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
|
||||
break;
|
||||
/* Handle an empty command like other simple commands. */
|
||||
case TSEMI:
|
||||
case TAND:
|
||||
case TOR:
|
||||
/*
|
||||
* An empty command before a ; doesn't make much sense, and
|
||||
* should certainly be disallowed in the case of `if ;'.
|
||||
*/
|
||||
if (!redir)
|
||||
synexpect(-1);
|
||||
case TAND:
|
||||
case TOR:
|
||||
case TNL:
|
||||
case TEOF:
|
||||
case TWORD:
|
||||
@@ -528,8 +527,9 @@ checkneg:
|
||||
|
||||
|
||||
STATIC union node *
|
||||
simplecmd(union node **rpp, union node *redir)
|
||||
{
|
||||
simplecmd(rpp, redir)
|
||||
union node **rpp, *redir;
|
||||
{
|
||||
union node *args, **app;
|
||||
union node **orig_rpp = rpp;
|
||||
union node *n = NULL, *n2;
|
||||
@@ -604,8 +604,7 @@ checkneg:
|
||||
}
|
||||
|
||||
STATIC union node *
|
||||
makename(void)
|
||||
{
|
||||
makename() {
|
||||
union node *n;
|
||||
|
||||
n = (union node *)stalloc(sizeof (struct narg));
|
||||
@@ -616,8 +615,11 @@ makename(void)
|
||||
return n;
|
||||
}
|
||||
|
||||
void fixredir(union node *n, const char *text, int err)
|
||||
{
|
||||
void fixredir(n, text, err)
|
||||
union node *n;
|
||||
const char *text;
|
||||
int err;
|
||||
{
|
||||
TRACE(("Fix redir %s %d\n", text, err));
|
||||
if (!err)
|
||||
n->ndup.vname = NULL;
|
||||
@@ -637,8 +639,7 @@ void fixredir(union node *n, const char *text, int err)
|
||||
|
||||
|
||||
STATIC void
|
||||
parsefname(void)
|
||||
{
|
||||
parsefname() {
|
||||
union node *n = redirnode;
|
||||
|
||||
if (readtoken() != TWORD)
|
||||
@@ -679,8 +680,7 @@ parsefname(void)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
parseheredoc(void)
|
||||
{
|
||||
parseheredoc() {
|
||||
struct heredoc *here;
|
||||
union node *n;
|
||||
|
||||
@@ -703,8 +703,7 @@ parseheredoc(void)
|
||||
}
|
||||
|
||||
STATIC int
|
||||
peektoken(void)
|
||||
{
|
||||
peektoken() {
|
||||
int t;
|
||||
|
||||
t = readtoken();
|
||||
@@ -713,8 +712,7 @@ peektoken(void)
|
||||
}
|
||||
|
||||
STATIC int
|
||||
readtoken(void)
|
||||
{
|
||||
readtoken() {
|
||||
int t;
|
||||
int savecheckkwd = checkkwd;
|
||||
struct alias *ap;
|
||||
@@ -742,9 +740,9 @@ readtoken(void)
|
||||
*/
|
||||
if (t == TWORD && !quoteflag)
|
||||
{
|
||||
const char * const *pp;
|
||||
char * const *pp;
|
||||
|
||||
for (pp = parsekwd; *pp; pp++) {
|
||||
for (pp = (char **)parsekwd; *pp; pp++) {
|
||||
if (**pp == *wordtext && equal(*pp, wordtext))
|
||||
{
|
||||
lasttoken = t = pp - parsekwd + KWDOFFSET;
|
||||
@@ -793,8 +791,7 @@ out:
|
||||
#define RETURN(token) return lasttoken = token
|
||||
|
||||
STATIC int
|
||||
xxreadtoken(void)
|
||||
{
|
||||
xxreadtoken() {
|
||||
int c;
|
||||
|
||||
if (tokpushback) {
|
||||
@@ -884,8 +881,12 @@ breakloop:
|
||||
#define PARSEARITH() {goto parsearith; parsearith_return:;}
|
||||
|
||||
STATIC int
|
||||
readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
|
||||
{
|
||||
readtoken1(firstc, syntax, eofmark, striptabs)
|
||||
int firstc;
|
||||
char const *syntax;
|
||||
char *eofmark;
|
||||
int striptabs;
|
||||
{
|
||||
int c = firstc;
|
||||
char *out;
|
||||
int len;
|
||||
@@ -1145,8 +1146,6 @@ parseredir: {
|
||||
np->type = NAPPEND;
|
||||
else if (c == '&')
|
||||
np->type = NTOFD;
|
||||
else if (c == '|')
|
||||
np->type = NCLOBBER;
|
||||
else {
|
||||
np->type = NTO;
|
||||
pungetc();
|
||||
@@ -1485,8 +1484,9 @@ RESET {
|
||||
*/
|
||||
|
||||
STATIC int
|
||||
noexpand(char *text)
|
||||
{
|
||||
noexpand(text)
|
||||
char *text;
|
||||
{
|
||||
char *p;
|
||||
char c;
|
||||
|
||||
@@ -1509,8 +1509,9 @@ noexpand(char *text)
|
||||
*/
|
||||
|
||||
int
|
||||
goodname(char *name)
|
||||
{
|
||||
goodname(name)
|
||||
char *name;
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = name;
|
||||
@@ -1531,7 +1532,8 @@ goodname(char *name)
|
||||
*/
|
||||
|
||||
STATIC void
|
||||
synexpect(int token)
|
||||
synexpect(token)
|
||||
int token;
|
||||
{
|
||||
char msg[64];
|
||||
|
||||
@@ -1546,8 +1548,9 @@ synexpect(int token)
|
||||
|
||||
|
||||
STATIC void
|
||||
synerror(char *msg)
|
||||
{
|
||||
synerror(msg)
|
||||
char *msg;
|
||||
{
|
||||
if (commandname)
|
||||
outfmt(&errout, "%s: %d: ", commandname, startlinno);
|
||||
outfmt(&errout, "Syntax error: %s\n", msg);
|
||||
@@ -1555,8 +1558,9 @@ synerror(char *msg)
|
||||
}
|
||||
|
||||
STATIC void
|
||||
setprompt(int which)
|
||||
{
|
||||
setprompt(which)
|
||||
int which;
|
||||
{
|
||||
whichprompt = which;
|
||||
|
||||
#ifndef NO_HISTORY
|
||||
@@ -1570,7 +1574,8 @@ setprompt(int which)
|
||||
* should be added here.
|
||||
*/
|
||||
char *
|
||||
getprompt(void *unused __unused)
|
||||
getprompt(unused)
|
||||
void *unused __unused;
|
||||
{
|
||||
switch (whichprompt) {
|
||||
case 0:
|
||||
|
||||
+4
-4
@@ -76,7 +76,7 @@ extern int tokpushback;
|
||||
extern int whichprompt; /* 1 == PS1, 2 == PS2 */
|
||||
|
||||
|
||||
union node *parsecmd(int);
|
||||
void fixredir(union node *, const char *, int);
|
||||
int goodname(char *);
|
||||
char *getprompt(void *);
|
||||
union node *parsecmd __P((int));
|
||||
void fixredir __P((union node *, const char *, int));
|
||||
int goodname __P((char *));
|
||||
char *getprompt __P((void *));
|
||||
+23
-31
@@ -38,12 +38,11 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)redir.c 8.2 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
@@ -63,7 +62,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include "output.h"
|
||||
#include "memalloc.h"
|
||||
#include "error.h"
|
||||
#include "options.h"
|
||||
|
||||
|
||||
#define EMPTY -2 /* marks an unused slot in redirtab */
|
||||
@@ -73,7 +71,7 @@ __FBSDID("$FreeBSD$");
|
||||
MKINIT
|
||||
struct redirtab {
|
||||
struct redirtab *next;
|
||||
int renamed[10];
|
||||
short renamed[10];
|
||||
};
|
||||
|
||||
|
||||
@@ -86,8 +84,8 @@ MKINIT struct redirtab *redirlist;
|
||||
*/
|
||||
int fd0_redirected = 0;
|
||||
|
||||
STATIC void openredirect(union node *, char[10 ]);
|
||||
STATIC int openhere(union node *);
|
||||
STATIC void openredirect __P((union node *, char[10 ]));
|
||||
STATIC int openhere __P((union node *));
|
||||
|
||||
|
||||
/*
|
||||
@@ -99,8 +97,10 @@ STATIC int openhere(union node *);
|
||||
*/
|
||||
|
||||
void
|
||||
redirect(union node *redir, int flags)
|
||||
{
|
||||
redirect(redir, flags)
|
||||
union node *redir;
|
||||
int flags;
|
||||
{
|
||||
union node *n;
|
||||
struct redirtab *sv = NULL;
|
||||
int i;
|
||||
@@ -161,9 +161,10 @@ again:
|
||||
|
||||
|
||||
STATIC void
|
||||
openredirect(union node *redir, char memory[10])
|
||||
{
|
||||
struct stat sb;
|
||||
openredirect(redir, memory)
|
||||
union node *redir;
|
||||
char memory[10];
|
||||
{
|
||||
int fd = redir->nfile.fd;
|
||||
char *fname;
|
||||
int f;
|
||||
@@ -210,9 +211,6 @@ movefd:
|
||||
goto movefd;
|
||||
case NTO:
|
||||
fname = redir->nfile.expfname;
|
||||
if (Cflag && stat(fname, &sb) != -1 && S_ISREG(sb.st_mode))
|
||||
error("cannot create %s: %s", fname,
|
||||
errmsg(EEXIST, E_CREAT));
|
||||
#ifdef O_CREAT
|
||||
if ((f = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
|
||||
@@ -221,11 +219,6 @@ movefd:
|
||||
error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
|
||||
#endif
|
||||
goto movefd;
|
||||
case NCLOBBER:
|
||||
fname = redir->nfile.expfname;
|
||||
if ((f = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
|
||||
error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
|
||||
goto movefd;
|
||||
case NAPPEND:
|
||||
fname = redir->nfile.expfname;
|
||||
#ifdef O_APPEND
|
||||
@@ -247,8 +240,7 @@ movefd:
|
||||
close(fd);
|
||||
copyfd(redir->ndup.dupfd, fd);
|
||||
}
|
||||
} else
|
||||
close(fd);
|
||||
}
|
||||
break;
|
||||
case NHERE:
|
||||
case NXHERE:
|
||||
@@ -268,8 +260,9 @@ movefd:
|
||||
*/
|
||||
|
||||
STATIC int
|
||||
openhere(union node *redir)
|
||||
{
|
||||
openhere(redir)
|
||||
union node *redir;
|
||||
{
|
||||
int pip[2];
|
||||
int len = 0;
|
||||
|
||||
@@ -309,8 +302,7 @@ out:
|
||||
*/
|
||||
|
||||
void
|
||||
popredir(void)
|
||||
{
|
||||
popredir() {
|
||||
struct redirtab *rp = redirlist;
|
||||
int i;
|
||||
|
||||
@@ -352,8 +344,7 @@ SHELLPROC {
|
||||
|
||||
/* Return true if fd 0 has already been redirected at least once. */
|
||||
int
|
||||
fd0_redirected_p(void)
|
||||
{
|
||||
fd0_redirected_p () {
|
||||
return fd0_redirected != 0;
|
||||
}
|
||||
|
||||
@@ -362,8 +353,7 @@ fd0_redirected_p(void)
|
||||
*/
|
||||
|
||||
void
|
||||
clearredir(void)
|
||||
{
|
||||
clearredir() {
|
||||
struct redirtab *rp;
|
||||
int i;
|
||||
|
||||
@@ -386,7 +376,9 @@ clearredir(void)
|
||||
*/
|
||||
|
||||
int
|
||||
copyfd(int from, int to)
|
||||
copyfd(from, to)
|
||||
int from;
|
||||
int to;
|
||||
{
|
||||
int newfd;
|
||||
|
||||
|
||||
+5
-5
@@ -42,9 +42,9 @@
|
||||
#define REDIR_BACKQ 02 /* save the command output in memory */
|
||||
|
||||
union node;
|
||||
void redirect(union node *, int);
|
||||
void popredir(void);
|
||||
int fd0_redirected_p(void);
|
||||
void clearredir(void);
|
||||
int copyfd(int, int);
|
||||
void redirect __P((union node *, int));
|
||||
void popredir __P((void));
|
||||
int fd0_redirected_p __P((void));
|
||||
void clearredir __P((void));
|
||||
int copyfd __P((int, int));
|
||||
|
||||
+185
-185
@@ -43,10 +43,10 @@
|
||||
.Nd command interpreter (shell)
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl /+abCEefIimnPpsTuVvx
|
||||
.Op Fl /+abCEefIimnpsTuVvx
|
||||
.Op Fl /+o Ar longname
|
||||
.Op Fl c Ar string
|
||||
.Op Ar arg ...
|
||||
.Op Ar arg ...\&
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
@@ -77,7 +77,7 @@ command.
|
||||
The shell
|
||||
implements a language that has flow control constructs,
|
||||
a macro facility that provides a variety of features in
|
||||
addition to data storage, along with built-in history and line
|
||||
addition to data storage, along with builtin history and line
|
||||
editing capabilities. It incorporates many features to
|
||||
aid interactive use and has the advantage that the interpretative
|
||||
language is common to both interactive and non-interactive
|
||||
@@ -164,9 +164,9 @@ the long name for an option may be specified as an argument to the
|
||||
.Fl /+o
|
||||
option of the
|
||||
.Ic set
|
||||
built-in command
|
||||
builtin command
|
||||
(described later in the section called
|
||||
.Sx Built-in Commands ) .
|
||||
.Sx Builtin Commands ) .
|
||||
Introducing an option with a dash
|
||||
.Pq Li -
|
||||
enables the option,
|
||||
@@ -185,7 +185,7 @@ and
|
||||
.Fl c
|
||||
options do not have long names.
|
||||
They take arguments and are described after the single letter options.
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Fl a Li allexport
|
||||
Flag variables for export when assignments are made to them.
|
||||
.It Fl b Li notify
|
||||
@@ -195,8 +195,9 @@ completion.
|
||||
.It Fl C Li noclobber
|
||||
Do not overwrite existing files with
|
||||
.Dq Li > .
|
||||
(UNIMPLEMENTED)
|
||||
.It Fl E Li emacs
|
||||
Enable the built-in
|
||||
Enable the builtin
|
||||
.Xr emacs 1
|
||||
command line editor (disables the
|
||||
.Fl V
|
||||
@@ -225,17 +226,6 @@ Turn on job control (set automatically when interactive).
|
||||
If not interactive, read commands but do not
|
||||
execute them. This is useful for checking the
|
||||
syntax of shell scripts.
|
||||
.It Fl P Li physical
|
||||
Change the default for the
|
||||
.Ic cd
|
||||
and
|
||||
.Ic pwd
|
||||
commands from
|
||||
.Fl L
|
||||
(logical directory layout)
|
||||
to
|
||||
.Fl P
|
||||
(physical directory layout).
|
||||
.It Fl p Li privileged
|
||||
Turn on privileged mode. This mode is enabled on startup
|
||||
if either the effective user or group id is not equal to the
|
||||
@@ -275,8 +265,9 @@ sh -T -c "trap 'exit 1' 2 ; some-blocking-program"
|
||||
Write a message to standard error when attempting
|
||||
to expand a variable that is not set, and if the
|
||||
shell is not interactive, exit immediately.
|
||||
(UNIMPLEMENTED)
|
||||
.It Fl V Li vi
|
||||
Enable the built-in
|
||||
Enable the builtin
|
||||
.Xr vi 1
|
||||
command line editor (disables
|
||||
.Fl E
|
||||
@@ -305,21 +296,13 @@ option takes as its only argument the long name of an option
|
||||
to be enabled or disabled.
|
||||
For example, the following two invocations of
|
||||
.Nm
|
||||
both enable the built-in
|
||||
both enable the builtin
|
||||
.Xr emacs 1
|
||||
command line editor:
|
||||
.Bd -literal -offset indent
|
||||
set -E
|
||||
set -o emacs
|
||||
.Ed
|
||||
.Pp
|
||||
If used without an argument, the
|
||||
.Fl o
|
||||
option displays the current option settings in a human-readable format.
|
||||
If
|
||||
.Cm +o
|
||||
is used without an argument, the current option settings are output
|
||||
in a format suitable for re-input into the shell.
|
||||
.Ss Lexical Structure
|
||||
The shell reads input in terms of lines from a file and breaks
|
||||
it up into words at whitespace (blanks and tabs), and at
|
||||
@@ -330,16 +313,38 @@ which are special to the shell.
|
||||
There are two types of operators: control operators and
|
||||
redirection operators (their meaning is discussed later).
|
||||
The following is a list of valid operators:
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Control operators:
|
||||
.Bl -column "XXX" "XXX" "XXX" "XXX" "XXX" -offset center -compact
|
||||
.It Li & Ta Li && Ta Li ( Ta Li ) Ta Li \en
|
||||
.It Li ;; Ta Li ; Ta Li | Ta Li ||
|
||||
.It Xo
|
||||
.Li & Ta Xo
|
||||
.Li && Ta Xo
|
||||
.Li ( Ta Xo
|
||||
.Li ) Ta Xo
|
||||
.Li \en
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Xo
|
||||
.Li ;; Ta Xo
|
||||
.Li ; Ta Xo
|
||||
.Li | Ta Xo
|
||||
.Li ||
|
||||
.Xc Xc Xc Xc
|
||||
.El
|
||||
.It Redirection operators:
|
||||
.Bl -column "XXX" "XXX" "XXX" "XXX" "XXX" -offset center -compact
|
||||
.It Li < Ta Li > Ta Li << Ta Li >> Ta Li <>
|
||||
.It Li <& Ta Li >& Ta Li <<- Ta Li >|
|
||||
.It Xo
|
||||
.Li < Ta Xo
|
||||
.Li > Ta Xo
|
||||
.Li << Ta Xo
|
||||
.Li >> Ta Xo
|
||||
.Li <>
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Xo
|
||||
.Li <& Ta Xo
|
||||
.Li >& Ta Xo
|
||||
.Li <<- Ta Xo
|
||||
.Li >|
|
||||
.Xc Xc Xc Xc
|
||||
.El
|
||||
.El
|
||||
.Ss Quoting
|
||||
@@ -347,7 +352,7 @@ Quoting is used to remove the special meaning of certain characters
|
||||
or words to the shell, such as operators, whitespace, or
|
||||
keywords. There are three types of quoting: matched single quotes,
|
||||
matched double quotes, and backslash.
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Single Quotes
|
||||
Enclosing characters in single quotes preserves the literal
|
||||
meaning of all the characters (except single quotes, making
|
||||
@@ -364,7 +369,13 @@ The backslash inside double quotes is historically weird.
|
||||
It remains literal unless it precedes the following characters,
|
||||
which it serves to quote:
|
||||
.Bl -column "XXX" "XXX" "XXX" "XXX" "XXX" -offset center -compact
|
||||
.It Li $ Ta Li ` Ta Li \&" Ta Li \e\ Ta Li \en
|
||||
.It Xo
|
||||
.Li $ Ta Xo
|
||||
.Li ` Ta Xo
|
||||
.Li \&" Ta Xo
|
||||
.Li \e\ Ta Xo
|
||||
.Li \en
|
||||
.Xc Xc Xc Xc Xc
|
||||
.El
|
||||
.It Backslash
|
||||
A backslash preserves the literal meaning of the following
|
||||
@@ -377,14 +388,32 @@ Reserved words are words that have special meaning to the
|
||||
shell and are recognized at the beginning of a line and
|
||||
after a control operator. The following are reserved words:
|
||||
.Bl -column "doneXX" "elifXX" "elseXX" "untilXX" "whileX" -offset center
|
||||
.It Li \&! Ta { Ta } Ta Ic case Ta Ic do
|
||||
.It Ic done Ta Ic elif Ta Ic else Ta Ic esac Ta Ic fi
|
||||
.It Ic for Ta Ic if Ta Ic then Ta Ic until Ta Ic while
|
||||
.It Xo
|
||||
.Li \&! Ta Xo
|
||||
.Li { Ta Xo
|
||||
.Li } Ta Xo
|
||||
.Ic case Ta Xo
|
||||
.Ic do
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Xo
|
||||
.Ic done Ta Xo
|
||||
.Ic elif Ta Xo
|
||||
.Ic else Ta Xo
|
||||
.Ic esac Ta Xo
|
||||
.Ic fi
|
||||
.Xc Xc Xc Xc Xc
|
||||
.It Xo
|
||||
.Ic for Ta Xo
|
||||
.Ic if Ta Xo
|
||||
.Ic then Ta Xo
|
||||
.Ic until Ta Xo
|
||||
.Ic while
|
||||
.Xc Xc Xc Xc Xc
|
||||
.El
|
||||
.Ss Aliases
|
||||
An alias is a name and corresponding value set using the
|
||||
.Ic alias
|
||||
built-in command. Whenever a reserved word may occur (see above),
|
||||
builtin command. Whenever a reserved word may occur (see above),
|
||||
and after checking for reserved words, the shell
|
||||
checks the word to see if it matches an alias.
|
||||
If it does, it replaces it in the input stream with its value.
|
||||
@@ -505,7 +534,7 @@ then leading tabs
|
||||
in the here-doc-text are stripped.
|
||||
.Ss Search and Execution
|
||||
There are three types of commands: shell functions,
|
||||
built-in commands, and normal programs.
|
||||
builtin commands, and normal programs.
|
||||
The command is searched for (by name) in that order.
|
||||
The three types of commands are all executed in a different way.
|
||||
.Pp
|
||||
@@ -521,12 +550,12 @@ The positional parameters are restored to their original values
|
||||
when the command completes.
|
||||
This all occurs within the current shell.
|
||||
.Pp
|
||||
Shell built-in commands are executed internally to the shell, without
|
||||
Shell builtin commands are executed internally to the shell, without
|
||||
spawning a new process.
|
||||
.Pp
|
||||
Otherwise, if the command name does not match a function
|
||||
or built-in command, the command is searched for as a normal
|
||||
program in the file system (as described in the next section).
|
||||
or builtin command, the command is searched for as a normal
|
||||
program in the filesystem (as described in the next section).
|
||||
When a normal program is executed, the shell runs the program,
|
||||
passing the arguments and the environment to the program.
|
||||
If the program is not a normal executable file
|
||||
@@ -555,7 +584,7 @@ as a
|
||||
.Ss Path Search
|
||||
When locating a command, the shell first looks to see if
|
||||
it has a shell function by that name. Then it looks for a
|
||||
built-in command by that name. If a built-in command is not found,
|
||||
builtin command by that name. If a builtin command is not found,
|
||||
one of two things happen:
|
||||
.Bl -enum
|
||||
.It
|
||||
@@ -579,7 +608,7 @@ of other shell commands. The paradigm is that a command exits
|
||||
with zero for normal or success, and non-zero for failure,
|
||||
error, or a false indication. The man page for each command
|
||||
should indicate the various exit codes and what they mean.
|
||||
Additionally, the built-in commands return exit codes, as does
|
||||
Additionally, the builtin commands return exit codes, as does
|
||||
an executed shell function.
|
||||
.Pp
|
||||
If a command is terminated by a signal, its exit status is 128 plus
|
||||
@@ -659,7 +688,7 @@ Note that unlike some other shells,
|
||||
executes each process in the pipeline as a child of the
|
||||
.Nm
|
||||
process.
|
||||
Shell built-in commands are the exception to this rule.
|
||||
Shell builtin commands are the exception to this rule.
|
||||
They are executed in the current shell, although they do not affect its
|
||||
environment when used in pipelines.
|
||||
.Ss Background Commands (&)
|
||||
@@ -683,7 +712,7 @@ and optionally terminated by one of these three characters.
|
||||
The commands in a
|
||||
list are executed in the order they are written.
|
||||
If command is followed by an ampersand, the shell starts the
|
||||
command and immediately proceeds onto the next command;
|
||||
command and immediately proceed onto the next command;
|
||||
otherwise it waits for the command to terminate before
|
||||
proceeding to the next one.
|
||||
.Ss Short-Circuit List Operators
|
||||
@@ -771,7 +800,7 @@ loops.
|
||||
The
|
||||
.Ic continue
|
||||
command continues with the next iteration of the innermost loop.
|
||||
These are implemented as built-in commands.
|
||||
These are implemented as builtin commands.
|
||||
.Pp
|
||||
The syntax of the
|
||||
.Ic case
|
||||
@@ -800,7 +829,7 @@ or
|
||||
.Ed
|
||||
.Pp
|
||||
The first form executes the commands in a subshell.
|
||||
Note that built-in commands thus executed do not affect the current shell.
|
||||
Note that builtin commands thus executed do not affect the current shell.
|
||||
The second form does not fork another shell,
|
||||
so it is slightly more efficient.
|
||||
Grouping commands together this way allows the user to
|
||||
@@ -830,13 +859,13 @@ This should appear as the first statement of a function,
|
||||
and the syntax is:
|
||||
.Bd -ragged -offset indent
|
||||
.Ic local
|
||||
.Op Ar variable ...
|
||||
.Op Ar variable ...\&
|
||||
.Op Ar -
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Ic local
|
||||
command is implemented as a built-in command.
|
||||
command is implemented as a builtin command.
|
||||
.Pp
|
||||
When a variable is made local, it inherits the initial
|
||||
value and exported and readonly flags from the variable
|
||||
@@ -879,7 +908,7 @@ command is
|
||||
It terminates the currently executing function.
|
||||
The
|
||||
.Ic return
|
||||
command is implemented as a built-in command.
|
||||
command is implemented as a builtin command.
|
||||
.Ss Variables and Parameters
|
||||
The shell maintains a set of parameters. A parameter
|
||||
denoted by a name is called a variable. When starting up,
|
||||
@@ -899,7 +928,7 @@ A positional parameter is a parameter denoted by a number greater than zero.
|
||||
The shell sets these initially to the values of its command line
|
||||
arguments that follow the name of the shell script. The
|
||||
.Ic set
|
||||
built-in command can also be used to set or reset them.
|
||||
builtin command can also be used to set or reset them.
|
||||
.Ss Special Parameters
|
||||
A special parameter is a parameter denoted by one of the following
|
||||
special characters. The value of the parameter is listed
|
||||
@@ -945,7 +974,7 @@ Expands to the exit status of the most recent pipeline.
|
||||
.It Li -
|
||||
(hyphen) Expands to the current option flags (the single-letter
|
||||
option names concatenated into a string) as specified on
|
||||
invocation, by the set built-in command, or implicitly
|
||||
invocation, by the set builtin command, or implicitly
|
||||
by the shell.
|
||||
.It Li $
|
||||
Expands to the process ID of the invoked shell. A subshell
|
||||
@@ -1047,7 +1076,7 @@ expansion, with the exception of the special parameter
|
||||
.Pp
|
||||
In addition, a parameter expansion can be modified by using one of the
|
||||
following formats.
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Li ${parameter:-word}
|
||||
Use Default Values. If parameter is unset or
|
||||
null, the expansion of word is
|
||||
@@ -1100,7 +1129,7 @@ the result of the expansion is unspecified.
|
||||
Enclosing the full parameter expansion string in double-quotes does not
|
||||
cause the following four varieties of pattern characters to be quoted,
|
||||
whereas quoting characters within the braces has this effect.
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Li ${parameter%word}
|
||||
Remove Smallest Suffix Pattern. The word
|
||||
is expanded to produce a pattern. The
|
||||
@@ -1240,16 +1269,16 @@ if any).
|
||||
To include a
|
||||
.Dq Li - ,
|
||||
make it the first or last character listed.
|
||||
.Ss Built-in Commands
|
||||
.Ss Builtin Commands
|
||||
This section lists the commands which
|
||||
are built-in because they need to perform some operation
|
||||
are builtin because they need to perform some operation
|
||||
that cannot be performed by a separate process. In addition to
|
||||
these, built-in versions of the
|
||||
these, builtin versions of the
|
||||
.Xr printf 1
|
||||
and
|
||||
.Xr test 1
|
||||
commands are provided for efficiency.
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Ic \&:
|
||||
A null command that returns a 0 (true) exit value.
|
||||
.It Ic \&. Ar file
|
||||
@@ -1264,7 +1293,9 @@ for the file. If it is not found in the
|
||||
.Ev PATH ,
|
||||
it is sought in the current working directory.
|
||||
.It Ic alias Op Ar name ...
|
||||
.It Ic alias Op Ar name Ns = Ns Ar string ...
|
||||
.It Ic alias Xo
|
||||
.Op Ar name Ns = Ns Ar string ...
|
||||
.Xc
|
||||
If
|
||||
.Ar name Ns = Ns Ar string
|
||||
is specified, the shell defines the alias
|
||||
@@ -1278,25 +1309,19 @@ is specified, the value of the alias
|
||||
is printed.
|
||||
With no arguments, the
|
||||
.Ic alias
|
||||
built-in command prints the names and values of all defined aliases
|
||||
builtin command prints the names and values of all defined aliases
|
||||
(see
|
||||
.Ic unalias ) .
|
||||
Alias values are written with appropriate quoting so that they are
|
||||
suitable for re-input to the shell.
|
||||
.It Ic bg Op Ar job ...
|
||||
Continue the specified jobs
|
||||
(or the current job if no jobs are given)
|
||||
in the background.
|
||||
.It Ic builtin Ar cmd Op Ar arg ...
|
||||
Execute the specified built-in command,
|
||||
.It Ic command Ar cmd Op Ar arg ...
|
||||
Execute the specified builtin command,
|
||||
.Ar cmd .
|
||||
This is useful when the user wishes to override a shell function
|
||||
with the same name as a built-in command.
|
||||
.It Ic bind Oo Fl aeklrsv Oc Oo Ar key Oo Ar command Oc Oc
|
||||
List or alter key bindings for the line editor.
|
||||
This command is documented in
|
||||
.Xr editrc 5 .
|
||||
.It Ic cd Oo Fl LP Oc Op Ar directory
|
||||
with the same name as a builtin command.
|
||||
.It Ic cd Op Ar directory
|
||||
Switch to the specified
|
||||
.Ar directory ,
|
||||
or to the directory specified in the
|
||||
@@ -1306,18 +1331,17 @@ environment variable if no
|
||||
is specified.
|
||||
If
|
||||
.Ar directory
|
||||
does not begin with
|
||||
.Pa / , \&. ,
|
||||
is not found as a subdirectory of the current directory
|
||||
(and does not begin with
|
||||
.Dq Li / ,
|
||||
.Dq Li ./ ,
|
||||
or
|
||||
.Pa .. ,
|
||||
.Dq Li ../ ) ,
|
||||
then the directories listed in the
|
||||
.Ev CDPATH
|
||||
variable will be
|
||||
searched for the specified
|
||||
.Ar directory .
|
||||
If
|
||||
.Ev CDPATH
|
||||
is unset, the current directory is searched.
|
||||
The format of
|
||||
.Ar CDPATH
|
||||
is the same as that of
|
||||
@@ -1331,49 +1355,26 @@ if this is different from the name that the user gave.
|
||||
These may be different either because the
|
||||
.Ev CDPATH
|
||||
mechanism was used or because a symbolic link was crossed.
|
||||
.Pp
|
||||
If the
|
||||
.Fl P
|
||||
option is specified,
|
||||
.Pa ..
|
||||
is handled physically and symbolic links are resolved before
|
||||
.Pa ..
|
||||
components are processed.
|
||||
If the
|
||||
.Fl L
|
||||
option is specified,
|
||||
.Pa ..
|
||||
is handled logically.
|
||||
This is the default.
|
||||
.It Ic chdir
|
||||
A synonym for the
|
||||
.Ic cd
|
||||
built-in command.
|
||||
.It Ic command Oo Fl p Oc Op Ar utility Op Ar argument ...
|
||||
Execute the specified
|
||||
.Ar utility
|
||||
as a simple command (see the
|
||||
.Sx Simple Commands
|
||||
section).
|
||||
.Pp
|
||||
If the
|
||||
.Fl p
|
||||
option is specified, the command search is performed using a
|
||||
default value of
|
||||
.Ev PATH
|
||||
that is guaranteed to find all of the standard utilities.
|
||||
.It Ic echo Oo Fl e | n Oc Op Ar string
|
||||
builtin command.
|
||||
.It Xo
|
||||
.Ic echo
|
||||
.Op Fl en
|
||||
.Ar string
|
||||
.Xc
|
||||
Print
|
||||
.Ar string
|
||||
to the standard output with a newline appended.
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Fl n
|
||||
Suppress the output of the trailing newline.
|
||||
.It Fl e
|
||||
Process C-style backslash escape sequences.
|
||||
.Ic echo
|
||||
understands the following character escapes:
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It \ea
|
||||
Alert (ring the terminal bell)
|
||||
.It \eb
|
||||
@@ -1416,12 +1417,6 @@ $ echo -e a\e\e\e\eb
|
||||
a\eb
|
||||
.Ed
|
||||
.El
|
||||
.Pp
|
||||
Only one of the
|
||||
.Fl e
|
||||
and
|
||||
.Fl n
|
||||
options may be specified.
|
||||
.It Ic eval Ar string ...
|
||||
Concatenate all the arguments with spaces.
|
||||
Then re-parse and execute the command.
|
||||
@@ -1430,7 +1425,7 @@ Unless
|
||||
.Ar command
|
||||
is omitted,
|
||||
the shell process is replaced with the specified program
|
||||
(which must be a real program, not a shell built-in command or function).
|
||||
(which must be a real program, not a shell builtin command or function).
|
||||
Any redirections on the
|
||||
.Ic exec
|
||||
command are marked as permanent,
|
||||
@@ -1444,7 +1439,7 @@ If
|
||||
is given
|
||||
it is used as the exit status of the shell;
|
||||
otherwise the exit status of the preceding command is used.
|
||||
.It Ic export Oo Fl p Oc Op Ar name ...
|
||||
.It Ic export Ar name ...
|
||||
The specified names are exported so that they will
|
||||
appear in the environment of subsequent commands.
|
||||
The only way to un-export a variable is to
|
||||
@@ -1458,19 +1453,28 @@ export name=value
|
||||
.Pp
|
||||
With no arguments the export command lists the names
|
||||
of all exported variables.
|
||||
If the
|
||||
.Fl p
|
||||
option is specified, the exported variables are printed as
|
||||
.Dq Ic export Ar name Ns = Ns Ar value
|
||||
lines, suitable for re-input to the shell.
|
||||
.It Ic fc Oo Fl e Ar editor Oc Op Ar first Op Ar last
|
||||
.It Ic fc Fl l Oo Fl nr Oc Op Ar first Op Ar last
|
||||
.It Ic fc Fl s Oo Ar old Ns = Ns Ar new Oc Op Ar first
|
||||
.It Xo
|
||||
.Ic fc
|
||||
.Op Fl e Ar editor
|
||||
.Op Ar first Op Ar last
|
||||
.Xc
|
||||
.It Xo
|
||||
.Ic fc
|
||||
.Fl l
|
||||
.Op Fl nr
|
||||
.Op Ar first Op Ar last
|
||||
.Xc
|
||||
.It Xo
|
||||
.Ic fc
|
||||
.Fl s
|
||||
.Op Ar old=new
|
||||
.Op Ar first
|
||||
.Xc
|
||||
The
|
||||
.Ic fc
|
||||
built-in command lists, or edits and re-executes,
|
||||
builtin command lists, or edits and re-executes,
|
||||
commands previously entered to an interactive shell.
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Fl e Ar editor
|
||||
Use the editor named by
|
||||
.Ar editor
|
||||
@@ -1527,7 +1531,7 @@ The value of
|
||||
or
|
||||
.Ar last
|
||||
or both are one of the following:
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Ar [+]num
|
||||
A positive number representing a command number;
|
||||
command numbers can be displayed with the
|
||||
@@ -1553,7 +1557,7 @@ the string form of the first operand cannot contain an embedded equal sign.
|
||||
.Pp
|
||||
The following environment variables affect the execution of
|
||||
.Ic fc :
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Ev FCEDIT
|
||||
Name of the editor to use.
|
||||
.It Ev HISTSIZE
|
||||
@@ -1584,7 +1588,11 @@ If an invalid option is encountered,
|
||||
is set to
|
||||
.Dq Li \&? .
|
||||
It returns a false value (1) when it encounters the end of the options.
|
||||
.It Ic hash Oo Fl rv Oc Op Ar command ...
|
||||
.It Xo
|
||||
.Ic hash
|
||||
.Op Fl rv
|
||||
.Op Ar command ...
|
||||
.Xc
|
||||
The shell maintains a hash table which remembers the locations of commands.
|
||||
With no arguments whatsoever, the
|
||||
.Ic hash
|
||||
@@ -1615,38 +1623,26 @@ Print the process id's of the processes in the specified
|
||||
If the
|
||||
.Ar job
|
||||
argument is omitted, use the current job.
|
||||
.It Ic jobs Oo Fl ls Oc Op Ar job ...
|
||||
Print information about the specified jobs, or all jobs if no
|
||||
.Ar job
|
||||
argument is given.
|
||||
The information printed includes job ID, status and command name.
|
||||
.Pp
|
||||
If the
|
||||
.Fl l
|
||||
option is specified, the PID of each job is also printed.
|
||||
If the
|
||||
.Fl s
|
||||
option is specified, only the PIDs of the jobs are printed, one per line.
|
||||
.It Ic pwd Op Fl LP
|
||||
Print the path of the current directory. The built-in command may
|
||||
.It Ic jobs
|
||||
This command lists out all the background processes
|
||||
which are children of the current shell process.
|
||||
.It Ic pwd
|
||||
Print the path of the current directory. The builtin command may
|
||||
differ from the program of the same name because the
|
||||
built-in command remembers what the current directory
|
||||
builtin command remembers what the current directory
|
||||
is rather than recomputing it each time. This makes
|
||||
it faster. However, if the current directory is
|
||||
renamed,
|
||||
the built-in version of
|
||||
the builtin version of
|
||||
.Xr pwd 1
|
||||
will continue to print the old name for the directory.
|
||||
.Pp
|
||||
If the
|
||||
.Fl P
|
||||
option is specified, symbolic links are resolved.
|
||||
If the
|
||||
.Fl L
|
||||
option is specified, the shell's notion of the current directory
|
||||
is printed (symbolic links are not resolved).
|
||||
This is the default.
|
||||
.It Ic read Oo Fl p Ar prompt Oc Oo Fl t Ar timeout Oc Oo Fl er Oc Ar variable ...
|
||||
.It Xo
|
||||
.Ic read
|
||||
.Op Fl p Ar prompt
|
||||
.Op Fl t Ar timeout
|
||||
.Op Fl er
|
||||
.Ar variable ...
|
||||
.Xc
|
||||
The
|
||||
.Ar prompt
|
||||
is printed if the
|
||||
@@ -1701,7 +1697,7 @@ is assumed.
|
||||
The
|
||||
.Fl e
|
||||
option exists only for backward compatibility with older scripts.
|
||||
.It Ic readonly Oo Fl p Oc Op Ar name ...
|
||||
.It Ic readonly Ar name ...
|
||||
Each specified
|
||||
.Ar name
|
||||
is marked as read only,
|
||||
@@ -1716,13 +1712,13 @@ readonly name=value
|
||||
With no arguments the
|
||||
.Ic readonly
|
||||
command lists the names of all read only variables.
|
||||
If the
|
||||
.Fl p
|
||||
option is specified, the read-only variables are printed as
|
||||
.Dq Ic readonly Ar name Ns = Ns Ar value
|
||||
lines, suitable for re-input to the shell.
|
||||
.It Ic set Oo Fl /+abCEefIimnpTuVvx Oc Oo Fl /+o Ar longname Oc Oo
|
||||
.Fl c Ar string Oc Op Fl - Ar arg ...
|
||||
.It Xo
|
||||
.Ic set
|
||||
.Op Fl /+abCEefIimnpTuVvx
|
||||
.Op Fl /+o Ar longname
|
||||
.Op Fl c Ar string
|
||||
.Op Fl - Ar arg ...
|
||||
.Xc
|
||||
The
|
||||
.Ic set
|
||||
command performs three different functions:
|
||||
@@ -1751,7 +1747,7 @@ which is equivalent to executing the command
|
||||
.Dq Li shift $# .
|
||||
The
|
||||
.Dq Fl -
|
||||
flag may be omitted when specifying arguments to be used
|
||||
flag may be ommitted when specifying arguments to be used
|
||||
as positional replacement parameters.
|
||||
This is not recommended,
|
||||
because the first argument may begin with a dash
|
||||
@@ -1786,7 +1782,11 @@ A shift sets the value of $1 to the value of $2,
|
||||
the value of $2 to the value of $3, and so on,
|
||||
decreasing the value of $# by one.
|
||||
If there are zero positional parameters, shifting does not do anything.
|
||||
.It Ic trap Oo Ar action Oc Ar signal ...
|
||||
.It Xo
|
||||
.Ic trap
|
||||
.Op Ar action
|
||||
.Ar signal ...
|
||||
.Xc
|
||||
Cause the shell to parse and execute
|
||||
.Ar action
|
||||
when any specified
|
||||
@@ -1808,12 +1808,16 @@ Interpret each
|
||||
.Ar name
|
||||
as a command and print the resolution of the command search.
|
||||
Possible resolutions are:
|
||||
shell keyword, alias, shell built-in command, command, tracked alias
|
||||
shell keyword, alias, shell builtin command, command, tracked alias
|
||||
and not found.
|
||||
For aliases the alias expansion is printed;
|
||||
for commands and tracked aliases
|
||||
the complete pathname of the command is printed.
|
||||
.It Ic ulimit Oo Fl HSabcdflmnstuv Oc Op Ar limit
|
||||
.It Xo
|
||||
.Ic ulimit
|
||||
.Op Fl HSabcdflmnust
|
||||
.Op Ar limit
|
||||
.Xc
|
||||
Set or display resource limits (see
|
||||
.Xr getrlimit 2 ) .
|
||||
If
|
||||
@@ -1850,7 +1854,7 @@ is not acceptable in this mode.
|
||||
The remaining options specify which resource value is to be
|
||||
displayed or modified.
|
||||
They are mutually exclusive.
|
||||
.Bl -tag -width indent
|
||||
.Bl -tag -width Ds
|
||||
.It Fl b Ar sbsize
|
||||
The maximum size of socket buffer usage, in bytes.
|
||||
.It Fl c Ar coredumpsize
|
||||
@@ -1872,8 +1876,6 @@ The maximal size of the stack segment, in kilobytes.
|
||||
The maximal amount of CPU time to be used by each process, in seconds.
|
||||
.It Fl u Ar userproc
|
||||
The maximal number of simultaneous processes for this user ID.
|
||||
.It Fl v Ar virtualmem
|
||||
The maximal virtual size of a process, in kilobytes.
|
||||
.El
|
||||
.It Ic umask Op Ar mask
|
||||
Set the file creation mask (see
|
||||
@@ -1881,25 +1883,23 @@ Set the file creation mask (see
|
||||
to the octal value specified by
|
||||
.Ar mask .
|
||||
If the argument is omitted, the current mask value is printed.
|
||||
.It Ic unalias Oo Fl a Oc Op Ar name
|
||||
.It Xo
|
||||
.Ic unalias
|
||||
.Op Fl a
|
||||
.Op Ar name
|
||||
.Xc
|
||||
If
|
||||
.Ar name
|
||||
is specified, the shell removes that alias.
|
||||
If
|
||||
.Fl a
|
||||
is specified, all aliases are removed.
|
||||
.It Ic unset Oo Fl fv Oc Ar name ...
|
||||
The specified variables or functions are unset and unexported.
|
||||
If the
|
||||
.Fl v
|
||||
option is specified or no options are given, the
|
||||
.It Ic unset Ar name ...
|
||||
The specified variables and functions are unset and unexported.
|
||||
If a given
|
||||
.Ar name
|
||||
arguments are treated as variable names.
|
||||
If the
|
||||
.Fl f
|
||||
option is specified, the
|
||||
.Ar name
|
||||
arguments are treated as function names.
|
||||
corresponds to both a variable and a function,
|
||||
both the variable and the function are unset.
|
||||
.It Ic wait Op Ar job
|
||||
Wait for the specified
|
||||
.Ar job
|
||||
@@ -1916,7 +1916,7 @@ and the command history
|
||||
(see
|
||||
.Ic fc
|
||||
in
|
||||
.Sx Built-in Commands )
|
||||
.Sx Builtin Commands )
|
||||
can be edited using vi-mode command line editing.
|
||||
This mode uses commands similar
|
||||
to a subset of those described in the vi man page.
|
||||
@@ -1951,4 +1951,4 @@ emacs-style command line editing features.
|
||||
A
|
||||
.Nm
|
||||
command appeared in
|
||||
.At v1 .
|
||||
.At V.1 .
|
||||
@@ -40,6 +40,9 @@
|
||||
/*
|
||||
* The follow should be set to reflect the type of system you have:
|
||||
* JOBS -> 1 if you have Berkeley job control, 0 otherwise.
|
||||
* SHORTNAMES -> 1 if your linker cannot handle long names.
|
||||
* define BSD if you are running 4.2 BSD or later.
|
||||
* define SYSV if you are running under System V.
|
||||
* define DEBUG=1 to compile in debugging (set global "debug" to turn on)
|
||||
* define DEBUG=2 to compile in and turn on debugging.
|
||||
*
|
||||
@@ -49,9 +52,22 @@
|
||||
|
||||
|
||||
#define JOBS 1
|
||||
#ifndef BSD
|
||||
#define BSD 1
|
||||
#endif
|
||||
/* #define DEBUG 1 */
|
||||
|
||||
#ifdef __STDC__
|
||||
typedef void *pointer;
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
#else /* not __STDC__ */
|
||||
typedef char *pointer;
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#endif /* not __STDC__ */
|
||||
#define STATIC static
|
||||
#define MKINIT /* empty */
|
||||
|
||||
|
||||
Loaded 100 of 3823 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user