aboutsummaryrefslogtreecommitdiffstats
path: root/builtins
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>1998-07-23 14:37:54 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:52 +0000
commitbc4cd23ce958feda898c618215f94d8a4e8f4ffa (patch)
tree32fc9a13b636cb4d29873feddc533d3dfb25a917 /builtins
parentcce855bc5b117cb7ae70064131120687bc69fac0 (diff)
downloadandroid_external_bash-bc4cd23ce958feda898c618215f94d8a4e8f4ffa.tar.gz
android_external_bash-bc4cd23ce958feda898c618215f94d8a4e8f4ffa.tar.bz2
android_external_bash-bc4cd23ce958feda898c618215f94d8a4e8f4ffa.zip
Imported from ../bash-2.02.1.tar.gz.
Diffstat (limited to 'builtins')
-rw-r--r--builtins/cd.def8
-rw-r--r--builtins/exec.def5
-rw-r--r--builtins/printf.def6
3 files changed, 15 insertions, 4 deletions
diff --git a/builtins/cd.def b/builtins/cd.def
index ef8d805..76ef14b 100644
--- a/builtins/cd.def
+++ b/builtins/cd.def
@@ -263,7 +263,7 @@ cd_builtin (list)
directory name is echoed to stdout, whether or not
the shell is interactive. */
if (opt)
- printf ("%s\n", the_current_working_directory);
+ printf ("%s\n", no_symlinks ? temp : the_current_working_directory);
free (temp);
/* Posix.2 says that after using CDPATH, the resultant
@@ -276,8 +276,10 @@ cd_builtin (list)
/* POSIX.2 says that if `.' does not appear in $CDPATH, we don't
try the current directory, so we just punt now with an error
- message if POSIXLY_CORRECT is non-zero. */
- if (posixly_correct)
+ message if POSIXLY_CORRECT is non-zero. The check for cdpath[0]
+ is so we don't mistakenly treat a CDPATH value of "" as not
+ specifying the current directory. */
+ if (posixly_correct && cdpath[0])
{
builtin_error ("%s: %s", dirname, strerror (ENOENT));
return (EXECUTION_FAILURE);
diff --git a/builtins/exec.def b/builtins/exec.def
index 4e1394d..d7166d7 100644
--- a/builtins/exec.def
+++ b/builtins/exec.def
@@ -191,6 +191,11 @@ exec_builtin (list)
#endif /* JOB_CONTROL */
shell_execve (command, args, env);
+
+ /* We have to set this to NULL because shell_execve has called realloc()
+ to stuff more items at the front of the array, which may have caused
+ the memory to be freed by realloc(). We don't want to free it twice. */
+ args = (char **)NULL;
if (cleanenv == 0)
adjust_shell_level (1);
diff --git a/builtins/printf.def b/builtins/printf.def
index 43ccb56..9d1493b 100644
--- a/builtins/printf.def
+++ b/builtins/printf.def
@@ -129,6 +129,10 @@ printf_builtin (list)
garglist = list->next;
+ /* If the format string is empty after preprocessing, return immediately. */
+ if (format == 0 || *format == 0)
+ return (EXECUTION_SUCCESS);
+
/* Basic algorithm is to scan the format string for conversion
specifications -- once one is found, find out if the field
width or precision is a '*'; if it is, gather up value. Note,
@@ -305,7 +309,7 @@ printf_builtin (list)
fmt[1] = nextch;
}
}
- while (garglist);
+ while (garglist && garglist != list->next);
PRETURN (retval);
}