]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - builtins/read.def
bash-4.3-beta overlay
[thirdparty/bash.git] / builtins / read.def
index 7a1dff6f0cdf1e34033344987a725453baa5e5cf..e5c927aab9b4fdec5e180e7b9eda8b832860976e 100644 (file)
@@ -329,6 +329,18 @@ read_builtin (list)
     return (input_avail (fd) ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
 #endif
 
+  /* Convenience: check early whether or not the first of possibly several
+     variable names is a valid identifier, and bail early if so. */
+#if defined (ARRAY_VARS)
+  if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word) == 0)
+#else
+  if (list && legal_identifier (list->word->word) == 0)
+#endif
+    {
+      sh_invalidid (list->word->word);
+      return (EXECUTION_FAILURE);
+    }
+
   /* If we're asked to ignore the delimiter, make sure we do. */
   if (ignore_delim)
     delim = -1;