diff options
Diffstat (limited to 'execute_cmd.c~')
-rw-r--r-- | execute_cmd.c~ | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/execute_cmd.c~ b/execute_cmd.c~ index 586771a1..226b0dda 100644 --- a/execute_cmd.c~ +++ b/execute_cmd.c~ @@ -1,6 +1,6 @@ /* execute_cmd.c -- Execute a COMMAND structure. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2006 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -96,8 +96,9 @@ extern int errno; #endif extern int posixly_correct; -extern int breaking, continuing, loop_level; extern int expand_aliases; +extern int autocd; +extern int breaking, continuing, loop_level; extern int parse_and_execute_level, running_trap; extern int command_string_index, line_number; extern int dot_found_in_search; @@ -1396,7 +1397,7 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) /* Make a pipeline between the two commands. */ if (pipe (fildes) < 0) { - sys_error ("pipe error"); + sys_error (_("pipe error")); #if defined (JOB_CONTROL) terminate_current_pipeline (); kill_current_pipeline (); @@ -2743,6 +2744,17 @@ fix_assignment_words (words) } } +/* Return 1 if the file found by searching $PATH for PATHNAME, defaulting + to PATHNAME, is a directory. Used by the autocd code below. */ +static int +is_dirname (pathname) + char *pathname; +{ + char *temp; + temp = search_for_command (pathname); + return (temp ? file_isdir (temp) : file_isdir (pathname)); +} + /* The meaty part of all the executions. We have to start hacking the real execution of commands here. Fork a process, set things up, execute the command. */ @@ -2792,7 +2804,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close) #endif first_word_quoted = - simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0; + simple_command->words ? (simple_command->words->word->flags & W_QUOTED) : 0; last_command_subst_pid = NO_PID; old_last_async_pid = last_asynchronous_pid; @@ -2975,6 +2987,7 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close) } #endif /* JOB_CONTROL */ +run_builtin: /* Remember the name of this command globally. */ this_command_name = words->word->word; @@ -3048,6 +3061,13 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close) } } + if (autocd && interactive && words->word && is_dirname (words->word->word)) + { + words = make_word_list (make_word ("cd"), words); + xtrace_print_word_list (words, 0); + goto run_builtin; + } + if (command_line == 0) command_line = savestring (the_printed_command_except_trap); |