SC3065 – ShellCheck Wiki

See this page on GitHub

Sitemap


In POSIX sh, test -k is undefined.

Problematic code:

if [ -k file ]
then
  echo "File has sticky bit set"
fi

Correct code:

if [ -n "$(find file -prune -perm /1000)" ]
then
  echo "File has sticky bit set"
fi

Rationale:

test -k file and [ -k file ] are not defined by POSIX. To ensure compatibility with all target systems, use find instead.

Exceptions:

None. If you are targeting a shell that supports test -k, specify it in the shebang.


ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.