elf.h: add ELFCOMPRESS_ZSTD
[musl] / src / misc / wordexp.c
index a5f1b65..db83a69 100644 (file)
 static void reap(pid_t pid)
 {
        int status;
-       for (;;) {
-               if (waitpid(pid, &status, 0) < 0) {
-                       if (errno != EINTR) return;
-               } else {
-                       if (WIFEXITED(status)) return;
-               }
-       }
+       while (waitpid(pid, &status, 0) < 0 && errno == EINTR);
 }
 
 static char *getword(FILE *f)
@@ -48,7 +42,7 @@ static int do_wordexp(const char *s, wordexp_t *we, int flags)
 
        if (flags & WRDE_NOCMD) for (i=0; s[i]; i++) switch (s[i]) {
        case '\\':
-               if (!sq) i++;
+               if (!sq && !s[++i]) return WRDE_SYNTAX;
                break;
        case '\'':
                if (!dq) sq^=1;
@@ -77,6 +71,7 @@ static int do_wordexp(const char *s, wordexp_t *we, int flags)
                if (!(sq|dq|np)) return WRDE_BADCHAR;
                break;
        case '$':
+               if (sq) break;
                if (s[i+1]=='(' && s[i+2]=='(') {
                        i += 2;
                        np += 2;