Imported from ../bash-4.0-rc1.tar.gz.
[platform/upstream/bash.git] / builtins / shift.def
index 6db7c7f..3213086 100644 (file)
@@ -1,23 +1,22 @@
 This file is shift.def, from which is created shift.c.
 It implements the builtin "shift" in Bash.
 
 This file is shift.def, from which is created shift.c.
 It implements the builtin "shift" in Bash.
 
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1987-2009 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
+Bash is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
 
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
+Bash is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
 
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING.  If not, write to the Free Software
-Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+You should have received a copy of the GNU General Public License
+along with Bash.  If not, see <http://www.gnu.org/licenses/>.
 
 $PRODUCES shift.c
 
 
 $PRODUCES shift.c
 
@@ -31,6 +30,7 @@ $PRODUCES shift.c
 #endif
 
 #include "../bashansi.h"
 #endif
 
 #include "../bashansi.h"
+#include "../bashintl.h"
 
 #include "../shell.h"
 #include "common.h"
 
 #include "../shell.h"
 #include "common.h"
@@ -38,8 +38,13 @@ $PRODUCES shift.c
 $BUILTIN shift
 $FUNCTION shift_builtin
 $SHORT_DOC shift [n]
 $BUILTIN shift
 $FUNCTION shift_builtin
 $SHORT_DOC shift [n]
-The positional parameters from $N+1 ... are renamed to $1 ...  If N is
+Shift positional parameters.
+
+Rename the positional parameters $N+1,$N+2 ... to $1,$2 ...  If N is
 not given, it is assumed to be 1.
 not given, it is assumed to be 1.
+
+Exit Status:
+Returns success unless N is negative or greater than $#.
 $END
 
 int print_shift_error;
 $END
 
 int print_shift_error;
@@ -52,23 +57,24 @@ int
 shift_builtin (list)
      WORD_LIST *list;
 {
 shift_builtin (list)
      WORD_LIST *list;
 {
-  long times;
+  intmax_t times;
   register int count;
   WORD_LIST *temp;
 
   register int count;
   WORD_LIST *temp;
 
-  times = get_numeric_arg (list, 0);
+  if (get_numeric_arg (list, 0, &times) == 0)
+    return (EXECUTION_FAILURE);
 
   if (times == 0)
     return (EXECUTION_SUCCESS);
   else if (times < 0)
     {
 
   if (times == 0)
     return (EXECUTION_SUCCESS);
   else if (times < 0)
     {
-      builtin_error ("shift count must be >= 0");
+      sh_erange (list ? list->word->word : NULL, _("shift count"));
       return (EXECUTION_FAILURE);
     }
   else if (times > number_of_args ())
     {
       if (print_shift_error)
       return (EXECUTION_FAILURE);
     }
   else if (times > number_of_args ())
     {
       if (print_shift_error)
-       builtin_error ("shift count must be <= $#");
+       sh_erange (list ? list->word->word : NULL, _("shift count"));
       return (EXECUTION_FAILURE);
     }
 
       return (EXECUTION_FAILURE);
     }