New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When does qx/STRING/ return undef? #16572
Comments
From rt.perl.org@mavit.org.ukThis is a bug report for perl from rt.perl.org@mavit.org.uk, The perlop man page says that the qx/STRING/ operator returns "undef if the command failed". It seems to me that this is misleading, because it does not go on to explain when the command is considered to have failed. The reader might reasonably expect that qx/STRING/ will return undef if the command exits non-zero, but this is not the case. I suspect that qx/STRING/ only returns undef if forking and execing /bin/sh fails, which isn't what I'd think of as "the command" in this context. Flags: Site configuration information for perl 5.26.2: Configured by Red Hat, Inc. at Mon Apr 16 12:45:12 UTC 2018. Summary of my perl5 (revision 5 version 26 subversion 2) configuration: Locally applied patches: @INC for perl 5.26.2: Environment for perl 5.26.2: |
From @jkeenanOn Tue, 29 May 2018 12:08:55 GMT, cpan@mavit.org.uk wrote:
I believe the documentation in pod/perlop.pod for ##### The part that is correct is that the return value from As far as I can tell from a couple of hours of focus on the If I'm correct then we need a patch for the documentation and possibly some tests like those in the attachment which drive the point home. Thank you very much. -- |
From @jkeenan#!/usr/bin/env perl my ($rv, @lines, $cmd); { my $sdir = File::Spec->catdir($tdir, qw(foo bar)); $cmd = "echo -n $hw"; $cmd = "echo -n $hw && cd $sdir"; $cmd = "cd $sdir && echo -n $hw"; $cmd = "echo $hw && cd $sdir && echo 'Who do you love?'"; $cmd = "$sdir"; make_path($sdir) or die "Unable to create $sdir for testing"; $cmd = "echo -n $hw && cd $sdir && echo -n ' ' && pwd"; $cmd = "echo $hw && cd $sdir && echo '' && pwd"; chdir done_testing(); |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Mon, 03 Sep 2018 17:08:33 -0700, jkeenan wrote:
$ ./perl -Ilib -lE '$x = `lsx`; print $x // "undef";' From looking at the code it "fails" if the fork or exec fails, or if other system calls fail (eg. pipe()) If your command includes shell metacharacters then the shell executes successfully and so a defined value is returned (and the shell complains): $ ./perl -Ilib -lE '$x = `lsx;`; print $x // "undef";' Tony |
Migrated from rt.perl.org#133235 (status was 'open')
Searchable as RT133235$
The text was updated successfully, but these errors were encountered: