+#if defined BB_FEATURE_SH_ENVIRONMENT && ! defined BB_FEATURE_SH_WORDEXP
+char * strsep_space( char *string, int * index)
+{
+ char *token, *begin;
+
+ begin = string;
+
+ /* Short circuit the trivial case */
+ if ( !string || ! string[*index])
+ return NULL;
+
+ /* Find the end of the token. */
+ while( string && string[*index] && !isspace(string[*index]) ) {
+ (*index)++;
+ }
+
+ /* Find the end of any whitespace trailing behind
+ * the token and let that be part of the token */
+ while( string && string[*index] && isspace(string[*index]) ) {
+ (*index)++;
+ }
+
+ if (! string && *index==0) {
+ /* Nothing useful was found */
+ return NULL;
+ }
+
+ token = xmalloc(*index+1);
+ token[*index] = '\0';
+ strncpy(token, string, *index);
+
+ return token;
+}
+#endif
+
+