Ingo Schwarze(schwa...@usta.de) on 2017.12.14 17:49:35 +0100:
> We are actually violating POSIX here:

ok to put this in?
we can continue working on it in tree

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#       usr.bin/cd
#       usr.bin/cd/Makefile
#       usr.bin/cd/cd
#       usr.bin/cd/cd.1
#
echo c - usr.bin/cd
mkdir -p usr.bin/cd > /dev/null 2>&1
echo x - usr.bin/cd/Makefile
sed 's/^X//' >usr.bin/cd/Makefile << 'END-of-usr.bin/cd/Makefile'
X#      $OpenBSD$
X
XMAN=   cd.1
X
XSCRIPT=        cd.sh
X
Xrealinstall:
X       ${INSTALL} ${INSTALL_COPY} -S -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
X           ${.CURDIR}/${SCRIPT} ${DESTDIR}${BINDIR}/cd
X
X.include <bsd.prog.mk>
END-of-usr.bin/cd/Makefile
echo x - usr.bin/cd/cd
sed 's/^X//' >usr.bin/cd/cd << 'END-of-usr.bin/cd/cd'
X#!/bin/sh
Xcd $@
END-of-usr.bin/cd/cd
echo x - usr.bin/cd/cd.1
sed 's/^X//' >usr.bin/cd/cd.1 << 'END-of-usr.bin/cd/cd.1'
X.\"    $OpenBSD: ksh.1,v 1.197 2017/12/12 11:34:38 tb Exp $
X.\"
X.\"    Public Domain
X.\"
X.Dd $Mdocdate: December 12 2017 $
X.Dt CD 1
X.Os
X.Sh NAME
X.Nm cd
X.Nd Change the shell working directory.
X.Sh SYNOPSIS
X.Nm cd
X.Bk -words
X.Op Fl LP
X.Op Ar dir
X.Ek
X.Nm cd
X.Bk -words
X.Op Fl LP
X.Ar new old
X.Sh DESCRIPTION
X.Nm
Xsets the working directory to
X.Ar dir .
XIf the parameter
X.Ev CDPATH
Xis set, it lists the search path for the directory containing
X.Ar dir .
XA
X.Dv NULL
Xpath means the current directory.
XIf
X.Ar dir
Xis found in any component of the
X.Ev CDPATH
Xsearch path other than the
X.Dv NULL
Xpath, the name of the new working directory will be written to standard output.
XIf
X.Ar dir
Xis missing, the home directory
X.Ev HOME
Xis used.
XIf
X.Ar dir
Xis
X.Ql - ,
Xthe previous working directory is used (see the
X.Ev OLDPWD
Xparameter).
X.Pp
XIf the
X.Fl L
Xoption (logical path) is used or if the
X.Ic physical
Xoption isn't set (see the
X.Ic set
Xcommand below), references to
X.Sq ..
Xin
X.Ar dir
Xare relative to the path used to get to the directory.
XIf the
X.Fl P
Xoption (physical path) is used or if the
X.Ic physical
Xoption is set,
X.Sq ..
Xis relative to the filesystem directory tree.
XThe
X.Ev PWD
Xand
X.Ev OLDPWD
Xparameters are updated to reflect the current and old working directory,
Xrespectively.
X.Pp
XIn the second form of invocation,
Xthe string
X.Ar new
Xis substituted for
X.Ar old
Xin the current directory, and the shell attempts to change to the new
Xdirectory.
X.Sh SEE ALSO
X.Xr csh 1 ,
X.Xr ksh 1 ,
X.Xr sh 1 ,
X.Xr shells 5 ,
X.Xr environ 7
X.Rs
X.%A IEEE Inc.
X.%D 1993
X.%O ISBN 1-55937-266-9
X.%T IEEE Standard for Information Technology \- Portable Operating \
X    System Interface (POSIX) \- Part 2: Shell and Utilities
X.Re
X.Sh CAVEATS
XCompared to the shell builtin,
X.Nm
Xis not very useful. The only thing it really does is set the exit code.
XIt looks like a striking example of standards' insanity.
X.Sh AUTHORS
X.An -nosplit
XThis command is based on the
X.Xr ksh 1
Xshell builtin.
XThe manpage was written by
X.An Sebastian Benoit
Xwith inspiration from
X.An Ingo Schwarze .
X
X
END-of-usr.bin/cd/cd.1
exit

Reply via email to