Skip to content

Commit

Permalink
bashrc, zshrc: add workaround for umask on WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
yous committed Nov 6, 2019
1 parent 1ed317e commit 350e8f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ case $- in
*) return;;
esac

if [ -e /proc/version ] && grep -q Microsoft /proc/version; then
# See https://github.com/microsoft/WSL/issues/352
if [ "$(umask)" = '000' ]; then

This comment has been minimized.

Copy link
@atifraza

atifraza Feb 14, 2020

I tried your fix and figured out the check was failing.

umask returned '0000' instead.
Changing that fixed the issue.
Thanks.

This comment has been minimized.

Copy link
@yous

yous Feb 14, 2020

Author Owner

I have umask 000, but it seems that some other versions have 0000. Try this:

if [ "$(umask)" -eq 0 ]; then

or

if [[ "$(umask)" = *'000' ]]; then
if [ -e /etc/login.defs ] && grep -q '^[[:space:]]*USERGROUPS_ENAB[[:space:]]\{1,\}yes' /etc/login.defs; then
umask 002
else
umask 022
fi
fi
fi

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
Expand Down
11 changes: 11 additions & 0 deletions zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ bundle_install() {
bundle install --jobs="$cores_num" "$@"
}

if [ -e /proc/version ] && grep -q Microsoft /proc/version; then
# See https://github.com/microsoft/WSL/issues/352
if [ "$(umask)" = '000' ]; then
if [ -e /etc/login.defs ] && grep -q '^[[:space:]]*USERGROUPS_ENAB[[:space:]]\{1,\}yes' /etc/login.defs; then
umask 002
else
umask 022
fi
fi
fi

if command -v brew >/dev/null; then
BREW_PREFIX="$(brew --prefix)"
fi
Expand Down

0 comments on commit 350e8f4

Please sign in to comment.