Macos 路径名为的Bash脚本失败
我正在使用以下Bash脚本,但出现以下愚蠢错误:Macos 路径名为的Bash脚本失败,macos,bash,shell,Macos,Bash,Shell,我正在使用以下Bash脚本,但出现以下愚蠢错误: Fixing perms on /Volumes/Volume-B/IMAGES/Prostock scans/ chmod: Failed to set ACL on file '/Volumes/Volume-B/IMAGES/Prostock': No such file or directory chmod: Failed to set ACL on file 'scans/': No such file or directory chm
Fixing perms on /Volumes/Volume-B/IMAGES/Prostock scans/
chmod: Failed to set ACL on file '/Volumes/Volume-B/IMAGES/Prostock': No such file or directory
chmod: Failed to set ACL on file 'scans/': No such file or directory
chmod: Unknown tag type 'inherited'
这是我的剧本:
#!/bin/bash
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
DEST=/Volumes/Volume-B/IMAGES/Prostock\ scans/
echo Fixing perms on $DEST
chmod -R +a "user:administrator allow list,add_file,search,delete,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit" $DEST
chmod -R +a "user:icadmin inherited allow list,add_file,search,delete,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit" $DEST
echo Done!
注意,我已经将$DEST包装在单引号和双引号中,在“Prostock”之后加上或不加反斜杠,得到了相同的错误
非常感谢您的建议
Dan您是否尝试过在
$DEST
变量周围加双引号
chmod -R +a "user:icadmin inherited allow...." "$DEST"
哎呀,刚才看到你关于双引号的评论……实际上,在“$DEST”周围加引号应该对chmod commandset起作用。在chmod$DEST周围加双引号可以纠正一个突出的错误(在
$DEST
周围缺少引号,应该是“$DEST”
…或者,如果您遵循约定并将非环境变量设置为小写,“$dest”
),这就成了关于OS X的chmod的问题,而不是关于bash的问题……很清楚,“没有这样的文件或目录”错误(其中有两个)是由于缺少引号而导致的;“未知标记类型”是关于OS X的chmod版本的问题,因为大多数操作系统根本不支持通过chmod命令的ACL,而是使用诸如satfacl
之类的工具。