Obtained from: partly from 1.1.5
Convert "" to "." for "cd" and "cd ''". chdir("") is required to fail on POSIX systems.
This commit is contained in:
parent
abdf111953
commit
61233bdc2e
@ -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
|
||||
@ -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;
|
||||
@ -220,7 +222,7 @@ top:
|
||||
STPUTC('\0', p);
|
||||
p = grabstackstr(p);
|
||||
INTOFF;
|
||||
if (chdir(p) < 0) {
|
||||
if (chdir(*p ? p : ".") < 0) {
|
||||
INTON;
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user