chmod
ErrorsCollection

chmod

Synthesised documentation from type/independent-routines type/IO/Path

From type/independent-routines

See Original text in context

sub chmod(Int() $mode*@filenames --> List)

Coerces all @filenames to IO::Path and calls IO::Path.chmod with $mode on them. Returns a List containing a subset of @filenames for which chmod was successfully executed.

chmod 0o755, <myfile1  myfile2># make two files executable by the owner

From type/IO/Path

See Original text in context

method chmod(IO::Path:D: Int() $mode --> Bool)

Changes the POSIX permissions of a file or directory to $mode. Returns True on success; on failure, fail with X::IO::Chmod.

The mode is expected as an integer following the standard numeric notation, and is best written as an octal number:

'myfile'.IO.chmod(0o444);          # make a file read-only 
'somedir'.IO.chmod(0o777);         # set 0777 permissions on a directory 

Make sure you don't accidentally pass the intended octal digits as a decimal number (or string containing a decimal number):

'myfile'.IO.chmod:  '0444';        # BAD!!! (interpreted as mode 0o674) 
'myfile'.IO.chmod: '0o444';        # OK (an octal in a string) 
'myfile'.IO.chmod:  0o444;         # Also OK (an octal literal)