这是一个测试文件test.applescript:
display dialog "foo" buttons {"OK"} cancel button 1 default button 1
下午 4:05 我将其编译为test.app:
osacompile -o test.app test.applescript
下午 4:07,我test.applescript通过将 替换foo为进行编辑bar,然后再次编译它,覆盖现有test.app文件。(它已成功覆盖。如果我运行它,对话框会显示“bar”,而不是“foo”。)
display dialog "bar" buttons {"OK"} cancel button 1 default button 1
osacompile -o test.app test.applescript
但尽管如此,date modified的值test.app仍然是下午 4:05。这是为什么?这怎么可能呢?
输出stat -x:
File: "test.app"
Size: 96 FileType: Directory
Mode: (0755/drwxr-xr-x) Uid: ( 501/ john) Gid: ( 20/ staff)
Device: 1,17 Inode: 79429067 Links: 3
Access: Sun Mar 23 16:05:52 2025
Modify: Sun Mar 23 16:05:52 2025
Change: Sun Mar 23 17:20:48 2025
Birth: Sun Mar 23 16:05:52 2025
您会注意到这
test.app是一个目录:每次添加、删除或重命名目录中的文件时,目录中的修改时间戳都会更新。重新编译应用程序时,各个子目录的内容会发生变化,但目录
test.app本身不会添加、删除或重命名任何内容。来自
osacompile(1)手册:因此,您创建的是“捆绑应用程序或 droplet”(MacOS 以特殊方式解释的目录),而不是“平面文件”(文件,而不是目录)。