Skip to content
Myr

Check permissions in shell rather than using find -exec

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Luke Childs · committed by Luke Childs · parent 5970a06 · Browse files · 1 file+12 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−2 removed

  • other:+12 added−2 removed

1 file+12 added−2 removed

modified:nvm.sh+12 added-2 removed
1828 unmodified lines
1829 NVM_SUCCESS_MSG="Uninstalled node $VERSION"1830 fi18311832 # Check version dir permissions1833 local FILES_WITHOUT_WRITE_PERMISIONS="$(find "$VERSION_PATH" -exec [ ! -w "{}" ] \; -exec echo "{}" \;)"1834 if [ "$FILES_WITHOUT_WRITE_PERMISIONS" ]; then1833 local PERMISSIONS_OK=true1834 check_file_permissions() {1835 for FILE in $1/* $1/.[!.]* $1/..?* ; do1836 if [ -d "$FILE" ]; then1837 check_file_permissions "$FILE"1838 elif [ -e "$FILE" ]; then1839 [ ! -w "$FILE" ] && PERMISSIONS_OK=false1840 fi1841 done1842 }1843 check_file_permissions "$VERSION_PATH"1844 if [ "$PERMISSIONS_OK" = false ]; then1845 >&2 echo 'Cannot uninstall, incorrect permissions on installation folder.'1846 >&2 echo 'This is usually caused by running `npm install -g` as root. Run the following command as root to fix the permissions and then try again.'1847 >&2 echo1848 >&2 echo " chown -R $(whoami) \"$VERSION_PATH\""
615 unmodified lines