Skip to content
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

chdir doesn't return a boolean, but manual says it returns true/false #22365

Closed
mauke opened this issue Jul 1, 2024 · 0 comments · Fixed by #22366
Closed

chdir doesn't return a boolean, but manual says it returns true/false #22365

mauke opened this issue Jul 1, 2024 · 0 comments · Fixed by #22366

Comments

@mauke
Copy link
Contributor

mauke commented Jul 1, 2024

Description

According to perldoc -f chdir:

It returns true on success, false otherwise.

However, chdir actually returns (integer) 1 and 0. This is mostly observable in the failure case, which (according to the documentation) should return a value that is eq "", but isn't.

Steps to Reproduce

$ perl -wE 'say chdir "/invalid*"'
0
$ perl -Mexperimental=builtin -wE 'say builtin::is_bool chdir "/invalid*"'

$

Expected behavior

$ perl -wE 'say chdir "/invalid*"'

$ perl -Mexperimental=builtin -wE 'say builtin::is_bool chdir "/invalid*"'
1
$

I.e. a false value should stringify to the empty string and be is_bool.

Alternatively, the documentation should be changed to match the existing behavior.

(This is with v5.40.0.)

mauke added a commit to mauke/perl5 that referenced this issue Jul 1, 2024
Previously it would return integer 1 and 0, not booleans.

Fixes Perl#22365.
mauke added a commit to mauke/perl5 that referenced this issue Jul 1, 2024
Previously it would return integer 1 and 0, not booleans.

Fixes Perl#22365.
mauke added a commit to mauke/perl5 that referenced this issue Jul 2, 2024
Previously it would return integer 1 and 0, not booleans.

Fixes Perl#22365.
mauke added a commit to mauke/perl5 that referenced this issue Jul 2, 2024
Previously it would return integer 1 and 0, not booleans.

Fixes Perl#22365.
mauke added a commit to mauke/perl5 that referenced this issue Jul 2, 2024
Previously it would return integer 1 and 0, not booleans.

Fixes Perl#22365.
mauke added a commit that referenced this issue Jul 4, 2024
Previously it would return integer 1 and 0, not booleans.

Fixes #22365.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant