module Bundler::FileUtils
def chmod(mode, list, noop: nil, verbose: nil)
Related: Bundler::FileUtils.chmod_R.
chmod u=wrx,go=rx /usr/bin/ruby
chmod u=wrx,go=rx src1.txt
chmod 644 src0.txt src0.dat
chmod 755 src0.txt
Output:
Bundler::FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby', noop: true, verbose: true)
Bundler::FileUtils.chmod('u=wrx,go=rx', 'src1.txt', noop: true, verbose: true)
Bundler::FileUtils.chmod(0644, ['src0.txt', 'src0.dat'], noop: true, verbose: true)
Bundler::FileUtils.chmod(0755, 'src0.txt', noop: true, verbose: true)
- verbose: true - prints an equivalent command:
- noop: true - does not change permissions; returns +nil+.
Keyword arguments:
Bundler::FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby')
Bundler::FileUtils.chmod('u=wrx,go=rx', 'src1.txt')
Examples:
- 't': Sticky bit.
- 's': Uid or gid.
must be used with '+')
- 'X': Search (for a directories only;
- 'x': Execute (search, for a directory).
- 'w': Write.
- 'r': Read.
may be any combination of these letters:
- +perms+ (may be repeated, with separating commas)
- '=': sets (replaces) permissions.
- '-': removes permissions.
- '+': adds permissions.
- +operator+ may be one of these letters:
- 'a' (the default): permissions apply to all users.
- 'o': permissions apply to other users not in the file's group.
- 'g': permissions apply to users in the file's group.
- 'u': permissions apply to the file's owner.
- +targets+ may be any combination of these letters:
The string is of the form [targets][[operator][perms[,perms]], where:
- \String +mode+: represents the permissions to be set:
Bundler::FileUtils.chmod(0644, ['src0.txt', 'src0.dat'])
Bundler::FileUtils.chmod(0755, 'src0.txt')
- \Integer +mode+: represents the permission bits to be set:
Argument +mode+ may be either an integer or a string:
should be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments].
Argument +list+ or its elements
{File.lchmod}[https://docs.ruby-lang.org/en/master/File.html#method-c-lchmod].
- Modifies each entry that is a symbolic link using
{File.chmod}[https://docs.ruby-lang.org/en/master/File.html#method-c-chmod].
- Modifies each entry that is a regular file using
returns +list+ if it is an array, [list] otherwise:
to the permissions given by +mode+;
(a single path or an array of paths)
Changes permissions on the entries at the paths given in +list+
def chmod(mode, list, noop: nil, verbose: nil) list = fu_list(list) fu_output_message sprintf('chmod %s %s', mode_to_s(mode), list.join(' ')) if verbose return if noop list.each do |path| Entry_.new(path).chmod(fu_mode(mode, path)) end end