运行 Perl 脚本意外锁定了一个文件夹

Running Perl script accidentally locked a folder

我有一个包含以下代码的 Perl 脚本

#/usr/bin/perl
use strict; use warnings;
chmod -R 775,"path-to-current-folder";

在 运行 此脚本后,我无法再访问当前文件夹(当然也无法打开此脚本)。在 Konqueror 中看到文件夹时,文件夹图标中有一个额外的锁。谁能告诉我发生了什么事,我该如何撤消?

我检查了这个文件夹的权限,显然它被更改为d---------。我已经通过重置权限解决了这个问题,但如果有人能解释为什么会这样,那就太好了。谢谢

我认为您将 'chmod' shell 命令与 'chmod' perl 函数混淆了。后者将单个列表作为参数,其第一个元素必须是以八进制表示的数字代码。来自 perldoc -f chmod ;

  chmod LIST
           Changes the permissions of a list of files.  The first element
           of the list must be the numeric mode, which should probably be
           an octal number, and which definitely should not be a string of
           octal digits: 0644 is okay, but "0644" is not.  Returns the
           number of files successfully changed.  See also "oct" if all
           you have is a string.

               $cnt = chmod 0755, "foo", "bar";
               chmod 0755, @executables;
           ... etc ...

前者 - 即 shell - 有一个 -R 开关。有关详细信息,请参阅 man chmod