Skip to content

Commit

Permalink
Obtained from: partly from 1.1.5
Browse files Browse the repository at this point in the history
Convert "" to "." for "cd" and "cd ''".  chdir("") is required to fail
on POSIX systems.
  • Loading branch information
Bruce Evans authored and Bruce Evans committed Dec 26, 1994
1 parent abdf111 commit 61233bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/sh/cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cd.c,v 1.2 1994/09/24 02:57:24 davidg Exp $
* $Id: cd.c,v 1.3 1994/11/06 01:29:26 jkh Exp $
*/

#ifndef lint
Expand Down Expand Up @@ -88,6 +88,8 @@ cdcmd(argc, argv) char **argv; {
nextopt(nullstr);
if ((dest = *argptr) == NULL && (dest = bltinlookup("HOME", 1)) == NULL)
error("HOME not set");
if (*dest == '\0')
dest = ".";
if (dest[0] == '-' && dest[1] == '\0') {
dest = prevdir ? prevdir : curdir;
print = 1;
Expand Down Expand Up @@ -220,7 +222,7 @@ docd(dest, print)
STPUTC('\0', p);
p = grabstackstr(p);
INTOFF;
if (chdir(p) < 0) {
if (chdir(*p ? p : ".") < 0) {
INTON;
return -1;
}
Expand Down

0 comments on commit 61233bd

Please sign in to comment.