aboutsummaryrefslogtreecommitdiffstats
path: root/builtins/pushd.def
diff options
context:
space:
mode:
Diffstat (limited to 'builtins/pushd.def')
-rw-r--r--builtins/pushd.def51
1 files changed, 30 insertions, 21 deletions
diff --git a/builtins/pushd.def b/builtins/pushd.def
index 83b69c4..0978fc9 100644
--- a/builtins/pushd.def
+++ b/builtins/pushd.def
@@ -1,7 +1,7 @@
This file is pushd.def, from which is created pushd.c. It implements the
builtins "pushd", "popd", and "dirs" in Bash.
-Copyright (C) 1987-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2004 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -151,13 +151,20 @@ int
pushd_builtin (list)
WORD_LIST *list;
{
+ WORD_LIST *orig_list;
char *temp, *current_directory, *top;
- int j, flags;
+ int j, flags, skipopt;
intmax_t num;
char direction;
+ orig_list = list;
if (list && list->word && ISOPTION (list->word->word, '-'))
- list = list->next;
+ {
+ list = list->next;
+ skipopt = 1;
+ }
+ else
+ skipopt = 0;
/* If there is no argument list then switch current and
top of list. */
@@ -181,7 +188,7 @@ pushd_builtin (list)
return j;
}
- for (flags = 0; list; list = list->next)
+ for (flags = 0; skipopt == 0 && list; list = list->next)
{
if (ISOPTION (list->word->word, 'n'))
{
@@ -265,7 +272,7 @@ pushd_builtin (list)
if (current_directory == 0)
return (EXECUTION_FAILURE);
- j = ((flags & NOCD) == 0) ? cd_builtin (list) : EXECUTION_SUCCESS;
+ j = ((flags & NOCD) == 0) ? cd_builtin (skipopt ? orig_list : list) : EXECUTION_SUCCESS;
if (j == EXECUTION_SUCCESS)
{
add_dirstack_element ((flags & NOCD) ? savestring (list->word->word) : current_directory);
@@ -499,9 +506,11 @@ cd_to_string (name)
char *name;
{
WORD_LIST *tlist;
+ WORD_LIST *dir;
int result;
- tlist = make_word_list (make_word (name), NULL);
+ dir = make_word_list (make_word (name), NULL);
+ tlist = make_word_list (make_word ("--"), dir);
result = cd_builtin (tlist);
dispose_words (tlist);
return (result);
@@ -648,11 +657,11 @@ get_directory_stack ()
}
#ifdef LOADABLE_BUILTIN
-static char *dirs_doc[] = {
+static char * const dirs_doc[] = {
N_("Display the list of currently remembered directories. Directories"),
N_("find their way onto the list with the `pushd' command; you can get"),
N_("back up through the list with the `popd' command."),
- N_(""),
+ N_(" "),
N_("The -l flag specifies that `dirs' should not print shorthand versions"),
N_("of directories which are relative to your home directory. This means"),
N_("that `~/bin' might be displayed as `/homes/bfox/bin'. The -v flag"),
@@ -660,54 +669,54 @@ static char *dirs_doc[] = {
N_("prepending the directory name with its position in the stack. The -p"),
N_("flag does the same thing, but the stack position is not prepended."),
N_("The -c flag clears the directory stack by deleting all of the elements."),
- N_(""),
+ N_(" "),
N_("+N displays the Nth entry counting from the left of the list shown by"),
N_(" dirs when invoked without options, starting with zero."),
- N_(""),
+ N_(" "),
N_("-N displays the Nth entry counting from the right of the list shown by"),
N_(" dirs when invoked without options, starting with zero."),
(char *)NULL
};
-static char *pushd_doc[] = {
+static char * const pushd_doc[] = {
N_("Adds a directory to the top of the directory stack, or rotates"),
N_("the stack, making the new top of the stack the current working"),
N_("directory. With no arguments, exchanges the top two directories."),
- N_(""),
+ N_(" "),
N_("+N Rotates the stack so that the Nth directory (counting"),
N_(" from the left of the list shown by `dirs', starting with"),
N_(" zero) is at the top."),
- N_(""),
+ N_(" "),
N_("-N Rotates the stack so that the Nth directory (counting"),
N_(" from the right of the list shown by `dirs', starting with"),
N_(" zero) is at the top."),
- N_(""),
+ N_(" "),
N_("-n suppress the normal change of directory when adding directories"),
N_(" to the stack, so only the stack is manipulated."),
- N_(""),
+ N_(" "),
N_("dir adds DIR to the directory stack at the top, making it the"),
N_(" new current working directory."),
- N_(""),
+ N_(" "),
N_("You can see the directory stack with the `dirs' command."),
(char *)NULL
};
-static char *popd_doc[] = {
+static char * const popd_doc[] = {
N_("Removes entries from the directory stack. With no arguments,"),
N_("removes the top directory from the stack, and cd's to the new"),
N_("top directory."),
- N_(""),
+ N_(" "),
N_("+N removes the Nth entry counting from the left of the list"),
N_(" shown by `dirs', starting with zero. For example: `popd +0'"),
N_(" removes the first directory, `popd +1' the second."),
- N_(""),
+ N_(" "),
N_("-N removes the Nth entry counting from the right of the list"),
N_(" shown by `dirs', starting with zero. For example: `popd -0'"),
N_(" removes the last directory, `popd -1' the next to last."),
- N_(""),
+ N_(" "),
N_("-n suppress the normal change of directory when removing directories"),
N_(" from the stack, so only the stack is manipulated."),
- N_(""),
+ N_(" "),
N_("You can see the directory stack with the `dirs' command."),
(char *)NULL
};