【发布时间】:2017-09-07 20:29:14
【问题描述】:
如何检查 umask 是否阻止设置组位?我的尝试:
#!/bin/sh
out=$(umask)
echo "$out"
if (($out & 070) != 0); then
echo "$out"
echo "Incorrect umask" > /dev/tty
exit 1
fi
输出:
./test.sh: line 6: syntax error near unexpected token `!='
./test.sh: line 6: `if (($out & 070) != 0); then'
如果它使事情变得更容易,我可以切换到 bash。
【问题讨论】:
-
您的问题获得了接近投票,因为它“太广泛了”。与其要求我们编写整个解决方案,不如尽力自己编写代码,如果无法正常工作,请在此处发布您编写的内容并寻求帮助来修复它。
-
到目前为止,我的尝试是一场灾难。我已经在问题中添加了它。
-
谢谢。我认为您需要
if [ $umask & 070 -ne 0 ]或只是if [ $umask & 070 ]。用快速谷歌搜索并不难。 -
./test.sh: line 6: [: missing ] ./test.sh: line 6: 070: command not found是我之前尝试的结果 -
您在某处缺少空格。你需要复制我写的内容。