內容

名稱

ExtUtils::Command - 在 Makefile 等中替換常見 UNIX 命令的工具程式

語法

perl -MExtUtils::Command -e cat files... > destination
perl -MExtUtils::Command -e mv source... destination
perl -MExtUtils::Command -e cp source... destination
perl -MExtUtils::Command -e touch files...
perl -MExtUtils::Command -e rm_f files...
perl -MExtUtils::Command -e rm_rf directories...
perl -MExtUtils::Command -e mkpath directories...
perl -MExtUtils::Command -e eqtime source destination
perl -MExtUtils::Command -e test_f file
perl -MExtUtils::Command -e test_d directory
perl -MExtUtils::Command -e chmod mode files...
...

說明

模組用於替換常見的 UNIX 命令。在所有情況下,函數都從 @ARGV 工作,而不是接受參數。這使得它們在 Makefile 中更容易處理。像這樣呼叫它們

perl -MExtUtils::Command -e some_command some files to work on

而不是像這樣

perl -MExtUtils::Command -e 'some_command qw(some files to work on)'

對於該用途,請使用 Shell::Command

帶有 * 和 ? 的檔案名稱將會擴充為 glob。

函數

cat
cat file ...

將命令列中提到的所有檔案串接至 STDOUT。

eqtime
eqtime source destination

將目標的修改時間設定為來源的修改時間。

rm_rf
rm_rf files or directories ...

移除檔案和目錄 - 遞迴 (即使是唯讀)

rm_f
rm_f file ...

移除檔案 (即使是唯讀)

touch
touch file ...

建立檔案,並使用目前的時戳。

mv
mv source_file destination_file
mv source_file source_file destination_dir

將來源移至目標。如果目標是現有的目錄,則允許多個來源。

如果所有移動都成功,則傳回 true,否則傳回 false。

cp
cp source_file destination_file
cp source_file source_file destination_dir

將來源複製至目標。如果目標是現有的目錄,則允許多個來源。

如果所有複製都成功,則傳回 true,否則傳回 false。

chmod
chmod mode files ...

對所有檔案設定類 UNIX 的權限「模式」。例如:0666

mkpath
mkpath directory ...

建立目錄,包括任何父目錄。

test_f
test_f file

測試檔案是否存在。如果存在,則以 0 結束,如果不存在,則以 1 結束 (即 shell 的真和假概念)。

test_d
test_d directory

測試目錄是否存在。如果存在,則以 0 結束,如果不存在,則以 1 結束 (即 shell 的真和假概念)。

dos2unix
dos2unix files or dirs ...

將 DOS 和 OS/2 的換行符號遞迴轉換為 Unix 風格。

另請參閱

Shell::Command,其具有這些相同的功能,但通常採用參數。

作者

Nick Ing-Simmons ni-s@cpan.org

由 Michael G Schwern schwern@pobox.com 在 ExtUtils-MakeMaker 套件中維護,並由 Randy Kobes r.kobes@uwinnipeg.ca 作為獨立的 CPAN 套件維護。