]> granicus.if.org Git - php/commitdiff
(PHP exec) Return last line of output properly.
authorAndrei Zmievski <andrei@php.net>
Tue, 22 Feb 2000 18:00:32 +0000 (18:00 +0000)
committerAndrei Zmievski <andrei@php.net>
Tue, 22 Feb 2000 18:00:32 +0000 (18:00 +0000)
ext/standard/exec.c

index e9a81d09a8ad673590a6ebd75b26634012d2b461..f91750d31a77ad50bf8e3428afddb8c3d626b372 100644 (file)
@@ -166,6 +166,14 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)
                while (l && isspace((int)buf[--l]));
                if (l < t) buf[l + 1] = '\0';
 
+               /* Return last line from the shell command */
+               if (PG(magic_quotes_runtime)) {
+                       int len;
+
+                       tmp = php_addslashes(buf, 0, &len, 0);
+                       RETVAL_STRINGL(tmp,len,0);
+               } else
+                       RETVAL_STRINGL(buf,l,1);
        } else {
                int b, i;
 
@@ -174,14 +182,6 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)
                                if (output) (void)PUTC(buf[i]);
                }
        }
-
-       /* Return last line from the shell command */
-       if (PG(magic_quotes_runtime) && type!=3) {
-               int len;
-               
-               tmp = php_addslashes(buf, 0, &len, 0);
-               RETVAL_STRINGL(tmp,len,0);
-       }
        
        ret = pclose(fp);
 #if HAVE_SYS_WAIT_H