Skip to content

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

@mauke

Description

@mauke

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions