diff -u builtins/cd.def.orig builtins/cd.def --- builtins/cd.def.orig 2014-01-20 16:52:02.000000000 -0700 +++ builtins/cd.def 2014-01-20 16:37:17.000000000 -0700 @@ -92,6 +92,8 @@ links -e if the -P option is supplied, and the current working directory cannot be determined successfully, exit with a non-zero status + -q prevent the working directory from being echoed when the + CDPATH variable is used to locate DIR The default is to follow symbolic links, as if `-L' were specified. @@ -187,7 +189,7 @@ WORD_LIST *list; { char *dirname, *cdpath, *path, *temp; - int path_index, no_symlinks, opt, lflag; + int path_index, no_symlinks, opt, lflag, qflag; #if defined (RESTRICTED_SHELL) if (restricted) @@ -198,9 +200,10 @@ #endif /* RESTRICTED_SHELL */ eflag = 0; + qflag = 0; no_symlinks = no_symbolic_links; reset_internal_getopt (); - while ((opt = internal_getopt (list, "LP")) != -1) + while ((opt = internal_getopt (list, "LPq")) != -1) { switch (opt) { @@ -213,6 +216,9 @@ case 'e': eflag = 1; break; + case 'q': + qflag = 1; + break; default: builtin_usage (); return (EXECUTION_FAILURE); @@ -274,7 +280,7 @@ is used to find the directory to change to, the new directory name is echoed to stdout, whether or not the shell is interactive. */ - if (opt && (path = no_symlinks ? temp : the_current_working_directory)) + if (opt && !qflag && (path = no_symlinks ? temp : the_current_working_directory)) printf ("%s\n", path); free (temp);